Mercurial > hg > Database > Alice
comparison src/main/java/alice/datasegment/ReceiveRemoteData.java @ 345:8f71c3e6f11d
Change directory structure Maven standard
author | sugi |
---|---|
date | Wed, 16 Apr 2014 18:26:07 +0900 |
parents | |
children | aefbe41fcf12 |
comparison
equal
deleted
inserted
replaced
344:9f97ec18f8c5 | 345:8f71c3e6f11d |
---|---|
1 package alice.datasegment; | |
2 | |
3 import java.io.IOException; | |
4 | |
5 import org.msgpack.type.ArrayValue; | |
6 import org.msgpack.type.Value; | |
7 import org.msgpack.type.ValueType; | |
8 | |
9 import alice.codesegment.SingletonMessage; | |
10 | |
11 public class ReceiveRemoteData implements ReceiverData { | |
12 public Value val; | |
13 | |
14 public ReceiveRemoteData() { | |
15 } | |
16 | |
17 public ReceiveRemoteData(Value val2) { | |
18 this.val = val2; | |
19 } | |
20 | |
21 public String asString() { | |
22 if (val.getType() == ValueType.RAW) { | |
23 return val.asRawValue().getString(); | |
24 } | |
25 return null; | |
26 } | |
27 | |
28 public int asInteger() { | |
29 if (val.getType() == ValueType.INTEGER) { | |
30 return val.asIntegerValue().getInt(); | |
31 } | |
32 return 0; | |
33 } | |
34 | |
35 public Float asFloat() { | |
36 if (val.getType() == ValueType.FLOAT) { | |
37 return val.asFloatValue().getFloat(); | |
38 } | |
39 return 0.0f; | |
40 } | |
41 | |
42 public ArrayValue asArray(){ | |
43 if (val.getType() == ValueType.ARRAY){ | |
44 return val.asArrayValue(); | |
45 } | |
46 return null; | |
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 | |
57 } | |
58 | |
59 @Override | |
60 public Value getVal() { | |
61 return val; | |
62 } | |
63 | |
64 @Override | |
65 public Object getObj() { | |
66 return val; | |
67 } | |
68 | |
69 } |