]>
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
5f91f0a90545d76ce301fe039f541fecf0ba5797
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.argeo
.slc
.core
.structure
.tree
;
19 import org
.argeo
.slc
.core
.structure
.SimpleSElement
;
20 import org
.argeo
.slc
.structure
.StructureAware
;
21 import org
.argeo
.slc
.structure
.StructureElement
;
22 import org
.argeo
.slc
.structure
.StructureRegistry
;
25 * Provides default implementations of some methods of <code>TreeSRelated</code>
28 public abstract class TreeSRelatedHelper
implements TreeSRelated
{
29 private TreeSPath basePath
;
30 private StructureRegistry
<TreeSPath
> registry
;
32 // private ThreadLocal<TreeSPath> basePath = new ThreadLocal<TreeSPath>();
33 // private ThreadLocal<StructureRegistry<TreeSPath>> registry = new
34 // ThreadLocal<StructureRegistry<TreeSPath>>();
36 public TreeSPath
getBasePath() {
40 public StructureRegistry
<TreeSPath
> getRegistry() {
44 public void notifyCurrentPath(StructureRegistry
<TreeSPath
> registry
,
47 this.registry
= registry
;
50 public StructureElement
getStructureElement(String key
) {
51 return new SimpleSElement(key
);
55 * Checks wether the object is {@link StructureAware} and forward path and
56 * registry. null safe for both arguments.
58 @SuppressWarnings(value
= { "unchecked" })
59 protected void forwardPath(Object obj
, String childName
) {
63 if (obj
instanceof StructureAware
&& basePath
!= null) {
65 if (childName
!= null)
66 path
= basePath
.createChild(childName
);
70 ((StructureAware
<TreeSPath
>) obj
).notifyCurrentPath(registry
, path
);