Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 242:30c0ca7d36a5 Implementation_of_communication
commandline show trees implements
author | tatsuki |
---|---|
date | Mon, 15 Feb 2016 14:20:09 +0900 |
parents | 5a301161e36a |
children | fe0d5ed68caf |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/DefaultJungle.java src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/Jungle.java src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/commandline/commandline.java src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/core/NetworkDefaultJungle.java src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungle.java |
diffstat | 5 files changed, 81 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/DefaultJungle.java Mon Feb 15 14:04:51 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/DefaultJungle.java Mon Feb 15 14:20:09 2016 +0900 @@ -1,24 +1,25 @@ package jp.ac.u_ryukyu.ie.cr.jungle; -import jp.ac.u_ryukyu.ie.cr.jungle.persistent.Journal; -import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.logger.DefaultTreeOperationLog; -import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.logger.TreeOperationLog; -import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; import jp.ac.u_ryukyu.ie.cr.jungle.persistent.ChangeList; +import jp.ac.u_ryukyu.ie.cr.jungle.persistent.Journal; import jp.ac.u_ryukyu.ie.cr.jungle.persistent.NullJournal; import jp.ac.u_ryukyu.ie.cr.jungle.store.TreeContext; import jp.ac.u_ryukyu.ie.cr.jungle.store.TreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.logger.DefaultTreeOperationLog; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.logger.TreeOperationLog; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.TreeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DefaultTreeContext; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import java.util.Enumeration; import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; @@ -89,4 +90,21 @@ } return newTree; } + + @Override + public Iterator<String> getTreeNames() { + Enumeration<String> treeNames = trees.keys(); + return new Iterator<String>(){ + + @Override + public boolean hasNext() { + return treeNames.hasMoreElements(); + } + + @Override + public String next() { + return treeNames.nextElement(); + } + }; + } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/Jungle.java Mon Feb 15 14:04:51 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/Jungle.java Mon Feb 15 14:20:09 2016 +0900 @@ -1,8 +1,11 @@ package jp.ac.u_ryukyu.ie.cr.jungle; +import java.util.Iterator; + public interface Jungle { public JungleTree getTreeByName(String name); public JungleTree createNewTree(String name); + public Iterator<String> getTreeNames(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/commandline/commandline.java Mon Feb 15 14:04:51 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/commandline/commandline.java Mon Feb 15 14:20:09 2016 +0900 @@ -39,11 +39,27 @@ InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String str = br.readLine(); - if (str.equals("exit")) - break; - parse(str); + switch (str) { + case "exit": + System.out.println("see you"); + System.exit(0); + break; + case "trees": + showTrees(); + default: + parse(str); + + } } - System.out.println("exit"); + } + + private void showTrees() { + System.out.println("---------------------------------------------------------------------"); + Iterator<String> treeNames = jungle.getTreeNames(); + for (; treeNames.hasNext(); ) { + System.out.println(treeNames.next()); + } + System.out.println("---------------------------------------------------------------------"); } private void parse(String sql) { @@ -97,7 +113,6 @@ } private void dataImport(String treeName, String url) { - //テストxmlの読み込み 後で消す if (treeName.equals("") || url.equals("")) { System.out.println("faild"); return; @@ -108,7 +123,7 @@ new XmlReader().start(url + ".xml", tree); } - private void update(String treeName, String args, Iterator<String> iterator) { + private void update(String treeName, String args, Iterator<String> iterator) { { String[] split = args.split(">");//,で分割するとpathがおかしくなるので>で分割することでpathとkey:valueの組み合わせに分ける if (split.length < 2) {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/core/NetworkDefaultJungle.java Mon Feb 15 14:04:51 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/core/NetworkDefaultJungle.java Mon Feb 15 14:20:09 2016 +0900 @@ -17,6 +17,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.transaction.NetworkDefaultJungleTree; +import java.util.Enumeration; import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; @@ -71,4 +72,21 @@ } return newTree; } + + @Override + public Iterator<String> getTreeNames() { + Enumeration<String> treeNames = trees.keys(); + return new Iterator<String>() { + + @Override + public boolean hasNext() { + return treeNames.hasMoreElements(); + } + + @Override + public String next() { + return treeNames.nextElement(); + } + }; + } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungle.java Mon Feb 15 14:04:51 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungle.java Mon Feb 15 14:20:09 2016 +0900 @@ -14,6 +14,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; +import java.util.Enumeration; import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; @@ -69,4 +70,20 @@ return newTree; } + @Override + public Iterator<String> getTreeNames() { + Enumeration<String> treeNames = trees.keys(); + return new Iterator<String>() { + + @Override + public boolean hasNext() { + return treeNames.hasMoreElements(); + } + + @Override + public String next() { + return treeNames.nextElement(); + } + }; + } }