Mercurial > hg > Database > jungle-network
view src/alice/jungle/datasegment/store/operations/DefaultNodePathContainer.java @ 67:89e39301ccaa
remove some warning
author | one |
---|---|
date | Thu, 10 Oct 2013 19:17:21 +0900 |
parents | 85bc7416ae02 |
children |
line wrap: on
line source
package alice.jungle.datasegment.store.operations; import java.io.IOException; import java.util.LinkedList; import java.util.List; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; import org.msgpack.MessagePack; import org.msgpack.annotation.Message; import org.msgpack.template.IntegerTemplate; import org.msgpack.template.ListTemplate; import org.msgpack.type.Value; @Message public class DefaultNodePathContainer { public Value pathValue; public static void main(String[] args) throws IOException { DefaultNodePath p = new DefaultNodePath(); p = p.add(1).add(2).add(3); DefaultNodePathContainer pathContainer = new DefaultNodePathContainer(); pathContainer.unconvert(p); NodePath convertedPath = pathContainer.convert(); for (int i : convertedPath) { System.out.println(i); } } public DefaultNodePathContainer() { } public void unconvert(NodePath path) throws IOException { MessagePack msgpack = new MessagePack(); List<Integer> list = new LinkedList<Integer>(); for(Integer i : path) { list.add(i); } /* Remove first Element(-1). */ list.remove(0); Value v = msgpack.unconvert(list); pathValue = v; } public DefaultNodePath convert() throws IOException { MessagePack msgpack = new MessagePack(); msgpack.register(List.class, new ListTemplate(IntegerTemplate.getInstance())); List<Integer> convertedList = (List<Integer>)msgpack.convert(pathValue, List.class); DefaultNodePath path = new DefaultNodePath(); for (int i: convertedList) { path = path.add(i); } return path; } }