Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 18:8d4cbd5a6525
added Operation
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/ChangeList.java Thu Dec 20 17:18:47 2012 +0900 @@ -0,0 +1,15 @@ +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.store.operations.Operation; + +public interface ChangeList +{ + public Tree getTree(); + public ChangeList prev(); + + public String uuid(); + public long revision(); + + public Iterable<Operation> getOperations(); +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/ChangeSet.java Thu Dec 20 14:23:25 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store; - -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Tree; - -public interface ChangeSet -{ - public Tree getTree(); - public ChangeSet prev(); - - public String uuid(); - public long revision(); - - public Iterable<Command> getCommands(); -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/Command.java Thu Dec 20 14:23:25 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/Command.java Thu Dec 20 17:18:47 2012 +0900 @@ -2,5 +2,8 @@ public enum Command { - APPEND_CHILD,DELETE_CHILD,PUT_ATTRIBUTE,DELETE_ATTRIBUTE; + APPEND_CHILD, + DELETE_CHILD, + SET_ATTRIBUTE, + DELETE_ATTRIBUTE; } \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Thu Dec 20 14:23:25 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Thu Dec 20 17:18:47 2012 +0900 @@ -77,6 +77,7 @@ DefaultTraverseEvaluator te = new DefaultTraverseEvaluator(_path); Iterable<TraverseResult> result = traverser.traverse(t,te); Iterator<TraverseResult> itr = result.iterator(); + if(itr.hasNext()){ TraverseResult r = itr.next(); cloneAndApplyToNodeEditorFromRoot(r,_editor); @@ -94,8 +95,7 @@ return; } - DefaultNode root = (DefaultNode)nodes.next(); - + DefaultNode root = (DefaultNode)nodes.next(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/AppendChildAt.java Thu Dec 20 14:23:25 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/AppendChildAt.java Thu Dec 20 17:18:47 2012 +0900 @@ -1,6 +1,13 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations; -public final class AppendChildAt +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; + +public abstract class AppendChildAt implements Operation { - public static final Parameter<Integer> POSITION = new DefaultParameter<Integer>(); + public Command getCommand() + { + return Command.APPEND_CHILD; + } + + public abstract int position(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/DefaultParameter.java Thu Dec 20 14:23:25 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations; - -public class DefaultParameter<T> implements Parameter<T> -{ -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/DeleteAttribute.java Thu Dec 20 14:23:25 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/DeleteAttribute.java Thu Dec 20 17:18:47 2012 +0900 @@ -1,6 +1,14 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations; -public final class DeleteAttribute +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; + +public abstract class DeleteAttribute implements Operation { - public static final Parameter<String> KEY = new DefaultParameter<String>(); + @Override + public Command getCommand() + { + return Command.DELETE_ATTRIBUTE; + } + + public abstract String getKey(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/DeleteChildAt.java Thu Dec 20 14:23:25 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/DeleteChildAt.java Thu Dec 20 17:18:47 2012 +0900 @@ -1,6 +1,14 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations; -public final class DeleteChildAt +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; + +public abstract class DeleteChildAt implements Operation { - public static final Parameter<Integer> POSITION = new DefaultParameter<Integer>(); + @Override + public Command getCommand() + { + return Command.DELETE_CHILD; + } + + public abstract int position(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/Operation.java Thu Dec 20 14:23:25 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/Operation.java Thu Dec 20 17:18:47 2012 +0900 @@ -5,7 +5,6 @@ public interface Operation { public Command getCommand(); - public Object getParameter(String _param); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/Parameter.java Thu Dec 20 14:23:25 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations; - -public interface Parameter<T> -{ -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/SetAttribute.java Thu Dec 20 14:23:25 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/SetAttribute.java Thu Dec 20 17:18:47 2012 +0900 @@ -1,9 +1,16 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations; import java.nio.ByteBuffer; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; -public final class SetAttribute +public abstract class SetAttribute implements Operation { - public static final Parameter<String> KEY = new DefaultParameter<String>(); - public static final Parameter<ByteBuffer> VALUE = new DefaultParameter<ByteBuffer>(); + @Override + public Command getCommand() + { + return Command.SET_ATTRIBUTE; + } + + public abstract String getKey(); + public abstract ByteBuffer getValue(); }