KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > tax > decl > NameType


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.decl;
20
21 import org.netbeans.tax.*;
22
23 /** Reference to other declared element.
24  * It links itself to context that element.
25  */

26 public class NameType extends LeafType {
27
28     /** */
29     public static final String JavaDoc PROP_TYPE_NAME = "nt-name"; // NOI18N
30

31     /** */
32     private String JavaDoc name;
33
34
35     //
36
// init
37
//
38

39     public NameType (String JavaDoc name, String JavaDoc mul) {
40         super ();
41
42         this.name = name;
43         setMultiplicity (mul);
44     }
45
46     public NameType (String JavaDoc name) {
47         this (name, ""); // NOI18N
48
}
49     
50     public NameType (NameType nameType) {
51         super (nameType);
52         
53         this.name = nameType.name;
54     }
55     
56     
57     //
58
// from TreeObject
59
//
60

61     /**
62      */

63     public Object JavaDoc clone () {
64         return new NameType (this);
65     }
66     
67     /**
68      */

69     public boolean equals (Object JavaDoc object, boolean deep) {
70         if (!!! super.equals (object, deep))
71             return false;
72         
73         NameType peer = (NameType) object;
74         if (!!! Util.equals (this.getName (), peer.getName ()))
75             return false;
76         
77         return true;
78     }
79     
80     /*
81      * Merges changes from passed object to actual object.
82      * @param node merge peer (TreeAttributeDecl)
83      * @throws CannotMergeException if can not merge with given node (invalid class)
84      */

85     public void merge (TreeObject treeObject) throws CannotMergeException {
86         super.merge (treeObject);
87         
88         NameType peer = (NameType) treeObject;
89         
90         // just become peer
91

92         setName (peer.getName ());
93     }
94     
95     
96     //
97
// itself
98
//
99

100     /**
101      */

102     public String JavaDoc getName () {
103         return name;
104     }
105     
106     /**
107      */

108     public void setName (String JavaDoc name) {
109         if (Util.equals (this.name, name))
110             return;
111         this.name = name;
112         if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("[NameType] firePropertyChange(PROP_TYPE_NAME, name);"); // NOI18N
113
}
114     
115     /**
116      */

117     public String JavaDoc toString () {
118         return name + getMultiplicity ();
119     }
120     
121     
122     /**
123      */

124     public boolean allowElements () {
125         return false; //??? should it report TreeElementDecl.forName(name);
126
}
127     
128     /**
129      */

130     public boolean allowText () {
131         return false; //??? should it report TreeElementDecl.forName(name);
132
}
133     
134 }
135
Popular Tags