annotate src/main/java/alice/datasegment/Receiver.java @ 650:4289b232b3fd

nulValue
author suruga
date Fri, 02 Feb 2018 18:26:49 +0900
parents 33f300d0720a
children 058bff2123c8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
1 package alice.datasegment;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
2
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
3
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
4 import alice.codesegment.InputDataSegment;
636
33f300d0720a running CodeSegment by Annotation without create Receiver :D
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 525
diff changeset
5 import javassist.compiler.ast.ASTree;
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
6
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
7 /**
523
145c425db88d add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 458
diff changeset
8 * idsコマンド(create, setKey)の処理をする。コマンドの定義はids/LDSM内にある。
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
9 * MessagePack implementation and DataSegment Receiver
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
10 * @author kazz
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
11 *
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
12 */
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
13 public class Receiver {
452
f68d103498e0 refactor (InputDataSegment holder class changed)
sugi
parents: 417
diff changeset
14 private ReceiveData data;
417
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
15 public InputDataSegment ids;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
16 public int index;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
17 public String from;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
18 public CommandType type;
525
30a74eee59c7 working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 523
diff changeset
19 public String managerKey;//DSMを一意に特定。localかremoteか、どのremoteからか。
417
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
20 public String key;
523
145c425db88d add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 458
diff changeset
21 public boolean compressedFlag = false;
417
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
22
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
23 public Receiver(InputDataSegment ids, CommandType type) {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
24 this.ids = ids;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
25 this.type = type;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
26 ids.register();
523
145c425db88d add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 458
diff changeset
27 }
417
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
28
523
145c425db88d add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 458
diff changeset
29 public Receiver(InputDataSegment ids, CommandType type, boolean compressedFlag) {
145c425db88d add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 458
diff changeset
30 this.ids = ids;
145c425db88d add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 458
diff changeset
31 this.type = type;
145c425db88d add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 458
diff changeset
32 ids.register();
145c425db88d add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 458
diff changeset
33 this.compressedFlag = compressedFlag;
417
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
34 }
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
35
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
36 public void setQuickKey(String managerKey, String key){
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
37 setQuickKey(managerKey, key, 0);
523
145c425db88d add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 458
diff changeset
38 }//?
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
39
417
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
40 public void setQuickKey(String managerKey, String key, int index) {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
41 this.managerKey = managerKey;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
42 this.key = key;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
43 switch (type) {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
44 case PEEK:
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
45 ids.quickPeek(this);
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
46 break;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
47 case TAKE:
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
48 ids.quickTake(this);
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
49 break;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
50 default:
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
51 break;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
52 }
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
53 ids.setKey();
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
54 }
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
55
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
56 public void setKey(String managerKey, String key) {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
57 setKey(managerKey, key, 0);
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
58 }
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
59
417
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
60 public void setKey(String managerKey, String key, int index) {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
61 this.managerKey = managerKey;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
62 this.key = key;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
63 this.index = index;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
64 switch (type) {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
65 case PEEK:
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
66 ids.peek(this);
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
67 break;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
68 case TAKE:
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
69 ids.take(this);
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
70 break;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
71 default:
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
72 break;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
73 }
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
74 ids.setKey();
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
75 }
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
76
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
77 public void setKey(String key) {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
78 setKey(key, 0);
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
79 }
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
80
417
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
81 public void setKey(String key, int index) {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
82 this.key = key;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
83 this.index = index;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
84 switch (type) {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
85 case PEEK:
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
86 ids.peek(this);
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
87 break;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
88 case TAKE:
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
89 ids.take(this);
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
90 break;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
91 default:
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
92 break;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
93 }
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
94 ids.setKey();
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
95 }
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
96
523
145c425db88d add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 458
diff changeset
97 //以下各型でDS本体を受け取る
452
f68d103498e0 refactor (InputDataSegment holder class changed)
sugi
parents: 417
diff changeset
98 public void setData(ReceiveData r) {
417
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
99 data = r;
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
100 }
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
101
417
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
102 public int asInteger() {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
103 return data.asInteger();
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
104 }
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
105
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
106 public String asString() {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
107 return data.asString();
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
108 }
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
109
417
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
110 public <T> T asClass(Class<T> clazz) {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
111 return data.asClass(clazz);
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
112 }
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
113
417
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
114 public Object getObj() {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
115 return data.getObj();
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
116 }
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
117
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
118 public Object getVal() {
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
119 return data.getVal();
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
120 }
aadea6a59376 create MetaCodeSegment use reflection
sugi
parents: 345
diff changeset
121
458
bcf6f4a6fcd0 need set Meta DataSegment PUT API
sugi
parents: 452
diff changeset
122 public ReceiveData getReceiveData() {
bcf6f4a6fcd0 need set Meta DataSegment PUT API
sugi
parents: 452
diff changeset
123 return data;
bcf6f4a6fcd0 need set Meta DataSegment PUT API
sugi
parents: 452
diff changeset
124 }
525
30a74eee59c7 working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 523
diff changeset
125
30a74eee59c7 working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 523
diff changeset
126 public boolean isCompressed(){
30a74eee59c7 working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 523
diff changeset
127 return data.compressed();
30a74eee59c7 working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents: 523
diff changeset
128 }
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
129 }