Mercurial > hg > Members > nobuyasu > PracticeJava
view src/ie/oshiro/messagepack/jungle/containvalue/ListValueValueValue.java @ 4:a7cd9a10033b
add PracticeEnum
author | one |
---|---|
date | Sun, 09 Jun 2013 13:13:02 +0900 |
parents | |
children |
line wrap: on
line source
package ie.oshiro.messagepack.jungle.containvalue; import java.io.IOException; import java.util.Arrays; import java.util.List; import org.msgpack.MessagePack; import org.msgpack.type.Value; public class ListValueValueValue { public Value lvv; public ListValueValueValue() { lvv = null; } public void setlvv(Value v) { lvv = v; } public Value getlvv() { return lvv; } public ListValueValue getLVV() throws IOException { MessagePack msgpack = new MessagePack(); return msgpack.convert(lvv, ListValueValue.class); } public void setLVV(ListValueValue _lvv) throws IOException { MessagePack msgpack = new MessagePack(); Value v = msgpack.unconvert(_lvv); lvv = v; } public static void main(String[] args) throws IOException { /* serialize */ List<Integer> list = Arrays.asList(20,21,22,23); ListValue listValue = new ListValue(); listValue.setList(list); ListValueValue lvv = new ListValueValue(); lvv.setListValue(listValue); ListValueValueValue lvvv = new ListValueValueValue(); lvvv.setLVV(lvv); /* deserialize */ ListValueValue convertedLVV = lvvv.getLVV(); ListValue convertedLV = convertedLVV.getListValue(); List<Value> convertedList = convertedLV.getList(); for (Value v: convertedList) { System.out.println(v.asIntegerValue()); } } }