]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRegistry.java
Improve formatting
[gpl/argeo-slc.git] / org.argeo.slc.core / src / main / java / org / argeo / slc / core / structure / tree / TreeSRegistry.java
index 32ea36413657a858d132263102a049d94431ff94..7337367dc1de8683f4388e6cc3f75d5e22f46d5f 100644 (file)
@@ -8,33 +8,34 @@ import java.util.Vector;
 import org.argeo.slc.core.UnsupportedException;\r
 import org.argeo.slc.core.structure.SimpleSElement;\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
 /** Tree based implementation of a structure registry. */\r
-public class TreeSRegistry implements StructureRegistry {\r
+public class TreeSRegistry implements StructureRegistry<TreeSPath> {\r
+       public final static String STATUS_ACTIVE = "STATUS_ACTIVE";\r
+\r
        /** For ORM */\r
        private Long tid;\r
-       private TreeSPath root;\r
+       private String status;\r
        private Map<TreeSPath, SimpleSElement> elements = new TreeMap<TreeSPath, SimpleSElement>();\r
 \r
        private String mode = StructureRegistry.ALL;\r
 \r
-       private List<StructurePath> activePaths;\r
+       private List<TreeSPath> activePaths;\r
 \r
-       public StructureElement getElement(StructurePath path) {\r
-               return elements.get(path);\r
+       public <T extends StructureElement> T getElement(TreeSPath path) {\r
+               return (T) elements.get(path);\r
        }\r
 \r
        public List<StructureElement> listElements() {\r
                return new Vector<StructureElement>(elements.values());\r
        }\r
 \r
-       public List<StructurePath> listPaths() {\r
-               return new Vector<StructurePath>(elements.keySet());\r
+       public List<TreeSPath> listPaths() {\r
+               return new Vector<TreeSPath>(elements.keySet());\r
        }\r
 \r
-       public void register(StructurePath path, StructureElement element) {\r
+       public void register(TreeSPath path, StructureElement element) {\r
                final SimpleSElement simpleSElement;\r
                if (element instanceof SimpleSElement) {\r
                        simpleSElement = (SimpleSElement) element;\r
@@ -42,10 +43,10 @@ public class TreeSRegistry implements StructureRegistry {
                        simpleSElement = new SimpleSElement(element.getLabel());\r
                }\r
 \r
-               if (!(path instanceof TreeSPath))\r
-                       throw new UnsupportedException("path", path);\r
+               if (path == null)\r
+                       throw new UnsupportedException("Path cannot be null.");\r
 \r
-               elements.put((TreeSPath) path, simpleSElement);\r
+               elements.put(path, simpleSElement);\r
 \r
        }\r
 \r
@@ -57,22 +58,20 @@ public class TreeSRegistry implements StructureRegistry {
                this.mode = mode;\r
        }\r
 \r
-       public List<StructurePath> getActivePaths() {\r
+       public List<TreeSPath> getActivePaths() {\r
                return activePaths;\r
        }\r
 \r
-       public void setActivePaths(List<StructurePath> activePaths) {\r
+       public void setActivePaths(List<TreeSPath> activePaths) {\r
                this.activePaths = activePaths;\r
        }\r
 \r
-       /** Gets the related root path. */\r
-       public TreeSPath getRoot() {\r
-               return root;\r
+       public String getStatus() {\r
+               return status;\r
        }\r
 \r
-       /** Sets the related root path. */\r
-       public void setRoot(TreeSPath root) {\r
-               this.root = root;\r
+       public void setStatus(String status) {\r
+               this.status = status;\r
        }\r
 \r
        /** Gets the elements. */\r