Mercurial > hg > Members > tatsuki > bench > jungle-core
changeset 31:418088ca2b30
added Generics parameters to EditableNode framework
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/Tree.java Tue Jan 15 23:39:44 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core; - -public interface Tree -{ - public Node getRoot(); -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/ChangeSet.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/ChangeSet.java Wed Jan 16 03:23:57 2013 +0900 @@ -1,12 +1,12 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Tree; +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.operations.Operation; public interface ChangeSet { - public Tree getTree(); + public Node getRoot(); public ChangeSet prev(); public ChangeList getChangeList();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TraversableNode.java Tue Jan 15 23:39:44 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store; - -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Evaluator; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Parent; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Traversal; - -public interface TraversableNode extends Parent<TraversableNode> -{ - public Traversal<TraversableNode> traverse(Evaluator<TraversableNode> _e); -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TraversableTree.java Tue Jan 15 23:39:44 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store; - -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Traversable; - -public interface TraversableTree extends Traversable<Node> -{ -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TreeEditor.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TreeEditor.java Wed Jan 16 03:23:57 2013 +0900 @@ -1,13 +1,14 @@ 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; public interface TreeEditor { - public TraversableTree getTree(); public Either<Error,TreeEditor> appendChild(NodePath _path,int _pos); public Either<Error,TreeEditor> deleteChild(NodePath _path,int _pos); public Either<Error,TreeEditor> putAttribute(NodePath _path,String _key,ByteBuffer _value);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultNode.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultNode.java Wed Jan 16 03:23:57 2013 +0900 @@ -2,17 +2,14 @@ import java.nio.ByteBuffer; import java.util.Iterator; - import fj.Ord; import fj.data.List; import fj.data.TreeMap; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableAttributes; -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.Children; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Parent; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.TraversableChildren; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.TraversableNode; -public class DefaultNode implements EditableNode , Parent<DefaultNode> +public class DefaultNode implements EditableNode<DefaultNode> , TraversableNode<DefaultNode> { public List<DefaultNode> children; public TreeMap<String,ByteBuffer> attrs; @@ -49,9 +46,9 @@ } @Override - public Children<DefaultNode> children() + public TraversableChildren<DefaultNode> children() { - return new Children<DefaultNode>(){ + return new TraversableChildren<DefaultNode>(){ @Override public Iterator<DefaultNode> iterator() {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTraversableTree.java Tue Jan 15 23:39:44 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl; - -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Tree; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TraversableTree; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Evaluator; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Traversal; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Traverser; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; - -public class DefaultTraversableTree implements TraversableTree -{ - private final Tree tree; - private final Traverser<Node> traverser; - - public DefaultTraversableTree(Tree _tree,Traverser<Node> _traverser) - { - tree = _tree; - traverser = _traverser; - } - - @Override - public Either<Error,Traversal<Node>> traverse(Evaluator<Node> _e) - { - Node root = tree.getRoot(); - return traverser.traverse(root,_e); - } -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Wed Jan 16 03:23:57 2013 +0900 @@ -74,7 +74,7 @@ } @Override - public Either<Error,TreeEditor> edit(NodePath _path, NodeEditor _editor) + public Either<Error,TreeEditor> edit(NodePath _path,NodeEditor _editor) { DefaultTree tree = tip.getTree(); DefaultNode root = tree.getRoot(); @@ -103,7 +103,12 @@ // target Direction<DefaultNode> targetDirection = path.head(); - LoggingNode loggingNode = (LoggingNode)_editor.edit(new LoggingNode(targetDirection.getTarget())); + Either<Error,LoggingNode<DefaultNode>> either = _editor.edit(new LoggingNode<DefaultNode>(targetDirection.getTarget())); + if(either.isA()){ + return DefaultEither.newA(either.a()); + } + + LoggingNode<DefaultNode> loggingNode = either.b(); Logger logger = loggingNode.getLogger(); DefaultNode newNode = (DefaultNode)loggingNode.getWrapper(); @@ -113,12 +118,12 @@ for(Direction<DefaultNode> parentDirection : path.tail()){ DefaultNode parent = parentDirection.getTarget(); DefaultChildren chs = parent.getChildren(); - Either<Error,DefaultNode> either = chs.replaceNode(child,pos); - if(either.isA()){ - return DefaultEither.newA(either.a()); + Either<Error,DefaultNode> ret = chs.replaceNode(child,pos); + if(ret.isA()){ + return DefaultEither.newA(ret.a()); } - DefaultNode newParent = either.b(); + DefaultNode newParent = ret.b(); child = newParent; pos = parentDirection.getPosition(); } @@ -131,7 +136,7 @@ protected Either<Error,TreeEditor> newEditor(Logger _logger,DefaultNode _newRoot) { List<Logger> logs = List.list(_logger); - TreeEditor newEditor = new DefaultModifiedTreeEditor(logs, + TreeEditor newEditor = null; return DefaultEither.newB(_theB); } } \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TraverserProvider.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TraverserProvider.java Wed Jan 16 03:23:57 2013 +0900 @@ -1,9 +1,9 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Parent; +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 Parent<T>> Traverser<T> newTraverser(); + public <T extends TraversableNode<T>> Traverser<T> newTraverser(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/DefaultLogger.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/DefaultLogger.java Wed Jan 16 03:23:57 2013 +0900 @@ -1,27 +1,22 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger; import java.util.Iterator; - import fj.data.List; - import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.Operation; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; public class DefaultLogger implements Logger { - private final EditableNode wrap; private final List<Operation> log; private static final List<Operation> EMPTY = List.nil(); - public DefaultLogger(EditableNode _wrap) + public DefaultLogger() { - this(_wrap,EMPTY); + this(EMPTY); } - private DefaultLogger(EditableNode _wrap,List<Operation> _log) + private DefaultLogger(List<Operation> _log) { - wrap = _wrap; log = _log; } @@ -34,6 +29,6 @@ @Override public Logger add(Operation _op) { - return new DefaultLogger(wrap,log.cons(_op)); + return new DefaultLogger(log.cons(_op)); } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingAttributes.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingAttributes.java Wed Jan 16 03:23:57 2013 +0900 @@ -10,12 +10,13 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -public class LoggingAttributes implements EditableAttributes +public class LoggingAttributes<T extends EditableNode<T>> + implements EditableAttributes<LoggingNode<T>> { - private final EditableAttributes wrap; + private final EditableAttributes<T> wrap; private final Logger log; - public LoggingAttributes(EditableAttributes _wrap,Logger _log) + public LoggingAttributes(EditableAttributes<T> _wrap,Logger _log) { wrap = _wrap; log = _log; @@ -28,12 +29,12 @@ } @Override - public Either<Error,EditableNode> delete(final String _key) + public Either<Error,LoggingNode<T>> delete(final String _key) { - Either<Error,EditableNode> either = wrap.delete(_key); + Either<Error,T> either = wrap.delete(_key); if(either.isA()){ - return either; + return DefaultEither.newA(either.a()); } Operation opDelete = new DeleteAttributeOperation(){ @@ -44,18 +45,18 @@ }; Logger newLog = log.add(opDelete); - EditableNode newWrap = either.b(); - EditableNode newLoggingNode = new LoggingNode(newWrap,newLog); + T newWrap = either.b(); + LoggingNode<T> newLoggingNode = new LoggingNode<T>(newWrap,newLog); return DefaultEither.newB(newLoggingNode); } @Override - public Either<Error,EditableNode> put(final String _key,final ByteBuffer _value) + public Either<Error,LoggingNode<T>> put(final String _key,final ByteBuffer _value) { - Either<Error,EditableNode> either = wrap.put(_key,_value); + Either<Error,T> either = wrap.put(_key,_value); if(either.isA()){ - return either; + return DefaultEither.newA(either.a()); } Operation opPut = new SetAttributeOperation(){ @@ -71,7 +72,7 @@ }; Logger newLog = log.add(opPut); - EditableNode newLoggingNode = new LoggingNode(either.b(),newLog); + LoggingNode<T> newLoggingNode = new LoggingNode<T>(either.b(),newLog); return DefaultEither.newB(newLoggingNode); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingChildren.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingChildren.java Wed Jan 16 03:23:57 2013 +0900 @@ -13,12 +13,13 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.IterableWrapper; -public class LoggingChildren implements EditableChildren +public class LoggingChildren<T extends EditableNode<T>> + implements EditableChildren<LoggingNode<T>> { - private final EditableChildren wrap; + private final EditableChildren<T> wrap; private final Logger log; - public LoggingChildren(EditableChildren _wrap,Logger _log) + public LoggingChildren(EditableChildren<T> _wrap,Logger _log) { wrap = _wrap; log = _log; @@ -38,11 +39,11 @@ } @Override - public Either<Error,EditableNode> addNewChildAt(final int _pos) + public Either<Error,LoggingNode<T>> addNewChildAt(final int _pos) { - Either<Error,EditableNode> either = wrap.addNewChildAt(_pos); + Either<Error,T> either = wrap.addNewChildAt(_pos); if(either.isA()){ - return either; + return DefaultEither.newA(either.a()); } Operation opAddChild = new AppendChildAtOperation(){ @@ -53,18 +54,18 @@ }; Logger newLog = log.add(opAddChild); - EditableNode newWrap = either.b(); - EditableNode newLoggingNode = new LoggingNode(newWrap,newLog); + T newWrap = either.b(); + LoggingNode<T> newLoggingNode = new LoggingNode<T>(newWrap,newLog); return DefaultEither.newB(newLoggingNode); } @Override - public Either<Error,EditableNode> deleteChildAt(final int _pos) + public Either<Error,LoggingNode<T>> deleteChildAt(final int _pos) { - Either<Error,EditableNode> either = wrap.deleteChildAt(_pos); + Either<Error,T> either = wrap.deleteChildAt(_pos); if(either.isA()){ - return either; + return DefaultEither.newA(either.a()); } Operation opDeleteChild = new DeleteChildAtOperation(){ @@ -75,7 +76,7 @@ }; Logger newLog = log.add(opDeleteChild); - EditableNode newLoggingNode = new LoggingNode(either.b(),newLog); + LoggingNode<T> newLoggingNode = new LoggingNode<T>(either.b(),newLog); return DefaultEither.newB(newLoggingNode); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingNode.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingNode.java Wed Jan 16 03:23:57 2013 +0900 @@ -4,32 +4,33 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableChildren; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; -public class LoggingNode implements EditableNode +public class LoggingNode<T extends EditableNode<T>> + implements EditableNode<LoggingNode<T>> { - public LoggingNode(EditableNode _wrap) + public LoggingNode(T _wrap) { - this(_wrap,new DefaultLogger(_wrap)); + this(_wrap,new DefaultLogger()); } - public LoggingNode(EditableNode _wrap,Logger _log) + public LoggingNode(T _wrap,Logger _log) { wrap = _wrap; log = _log; } - private final EditableNode wrap; + private final T wrap; private final Logger log; @Override - public EditableAttributes getAttributes() + public EditableAttributes<LoggingNode<T>> getAttributes() { - return new LoggingAttributes(wrap.getAttributes(),log); + return new LoggingAttributes<T>(wrap.getAttributes(),log); } @Override - public EditableChildren getChildren() + public EditableChildren<LoggingNode<T>> getChildren() { - return new LoggingChildren(wrap.getChildren(),log); + return new LoggingChildren<T>(wrap.getChildren(),log); } public Logger getLogger() @@ -37,7 +38,7 @@ return log; } - public EditableNode getWrapper() + public T getWrapper() { return wrap; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/AppendChildAt.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/AppendChildAt.java Wed Jan 16 03:23:57 2013 +0900 @@ -14,9 +14,9 @@ } @Override - public Either<Error,EditableNode> edit(EditableNode _e) + public <T extends EditableNode<T>> Either<Error,T> edit(T _e) { - Either<Error,EditableNode> either = _e.getChildren().addNewChildAt(pos); + Either<Error,T> either = _e.getChildren().addNewChildAt(pos); if(either.isA()){ // error return either;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/DeleteAttribute.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/DeleteAttribute.java Wed Jan 16 03:23:57 2013 +0900 @@ -13,7 +13,7 @@ } @Override - public Either<Error,EditableNode> edit(EditableNode _e) + public <T extends EditableNode<T>> Either<Error,T> edit(T _e) { return _e.getAttributes().delete(key); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/DeleteChildAt.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/DeleteChildAt.java Wed Jan 16 03:23:57 2013 +0900 @@ -13,7 +13,7 @@ } @Override - public Either<Error,EditableNode> edit(EditableNode _e) + public <T extends EditableNode<T>> Either<Error,T> edit(T _e) { return _e.getChildren().deleteChildAt(pos); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/EditableAttributes.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/EditableAttributes.java Wed Jan 16 03:23:57 2013 +0900 @@ -6,10 +6,11 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -public interface EditableAttributes extends Attributes +public interface EditableAttributes<T extends EditableNode<T>> + extends Attributes { - public Either<Error,EditableNode> delete(String _key); - public Either<Error,EditableNode> put(String _key,ByteBuffer _value); + public Either<Error,T> delete(String _key); + public Either<Error,T> put(String _key,ByteBuffer _value); public static final Error KEY_NOT_FOUND = new DefaultError(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/EditableChildren.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/EditableChildren.java Wed Jan 16 03:23:57 2013 +0900 @@ -5,10 +5,11 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; -public interface EditableChildren extends Children +public interface EditableChildren<T extends EditableNode<T>> + extends Children { - public Either<Error,EditableNode> addNewChildAt(int _pos); - public Either<Error,EditableNode> deleteChildAt(int _pos); + public Either<Error,T> addNewChildAt(int _pos); + public Either<Error,T> deleteChildAt(int _pos); public final Error OUT_OF_RANGE = new DefaultError(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/EditableNode.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/EditableNode.java Wed Jan 16 03:23:57 2013 +0900 @@ -2,11 +2,13 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; -public interface EditableNode extends Node +public interface EditableNode<T extends EditableNode<T>> + extends Node { @Override - public EditableAttributes getAttributes(); + public EditableAttributes<T> getAttributes(); @Override - public EditableChildren getChildren(); -} \ No newline at end of file + public EditableChildren<T> getChildren(); +} +
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/NodeEditor.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/NodeEditor.java Wed Jan 16 03:23:57 2013 +0900 @@ -5,5 +5,5 @@ public interface NodeEditor { - public Either<Error,EditableNode> edit(EditableNode _e); + public <T extends EditableNode<T>> Either<Error,T> edit(T _e); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/PutAttribute.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/PutAttribute.java Wed Jan 16 03:23:57 2013 +0900 @@ -17,9 +17,9 @@ } @Override - public Either<Error,EditableNode> edit(EditableNode _e) + public <T extends EditableNode<T>> Either<Error,T> edit(T _e) { - EditableAttributes attrs = _e.getAttributes(); + EditableAttributes<T> attrs = _e.getAttributes(); return attrs.put(key,value); } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Children.java Tue Jan 15 23:39:44 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; - -public interface Children<T> extends Iterable<T> -{ - public int size(); -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/DefaultEvaluation.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/DefaultEvaluation.java Wed Jan 16 03:23:57 2013 +0900 @@ -1,6 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; -public class DefaultEvaluation<T extends Parent<T>> implements Evaluation<T> +public class DefaultEvaluation<T extends TraversableNode<T>> implements Evaluation<T> { private final Result result; private final Evaluator<T> evaluator;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/DefaultEvaluator.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/DefaultEvaluator.java Wed Jan 16 03:23:57 2013 +0900 @@ -3,7 +3,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair; -public class DefaultEvaluator<T extends Parent<T>> implements Evaluator<T> +public class DefaultEvaluator<T extends TraversableNode<T>> implements Evaluator<T> { private final NodePath path;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/DefaultTraverser.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/DefaultTraverser.java Wed Jan 16 03:23:57 2013 +0900 @@ -7,12 +7,12 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; import fj.data.List; -public class DefaultTraverser<T extends Parent<T>> implements Traverser<T> +public class DefaultTraverser<T extends TraversableNode<T>> implements Traverser<T> { @Override public Either<Error,Traversal<T>> traverse(final T _root,Evaluator<T> _evaluator) { - Children<T> wrapper = new Children<T>(){ + TraversableChildren<T> wrapper = new TraversableChildren<T>(){ @Override public Iterator<T> iterator(){ List<T> list = List.nil(); @@ -47,7 +47,7 @@ return DefaultEither.newB(traversal); } - private Either<Error,List<Direction<T>>> _traverse(Children<T> _chs,Evaluator<T> _evaluator) + private Either<Error,List<Direction<T>>> _traverse(TraversableChildren<T> _chs,Evaluator<T> _evaluator) { int pos = 0; for(T ch : _chs){ @@ -75,7 +75,7 @@ private Either<Error,List<Direction<T>>> _accept(final T _current,final int _pos,Evaluator<T> _evaluator) { - Children<T> chs = _current.children(); + TraversableChildren<T> chs = _current.children(); Either<Error,List<Direction<T>>> either = _traverse(chs,_evaluator); if(either.isA()){ return either;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Evaluation.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Evaluation.java Wed Jan 16 03:23:57 2013 +0900 @@ -1,6 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; -public interface Evaluation<T extends Parent<T>> +public interface Evaluation<T extends TraversableNode<T>> { public Result result(); public Evaluator<T> evaluator();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Evaluator.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Evaluator.java Wed Jan 16 03:23:57 2013 +0900 @@ -1,6 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; -public interface Evaluator<T extends Parent<T>> +public interface Evaluator<T extends TraversableNode<T>> { public Evaluation<T> evaluate(T _current,int _pos); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Parent.java Tue Jan 15 23:39:44 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; - -public interface Parent<T> -{ - public Children<T> children(); -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Traversable.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Traversable.java Wed Jan 16 03:23:57 2013 +0900 @@ -3,7 +3,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -public interface Traversable<T extends Parent<T>> +public interface Traversable<T extends TraversableNode<T>> { public Either<Error,Traversal<T>> traverse(Evaluator<T> _e); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/TraversableChildren.java Wed Jan 16 03:23:57 2013 +0900 @@ -0,0 +1,6 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; + +public interface TraversableChildren<T> extends Iterable<T> +{ + public int size(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/TraversableNode.java Wed Jan 16 03:23:57 2013 +0900 @@ -0,0 +1,6 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; + +public interface TraversableNode<T> +{ + public TraversableChildren<T> children(); +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Traversal.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Traversal.java Wed Jan 16 03:23:57 2013 +0900 @@ -1,6 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; -public interface Traversal<T extends Parent<T>> extends Iterable<Direction<T>> +public interface Traversal<T extends TraversableNode<T>> extends Iterable<Direction<T>> { public T destination(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Traverser.java Tue Jan 15 23:39:44 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/Traverser.java Wed Jan 16 03:23:57 2013 +0900 @@ -3,7 +3,7 @@ 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<T extends Parent<T>> +public interface Traverser<T extends TraversableNode<T>> { public Either<Error,Traversal<T>> traverse(T _root,Evaluator<T> _evaluator); }