Mercurial > hg > Members > nobuyasu > PracticeJava
view src/ie/oshiro/messagepack/jungle/containvalue/ListValue.java @ 4:a7cd9a10033b
add PracticeEnum
author | one |
---|---|
date | Sun, 09 Jun 2013 13:13:02 +0900 |
parents | src/ie/oshiro/messagepack/jungle/practice/ListValue.java@5b77974d641b |
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.annotation.Message; import org.msgpack.template.ListTemplate; import org.msgpack.template.ValueTemplate; import org.msgpack.type.Value; @Message public class ListValue { public Value iterValue; public ListValue() { iterValue = null; } public void setList(List<Integer> list) throws IOException { MessagePack msgpack = new MessagePack(); Value v = msgpack.unconvert(list); iterValue = v; } public List<Value> getList() throws IOException { MessagePack msgpack = new MessagePack(); msgpack.register(List.class, new ListTemplate(ValueTemplate.getInstance())); return (List<Value>)msgpack.convert(iterValue, List.class); } public void setIterValue(Value iter) { iterValue = iter; } public Value getIterValue() { return iterValue; } public static void main(String[] args) throws IOException { List<Integer> list = Arrays.asList(1,2,3,4); ListValue lv = new ListValue(); lv.setList(list); List<Value> convertedList = lv.getList(); for (Value v: convertedList) { System.out.println(v.asIntegerValue()); } } }