diff code/composite-composite.java @ 8:c9e5dcd79aae

rename; cleanups
author meillo@marmaro.de
date Mon, 18 Jun 2007 12:38:48 +0200
parents code/composite-component.java@20c0116dcb97
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/code/composite-composite.java	Mon Jun 18 12:38:48 2007 +0200
@@ -0,0 +1,34 @@
+    class Composite implements IComponent {
+            private String id;
+            private List<IComponent> list = new ArrayList<IComponent> ();
+
+            public Composite(String id) {
+                    this.id = id;
+            }
+
+            public String toString() {
+                    StringBuilder buf = new StringBuilder();
+                    buf.append(String.format("(%s:", id));
+
+                    for (IComponent child : list) {
+                          buf.append(" " + child.toString());
+                    }
+                    buf.append(")");
+
+                    return buf.toString();
+            }
+
+            //public List<IComponent> getChildren()
+
+            public Collection getChildren(){
+                    return list;
+            }
+
+            public boolean addComponent(IComponent c){
+                    return list.add(c);
+            }
+
+            public boolean removeComponent(IComponent c){
+                    return list.remove(c);
+            }
+    }