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
.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 public <T
extends StructureElement
> T
getElement(TreeSPath path
) {
24 return (T
) elements
.get(path
);
27 public List
<StructureElement
> listElements() {
28 return new Vector
<StructureElement
>(elements
.values());
31 public List
<TreeSPath
> listPaths() {
32 return new Vector
<TreeSPath
>(elements
.keySet());
35 public void register(TreeSPath path
, StructureElement element
) {
37 throw new UnsupportedException("Cannot register under a null path.");
39 throw new UnsupportedException(
40 "Cannot register null element for path " + path
);
41 if (element
.getLabel() == null)
42 throw new UnsupportedException(
43 "Cannot register an element with null label for path "
46 final SimpleSElement simpleSElement
;
47 if (element
instanceof SimpleSElement
) {
48 simpleSElement
= (SimpleSElement
) element
;
50 simpleSElement
= new SimpleSElement(element
.getLabel());
53 elements
.put(path
, simpleSElement
);
56 public String
getMode() {
60 public void setMode(String mode
) {
64 public List
<TreeSPath
> getActivePaths() {
68 public void setActivePaths(List
<TreeSPath
> activePaths
) {
69 this.activePaths
= activePaths
;
72 /** Gets the elements. */
73 public Map
<TreeSPath
, SimpleSElement
> getElements() {
77 /** Sets the elements (for ORM). */
78 public void setElements(Map
<TreeSPath
, SimpleSElement
> elements
) {
79 this.elements
= elements
;
86 void setTid(Long tid
) {