view src/main/java/jungle/core/table/simple/SimpleTable.java @ 3:9eb9fabd9f29

added Table framework
author shoshi <shoshi@cr.ie.u-ryukyu.ac.jp>
date Wed, 13 Jun 2012 01:29:02 +0900
parents
children 761d04aecfcb
line wrap: on
line source

package jungle.core.table.simple;

import java.util.concurrent.ConcurrentHashMap;

import jungle.core.table.Record;
import jungle.core.table.Table;

public class SimpleTable implements Table
{
	private final ConcurrentHashMap<String,Record> table;
	
	public SimpleTable()
	{
		table = new ConcurrentHashMap<String,Record>();
	}

	@Override
	public Record create(String _key)
	{
		SimpleRecord r = new SimpleRecord();
		Record b = table.putIfAbsent(_key,r);
		return (b == null) ? r : null;
	}

	@Override
	public Record find(String _key)
	{
		return table.get(_key);
	}

	@Override
	public Record remove(String _key)
	{
		return table.remove(_key);
	}
}