]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRelatedHelper.java
1 package org
.argeo
.slc
.core
.structure
.tree
;
3 import org
.argeo
.slc
.core
.structure
.SimpleSElement
;
4 import org
.argeo
.slc
.structure
.StructureAware
;
5 import org
.argeo
.slc
.structure
.StructureElement
;
6 import org
.argeo
.slc
.structure
.StructureRegistry
;
9 * Provides default implementations of some methods of <code>TreeSRelated</code>
12 public abstract class TreeSRelatedHelper
implements TreeSRelated
{
13 private TreeSPath basePath
;
14 private StructureRegistry
<TreeSPath
> registry
;
16 // private ThreadLocal<TreeSPath> basePath = new ThreadLocal<TreeSPath>();
17 // private ThreadLocal<StructureRegistry<TreeSPath>> registry = new
18 // ThreadLocal<StructureRegistry<TreeSPath>>();
20 public TreeSPath
getBasePath() {
24 public StructureRegistry
<TreeSPath
> getRegistry() {
28 public void notifyCurrentPath(StructureRegistry
<TreeSPath
> registry
,
31 this.registry
= registry
;
34 public StructureElement
getStructureElement(String key
) {
35 return new SimpleSElement(key
);
39 * Checks wether the object is {@link StructureAware} and forward path and
40 * registry. null safe for both arguments.
42 @SuppressWarnings(value
= { "unchecked" })
43 protected void forwardPath(Object obj
, String childName
) {
47 if (obj
instanceof StructureAware
&& basePath
!= null) {
49 if (childName
!= null)
50 path
= basePath
.createChild(childName
);
54 ((StructureAware
<TreeSPath
>) obj
).notifyCurrentPath(registry
, path
);