1 package org
.argeo
.slc
.core
.structure
.tree
;
5 import java
.util
.TreeMap
;
6 import java
.util
.Vector
;
8 import org
.argeo
.slc
.UnsupportedException
;
9 import org
.argeo
.slc
.core
.structure
.SimpleSElement
;
10 import org
.argeo
.slc
.structure
.StructureElement
;
11 import org
.argeo
.slc
.structure
.StructureRegistry
;
13 /** Tree based implementation of a structure registry. */
14 public class TreeSRegistry
implements StructureRegistry
<TreeSPath
> {
17 private Map
<TreeSPath
, SimpleSElement
> elements
= new TreeMap
<TreeSPath
, SimpleSElement
>();
19 private String mode
= StructureRegistry
.ALL
;
21 private List
<TreeSPath
> activePaths
;
23 @SuppressWarnings("unchecked")
24 public <T
extends StructureElement
> T
getElement(TreeSPath path
) {
25 return (T
) elements
.get(path
);
28 public List
<StructureElement
> listElements() {
29 return new Vector
<StructureElement
>(elements
.values());
32 public List
<TreeSPath
> listPaths() {
33 return new Vector
<TreeSPath
>(elements
.keySet());
36 public void register(TreeSPath path
, StructureElement element
) {
38 throw new UnsupportedException("Cannot register under a null path.");
40 throw new UnsupportedException(
41 "Cannot register null element for path " + path
);
42 if (element
.getLabel() == null)
43 throw new UnsupportedException(
44 "Cannot register an element with null label for path "
47 final SimpleSElement simpleSElement
;
48 if (element
instanceof SimpleSElement
) {
49 simpleSElement
= (SimpleSElement
) element
;
51 simpleSElement
= new SimpleSElement(element
.getLabel());
54 elements
.put(path
, simpleSElement
);
57 public String
getMode() {
61 public void setMode(String mode
) {
65 public List
<TreeSPath
> getActivePaths() {
69 public void setActivePaths(List
<TreeSPath
> activePaths
) {
70 this.activePaths
= activePaths
;
73 /** Gets the elements. */
74 public Map
<TreeSPath
, SimpleSElement
> getElements() {
78 /** Sets the elements (for ORM). */
79 public void setElements(Map
<TreeSPath
, SimpleSElement
> elements
) {
80 this.elements
= elements
;
87 void setTid(Long tid
) {