Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 73:e97a59269bf5
change to Various
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungle.java Tue Aug 26 07:41:35 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungle.java Wed Aug 27 01:02:11 2014 +0900 @@ -76,7 +76,7 @@ }; DefaultTreeNode root = new DefaultTreeNode(); - ChangeSet set = new DefaultChangeSet(root.getAsNode(),null,list,uuid,_name,0); + ChangeSet set = new DefaultChangeSet(root,null,list,uuid,_name,0); DefaultTreeContext<DefaultTreeNode> tc = new DefaultTreeContext<DefaultTreeNode>(root,set); JungleTree newTree = new DefaultJungleTree<DefaultTreeNode>(tc,uuid,journal.getWriter(),editor); if(trees.putIfAbsent(_name,newTree) != null){
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungleTree.java Tue Aug 26 07:41:35 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungleTree.java Wed Aug 27 01:02:11 2014 +0900 @@ -1,6 +1,5 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; @@ -10,7 +9,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTransactionManager; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.TreeContext; -public class DefaultJungleTree<T extends TreeNode<T>> implements JungleTree +public class DefaultJungleTree<T extends TreeNode<T>> implements JungleTree<T> { private final AtomicReservableReference<TreeContext<T>> repository; private final String uuid; @@ -30,7 +29,7 @@ { TreeContext<T> tc = repository.get(); DefaultTransactionManager<T> txManager = new DefaultTransactionManager<T>(writer,tc,repository,uuid); - T root = tc.getTreeNode(); + TreeNode<T> root = tc.getTreeNode(); return new DefaultJungleTreeEditor<T>(root,txManager,editor); } @@ -41,10 +40,10 @@ } @Override - public Node getRootNode() + public TreeNode<T> getRootNode() { TreeContext<T> tc = repository.get(); - ChangeSet cs = tc.getChangeSet(); + ChangeSet<T> cs = tc.getChangeSet(); return cs.getRoot(); } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/JungleTree.java Tue Aug 26 07:41:35 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/JungleTree.java Wed Aug 27 01:02:11 2014 +0900 @@ -1,10 +1,10 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -public interface JungleTree +public interface JungleTree<T extends TreeNode<T>> { public JungleTreeEditor getTreeEditor(); public JungleTreeEditor getLocalTreeEditor(); - public Node getRootNode(); + public TreeNode<T> getRootNode(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/App.java Tue Aug 26 07:41:35 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/App.java Wed Aug 27 01:02:11 2014 +0900 @@ -1,11 +1,13 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core; import java.nio.ByteBuffer; + import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; @@ -14,13 +16,13 @@ * Hello world! * */ -public class App +public class App { - public static void main( String[] args ) + public static <T extends TreeNode<T>>void main( String[] args ) { DefaultJungle jungle = new DefaultJungle(null,"sample",new DefaultTreeEditor(new DefaultTraverser())); jungle.createNewTree("hoge"); - JungleTree tree = jungle.getTreeByName("hoge"); + JungleTree<T> tree = jungle.getTreeByName("hoge"); JungleTreeEditor editor = tree.getTreeEditor(); DefaultNodePath path = new DefaultNodePath(); @@ -32,7 +34,7 @@ e.success(); - Node root = tree.getRootNode(); + TreeNode<T> root = tree.getRootNode(); ByteBuffer v = root.getAttributes().get(key); String str = new String(v.array()); System.out.println(str);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/ChangeSet.java Tue Aug 26 07:41:35 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/ChangeSet.java Wed Aug 27 01:02:11 2014 +0900 @@ -2,12 +2,13 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; -public interface ChangeSet +public interface ChangeSet<T extends TreeNode<T>> { - public Node getRoot(); - public ChangeSet prev(); + public TreeNode<T> getRoot(); + public ChangeSet<T> prev(); public ChangeList getChangeList(); public String uuid();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultChangeSet.java Tue Aug 26 07:41:35 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultChangeSet.java Wed Aug 27 01:02:11 2014 +0900 @@ -1,20 +1,20 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; -public class DefaultChangeSet implements ChangeSet +public class DefaultChangeSet<T extends TreeNode<T>> implements ChangeSet<T> { - private final Node root; - private final ChangeSet previous; + private final TreeNode<T> root; + private final ChangeSet<T> previous; private final ChangeList changeList; private final String uuid; private final String treeName; private final long revision; - public DefaultChangeSet(Node _node,ChangeSet _prev,ChangeList _log,String _uuid, String _treeName, long _revision) + public DefaultChangeSet(TreeNode<T> _node,ChangeSet<T> _prev,ChangeList _log,String _uuid, String _treeName, long _revision) { root = _node; previous = _prev; @@ -25,13 +25,13 @@ } @Override - public Node getRoot() + public TreeNode<T> getRoot() { return root; } @Override - public ChangeSet prev() + public ChangeSet<T> prev() { return previous; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultJungleTreeEditor.java Tue Aug 26 07:41:35 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultJungleTreeEditor.java Wed Aug 27 01:02:11 2014 +0900 @@ -26,16 +26,16 @@ public class DefaultJungleTreeEditor<T extends TreeNode<T>> implements JungleTreeEditor { private final TransactionManager<T> txManager; - private final T root; + private final TreeNode<T> root; private final TreeEditor editor; private final TreeOperationLog log; - public DefaultJungleTreeEditor(T _root,TransactionManager<T> _txManager,TreeEditor _editor) + public DefaultJungleTreeEditor(TreeNode<T> _root,TransactionManager<T> _txManager,TreeEditor _editor) { this(_root,_txManager,_editor,new DefaultTreeOperationLog()); } - public DefaultJungleTreeEditor(T _root,TransactionManager<T> _txManager,TreeEditor _editor,TreeOperationLog _log) + public DefaultJungleTreeEditor(TreeNode<T> _root,TransactionManager<T> _txManager,TreeEditor _editor,TreeOperationLog _log) { root = _root; txManager = _txManager; @@ -46,12 +46,13 @@ private Either<Error,JungleTreeEditor> _edit(final NodePath _path,NodeEditor _e) { LoggingNodeHook hook = new LoggingNodeHook(_e); - Either<Error,T> either = editor.edit(root,_path,hook); + Either<Error,TreeNode<T>> either = editor.edit(root,_path,hook); if(either.isA()){ return DefaultEither.newA(either.a()); } - T newNode = either.b(); + TreeNode<T> newNode = either.b(); + OperationLog newLog = hook.getLog(); IterableConverter.Converter<TreeOperation,NodeOperation> converter = new IterableConverter.Converter<TreeOperation,NodeOperation>(){
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java Tue Aug 26 07:41:35 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java Wed Aug 27 01:02:11 2014 +0900 @@ -32,9 +32,9 @@ } @Override - public Either<Error,TransactionManager<T>> commit(T _newRoot,final TreeOperationLog _log) + public Either<Error,TransactionManager<T>> commit(TreeNode<T> _newRoot,final TreeOperationLog _log) { - ChangeSet cs = tip.getChangeSet(); + ChangeSet<T> cs = tip.getChangeSet(); long currentRevision = cs.revision(); long nextRevision = currentRevision + 1; @@ -54,8 +54,8 @@ } }; - Node root = _newRoot.getAsNode(); - DefaultChangeSet newCs = new DefaultChangeSet(root,cs,list,uuid, _treeName, nextRevision); + TreeNode<T> root = _newRoot; + DefaultChangeSet<T> newCs = new DefaultChangeSet(root,cs,list,uuid, _treeName, nextRevision); DefaultTreeContext<T> newContext = new DefaultTreeContext<T>(_newRoot,newCs); @SuppressWarnings("rawtypes") @@ -81,7 +81,7 @@ @Override public long getRevision() { - ChangeSet cs = tip.getChangeSet(); + ChangeSet<T> cs = tip.getChangeSet(); return cs.revision(); } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeContext.java Tue Aug 26 07:41:35 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeContext.java Wed Aug 27 01:02:11 2014 +0900 @@ -5,23 +5,23 @@ public class DefaultTreeContext<T extends TreeNode<T>> implements TreeContext<T> { - private final T root; - private final ChangeSet cs; + private final TreeNode<T> root; + private final ChangeSet<T> cs; - public DefaultTreeContext(T _newRoot,ChangeSet _cs) + public DefaultTreeContext(TreeNode<T> _newRoot,ChangeSet<T> _cs) { root = _newRoot; cs = _cs; } @Override - public ChangeSet getChangeSet() + public ChangeSet<T> getChangeSet() { return cs; } @Override - public T getTreeNode() + public TreeNode<T> getTreeNode() { return root; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/TransactionManager.java Tue Aug 26 07:41:35 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/TransactionManager.java Wed Aug 27 01:02:11 2014 +0900 @@ -7,7 +7,7 @@ public interface TransactionManager<T extends TreeNode<T>> { - public Either<Error,TransactionManager<T>> commit(T _newRoot,TreeOperationLog _log); + public Either<Error,TransactionManager<T>> commit(TreeNode<T> _newRoot,TreeOperationLog _log); public String getUUID(); public long getRevision(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/TreeContext.java Tue Aug 26 07:41:35 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/TreeContext.java Wed Aug 27 01:02:11 2014 +0900 @@ -5,6 +5,6 @@ public interface TreeContext<T extends TreeNode<T>> { - public ChangeSet getChangeSet(); - public T getTreeNode(); + public ChangeSet<T> getChangeSet(); + public TreeNode<T> getTreeNode(); }