Mercurial > hg > Members > shoshi > TreeCMS > TreeCMSPrototype1
changeset 7:18f696e9fc1e
merge
author | shoshi |
---|---|
date | Sat, 28 Aug 2010 15:43:18 +0900 |
parents | 1c67e35efd1c |
children | 8fbe7ba1d820 |
files | src/treecms/proto/api/NodeAPI.java src/treecms/proto/api/NodeAPITreeBuilder.java src/treecms/proto/edit/EditableNodeAPITreeBuilder.java src/treecms/proto/simple/SimpleNodeAPI.java src/treecms/proto/simple/SimpleNodeAPITreeBuilder.java src/treecms/proto/test/PreOrderTreeWalker.java src/treecms/proto/test/PreOrderTreeWalkerRecursive.java src/treecms/proto/test/Test1.java |
diffstat | 8 files changed, 81 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/treecms/proto/api/NodeAPI.java Sat Aug 28 15:40:49 2010 +0900 +++ b/src/treecms/proto/api/NodeAPI.java Sat Aug 28 15:43:18 2010 +0900 @@ -10,7 +10,7 @@ List<NodeAPI> getChildList(); boolean isChild(NodeAPI _child); - NodeAPI addChild(); + void addChild(NodeAPI _child); void removeChild(NodeAPI _child); void up(NodeAPI _child);
--- a/src/treecms/proto/api/NodeAPITreeBuilder.java Sat Aug 28 15:40:49 2010 +0900 +++ b/src/treecms/proto/api/NodeAPITreeBuilder.java Sat Aug 28 15:43:18 2010 +0900 @@ -2,5 +2,6 @@ public interface NodeAPITreeBuilder { - NodeAPI getContents(); + public NodeAPI getContents(); + public NodeAPI createNode(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/treecms/proto/edit/EditableNodeAPITreeBuilder.java Sat Aug 28 15:43:18 2010 +0900 @@ -0,0 +1,25 @@ +package treecms.proto.edit; + +import treecms.proto.api.NodeAPI; +import treecms.proto.api.NodeAPITreeBuilder; + +public class EditableNodeAPITreeBuilder implements NodeAPITreeBuilder +{ + public EditableNodeAPITreeBuilder() + { + + } + + @Override + public NodeAPI getContents() { + // TODO Auto-generated method stub + return null; + } + + @Override + public NodeAPI createNode() { + // TODO Auto-generated method stub + return null; + } + +}
--- a/src/treecms/proto/simple/SimpleNodeAPI.java Sat Aug 28 15:40:49 2010 +0900 +++ b/src/treecms/proto/simple/SimpleNodeAPI.java Sat Aug 28 15:43:18 2010 +0900 @@ -12,12 +12,20 @@ private String m_class; private String m_title; + private String m_uuid; - public SimpleNodeAPI() + public SimpleNodeAPI(String _uuid) { m_childs = new LinkedList<NodeAPI>(); m_class = ""; m_title = ""; + + m_uuid = _uuid; + } + + public String getUUID() + { + return m_uuid; } @Override @@ -34,11 +42,9 @@ } @Override - public NodeAPI addChild() { + public void addChild(NodeAPI _child) { // TODO Auto-generated method stub - NodeAPI newChild = new SimpleNodeAPI(); - m_childs.add(newChild); - return newChild; + m_childs.add(_child); } @Override
--- a/src/treecms/proto/simple/SimpleNodeAPITreeBuilder.java Sat Aug 28 15:40:49 2010 +0900 +++ b/src/treecms/proto/simple/SimpleNodeAPITreeBuilder.java Sat Aug 28 15:43:18 2010 +0900 @@ -2,14 +2,28 @@ import treecms.proto.api.*; +import java.util.*; + public class SimpleNodeAPITreeBuilder implements NodeAPITreeBuilder { public SimpleNodeAPITreeBuilder() { return; } + public NodeAPI getContents() { - return new SimpleNodeAPI(); + return new SimpleNodeAPI(generateUUID()); + } + + public NodeAPI createNode() + { + return new SimpleNodeAPI(generateUUID()); } + + String generateUUID() + { + return UUID.randomUUID().toString(); + } + }
--- a/src/treecms/proto/test/PreOrderTreeWalker.java Sat Aug 28 15:40:49 2010 +0900 +++ b/src/treecms/proto/test/PreOrderTreeWalker.java Sat Aug 28 15:43:18 2010 +0900 @@ -32,7 +32,6 @@ position = 0; nodeStack = new LinkedList<NodeState>(); } - public boolean hasNext() { while (position>=children.size()) { if (nodeStack.isEmpty()) return false; @@ -60,6 +59,4 @@ public Iterator<NodeAPI> iterator() { return new IteratorState(m_root); } - - }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/treecms/proto/test/PreOrderTreeWalkerRecursive.java Sat Aug 28 15:43:18 2010 +0900 @@ -0,0 +1,5 @@ +package treecms.proto.test; + +public class PreOrderTreeWalkerRecursive { + +}
--- a/src/treecms/proto/test/Test1.java Sat Aug 28 15:40:49 2010 +0900 +++ b/src/treecms/proto/test/Test1.java Sat Aug 28 15:43:18 2010 +0900 @@ -9,29 +9,42 @@ { public static void main(String _arg[]) { - NodeAPI root = (new SimpleNodeAPITreeBuilder()).getContents(); + NodeAPITreeBuilder builder = new SimpleNodeAPITreeBuilder(); + NodeAPI root = builder.getContents(); root.setTitle("root"); - NodeAPI child1 = root.addChild(); + NodeAPI child1 = builder.createNode(); child1.setTitle("child1"); - NodeAPI child2 = root.addChild(); + NodeAPI child2 = builder.createNode(); child2.setTitle("child2"); - NodeAPI child11 = child1.addChild(); + root.addChild(child1); + root.addChild(child2); + + NodeAPI child11 = builder.createNode(); child11.setTitle("child11"); - NodeAPI child12 = child1.addChild(); + NodeAPI child12 = builder.createNode(); child12.setTitle("child12"); - NodeAPI child13 = child1.addChild(); + NodeAPI child13 = builder.createNode(); child13.setTitle("child13"); - NodeAPI child21 = child2.addChild(); + child1.addChild(child11); + child1.addChild(child12); + child1.addChild(child13); + + NodeAPI child21 = builder.createNode(); child21.setTitle("child21"); - NodeAPI child211 = child21.addChild(); + child2.addChild(child21); + + NodeAPI child211 = builder.createNode(); child211.setTitle("child211"); - NodeAPI child212 = child21.addChild(); + NodeAPI child212 = builder.createNode(); child212.setTitle("child212"); + child21.addChild(child211); + child21.addChild(child212); + PreOrderTreeWalker walker = new PreOrderTreeWalker(root); Iterator<NodeAPI> itr = walker.iterator();