KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > workbench > tree > examples > TestTreeNode


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.workbench.tree.examples;
16
17 import org.apache.tapestry.contrib.tree.model.IMutableTreeNode;
18 import org.apache.tapestry.contrib.tree.simple.TreeNode;
19
20 /**
21  * @author ceco
22  */

23 public class TestTreeNode extends TreeNode {
24
25     private String JavaDoc m_strValue;
26
27     /**
28      * Constructor for TestTreeNode.
29      */

30     public TestTreeNode(String JavaDoc strValue) {
31         this(null, strValue);
32     }
33
34     /**
35      * Constructor for TestTreeNode.
36      * @param parentNode
37      */

38     public TestTreeNode(IMutableTreeNode parentNode, String JavaDoc strValue) {
39         super(parentNode);
40         m_strValue = strValue;
41     }
42
43     public String JavaDoc toString(){
44         return m_strValue;
45     }
46
47     public int hashCode(){
48         return m_strValue.hashCode();
49     }
50
51     public boolean equals(Object JavaDoc objTarget){
52         if(objTarget == this)
53             return true;
54         if(! (objTarget instanceof TestTreeNode))
55             return false;
56
57         TestTreeNode objTargetNode = (TestTreeNode)objTarget;
58         return this.getValue().equals(objTargetNode.getValue());
59     }
60
61     /**
62      * Returns the value.
63      * @return String
64      */

65     public String JavaDoc getValue() {
66         return m_strValue;
67     }
68
69 }
70
Popular Tags