package org.argeo.slc.core.structure.tree; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.Vector; import org.argeo.slc.core.UnsupportedException; import org.argeo.slc.core.structure.SimpleSElement; import org.argeo.slc.core.structure.StructureElement; import org.argeo.slc.core.structure.StructureRegistry; /** Tree based implementation of a structure registry. */ public class TreeSRegistry implements StructureRegistry { public final static String STATUS_ACTIVE = "STATUS_ACTIVE"; /** For ORM */ private Long tid; private String status; private Map elements = new TreeMap(); private String mode = StructureRegistry.ALL; private List activePaths; public T getElement(TreeSPath path) { return (T) elements.get(path); } public List listElements() { return new Vector(elements.values()); } public List listPaths() { return new Vector(elements.keySet()); } public void register(TreeSPath path, StructureElement element) { final SimpleSElement simpleSElement; if (element instanceof SimpleSElement) { simpleSElement = (SimpleSElement) element; } else { simpleSElement = new SimpleSElement(element.getLabel()); } if (path == null) throw new UnsupportedException("Path cannot be null."); elements.put(path, simpleSElement); } 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; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } /** Gets the elements. */ public Map getElements() { return elements; } /** Sets the elements (for ORM). */ public void setElements(Map elements) { this.elements = elements; } Long getTid() { return tid; } void setTid(Long tid) { this.tid = tid; } }