View Javadoc

1   package org.gnomekr.potron.web.tree;
2   
3   import java.io.Serializable;
4   import java.util.List;
5   
6   import org.apache.myfaces.custom.tree2.TreeNode;
7   
8   /***
9    * AbstractNavigationNode.java
10   * @author Xavier Cho
11   * @version $Revision 1.1 $ $Date: 2005/07/12 10:02:53 $
12   */
13  public abstract class AbstractNavigationNode<T extends Serializable> implements
14          TreeNode {
15  
16      private T userObject;
17      private List<TreeNode> children;
18      private String identifier;
19      private String type;
20      private String description;
21  
22      public AbstractNavigationNode() {
23          this(null);
24      }
25  
26      public AbstractNavigationNode(T userObject) {
27          this.userObject = userObject;
28  
29          if (userObject != null) {
30              this.type = userObject.getClass().getName();
31          }
32  
33          this.children = createChildNodes();
34      }
35  
36      protected abstract List<TreeNode> createChildNodes();
37  
38      /***
39       * @see org.apache.myfaces.custom.tree2.TreeNode#isLeaf()
40       */
41      public boolean isLeaf() {
42          return getChildCount() == 0;
43      }
44  
45      /***
46       * @see org.apache.myfaces.custom.tree2.TreeNode#setLeaf(boolean)
47       */
48      public void setLeaf(boolean leaf) {
49          //Who the hell designed this??
50      }
51  
52      /***
53       * @see org.apache.myfaces.custom.tree2.TreeNode#getChildren()
54       */
55      public List<TreeNode> getChildren() {
56          return children;
57      }
58  
59      /***
60       * @see org.apache.myfaces.custom.tree2.TreeNode#getType()
61       */
62      public String getType() {
63          return type;
64      }
65  
66      /***
67       * @see org.apache.myfaces.custom.tree2.TreeNode#setType(java.lang.String)
68       */
69      public void setType(String type) {
70          this.type = type;
71      }
72  
73      /***
74       * @see org.apache.myfaces.custom.tree2.TreeNode#getDescription()
75       */
76      public String getDescription() {
77          return description;
78      }
79  
80      /***
81       * @see org.apache.myfaces.custom.tree2.TreeNode#setDescription(java.lang.String)
82       */
83      public void setDescription(String description) {
84          this.description = description;
85      }
86  
87      /***
88       * @see org.apache.myfaces.custom.tree2.TreeNode#setIdentifier(java.lang.String)
89       */
90      public void setIdentifier(String identifier) {
91          this.identifier = identifier;
92      }
93  
94      /***
95       * @see org.apache.myfaces.custom.tree2.TreeNode#getIdentifier()
96       */
97      public String getIdentifier() {
98          return identifier;
99      }
100 
101     /***
102      * @see org.apache.myfaces.custom.tree2.TreeNode#getChildCount()
103      */
104     public int getChildCount() {
105         return getChildren().size();
106     }
107 
108     public T getUserObject() {
109         return userObject;
110     }
111 }