Mercurial > hg > Members > tatsuki > bench > jungle-core
view src/main/java/jungle/core/table/simple/SimpleRecord.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.Iterator; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.concurrent.ThreadSafe; import jungle.core.table.PropertySequence; import jungle.core.table.Record; import jungle.util.Pair; @ThreadSafe public class SimpleRecord implements Record { private final ConcurrentHashMap<String,String> properties; private final ConcurrentHashMap<String,PropertySequence> sequences; public SimpleRecord() { properties = new ConcurrentHashMap<String,String>(); sequences = new ConcurrentHashMap<String,PropertySequence>(); } @Override public void setProperty(String _key, String _value) { properties.put(_key,_value); } @Override public String getProperty(String _key) { return properties.get(_key); } @Override public String removeProperty(String _key) { return properties.remove(_key); } @Override public PropertySequence createSequence(String _key) { SimplePropertySequence seq = new SimplePropertySequence(); sequences.put(_key,seq); return seq; } @Override public PropertySequence getSequence(String _key) { return sequences.get(_key); } @Override public PropertySequence removeSequence(String _key) { return sequences.remove(_key); } @Override public Iterator<Pair<String, String>> properties() { final Set<Entry<String,String>> entries = properties.entrySet(); final Iterator<Entry<String,String>> itr = entries.iterator(); return new Iterator<Pair<String,String>>(){ @Override public boolean hasNext() { return itr.hasNext(); } @Override public Pair<String, String> next() { Entry<String,String> ent = itr.next(); return new Pair<String,String>(ent.getKey(),ent.getValue()); } @Override public void remove() { throw new UnsupportedOperationException("removing is not supported"); } }; } @Override public Iterator<Pair<String, PropertySequence>> sequences() { final Set<Entry<String,PropertySequence>> entries = sequences.entrySet(); final Iterator<Entry<String,PropertySequence>> itr = entries.iterator(); return new Iterator<Pair<String,PropertySequence>>(){ @Override public boolean hasNext() { return itr.hasNext(); } @Override public Pair<String, PropertySequence> next() { Entry<String,PropertySequence> ent = itr.next(); return new Pair<String,PropertySequence> (ent.getKey(),ent.getValue()); } @Override public void remove() { throw new UnsupportedOperationException("removeing is not supported."); } }; } }