Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 72:5969848b1bb8
deleting defaultNode(change to DefaultTreeNodeAttribute and DefaultTreeNode)
have error
author | one |
---|---|
date | Tue, 26 Aug 2014 07:41:35 +0900 |
parents | 5dbae471a3b3 |
children | e97a59269bf5 3a3622cf2eef |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TreeNode.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNode.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java |
diffstat | 3 files changed, 32 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TreeNode.java Tue Aug 26 07:32:15 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TreeNode.java Tue Aug 26 07:41:35 2014 +0900 @@ -12,6 +12,6 @@ @Override public TreeNodeAttributes<T> getAttributes(); - public Node getAsNode(); + //public Node getAsNode(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNode.java Tue Aug 26 07:32:15 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNode.java Tue Aug 26 07:41:35 2014 +0900 @@ -38,22 +38,22 @@ @Override public DefaultTreeNodeAttribute getAttributes() { - return new DefaultTreeNodeAttribute(wrap); + return new DefaultTreeNodeAttribute(children, attrs); } - public DefaultNode getWrap() + /*public DefaultNode getWrap() { return wrap; - } + }*/ - @Override + /*@Override public Node getAsNode() { return getWrap(); } - - public DefaultNode clone() + */ + public DefaultTreeNode clone() { - return new DefaultNode(children,attrs); + return new DefaultTreeNode(children,attrs); } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java Tue Aug 26 07:32:15 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java Tue Aug 26 07:41:35 2014 +0900 @@ -1,6 +1,9 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction; import java.nio.ByteBuffer; + +import fj.data.List; +import fj.data.Option; import fj.data.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultAttributes; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultChildren; @@ -13,11 +16,13 @@ public class DefaultTreeNodeAttribute implements TreeNodeAttributes<DefaultTreeNode> { - private final DefaultNode wrap; + public List<DefaultTreeNode> children; + public TreeMap<String,ByteBuffer> attrs; - public DefaultTreeNodeAttribute(DefaultNode _wrap) + public DefaultTreeNodeAttribute(List<DefaultTreeNode> _children,TreeMap<String,ByteBuffer> _attrs) { - wrap = _wrap; + children = _children; + attrs = _attrs; } @Override @@ -27,19 +32,15 @@ return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); } - DefaultAttributes attrs = wrap.getAttributes(); - DefaultChildren children = wrap.getChildren(); - - TreeMap<String,ByteBuffer> raw = attrs.getAttributesAsRawMap(); - if(!raw.contains(_key)){ + if(!attrs.contains(_key)){ return DefaultEither.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); } - TreeMap<String,ByteBuffer> newMap = raw.delete(_key); + TreeMap<String,ByteBuffer> newMap = attrs.delete(_key); - DefaultNode newNode = new DefaultNode(children.getChildrenAsRawList(),newMap); + DefaultTreeNode newNode = new DefaultTreeNode(children,newMap); - return DefaultEither.newB(new DefaultTreeNode(newNode)); + return DefaultEither.newB(newNode); } @Override @@ -49,20 +50,25 @@ return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); } - DefaultAttributes attrs = wrap.getAttributes(); - DefaultChildren children = wrap.getChildren(); + //DefaultAttributes attrs = wrap.getAttributes(); + //DefaultChildren children = wrap.getChildren(); - TreeMap<String,ByteBuffer> raw = attrs.getAttributesAsRawMap(); - TreeMap<String,ByteBuffer> newMap = raw.set(_key,_value); + //TreeMap<String,ByteBuffer> raw = attrs.getAttributesAsRawMap(); + TreeMap<String,ByteBuffer> newMap = attrs.set(_key,_value); - DefaultNode newNode = new DefaultNode(children.getChildrenAsRawList(),newMap); + DefaultTreeNode newNode = new DefaultTreeNode(children,newMap); - return DefaultEither.newB(new DefaultTreeNode(newNode)); + return DefaultEither.newB(newNode); } @Override public ByteBuffer get(String _key) { - return wrap.getAttributes().get(_key); + if(_key == null){ + return null; + } + + Option<ByteBuffer> result = attrs.get(_key); + return result.isSome() ? result.some() : null; } }