Mercurial > hg > Members > nobuyasu > jungle-network
comparison src/alice/jungle/operations/NetworkNodeOperation.java @ 79:5b9708d9febc
Modified NetworkTreeOperationLog NetworkNodeOperation
author | one |
---|---|
date | Wed, 16 Oct 2013 19:25:02 +0900 |
parents | 0055d917c796 |
children | b3ccefdf2b43 |
comparison
equal
deleted
inserted
replaced
78:0055d917c796 | 79:5b9708d9febc |
---|---|
2 | 2 |
3 import java.nio.ByteBuffer; | 3 import java.nio.ByteBuffer; |
4 | 4 |
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; | 5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; |
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; | 6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; |
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.DeleteAttribute; | |
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.DeleteChildAt; | |
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; | |
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.PutAttribute; | |
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; | |
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; | |
7 | 13 |
8 import org.msgpack.annotation.Message; | 14 import org.msgpack.annotation.Message; |
9 | 15 |
16 import alice.jungle.datasegment.store.transformer.NetworkAppendChildAt; | |
17 | |
10 @Message | 18 @Message |
11 public class NetworkNodeOperation { | 19 public class NetworkNodeOperation implements NodeOperation{ |
12 | 20 |
13 public int pos; | 21 public int pos; |
14 public String key; | 22 public String key; |
15 public ByteBuffer value; | 23 public ByteBuffer value; |
16 public int commandType; | 24 public int commandType; |
75 | 83 |
76 public ByteBuffer getValue() { | 84 public ByteBuffer getValue() { |
77 return value; | 85 return value; |
78 } | 86 } |
79 | 87 |
88 @Override | |
89 public <T extends EditableNode<T>> Either<Error, T> invoke(T _target) { | |
90 switch(getCommand(commandType)) { | |
91 case PUT_ATTRIBUTE: | |
92 PutAttribute putAttribute = new PutAttribute(key,value); | |
93 return putAttribute.edit(_target); | |
94 case APPEND_CHILD: | |
95 NetworkAppendChildAt appendChildAt = new NetworkAppendChildAt(pos); | |
96 return appendChildAt.edit(_target); | |
97 case DELETE_CHILD: | |
98 DeleteChildAt deleteChildAt = new DeleteChildAt(pos); | |
99 return deleteChildAt.edit(_target); | |
100 case DELETE_ATTRIBUTE: | |
101 DeleteAttribute deleteAttribute = new DeleteAttribute(key); | |
102 return deleteAttribute.edit(_target); | |
103 default: | |
104 break; | |
105 } | |
106 return null; | |
107 } | |
108 | |
80 } | 109 } |