Mercurial > hg > Database > Alice
comparison src/main/java/alice/datasegment/ReceiveRemoteData.java @ 419:aefbe41fcf12 dispose
change tab to space
author | sugi |
---|---|
date | Tue, 15 Jul 2014 16:00:22 +0900 |
parents | 8f71c3e6f11d |
children | 2f2623484b77 |
comparison
equal
deleted
inserted
replaced
418:a269a019f5f8 | 419:aefbe41fcf12 |
---|---|
7 import org.msgpack.type.ValueType; | 7 import org.msgpack.type.ValueType; |
8 | 8 |
9 import alice.codesegment.SingletonMessage; | 9 import alice.codesegment.SingletonMessage; |
10 | 10 |
11 public class ReceiveRemoteData implements ReceiverData { | 11 public class ReceiveRemoteData implements ReceiverData { |
12 public Value val; | 12 public Value val; |
13 | 13 |
14 public ReceiveRemoteData() { | 14 public ReceiveRemoteData() { |
15 } | 15 } |
16 | 16 |
17 public ReceiveRemoteData(Value val2) { | 17 public ReceiveRemoteData(Value val2) { |
18 this.val = val2; | 18 this.val = val2; |
19 } | 19 } |
20 | 20 |
21 public String asString() { | 21 public String asString() { |
22 if (val.getType() == ValueType.RAW) { | 22 if (val.getType() == ValueType.RAW) { |
23 return val.asRawValue().getString(); | 23 return val.asRawValue().getString(); |
24 } | 24 } |
25 return null; | 25 return null; |
26 } | 26 } |
27 | 27 |
28 public int asInteger() { | 28 public int asInteger() { |
29 if (val.getType() == ValueType.INTEGER) { | 29 if (val.getType() == ValueType.INTEGER) { |
30 return val.asIntegerValue().getInt(); | 30 return val.asIntegerValue().getInt(); |
31 } | 31 } |
32 return 0; | 32 return 0; |
33 } | 33 } |
34 | 34 |
35 public Float asFloat() { | 35 public Float asFloat() { |
36 if (val.getType() == ValueType.FLOAT) { | 36 if (val.getType() == ValueType.FLOAT) { |
37 return val.asFloatValue().getFloat(); | 37 return val.asFloatValue().getFloat(); |
38 } | 38 } |
39 return 0.0f; | 39 return 0.0f; |
40 } | 40 } |
41 | 41 |
42 public ArrayValue asArray(){ | 42 public ArrayValue asArray(){ |
43 if (val.getType() == ValueType.ARRAY){ | 43 if (val.getType() == ValueType.ARRAY){ |
44 return val.asArrayValue(); | 44 return val.asArrayValue(); |
45 } | 45 } |
46 return null; | 46 return null; |
47 } | 47 } |
48 | |
49 public <T> T asClass(Class<T> clazz) { | |
50 try { | |
51 return SingletonMessage.getInstance().convert(val, clazz); | |
52 } catch (IOException e) { | |
53 e.printStackTrace(); | |
54 } | |
55 return null; | |
56 | 48 |
57 } | 49 public <T> T asClass(Class<T> clazz) { |
50 try { | |
51 return SingletonMessage.getInstance().convert(val, clazz); | |
52 } catch (IOException e) { | |
53 e.printStackTrace(); | |
54 } | |
55 return null; | |
58 | 56 |
59 @Override | 57 } |
60 public Value getVal() { | |
61 return val; | |
62 } | |
63 | 58 |
64 @Override | 59 @Override |
65 public Object getObj() { | 60 public Value getVal() { |
66 return val; | 61 return val; |
67 } | 62 } |
68 | 63 |
64 @Override | |
65 public Object getObj() { | |
66 return val; | |
67 } | |
68 | |
69 } | 69 } |