KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > spi > dom > AbstractNode


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
20 package org.netbeans.modules.xml.spi.dom;
21
22 import org.w3c.dom.*;
23
24 /**
25  * Neutral DOM level 1 Core Node implementation.
26  * All methods return <code>null</code> or <code>false</code>
27  * or throws an exception if they attempt to modify DOM tree
28  * or they are defined at higher DOM level. Clone method
29  * returns <code>this</code> as it probably safe for read-only DOM.
30  * <p>
31  * As a bonus it also implements some other DOM interfaces
32  * by throwing a DOMException.
33  *
34  * @author Petr Kuzel
35  */

36 public abstract class AbstractNode implements Node {
37
38     public String JavaDoc getNodeName() {
39         return null;
40     }
41
42     /**
43      * @return false
44      */

45     public boolean isSupported(String JavaDoc feature, String JavaDoc version) {
46         return "1.0".equals(version);
47     }
48     
49     public void setPrefix(String JavaDoc str) throws org.w3c.dom.DOMException JavaDoc {
50         throw new ROException();
51     }
52     
53     public String JavaDoc getPrefix() {
54         return null; // some client determines DOM1 by NoSuchMethodError
55
}
56
57     public org.w3c.dom.Node JavaDoc getPreviousSibling() {
58         return null;
59     }
60     
61     //!!! rather abstract to force all to reimplement
62
public abstract short getNodeType();
63     
64     public org.w3c.dom.Document JavaDoc getOwnerDocument() {
65         // let it be the first item
66
return null;
67     }
68     
69     public org.w3c.dom.Node JavaDoc replaceChild(org.w3c.dom.Node JavaDoc node, org.w3c.dom.Node JavaDoc node1) throws org.w3c.dom.DOMException JavaDoc {
70         throw new ROException();
71     }
72     
73     public org.w3c.dom.Node JavaDoc cloneNode(boolean param) {
74         return (Node) this; //we are immutable, only problem with references may appear
75
}
76     
77     public org.w3c.dom.Node JavaDoc getNextSibling() {
78         return null;
79     }
80     
81     public org.w3c.dom.Node JavaDoc insertBefore(org.w3c.dom.Node JavaDoc node, org.w3c.dom.Node JavaDoc node1) throws org.w3c.dom.DOMException JavaDoc {
82         throw new ROException();
83     }
84     
85     public String JavaDoc getNamespaceURI() {
86         return null; // some client determines DOM1 by NoSuchMethodError
87
}
88     
89     public org.w3c.dom.NamedNodeMap JavaDoc getAttributes() {
90         return NamedNodeMapImpl.EMPTY;
91     }
92     
93     public org.w3c.dom.NodeList JavaDoc getChildNodes() {
94         return NodeListImpl.EMPTY;
95     }
96     
97     public String JavaDoc getNodeValue() throws org.w3c.dom.DOMException JavaDoc {
98         // attribute, text, pi data
99
return null;
100     }
101     
102     public org.w3c.dom.Node JavaDoc appendChild(org.w3c.dom.Node JavaDoc node) throws org.w3c.dom.DOMException JavaDoc {
103         throw new ROException();
104     }
105     
106     public String JavaDoc getLocalName() {
107         return null; // some client determines DOM1 by NoSuchMethodError
108
}
109     
110     public org.w3c.dom.Node JavaDoc getParentNode() {
111         return null;
112     }
113     
114     public void setNodeValue(String JavaDoc str) throws org.w3c.dom.DOMException JavaDoc {
115         throw new ROException();
116     }
117     
118     public org.w3c.dom.Node JavaDoc getLastChild() {
119         return null;
120     }
121     
122     public boolean hasAttributes() {
123         throw new UOException();
124     }
125     
126     public void normalize() {
127         // ignore
128
}
129     
130     public org.w3c.dom.Node JavaDoc removeChild(org.w3c.dom.Node JavaDoc node) throws org.w3c.dom.DOMException JavaDoc {
131         throw new ROException();
132     }
133     
134     /**
135      * @return false
136      */

137     public boolean hasChildNodes() {
138         return false;
139     }
140     
141     /**
142      * @return null
143      */

144     public org.w3c.dom.Node JavaDoc getFirstChild() {
145         return null;
146     }
147     
148     
149     // A bonus Element interface ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
150

151     public NodeList getElementsByTagNameNS(String JavaDoc namespaceURI, String JavaDoc localName) {
152         throw new UOException();
153     }
154
155     public String JavaDoc getAttributeNS(String JavaDoc namespaceURI, String JavaDoc localName) {
156         throw new UOException();
157     }
158
159     public String JavaDoc getAttribute(String JavaDoc name) {
160         throw new UOException();
161     }
162
163     public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
164         throw new UOException();
165     }
166
167     public Attr getAttributeNode(String JavaDoc name) {
168         throw new UOException();
169     }
170
171     public boolean hasAttribute(String JavaDoc name) {
172         throw new UOException();
173     }
174
175     public String JavaDoc getTagName() {
176         throw new UOException();
177     }
178
179     public Attr getAttributeNodeNS(String JavaDoc namespaceURI, String JavaDoc localName) {
180         throw new UOException();
181     }
182
183     public void removeAttribute(String JavaDoc name) throws DOMException {
184         throw new UOException();
185     }
186
187     public Attr setAttributeNodeNS(Attr newAttr) throws DOMException {
188         throw new UOException();
189     }
190
191     public void setAttribute(String JavaDoc name, String JavaDoc value) throws DOMException {
192         throw new UOException();
193     }
194
195     public NodeList getElementsByTagName(String JavaDoc name) {
196         throw new UOException();
197     }
198
199     public boolean hasAttributeNS(String JavaDoc namespaceURI, String JavaDoc localName) {
200         throw new UOException();
201     }
202
203     public Attr setAttributeNode(Attr newAttr) throws DOMException {
204         throw new UOException();
205     }
206
207     public void removeAttributeNS(String JavaDoc namespaceURI, String JavaDoc localName) throws DOMException {
208         throw new UOException();
209     }
210
211     public void setAttributeNS(String JavaDoc namespaceURI, String JavaDoc qualifiedName, String JavaDoc value) throws DOMException {
212         throw new UOException();
213     }
214
215     
216     // A bonus Attr implementation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
217

218     public boolean getSpecified() {
219         throw new UOException();
220     }
221
222     public String JavaDoc getName() {
223         throw new UOException();
224     }
225
226     public Element getOwnerElement() {
227         throw new UOException();
228     }
229
230     public void setValue(String JavaDoc value) throws DOMException {
231         throw new UOException();
232     }
233
234     public String JavaDoc getValue() {
235         throw new UOException();
236     }
237
238     // Notation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
239

240     public String JavaDoc getPublicId() {
241         throw new UOException();
242     }
243
244     public String JavaDoc getSystemId() {
245         throw new UOException();
246     }
247     
248    
249     // Bonus Text implementation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
250

251     public void insertData(int offset, String JavaDoc arg) throws DOMException {
252         throw new ROException();
253     }
254     
255     public void replaceData(int offset, int count, String JavaDoc arg) throws DOMException {
256         throw new ROException();
257     }
258
259     public void setData(String JavaDoc data) throws DOMException {
260         throw new ROException();
261     }
262
263     public Text splitText(int offset) throws DOMException {
264         throw new ROException();
265     }
266
267     public String JavaDoc substringData(int offset, int count) throws DOMException {
268         throw new UOException();
269     }
270     
271     public void appendData(String JavaDoc arg) throws DOMException {
272         throw new ROException();
273     }
274
275     public void deleteData(int offset, int count) throws DOMException {
276         throw new ROException();
277     }
278
279     public String JavaDoc getData() throws DOMException {
280         throw new UOException();
281     }
282
283     public int getLength() {
284         throw new UOException();
285     }
286
287     //
288
// Implementation of DOM Level 3 methods
289
//
290

291     public short compareDocumentPosition (Node a) {
292         throw new UOException();
293     }
294     
295     public String JavaDoc getBaseURI() {
296         throw new UOException();
297     }
298     public Object JavaDoc getFeature(String JavaDoc a, String JavaDoc b) {
299         throw new UOException();
300     }
301     public String JavaDoc getTextContent () {
302         throw new UOException();
303     }
304     public Object JavaDoc getUserData(String JavaDoc a) {
305         throw new UOException();
306     }
307     public boolean isDefaultNamespace (String JavaDoc a) {
308         throw new UOException();
309     }
310     public boolean isEqualNode(Node a) {
311         throw new UOException();
312     }
313     public boolean isSameNode(Node a) {
314         throw new UOException();
315     }
316     public String JavaDoc lookupNamespaceURI(String JavaDoc a) {
317         throw new UOException();
318     }
319     public String JavaDoc lookupPrefix(String JavaDoc a) {
320         throw new UOException();
321     }
322     public void setTextContent(String JavaDoc a) {
323         throw new UOException();
324     }
325     public Object JavaDoc setUserData(String JavaDoc a, Object JavaDoc b, UserDataHandler c) {
326         throw new UOException();
327     }
328     
329     // Implementation of DOM Level 3 methods for Element
330
public TypeInfo getSchemaTypeInfo() {
331         throw new UOException ();
332     }
333     public void setIdAttribute(String JavaDoc a, boolean b) {
334         throw new UOException ();
335     }
336     public void setIdAttributeNS(String JavaDoc a, String JavaDoc b, boolean c) {
337         throw new UOException ();
338     }
339     public void setIdAttributeNode(Attr a, boolean b) {
340         throw new UOException ();
341     }
342     // Implementation of DOM Level 3 methods for Attr
343

344     public boolean isId () {
345         throw new UOException ();
346     }
347     // Implementation of DOM Level 3 methods for Text
348
public Text replaceWholeText (String JavaDoc a) {
349         throw new UOException ();
350     }
351     public String JavaDoc getWholeText() {
352         throw new UOException ();
353     }
354     public boolean isElementContentWhitespace() {
355         throw new UOException ();
356     }
357     
358     // Dom Level 3 methods for Document
359
public Node adoptNode (Node a) {
360         throw new UOException ();
361     }
362     public String JavaDoc getDocumentURI () {
363         throw new UOException ();
364     }
365     public DOMConfiguration getDomConfig() {
366         throw new UOException ();
367     }
368     public String JavaDoc getInputEncoding() {
369         throw new UOException ();
370     }
371     public boolean getStrictErrorChecking() {
372         throw new UOException ();
373     }
374     public String JavaDoc getXmlEncoding () {
375         throw new UOException ();
376     }
377     public boolean getXmlStandalone() {
378         throw new UOException ();
379     }
380     public String JavaDoc getXmlVersion() {
381         throw new UOException ();
382     }
383     public void normalizeDocument() {
384         throw new UOException ();
385     }
386     public Node renameNode(Node a, String JavaDoc nb, String JavaDoc c) {
387         throw new UOException ();
388     }
389     public void setDocumentURI(String JavaDoc a) {
390         throw new UOException ();
391     }
392     public void setStrictErrorChecking(boolean a) {
393         throw new UOException ();
394     }
395     public void setXmlStandalone(boolean a) {
396         throw new UOException ();
397     }
398     public void setXmlVersion(String JavaDoc a) {
399         throw new UOException ();
400     }
401     
402 }
403
Popular Tags