KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > tax > TreeEntityReference


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.tax;
20
21 /**
22  *
23  * @author Libor Kramolis
24  * @version 0.1
25  */

26 public abstract class TreeEntityReference extends TreeParentNode implements TreeReference {
27     /** */
28     public static final String JavaDoc PROP_NAME = "name"; // NOI18N
29

30
31     /** */
32     private String JavaDoc name;
33
34     /** -- can be null. */
35     private TreeEntityDecl entityDecl;
36
37
38     //
39
// init
40
//
41

42     /** Creates new TreeEntityReference.
43      * @throws InvalidArgumentException
44      */

45     protected TreeEntityReference (String JavaDoc name) throws InvalidArgumentException {
46         super ();
47         
48         checkName (name);
49         this.name = name;
50     }
51     
52     /** Creates new TreeEntityReference -- copy constructor. */
53     protected TreeEntityReference (TreeEntityReference entityReference, boolean deep) {
54         super (entityReference, deep);
55         
56         this.name = entityReference.name;
57         // this.entityDecl = entityReference.entityDecl;
58
}
59     
60     
61     //
62
// from TreeObject
63
//
64

65     /**
66      */

67     public boolean equals (Object JavaDoc object, boolean deep) {
68         if (!!! super.equals (object, deep))
69             return false;
70         
71         TreeEntityReference peer = (TreeEntityReference) object;
72         if (!!! Util.equals (this.getName (), peer.getName ()))
73             return false;
74         
75         return true;
76     }
77     
78     /*
79      * Checks instance and delegate to superclass.
80      */

81     public void merge (TreeObject treeObject) throws CannotMergeException {
82         super.merge (treeObject);
83         
84         TreeEntityReference peer = (TreeEntityReference) treeObject;
85         setNameImpl (peer.getName ());
86     }
87     
88     
89     //
90
// itself
91
//
92

93     /**
94      */

95     public String JavaDoc getName () {
96         return name;
97     }
98     
99     /**
100      */

101     private final void setNameImpl (String JavaDoc newName) {
102         String JavaDoc oldName = this.name;
103         
104         this.name = newName;
105         
106         firePropertyChange (PROP_NAME, oldName, newName);
107     }
108     
109     /**
110      * @throws ReadOnlyException
111      * @throws InvalidArgumentException
112      */

113     public final void setName (String JavaDoc newName) throws ReadOnlyException, InvalidArgumentException {
114         //
115
// check new value
116
//
117
if ( Util.equals (this.name, newName) )
118             return;
119         checkReadOnly ();
120         checkName (newName);
121         
122         //
123
// set new value
124
//
125
setNameImpl (newName);
126     }
127     
128     
129     /**
130      */

131     protected abstract void checkName (String JavaDoc name) throws InvalidArgumentException;
132     
133     
134     /**
135      */

136     public TreeEntityDecl getEntityDecl () {
137         return entityDecl;
138     }
139     
140     
141     //
142
// TreeObjectList.ContentManager
143
//
144

145     /**
146      *
147      */

148     protected abstract class ChildListContentManager extends TreeParentNode.ChildListContentManager {
149         
150     } // end: class ChildListContentManager
151

152 }
153
Popular Tags