Mercurial > hg > Members > nobuyasu > jungle-network
diff src/main/java/app/bbs/NetworkJungleBulletinBoard.java @ 179:d6944d788121
fit Junglecore
author | tatsuki |
---|---|
date | Thu, 04 Sep 2014 13:12:25 +0900 |
parents | 6f104ab4eb81 |
children | 2828205bdc3a |
line wrap: on
line diff
--- a/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Mon Sep 01 17:16:20 2014 +0900 +++ b/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Thu Sep 04 13:12:25 2014 +0900 @@ -125,7 +125,7 @@ public Iterable<String> getBoards() { JungleTree tree = jungle.getTreeByName("boards"); TreeNode node = tree.getRootNode(); - Children<TreeNode> chs = node.getChildren(); + Children chs = node.getChildren(); IterableConverter.Converter<String, TreeNode> converter = new IterableConverter.Converter<String, TreeNode>() { public String conv(TreeNode _b) { @@ -186,8 +186,7 @@ NodeEditor e = new NodeEditor() { ByteBuffer tBuffer2 = ByteBuffer.allocate(16); - public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { - TreeNode node = _e; + public Either<Error, TreeNode> edit(TreeNode node) { node = node.getAttributes().put("author", ByteBuffer.wrap(_author.getBytes())).b(); node = node.getAttributes().put("mes", ByteBuffer.wrap(_initMessage.getBytes())).b(); node = node.getAttributes().put("key", ByteBuffer.wrap(_editKey.getBytes())).b(); @@ -196,15 +195,6 @@ return DefaultEither.newB(node); } - @Override - public OperationLog getLog() { - OperationLog op = new DefaultOperationLog(); - op = op.add(new PutAttributeOperation("author", ByteBuffer.wrap(_author.getBytes()))); - op = op.add(new PutAttributeOperation("mes", ByteBuffer.wrap(_initMessage.getBytes()))); - op = op.add(new PutAttributeOperation("key", ByteBuffer.wrap(_editKey.getBytes()))); - op = op.add(new PutAttributeOperation("timestamp", tBuffer2)); - return op; - } }; either = editor.edit(root.add(0), e); @@ -242,13 +232,13 @@ // TraversableNodeWrapper<Node> traversable = new // TraversableNodeWrapper<Node>(node); DefaultEvaluator evaluator = new DefaultEvaluator(path); - Either<Error, Traversal<TreeNode>> ret = traverser.traverse(node, + Either<Error, Traversal> ret = traverser.traverse(node, evaluator); if (ret.isA()) { Assert.fail(); } - Traversal<TreeNode> traversal = ret.b(); + Traversal traversal = ret.b(); TreeNode target = traversal.destination(); int size = target.getChildren().size(); JungleTreeEditor editor = tree.getTreeEditor(); @@ -260,20 +250,12 @@ NodeEditor e = new NodeEditor() { - public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { - TreeNode node = _e; + public Either<Error, TreeNode> edit(TreeNode node) { node = node.getAttributes().put("mes", ByteBuffer.wrap(_message.getBytes())).b(); node = node.getAttributes().put("timestamp", tBuffer).b(); return DefaultEither.newB(node); } - @Override - public OperationLog getLog() { - OperationLog op = new DefaultOperationLog(); - op = op.add(new PutAttributeOperation("mes", ByteBuffer.wrap(_message.getBytes()))); - op = op.add(new PutAttributeOperation("timestamp", tBuffer)); - return op; - } }; path = path.add(size); either = editor.edit(path, e); @@ -311,8 +293,7 @@ editor = either.b(); NodeEditor e = new NodeEditor() { - public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { - TreeNode node = _e; + public Either<Error, TreeNode> edit(TreeNode node) { node = node.getAttributes().put("author", ByteBuffer.wrap(_author.getBytes())).b(); node = node.getAttributes().put("mes", ByteBuffer.wrap(_message.getBytes())).b(); node = node.getAttributes().put("key", ByteBuffer.wrap(_editKey.getBytes())).b(); @@ -320,15 +301,6 @@ return DefaultEither.newB(node); } - @Override - public OperationLog getLog() { - OperationLog op = new DefaultOperationLog(); - op = op.add(new PutAttributeOperation("author", ByteBuffer.wrap(_author.getBytes()))); - op = op.add(new PutAttributeOperation("mes", ByteBuffer.wrap(_message.getBytes()))); - op = op.add(new PutAttributeOperation("key", ByteBuffer.wrap(_editKey.getBytes()))); - op = op.add(new PutAttributeOperation("timestamp", tBuffer)); - return op; - } }; path = path.add(size); either = editor.edit(path, e); @@ -360,8 +332,7 @@ } JungleTreeEditor editor = tree.getTreeEditor(); NodeEditor e = new NodeEditor() { - public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { - TreeNode node = _e; + public Either<Error, TreeNode> edit(TreeNode node) { System.out.println(new String(node.getAttributes().get("mes").array())); node = node.getAttributes().put("author", ByteBuffer.wrap(_author.getBytes())).b(); node = node.getAttributes().put("mes", ByteBuffer.wrap(_message.getBytes())).b(); @@ -371,15 +342,6 @@ return DefaultEither.newB(node); } - @Override - public OperationLog getLog() { - OperationLog op = new DefaultOperationLog(); - op = op.add(new PutAttributeOperation("author", ByteBuffer.wrap(_author.getBytes()))); - op = op.add(new PutAttributeOperation("mes", ByteBuffer.wrap(_message.getBytes()))); - op = op.add(new PutAttributeOperation("key", ByteBuffer.wrap(_editKey.getBytes()))); - op = op.add(new PutAttributeOperation("timestamp", tBuffer)); - return op; - } }; either = editor.edit(path, e); if (either.isA()) { @@ -413,11 +375,10 @@ NodeEditor e = new NodeEditor() { String str; - public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { - TreeNode node = _e; + public Either<Error, TreeNode> edit(TreeNode node) { str = "0"; int count = 0; - for (; _e.getAttributes().get("mes" + String.valueOf(count)) != null; count++) { + for (; node.getAttributes().get("mes" + String.valueOf(count)) != null; count++) { } str = String.valueOf(count); node = node.getAttributes().put("mes" + str,ByteBuffer.wrap(_message.getBytes())).b(); @@ -425,13 +386,6 @@ return DefaultEither.newB(node); } - @Override - public OperationLog getLog() { - OperationLog op = new DefaultOperationLog(); - op = op.add(new PutAttributeOperation("mes" + str,ByteBuffer.wrap(_message.getBytes()))); - op = op.add(new PutAttributeOperation("timestamp" + str,tBuffer)); - return op; - } }; either = editor.edit(path, e); if (either.isA()) { @@ -462,21 +416,13 @@ JungleTreeEditor editor = tree.getTreeEditor(); NodeEditor e = new NodeEditor() { - public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { - TreeNode node = _e; + public Either<Error, TreeNode> edit(TreeNode node) { // EnableNodeWrapper<T> node = _e.getWrap(); node = node.getAttributes().put("mes" + id,ByteBuffer.wrap(_message.getBytes())).b(); node = node.getAttributes().put("timestamp" + id, tBuffer).b(); return DefaultEither.newB(node); } - @Override - public OperationLog getLog() { - OperationLog op = new DefaultOperationLog(); - op = op.add(new PutAttributeOperation("mes"+ id, ByteBuffer.wrap(_message.getBytes()))); - op = op.add(new PutAttributeOperation("timestamp"+ id, tBuffer)); - return op; - } }; either = editor.edit(path, e); if (either.isA()) { @@ -538,13 +484,12 @@ JungleTreeEditor editor = tree.getTreeEditor(); NodeEditor e = new NodeEditor() { - public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { - TreeNode node = _e; + public Either<Error, TreeNode> edit(TreeNode node) { node = node.getAttributes().delete("mes" + id).b(); node = node.getAttributes().delete("timestamp" + id).b(); int count = Integer.parseInt(id); for (; node.getAttributes().get("mes" + String.valueOf(count + 1)) != null;) { - node = node.getAttributes().put("mes" + count,_e.getAttributes().get("mes"+ String.valueOf(count + 1))).b(); + node = node.getAttributes().put("mes" + count,node.getAttributes().get("mes"+ String.valueOf(count + 1))).b(); node = node.getAttributes().put("timestamp" + count, tBuffer).b(); count++; } @@ -556,10 +501,6 @@ return DefaultEither.newB(node); } - @Override - public OperationLog getLog() { - return new DefaultOperationLog(); - } }; either = editor.edit(path, e); if (either.isA()) { @@ -584,24 +525,13 @@ JungleTreeEditor editor = tree.getTreeEditor(); NodeEditor e = new NodeEditor() { - public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { - TreeNode node = _e; + public Either<Error, TreeNode> edit(TreeNode node) { node = node.getAttributes().put("author", ByteBuffer.wrap(_author.getBytes())).b(); node = node.getAttributes().put("mes", ByteBuffer.wrap(_message.getBytes())).b(); node = node.getAttributes().put("key", ByteBuffer.wrap(_editKey.getBytes())).b(); node = node.getAttributes().put("timestamp", tBuffer).b(); return DefaultEither.newB(node); } - - @Override - public OperationLog getLog() { - OperationLog op = new DefaultOperationLog(); - op = op.add(new PutAttributeOperation("author", ByteBuffer.wrap(_author.getBytes()))); - op = op.add(new PutAttributeOperation("mes", ByteBuffer.wrap(_message.getBytes()))); - op = op.add(new PutAttributeOperation("key", ByteBuffer.wrap(_editKey.getBytes()))); - op = op.add(new PutAttributeOperation("timestamp", tBuffer)); - return op; - } }; either = editor.edit(path, e); if (either.isA()) { @@ -617,7 +547,7 @@ requestCounter.incrementAndGet(); JungleTree tree = jungle.getTreeByName(_boardName); TreeNode node = tree.getRootNode(); - Children<TreeNode> chs = node.getChildren(); + Children chs = node.getChildren(); final AtomicInteger counter = new AtomicInteger(0); IterableConverter.Converter<BoardMessage, TreeNode> converter = new IterableConverter.Converter<BoardMessage, TreeNode>() { public BoardMessage conv(TreeNode _b) { @@ -649,15 +579,15 @@ // TraversableNodeWrapper<Node> traversable = new // TraversableNodeWrapper<Node>(node); DefaultEvaluator evaluator = new DefaultEvaluator(path); - Either<Error, Traversal<TreeNode>> ret = traverser.traverse(node, + Either<Error, Traversal> ret = traverser.traverse(node, evaluator); if (ret.isA()) { Assert.fail(); } - Traversal<TreeNode> traversal = ret.b(); + Traversal traversal = ret.b(); TreeNode target = traversal.destination(); - Children<TreeNode> chs = target.getChildren(); + Children chs = target.getChildren(); final AtomicInteger counter = new AtomicInteger(0); IterableConverter.Converter<BoardMessage, TreeNode> converter = new IterableConverter.Converter<BoardMessage, TreeNode>() { @@ -691,13 +621,13 @@ // TraversableNodeWrapper<Node> traversable = new // TraversableNodeWrapper<Node>(node); DefaultEvaluator evaluator = new DefaultEvaluator(path); - Either<Error, Traversal<TreeNode>> ret = traverser.traverse(node, + Either<Error, Traversal> ret = traverser.traverse(node, evaluator); if (ret.isA()) { Assert.fail(); } - Traversal<TreeNode> traversal = ret.b(); + Traversal traversal = ret.b(); TreeNode target = traversal.destination(); return new getAttributeImp(target); }