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
> {
15 public final static String STATUS_ACTIVE
= "STATUS_ACTIVE";
19 private String status
;
20 private Map
<TreeSPath
, SimpleSElement
> elements
= new TreeMap
<TreeSPath
, SimpleSElement
>();
22 private String mode
= StructureRegistry
.ALL
;
24 private List
<TreeSPath
> activePaths
;
26 public <T
extends StructureElement
> T
getElement(TreeSPath path
) {
27 return (T
) elements
.get(path
);
30 public List
<StructureElement
> listElements() {
31 return new Vector
<StructureElement
>(elements
.values());
34 public List
<TreeSPath
> listPaths() {
35 return new Vector
<TreeSPath
>(elements
.keySet());
38 public void register(TreeSPath path
, StructureElement element
) {
39 final SimpleSElement simpleSElement
;
40 if (element
instanceof SimpleSElement
) {
41 simpleSElement
= (SimpleSElement
) element
;
43 simpleSElement
= new SimpleSElement(element
.getLabel());
47 throw new UnsupportedException("Path cannot be null.");
49 elements
.put(path
, simpleSElement
);
53 public String
getMode() {
57 public void setMode(String mode
) {
61 public List
<TreeSPath
> getActivePaths() {
65 public void setActivePaths(List
<TreeSPath
> activePaths
) {
66 this.activePaths
= activePaths
;
69 public String
getStatus() {
73 public void setStatus(String status
) {
77 /** Gets the elements. */
78 public Map
<TreeSPath
, SimpleSElement
> getElements() {
82 /** Sets the elements (for ORM). */
83 public void setElements(Map
<TreeSPath
, SimpleSElement
> elements
) {
84 this.elements
= elements
;
91 void setTid(Long tid
) {