01: package org.romaframework.core.domain.type;
02:
03: import java.io.Serializable;
04:
05: import org.romaframework.aspect.core.annotation.AnnotationConstants;
06: import org.romaframework.aspect.view.annotation.ViewField;
07: import org.romaframework.core.config.Destroyable;
08: import org.romaframework.module.crud.CRUDHelper;
09:
10: public abstract class TreeNodeBase implements TreeNode, Cloneable,
11: Serializable, Destroyable {
12: protected String name;
13: protected TreeNode parent;
14:
15: @Override
16: public String toString() {
17: return name != null ? name : "";
18: }
19:
20: @ViewField(visible=AnnotationConstants.FALSE)
21: public TreeNode getParent() {
22: return parent;
23: }
24:
25: public void setParent(TreeNode iParent) {
26: this .parent = iParent;
27: }
28:
29: public String getName() {
30: return name;
31: }
32:
33: public void setName(String iName) {
34: this .name = iName;
35: }
36:
37: public void onChildrenAdd() {
38: CRUDHelper.show((Class) getClass(), this , "children");
39: }
40:
41: /**
42: * Return a String containing the path of the node.
43: *
44: * @return The string representation of the node.
45: */
46: @ViewField(visible=AnnotationConstants.FALSE)
47: public String getPath() {
48: return TreeNodeHelper.getPath(this );
49: }
50:
51: /**
52: * Find a child node following a path. Paths can be expressed using a XPath-like language. / is the separator for tree nodes:
53: * <ul>
54: * <li><b>no prefix</b> = browse all tree (ie: log)</li>
55: * <li><b>/</b> = child (ie: /root/log)</li>
56: * <li><b>../</b> = parent (ie: ../log)</li>
57: * <li><b>./</b> = current (ie: ./log)</li>
58: * </ul>
59: *
60: * @param iChildPath
61: * @return TreeNode instance if found, otherwise null
62: */
63: public TreeNode searchNode(String iChildPath) {
64: return TreeNodeHelper.searchNode(this , iChildPath);
65: }
66:
67: public TreeNode findChild(String iChildPath) {
68: return TreeNodeHelper.findChild(this, iChildPath);
69: }
70: }
|