import java.util.List;\r
import java.util.Vector;\r
\r
+import org.argeo.slc.core.structure.StructureAware;\r
import org.argeo.slc.core.structure.StructureElement;\r
+import org.argeo.slc.core.structure.StructurePath;\r
import org.argeo.slc.core.structure.StructureRegistry;\r
\r
-public class DefaultTreeSAware implements TreeSAware{\r
- private TreeSElement element;\r
- private List<TreeSAware> children = new Vector<TreeSAware>();\r
+/**\r
+ * Default implementation of <code>TreeSAware</code> for tree based\r
+ * registries, using <code>TreeSPath</code>. Convenient to be wrapped in\r
+ * classes which cannot extend it.\r
+ */\r
+public class DefaultTreeSAware implements StructureAware {\r
+ private StructureElement element;\r
+ private List<String> names = new Vector<String>();\r
+ private List<StructureAware> children = new Vector<StructureAware>();\r
\r
public StructureElement getElement() {\r
return element;\r
}\r
\r
- public void setElement(TreeSElement element) {\r
+ public void setElement(StructureElement element) {\r
this.element = element;\r
}\r
\r
- public void onRegister(StructureRegistry registry) {\r
- for(TreeSAware sAware : children){\r
- registry.register(sAware.getElement());\r
- sAware.onRegister(registry);\r
+ public void onRegister(StructureRegistry registry, StructurePath path) {\r
+ int index = 0;\r
+ for (StructureAware sAware : children) {\r
+ TreeSPath childPath = ((TreeSPath) path).createChild(names\r
+ .get(index)\r
+ + index);\r
+ registry.register(childPath, sAware.getElement());\r
+ sAware.onRegister(registry, childPath);\r
+ index++;\r
}\r
}\r
\r
- public void addChild(TreeSAware sAware){\r
+ public void addToPropagationList(String name, StructureAware sAware) {\r
+ names.add(name);\r
children.add(sAware);\r
}\r
\r
- public List<TreeSAware> getChildren() {\r
+ public List<StructureAware> getPropagationList() {\r
return children;\r
}\r
- \r
+\r
}\r