KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.netbeans.tax.spec.DTD;
22 import org.netbeans.tax.spec.ParameterEntityReference;
23 import org.netbeans.tax.spec.DocumentType;
24 import org.netbeans.tax.spec.ConditionalSection;
25
26 /**
27  *
28  * @author Libor Kramolis
29  * @version 0.1
30  */

31 public class TreeNotationDecl extends TreeNodeDecl implements DTD.Child, ParameterEntityReference.Child, DocumentType.Child, ConditionalSection.Child {
32     /** */
33     public static final String JavaDoc PROP_NAME = "name"; // NOI18N
34
/** */
35     public static final String JavaDoc PROP_PUBLIC_ID = "publicId"; // NOI18N
36
/** */
37     public static final String JavaDoc PROP_SYSTEM_ID = "systemId"; // NOI18N
38

39     
40     /** */
41     private String JavaDoc name;
42     
43     /** -- can be null. */
44     private String JavaDoc systemId;
45     
46     /** -- can be null. */
47     private String JavaDoc publicId;
48     
49     
50     //
51
// init
52
//
53

54     /** Creates new TreeNotationDecl.
55      * @throws InvalidArgumentException
56      */

57     public TreeNotationDecl (String JavaDoc name, String JavaDoc publicId, String JavaDoc systemId) throws InvalidArgumentException {
58         super ();
59         
60         checkName (name);
61         this.name = name;
62         
63         checkPublicId (publicId);
64         checkSystemId (systemId);
65         checkExternalId (publicId, systemId);
66         this.systemId = systemId;
67         this.publicId = publicId;
68     }
69     
70     
71     /** Creates new TreeNotationDecl -- copy constructor. */
72     protected TreeNotationDecl (TreeNotationDecl notationDecl) {
73         super (notationDecl);
74         
75         this.name = notationDecl.name;
76         this.publicId = notationDecl.publicId;
77         this.systemId = notationDecl.systemId;
78     }
79     
80     
81     //
82
// from TreeObject
83
//
84

85     /**
86      */

87     public Object JavaDoc clone () {
88         return new TreeNotationDecl (this);
89     }
90     
91     /**
92      */

93     public boolean equals (Object JavaDoc object, boolean deep) {
94         if (!!! super.equals (object, deep))
95             return false;
96         
97         TreeNotationDecl peer = (TreeNotationDecl) object;
98         if (!!! Util.equals (this.getName (), peer.getName ())) {
99             return false;
100         }
101         if (!!! Util.equals (this.getSystemId (), peer.getSystemId ())) {
102             return false;
103         }
104         if (!!! Util.equals (this.getPublicId (), peer.getPublicId ())) {
105             return false;
106         }
107         
108         return true;
109     }
110     
111     /*
112      * Merges properties: name, system ID and public ID.
113      */

114     public void merge (TreeObject treeObject) throws CannotMergeException {
115         super.merge (treeObject);
116         
117         TreeNotationDecl peer = (TreeNotationDecl) treeObject;
118         
119         setNameImpl (peer.getName ());
120         setSystemIdImpl (peer.getSystemId ());
121         setPublicIdImpl (peer.getPublicId ());
122     }
123     
124     
125     //
126
// itself
127
//
128

129     /**
130      */

131     public String JavaDoc getName () {
132         return name;
133     }
134     
135     /**
136      */

137     private final void setNameImpl (String JavaDoc newName) {
138         String JavaDoc oldName = this.name;
139         
140         this.name = newName;
141         
142         firePropertyChange (PROP_NAME, oldName, newName);
143     }
144     
145     /**
146      * @throws ReadOnlyException
147      * @throws InvalidArgumentException
148      */

149     public final void setName (String JavaDoc newName) throws ReadOnlyException, InvalidArgumentException {
150         //
151
// check new value
152
//
153
if ( Util.equals (this.name, newName) )
154             return;
155         checkReadOnly ();
156         checkName (newName);
157         
158         //
159
// set new value
160
//
161
setNameImpl (newName);
162     }
163     
164     /**
165      */

166     protected final void checkName (String JavaDoc name) throws InvalidArgumentException {
167         TreeUtilities.checkNotationDeclName (name);
168     }
169     
170     /**
171      */

172     public String JavaDoc getPublicId () {
173         return publicId;
174     }
175     
176     /**
177      */

178     private final void setPublicIdImpl (String JavaDoc newPublicId) {
179         String JavaDoc oldPublicId = this.publicId;
180         
181         this.publicId = newPublicId;
182         
183         firePropertyChange (PROP_PUBLIC_ID, oldPublicId, newPublicId);
184     }
185     
186     /**
187      * @throws ReadOnlyException
188      * @throws InvalidArgumentException
189      */

190     public final void setPublicId (String JavaDoc newPublicId) throws ReadOnlyException, InvalidArgumentException {
191         //
192
// check new value
193
//
194
if ( Util.equals (this.publicId, newPublicId) )
195             return;
196         checkReadOnly ();
197         checkPublicId (newPublicId);
198         checkExternalId (newPublicId, this.systemId);
199         
200         //
201
// set new value
202
//
203
setPublicIdImpl (newPublicId);
204     }
205     
206     /**
207      */

208     protected final void checkPublicId (String JavaDoc publicId) throws InvalidArgumentException {
209         TreeUtilities.checkNotationDeclPublicId (publicId);
210     }
211     
212     /**
213      */

214     public String JavaDoc getSystemId () {
215         return systemId;
216     }
217     
218     /**
219      */

220     private final void setSystemIdImpl (String JavaDoc newSystemId) {
221         String JavaDoc oldSystemId = this.systemId;
222         
223         this.systemId = newSystemId;
224         
225         firePropertyChange (PROP_SYSTEM_ID, oldSystemId, newSystemId);
226     }
227     
228     /**
229      * @throws ReadOnlyException
230      * @throws InvalidArgumentException
231      */

232     public final void setSystemId (String JavaDoc newSystemId) throws ReadOnlyException, InvalidArgumentException {
233         //
234
// check new value
235
//
236
if ( Util.equals (this.systemId, newSystemId) )
237             return;
238         checkReadOnly ();
239         checkSystemId (newSystemId);
240         checkExternalId (this.publicId, newSystemId);
241         
242         //
243
// set new value
244
//
245
setSystemIdImpl (newSystemId);
246     }
247     
248     /**
249      */

250     protected final void checkSystemId (String JavaDoc systemId) throws InvalidArgumentException {
251         TreeUtilities.checkNotationDeclSystemId (systemId);
252     }
253     
254     
255     /**
256      */

257     protected final void checkExternalId (String JavaDoc publicId, String JavaDoc systemId) throws InvalidArgumentException {
258         if ( (publicId == null) && (systemId == null) ) {
259             throw new InvalidArgumentException (Util.THIS.getString ("EXC_invalid_nulls"),
260             new NullPointerException JavaDoc ());
261         }
262     }
263     
264 }
265
Popular Tags