Mercurial > hg > Database > jungle-network
changeset 25:2232263d449b
print message in ShowAttribute
author | one |
---|---|
date | Sun, 30 Jun 2013 10:56:19 +0900 |
parents | 2a378b94cc55 |
children | 1d7f52c3b3d9 |
files | src/jungle/test/codesegment/practice/ShowAttribute.java src/jungle/test/codesegment/practice/TestPutAttributeCodeSegment.java |
diffstat | 2 files changed, 25 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jungle/test/codesegment/practice/ShowAttribute.java Sun Jun 30 04:32:37 2013 +0900 +++ b/src/jungle/test/codesegment/practice/ShowAttribute.java Sun Jun 30 10:56:19 2013 +0900 @@ -47,7 +47,8 @@ Node node = tree.getRootNode(); Children<Node> chs = node.getChildren(); for(Node n : chs) { - System.out.println(n.getAttributes().get("key1")); + ByteBuffer b = n.getAttributes().get("key1"); + System.out.println(new String(b.array())); } System.exit(0);
--- a/src/jungle/test/codesegment/practice/TestPutAttributeCodeSegment.java Sun Jun 30 04:32:37 2013 +0900 +++ b/src/jungle/test/codesegment/practice/TestPutAttributeCodeSegment.java Sun Jun 30 10:56:19 2013 +0900 @@ -52,8 +52,23 @@ } Jungle jungle = new JungleManager().getJungle(); JungleTree tree = jungle.getTreeByName("tree"); - NetworkDefaultJungleTreeEditor editor = (NetworkDefaultJungleTreeEditor) tree.getTreeEditor(); - edit(editor, convertedOp); + JungleTreeEditor ed = tree.getTreeEditor(); + DefaultNodePath root = new DefaultNodePath(); + Either<Error,JungleTreeEditor> r = ed.addNewChildAt(root, 0); + if(r.isA()) { + throw new IllegalStateException(); + } + ed = r.b(); + ed.success(); + + + + NetworkDefaultJungleTreeEditor nEditor = (NetworkDefaultJungleTreeEditor) tree.getTreeEditor(); + Either<Error,JungleTreeEditor> either = edit(nEditor, convertedOp); + if(either.isA()) { + throw new IllegalStateException(); + } + JungleTreeEditor editor = either.b(); editor.success(); if (arg1.index >= 10) { new ShowAttribute(); @@ -82,7 +97,7 @@ return treeOp; } - public void edit(JungleTreeEditor editor, TreeOperation op) { + public Either<Error, JungleTreeEditor> edit(JungleTreeEditor editor, TreeOperation op) { NodePath path = op.getNodePath(); NodeOperation nodeOp = op.getNodeOperation(); Command c = nodeOp.getCommand(); @@ -98,26 +113,18 @@ } else { str = String.format("key:%s,value:%d", key, value.limit()); } - editor.putAttribute(path, key, value); - break; + return editor.putAttribute(path, key, value); case DELETE_ATTRIBUTE: key = nodeOp.getKey(); str = String.format("key:%s", nodeOp.getKey()); - editor.deleteAttribute(path, key); - break; + return editor.deleteAttribute(path, key); case APPEND_CHILD: str = String.format("pos:%d", nodeOp.getPosition()); - editor.addNewChildAt(path, 0); - break; + return editor.addNewChildAt(path, 0); case DELETE_CHILD: str = String.format("pos:%d", nodeOp.getPosition()); - editor.deleteChildAt(path, 0); - break; + return editor.deleteChildAt(path, 0); } - System.out.println(String.format("[%s:%s]", c, str)); - System.out.println("path:"); - for (int i: path ) { - System.out.println(i); - } + return null; } }