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