Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 35:cf958638a471
test
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/Jungle.java Wed Jan 23 14:12:08 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/Jungle.java Sat Jan 26 00:25:17 2013 +0900 @@ -2,4 +2,5 @@ public interface Jungle { + public JungleTree getTree(String _name); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/JungleTree.java Sat Jan 26 00:25:17 2013 +0900 @@ -0,0 +1,6 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core; + +public interface JungleTree +{ + public JungleNode getRoot(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/Transaction.java Sat Jan 26 00:25:17 2013 +0900 @@ -0,0 +1,8 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; + +public interface Transaction<T> +{ + public Either<Error,T> success(); +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TreeEditor.java Wed Jan 23 14:12:08 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TreeEditor.java Sat Jan 26 00:25:17 2013 +0900 @@ -1,8 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store; import java.nio.ByteBuffer; - -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.NodeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; @@ -14,6 +12,4 @@ public Either<Error,TreeEditor> putAttribute(NodePath _path,String _key,ByteBuffer _value); public Either<Error,TreeEditor> deleteAttribute(NodePath _path,String _key); public Either<Error,TreeEditor> edit(NodePath _path,NodeEditor _transformer); - - public boolean success(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/ChangeSetRepository.java Wed Jan 23 14:12:08 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl; - -import java.util.concurrent.atomic.AtomicReference; - -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.util.Commitment; - -public class ChangeSetRepository -{ - private final AtomicReference<Commitment.Value<DefaultChangeSet>> tip; - - public ChangeSetRepository() - { - tip = new AtomicReference<Commitment.Value<DefaultChangeSet>>(); - } - - public Commitment.Publisher<DefaultChangeSet> preCommit(DefaultChangeSet _changeSet) - { - - } -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Wed Jan 23 14:12:08 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Sat Jan 26 00:25:17 2013 +0900 @@ -24,29 +24,28 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -public class DefaultTreeEditor implements TreeEditor +public class DefaultTreeEditor<T extends EditableNode<T>> + implements TreeEditor { - private final DefaultChangeSet tip; - private final TraverserProvider tProvider; + private final T root; + private final Traverser traverser; - public DefaultTreeEditor(DefaultChangeSet _tip,ChangeListWriter _writer,TraverserProvider _tProvider) + public DefaultTreeEditor(T _root,Traverser _traverser) { - tip = _tip; - tProvider = _tProvider; + root = _root; + traverser = _traverser; + } + + public T getRootNode() + { + return root; } @Override - public Node getRoot() - { - return null; - } - - @Override public Either<Error,TreeEditor> appendChild(NodePath _path,int _pos) { return edit(_path,new AppendChildAt(_pos)); } - @Override public Either<Error,TreeEditor> deleteChild(NodePath _path,int _pos) @@ -67,20 +66,11 @@ } @Override - public boolean success() - { - return false; - } - - @Override public Either<Error,TreeEditor> edit(NodePath _path,NodeEditor _editor) { - DefaultTree tree = tip.getTree(); - DefaultNode root = tree.getRoot(); - Traverser<DefaultNode> traverser = tProvider.newTraverser(); - DefaultEvaluator<DefaultNode> e = new DefaultEvaluator<DefaultNode>(_path); + DefaultEvaluator e = new DefaultEvaluator(_path); - Either<Error,Traversal<DefaultNode>> either = traverser.traverse(root,e); + Either<Error,Traversal<T>> either = traverser.traverse(root,e); if(either.isA()){ return DefaultEither.newA(either.a()); } @@ -109,7 +99,7 @@ LoggingNode<DefaultNode> loggingNode = either.b(); Logger logger = loggingNode.getLogger(); - DefaultNode newNode = (DefaultNode)loggingNode.getWrapper(); + DefaultNode newNode = loggingNode.getWrapper(); // top int pos = targetDirection.getPosition();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TraversableChildrenWrapper.java Sat Jan 26 00:25:17 2013 +0900 @@ -0,0 +1,29 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl; + +import java.util.Iterator; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.TraversableChildren; + +public class TraversableChildrenWrapper<T extends EditableNode<T>> + implements TraversableChildren<TraversableNodeWrapper<T>> +{ + private final T node; + + public TraversableChildrenWrapper(T _node) + { + node = _node; + } + + @Override + public Iterator<TraversableNodeWrapper<T>> iterator() + { + return null; + } + + @Override + public int size() + { + return 0; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TraversableNodeWrapper.java Sat Jan 26 00:25:17 2013 +0900 @@ -0,0 +1,24 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableChildren; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.TraversableChildren; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.TraversableNode; + +public class TraversableNodeWrapper<T extends EditableNode<T>> + implements TraversableNode<TraversableNodeWrapper<T>> +{ + private final T wrap; + + public TraversableNodeWrapper(T _wrap) + { + wrap = _wrap; + } + + @Override + public TraversableChildren<TraversableNodeWrapper<T>> children() + { + EditableChildren<T> children = wrap.getChildren(); + return new TraversableChildrenWrapper<TraversableNodeWrapper<T>>(children); + } +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TraverserProvider.java Wed Jan 23 14:12:08 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl; - -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.TraversableNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Traverser; - -public interface TraverserProvider -{ - public <T extends TraversableNode<T>> Traverser<T> newTraverser(); -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingChildren.java Wed Jan 23 14:12:08 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingChildren.java Sat Jan 26 00:25:17 2013 +0900 @@ -11,6 +11,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.IterableConverter; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.IterableWrapper; public class LoggingChildren<T extends EditableNode<T>> @@ -34,9 +35,21 @@ @Override public Iterator<Node> iterator() { - IterableWrapper<Node> wrapper = new IterableWrapper<Node>(this); + IterableWrapper<Node> wrapper = new IterableWrapper<Node>(wrap); return wrapper.iterator(); } + + @Override + public Iterator<LoggingNode<T>> iteratorWithType() + { + IterableConverter.Converter<LoggingNode<T>,EditableChildren<T>> converter + = new IterableConverter.Converter<LoggingNode<T>,EditableChildren<T>>(){ + }; + + IterableConverter<LoggingNode<T>,T> iterable = new IterableConverter<LoggingNode<T>,T>(wrap,converter); + + return iterable; + } @Override public Either<Error,LoggingNode<T>> addNewChildAt(final int _pos)
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/EditableChildren.java Wed Jan 23 14:12:08 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/EditableChildren.java Sat Jan 26 00:25:17 2013 +0900 @@ -1,5 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer; +import java.util.Iterator; + import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Children; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultError; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; @@ -10,6 +12,7 @@ { public Either<Error,T> addNewChildAt(int _pos); public Either<Error,T> deleteChildAt(int _pos); + public Iterator<T> iteratorWithType(); public final Error OUT_OF_RANGE = new DefaultError(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/util/Parent.java Sat Jan 26 00:25:17 2013 +0900 @@ -0,0 +1,23 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; + +public interface Parent<T extends Parent<T>> +{ + public Children<T> succ(); +} + +interface Children<T extends Parent<T>> extends Iterable<T> +{ + +} + +interface A extends RecursiveType<B> +{ + public B succ(); +} + +interface B extends RecursiveType<A> +{ + public A succ(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/util/TraversableWrapper.java Sat Jan 26 00:25:17 2013 +0900 @@ -0,0 +1,15 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.TraversableChildren; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.TraversableNode; + +public class TraversableWrapper<T> implements TraversableNode<TraversableWrapper<T>> +{ + + @Override + public TraversableChildren<TraversableWrapper<T>> children() + { + return null; + } + +}