diff src/treecms/api/NodeAttributesImpl.java @ 14:8bf59f161b23

separete Node methods to NodeContext , NodeAttribute , NodeChildren
author misaka
date Tue, 17 May 2011 18:44:14 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/treecms/api/NodeAttributesImpl.java	Tue May 17 18:44:14 2011 +0900
@@ -0,0 +1,80 @@
+package treecms.api;
+
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+public class NodeAttributesImpl implements NodeAttributes
+{
+	private Map<ByteBuffer,ByteBuffer> m_attrs;
+	
+	public NodeAttributesImpl()
+	{
+		m_attrs = new HashMap<ByteBuffer,ByteBuffer>();
+	}
+	
+	public NodeAttributesImpl(NodeAttributesImpl _attrs)
+	{
+		super();
+		m_attrs.putAll(_attrs.m_attrs);
+	}
+	
+	@Override
+	public Set<ByteBuffer> getKeySet()
+	{
+		return m_attrs.keySet();
+	}
+
+	@Override
+	public void put(ByteBuffer _name, ByteBuffer _value)
+	{
+		m_attrs.put(_name,_value);
+	}
+
+	@Override
+	public void putAll(NodeAttributes _attrs)
+	{
+		m_attrs.putAll(_attrs.asMap());
+	}
+	
+	@Override
+	public Map<ByteBuffer,ByteBuffer> asMap()
+	{
+		return Collections.unmodifiableMap(m_attrs);
+	}
+
+	@Override
+	public ByteBuffer get(ByteBuffer _name)
+	{
+		return m_attrs.get(_name);
+	}
+
+	@Override
+	public NodeAttributes getAll()
+	{
+		return this;
+	}
+
+	@Override
+	public void remove(ByteBuffer _name)
+	{
+		m_attrs.remove(_name);
+	}
+
+	@Override
+	public void removeAll(Set<ByteBuffer> _keySet)
+	{
+		for(ByteBuffer _key : _keySet){
+			remove(_key);
+		}
+	}
+
+	@Override
+	public void clearAttributes()
+	{
+		m_attrs.clear();
+	}
+
+}