Mercurial > hg > Members > nobuyasu > jungle-network
view src/main/java/alice/jungle/persistent/AliceJournal.java @ 135:2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 12 Jan 2014 06:18:37 +0900 |
parents | 895ab2907db3 |
children |
line wrap: on
line source
package alice.jungle.persistent; import java.io.File; import java.io.FileNotFoundException; import java.util.Iterator; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Result; public class AliceJournal implements NetworkJournal { private static final AliceChangeListWriter ALICE_WRITER = new AliceChangeListWriter(); private static final AliceChangeListReader ALICE_READER = new AliceChangeListReader(); @Override public ChangeListReader getReader() { return ALICE_READER; } @Override public ChangeListWriter getWriter() { return ALICE_WRITER; } private static class AliceChangeListWriter implements ChangeListWriter { @Override public Result write(ChangeList _operations) { /* for(TreeOperation op : _operations){ NodePath p = op.getNodePath(); NodeOperation nodeOp = op.getNodeOperation(); Command c = nodeOp.getCommand(); String args = ""; switch(c){ case PUT_ATTRIBUTE: String key = nodeOp.getKey(); ByteBuffer value = nodeOp.getValue(); if(value.limit() < 100){ args = String.format("key:%s,value:%s",key,new String(value.array())); }else{ args = String.format("key:%s,value:%d",key,value.limit()); } break; case DELETE_ATTRIBUTE: args = String.format("key:%s",nodeOp.getKey()); break; case APPEND_CHILD: args = String.format("pos:%d",nodeOp.getPosition()); break; case DELETE_CHILD: args = String.format("pos:%d",nodeOp.getPosition()); break; } System.out.println(String.format("[%s:%s:%s]",c,p,args)); } */ return Result.SUCCESS; } } private static class AliceChangeListReader implements ChangeListReader { @Override public ChangeListReader newReader() { return this; } @Override public ChangeList read() { return null; } @Override public Iterator<ChangeList> iterator() { return null; } } @Override public void setInputFile(File file) throws FileNotFoundException { } @Override public void setOutputFile(File file) throws FileNotFoundException { } }