package org.argeo.slc.core.structure; import java.util.List; import java.util.Vector; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Default implementation of a StructureRegistry.*/ public class DefaultSRegistry implements StructureRegistry { private static Log log = LogFactory.getLog(DefaultSRegistry.class); private List elements = new Vector(); private List paths = new Vector(); private String mode = StructureRegistry.ALL; private List activePaths; public List listElements() { return new Vector(elements); } public void register(StructureElement element) { StructureElement treeSElement = element; elements.add(treeSElement); paths.add( treeSElement.getPath()); log.debug("Registered " + treeSElement.getPath() + " (desc: " + treeSElement.getDescription() + " position: " + elements.size() + ")"); } public void register(StructureAware structureAware) { register(structureAware.getElement()); structureAware.onRegister(this); } public StructureElement getElement(StructurePath path) { int index = paths.indexOf(path); if (index >= 0) { return elements.get(index); } else {// not found return null; } } public String getMode() { return mode; } public void setMode(String mode) { this.mode = mode; } public List getActivePaths() { return activePaths; } public void setActivePaths(List activePaths) { this.activePaths = activePaths; } }