Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 68:240a385bf79d
delete traversalNodewrapper but not change test source(error)
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Mon Jun 16 16:47:12 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Wed Aug 20 14:49:51 2014 +0900 @@ -25,31 +25,31 @@ public <T extends TreeNode<T>> Either<Error,T> edit(T _root,NodePath _path,NodeEditor _editor) { DefaultEvaluator e = new DefaultEvaluator(_path); - TraversableNodeWrapper<T> wrap = new TraversableNodeWrapper<T>(_root); - Either<Error, Traversal<TraversableNodeWrapper<T>>> either = traverser.traverse(wrap,e); + //TraversableNodeWrapper<T> wrap = new TraversableNodeWrapper<T>(_root); + Either<Error, Traversal<T>> either = traverser.traverse(_root,e); if(either.isA()){ return DefaultEither.newA(either.a()); } - Traversal<TraversableNodeWrapper<T>> t = either.b(); + Traversal<T> t = either.b(); Either<Error,T> ret = clone(t,_editor); return ret; } - private <T extends TreeNode<T>> Either<Error,T> clone(Traversal<TraversableNodeWrapper<T>> _t,NodeEditor _editor) + private <T extends TreeNode<T>> Either<Error,T> clone(Traversal<T> _t,NodeEditor _editor) { // copying nodes from bottom to root - List<Direction<TraversableNodeWrapper<T>>> path = List.nil(); - for(Direction<TraversableNodeWrapper<T>> direction : _t){ + List<Direction<T>> path = List.nil(); + for(Direction<T> direction : _t){ path = path.cons(direction); } // target - Direction<TraversableNodeWrapper<T>> targetDirection = path.head(); - T target = targetDirection.getTarget().getWrapped(); + Direction<T> targetDirection = path.head(); + T target = targetDirection.getTarget(); EditableNodeWrapper<T> wrapper = new EditableNodeWrapper<T>(target); Either<Error,EditableNodeWrapper<T>> either = _editor.edit(wrapper); if(either.isA()){ @@ -61,9 +61,8 @@ // top int pos = targetDirection.getPosition(); T child = newNode; - for(Direction<TraversableNodeWrapper<T>> parentDirection : path.tail()){ - TraversableNodeWrapper<T> parent = parentDirection.getTarget(); - TreeNodeChildren<T> chs = parent.getWrapped().getChildren(); + for(Direction<T> parentDirection : path.tail()){ + TreeNodeChildren<T> chs = parentDirection.getTarget().getChildren(); Either<Error,T> ret = chs.replaceNode(pos,child); if(ret.isA()){
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TraversableNodeWrapper.java Mon Jun 16 16:47:12 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TraversableNodeWrapper.java Wed Aug 20 14:49:51 2014 +0900 @@ -1,4 +1,4 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl; +/*package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl; import java.util.Iterator; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Children; @@ -66,4 +66,4 @@ } }; } -} +}*/
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/DefaultEvaluator.java Mon Jun 16 16:47:12 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/DefaultEvaluator.java Wed Aug 20 14:49:51 2014 +0900 @@ -1,6 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair; public class DefaultEvaluator implements Evaluator @@ -13,7 +14,7 @@ } @Override - public <T extends TraversableNode<T>> Evaluation evaluate(T _current,int _pos) + public <T extends TreeNode<T>> Evaluation evaluate(T _current,int _pos) { Pair<Integer,NodePath> pop = path.pop(); int head = pop.left();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/DefaultTraverser.java Mon Jun 16 16:47:12 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/DefaultTraverser.java Wed Aug 20 14:49:51 2014 +0900 @@ -3,6 +3,7 @@ import java.util.Iterator; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Children; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.NodeEditorError; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; @@ -12,7 +13,7 @@ public class DefaultTraverser implements Traverser { @Override - public <T extends TraversableNode<T>> Either<Error,Traversal<T>> traverse(final T _root,Evaluator _evaluator) + public <T extends TreeNode<T>> Either<Error,Traversal<T>> traverse(final T _root,Evaluator _evaluator) { Children<T> wrapper = new Children<T>(){ @Override @@ -61,7 +62,7 @@ return DefaultEither.newB(traversal); } - private <T extends TraversableNode<T>> Either<Error,List<Direction<T>>> _traverse(Children<T> _chs,Evaluator _evaluator,int _pos) + private <T extends TreeNode<T>> Either<Error,List<Direction<T>>> _traverse(Children<T> _chs,Evaluator _evaluator,int _pos) { int pos = _pos; for(T ch : _chs){ @@ -90,7 +91,7 @@ return DefaultEither.newA(TraverserError.PATH_NOT_FOUND); } - private <T extends TraversableNode<T>> List<Direction<T>> _goal(final T _current,final int _pos) + private <T extends TreeNode<T>> List<Direction<T>> _goal(final T _current,final int _pos) { Direction<T> d = new Direction<T>(){ @Override @@ -111,7 +112,7 @@ return newList; } - private <T extends TraversableNode<T>> Either<Error,List<Direction<T>>> _accept(final T _current,final int _pos,Evaluator _evaluator) + private <T extends TreeNode<T>> Either<Error,List<Direction<T>>> _accept(final T _current,final int _pos,Evaluator _evaluator) { Children<T> chs = _current.getChildren(); Either<Error,List<Direction<T>>> either = _traverse(chs,_evaluator,0);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Evaluator.java Mon Jun 16 16:47:12 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Evaluator.java Wed Aug 20 14:49:51 2014 +0900 @@ -1,6 +1,8 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; + public interface Evaluator { - public <T extends TraversableNode<T>> Evaluation evaluate(T _current,int _pos); + public <T extends TreeNode<T>> Evaluation evaluate(T _current,int _pos); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Traversable.java Mon Jun 16 16:47:12 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Traversable.java Wed Aug 20 14:49:51 2014 +0900 @@ -5,5 +5,5 @@ public interface Traversable<T extends TraversableNode<T>> { - public Either<Error,Traversal<T>> traverse(Evaluator _e); + public Either<Error,Traversal> traverse(Evaluator _e); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/TraversableNode.java Mon Jun 16 16:47:12 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/TraversableNode.java Wed Aug 20 14:49:51 2014 +0900 @@ -1,7 +1,8 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; +/*package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Parent; public interface TraversableNode<T> extends Parent<T> { } +*/ \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Traversal.java Mon Jun 16 16:47:12 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Traversal.java Wed Aug 20 14:49:51 2014 +0900 @@ -1,6 +1,8 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; -public interface Traversal<T extends TraversableNode<T>> extends Iterable<Direction<T>> +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; + +public interface Traversal<T extends TreeNode<T>> extends Iterable<Direction<T>> { public T destination(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Traverser.java Mon Jun 16 16:47:12 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Traverser.java Wed Aug 20 14:49:51 2014 +0900 @@ -1,9 +1,12 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; public interface Traverser { - public <T extends TraversableNode<T>> Either<Error,Traversal<T>> traverse(T _root,Evaluator _evaluator); + public <T extends TreeNode<T>> Either<Error,Traversal<T>> traverse(final T _root,Evaluator _evaluator); + + }