1 package org
.argeo
.slc
.core
.structure
.tree
;
4 import java
.util
.Vector
;
6 import org
.apache
.commons
.logging
.Log
;
7 import org
.apache
.commons
.logging
.LogFactory
;
9 import org
.argeo
.slc
.core
.structure
.StructureAware
;
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 public class TreeSRegistry
implements StructureRegistry
{
15 private static Log log
= LogFactory
.getLog(TreeSRegistry
.class);
17 private List
<TreeSElement
> elements
= new Vector
<TreeSElement
>();
18 private List
<TreeSPath
> paths
= new Vector
<TreeSPath
>();
19 private String mode
= StructureRegistry
.ALL
;
21 private List
<StructurePath
> activePaths
;
23 public List
<StructureElement
> listElements() {
24 return new Vector
<StructureElement
>(elements
);
27 public void register(StructureElement element
) {
28 TreeSElement treeSElement
= checkElement(element
);
29 elements
.add(treeSElement
);
30 paths
.add((TreeSPath
) treeSElement
.getPath());
31 log
.debug("Registered " + treeSElement
.getPath() + " (desc: "
32 + treeSElement
.getDescription() + " position: "
33 + elements
.size() + ")");
36 public void register(StructureAware structureAware
) {
37 register(structureAware
.getElement());
38 structureAware
.onRegister(this);
41 public StructureElement
getElement(StructurePath path
) {
42 int index
= paths
.indexOf(path
);
44 return elements
.get(index
);
50 protected TreeSElement
checkElement(StructureElement element
) {
51 if (!(element
instanceof TreeSElement
)) {
52 throw new RuntimeException("Element class " + element
.getClass()
53 + " is not supported.");
55 return (TreeSElement
) element
;
58 public String
getMode() {
62 public void setMode(String mode
) {
66 public List
<StructurePath
> getActivePaths() {
70 public void setActivePaths(List
<StructurePath
> activePaths
) {
71 this.activePaths
= activePaths
;