1 package org
.argeo
.slc
.core
.structure
.tree
;
5 import java
.util
.TreeMap
;
6 import java
.util
.Vector
;
8 import org
.argeo
.slc
.core
.UnsupportedException
;
9 import org
.argeo
.slc
.core
.structure
.SimpleSElement
;
10 import org
.argeo
.slc
.core
.structure
.StructureElement
;
11 import org
.argeo
.slc
.core
.structure
.StructurePath
;
12 import org
.argeo
.slc
.core
.structure
.StructureRegistry
;
14 /** Tree based implementation of a structure registry. */
15 public class TreeSRegistry
implements StructureRegistry
{
18 private TreeSPath root
;
19 private Map
<TreeSPath
, SimpleSElement
> elements
= new TreeMap
<TreeSPath
, SimpleSElement
>();
21 private String mode
= StructureRegistry
.ALL
;
23 private List
<StructurePath
> activePaths
;
25 public StructureElement
getElement(StructurePath path
) {
26 return elements
.get(path
);
29 public List
<StructureElement
> listElements() {
30 return new Vector
<StructureElement
>(elements
.values());
33 public List
<StructurePath
> listPaths() {
34 return new Vector
<StructurePath
>(elements
.keySet());
37 public void register(StructurePath path
, StructureElement element
) {
38 final SimpleSElement simpleSElement
;
39 if (element
instanceof SimpleSElement
) {
40 simpleSElement
= (SimpleSElement
) element
;
42 simpleSElement
= new SimpleSElement(element
.getDescription());
45 if (!(path
instanceof TreeSPath
))
46 throw new UnsupportedException("path", path
);
48 elements
.put((TreeSPath
) path
, simpleSElement
);
52 public String
getMode() {
56 public void setMode(String mode
) {
60 public List
<StructurePath
> getActivePaths() {
64 public void setActivePaths(List
<StructurePath
> activePaths
) {
65 this.activePaths
= activePaths
;
68 /** Gets the related root path. */
69 public TreeSPath
getRoot() {
73 /** Sets the related root path. */
74 public void setRoot(TreeSPath root
) {
78 /** Gets the elements. */
79 public Map
<TreeSPath
, SimpleSElement
> getElements() {
83 /** Sets the elements (for ORM). */
84 public void setElements(Map
<TreeSPath
, SimpleSElement
> elements
) {
85 this.elements
= elements
;
92 void setTid(Long tid
) {