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 List listPaths() {
return new Vector(paths);
}
public void register(StructurePath path, StructureElement element) {
StructureElement treeSElement = element;
elements.add(treeSElement);
paths.add(path);
if (log.isTraceEnabled())
log.trace("Registered " + path + " (label: '"
+ treeSElement.getLabel() + "', position: "
+ elements.size() + ")");
}
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;
}
}