001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.xml.spi.dom;
043:
044: import org.w3c.dom.*;
045:
046: /**
047: * Neutral DOM level 1 Core Node implementation.
048: * All methods return <code>null</code> or <code>false</code>
049: * or throws an exception if they attempt to modify DOM tree
050: * or they are defined at higher DOM level. Clone method
051: * returns <code>this</code> as it probably safe for read-only DOM.
052: * <p>
053: * As a bonus it also implements some other DOM interfaces
054: * by throwing a DOMException.
055: *
056: * @author Petr Kuzel
057: */
058: public abstract class AbstractNode implements Node {
059:
060: public String getNodeName() {
061: return null;
062: }
063:
064: /**
065: * @return false
066: */
067: public boolean isSupported(String feature, String version) {
068: return "1.0".equals(version);
069: }
070:
071: public void setPrefix(String str) throws org.w3c.dom.DOMException {
072: throw new ROException();
073: }
074:
075: public String getPrefix() {
076: return null; // some client determines DOM1 by NoSuchMethodError
077: }
078:
079: public org.w3c.dom.Node getPreviousSibling() {
080: return null;
081: }
082:
083: //!!! rather abstract to force all to reimplement
084: public abstract short getNodeType();
085:
086: public org.w3c.dom.Document getOwnerDocument() {
087: // let it be the first item
088: return null;
089: }
090:
091: public org.w3c.dom.Node replaceChild(org.w3c.dom.Node node,
092: org.w3c.dom.Node node1) throws org.w3c.dom.DOMException {
093: throw new ROException();
094: }
095:
096: public org.w3c.dom.Node cloneNode(boolean param) {
097: return (Node) this ; //we are immutable, only problem with references may appear
098: }
099:
100: public org.w3c.dom.Node getNextSibling() {
101: return null;
102: }
103:
104: public org.w3c.dom.Node insertBefore(org.w3c.dom.Node node,
105: org.w3c.dom.Node node1) throws org.w3c.dom.DOMException {
106: throw new ROException();
107: }
108:
109: public String getNamespaceURI() {
110: return null; // some client determines DOM1 by NoSuchMethodError
111: }
112:
113: public org.w3c.dom.NamedNodeMap getAttributes() {
114: return NamedNodeMapImpl.EMPTY;
115: }
116:
117: public org.w3c.dom.NodeList getChildNodes() {
118: return NodeListImpl.EMPTY;
119: }
120:
121: public String getNodeValue() throws org.w3c.dom.DOMException {
122: // attribute, text, pi data
123: return null;
124: }
125:
126: public org.w3c.dom.Node appendChild(org.w3c.dom.Node node)
127: throws org.w3c.dom.DOMException {
128: throw new ROException();
129: }
130:
131: public String getLocalName() {
132: return null; // some client determines DOM1 by NoSuchMethodError
133: }
134:
135: public org.w3c.dom.Node getParentNode() {
136: return null;
137: }
138:
139: public void setNodeValue(String str)
140: throws org.w3c.dom.DOMException {
141: throw new ROException();
142: }
143:
144: public org.w3c.dom.Node getLastChild() {
145: return null;
146: }
147:
148: public boolean hasAttributes() {
149: throw new UOException();
150: }
151:
152: public void normalize() {
153: // ignore
154: }
155:
156: public org.w3c.dom.Node removeChild(org.w3c.dom.Node node)
157: throws org.w3c.dom.DOMException {
158: throw new ROException();
159: }
160:
161: /**
162: * @return false
163: */
164: public boolean hasChildNodes() {
165: return false;
166: }
167:
168: /**
169: * @return null
170: */
171: public org.w3c.dom.Node getFirstChild() {
172: return null;
173: }
174:
175: // A bonus Element interface ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
176:
177: public NodeList getElementsByTagNameNS(String namespaceURI,
178: String localName) {
179: throw new UOException();
180: }
181:
182: public String getAttributeNS(String namespaceURI, String localName) {
183: throw new UOException();
184: }
185:
186: public String getAttribute(String name) {
187: throw new UOException();
188: }
189:
190: public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
191: throw new UOException();
192: }
193:
194: public Attr getAttributeNode(String name) {
195: throw new UOException();
196: }
197:
198: public boolean hasAttribute(String name) {
199: throw new UOException();
200: }
201:
202: public String getTagName() {
203: throw new UOException();
204: }
205:
206: public Attr getAttributeNodeNS(String namespaceURI, String localName) {
207: throw new UOException();
208: }
209:
210: public void removeAttribute(String name) throws DOMException {
211: throw new UOException();
212: }
213:
214: public Attr setAttributeNodeNS(Attr newAttr) throws DOMException {
215: throw new UOException();
216: }
217:
218: public void setAttribute(String name, String value)
219: throws DOMException {
220: throw new UOException();
221: }
222:
223: public NodeList getElementsByTagName(String name) {
224: throw new UOException();
225: }
226:
227: public boolean hasAttributeNS(String namespaceURI, String localName) {
228: throw new UOException();
229: }
230:
231: public Attr setAttributeNode(Attr newAttr) throws DOMException {
232: throw new UOException();
233: }
234:
235: public void removeAttributeNS(String namespaceURI, String localName)
236: throws DOMException {
237: throw new UOException();
238: }
239:
240: public void setAttributeNS(String namespaceURI,
241: String qualifiedName, String value) throws DOMException {
242: throw new UOException();
243: }
244:
245: // A bonus Attr implementation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
246:
247: public boolean getSpecified() {
248: throw new UOException();
249: }
250:
251: public String getName() {
252: throw new UOException();
253: }
254:
255: public Element getOwnerElement() {
256: throw new UOException();
257: }
258:
259: public void setValue(String value) throws DOMException {
260: throw new UOException();
261: }
262:
263: public String getValue() {
264: throw new UOException();
265: }
266:
267: // Notation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268:
269: public String getPublicId() {
270: throw new UOException();
271: }
272:
273: public String getSystemId() {
274: throw new UOException();
275: }
276:
277: // Bonus Text implementation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
278:
279: public void insertData(int offset, String arg) throws DOMException {
280: throw new ROException();
281: }
282:
283: public void replaceData(int offset, int count, String arg)
284: throws DOMException {
285: throw new ROException();
286: }
287:
288: public void setData(String data) throws DOMException {
289: throw new ROException();
290: }
291:
292: public Text splitText(int offset) throws DOMException {
293: throw new ROException();
294: }
295:
296: public String substringData(int offset, int count)
297: throws DOMException {
298: throw new UOException();
299: }
300:
301: public void appendData(String arg) throws DOMException {
302: throw new ROException();
303: }
304:
305: public void deleteData(int offset, int count) throws DOMException {
306: throw new ROException();
307: }
308:
309: public String getData() throws DOMException {
310: throw new UOException();
311: }
312:
313: public int getLength() {
314: throw new UOException();
315: }
316:
317: //
318: // Implementation of DOM Level 3 methods
319: //
320:
321: public short compareDocumentPosition(Node a) {
322: throw new UOException();
323: }
324:
325: public String getBaseURI() {
326: throw new UOException();
327: }
328:
329: public Object getFeature(String a, String b) {
330: throw new UOException();
331: }
332:
333: public String getTextContent() {
334: throw new UOException();
335: }
336:
337: public Object getUserData(String a) {
338: throw new UOException();
339: }
340:
341: public boolean isDefaultNamespace(String a) {
342: throw new UOException();
343: }
344:
345: public boolean isEqualNode(Node a) {
346: throw new UOException();
347: }
348:
349: public boolean isSameNode(Node a) {
350: throw new UOException();
351: }
352:
353: public String lookupNamespaceURI(String a) {
354: throw new UOException();
355: }
356:
357: public String lookupPrefix(String a) {
358: throw new UOException();
359: }
360:
361: public void setTextContent(String a) {
362: throw new UOException();
363: }
364:
365: public Object setUserData(String a, Object b, UserDataHandler c) {
366: throw new UOException();
367: }
368:
369: // Implementation of DOM Level 3 methods for Element
370: public TypeInfo getSchemaTypeInfo() {
371: throw new UOException();
372: }
373:
374: public void setIdAttribute(String a, boolean b) {
375: throw new UOException();
376: }
377:
378: public void setIdAttributeNS(String a, String b, boolean c) {
379: throw new UOException();
380: }
381:
382: public void setIdAttributeNode(Attr a, boolean b) {
383: throw new UOException();
384: }
385:
386: // Implementation of DOM Level 3 methods for Attr
387:
388: public boolean isId() {
389: throw new UOException();
390: }
391:
392: // Implementation of DOM Level 3 methods for Text
393: public Text replaceWholeText(String a) {
394: throw new UOException();
395: }
396:
397: public String getWholeText() {
398: throw new UOException();
399: }
400:
401: public boolean isElementContentWhitespace() {
402: throw new UOException();
403: }
404:
405: // Dom Level 3 methods for Document
406: public Node adoptNode(Node a) {
407: throw new UOException();
408: }
409:
410: public String getDocumentURI() {
411: throw new UOException();
412: }
413:
414: public DOMConfiguration getDomConfig() {
415: throw new UOException();
416: }
417:
418: public String getInputEncoding() {
419: throw new UOException();
420: }
421:
422: public boolean getStrictErrorChecking() {
423: throw new UOException();
424: }
425:
426: public String getXmlEncoding() {
427: throw new UOException();
428: }
429:
430: public boolean getXmlStandalone() {
431: throw new UOException();
432: }
433:
434: public String getXmlVersion() {
435: throw new UOException();
436: }
437:
438: public void normalizeDocument() {
439: throw new UOException();
440: }
441:
442: public Node renameNode(Node a, String nb, String c) {
443: throw new UOException();
444: }
445:
446: public void setDocumentURI(String a) {
447: throw new UOException();
448: }
449:
450: public void setStrictErrorChecking(boolean a) {
451: throw new UOException();
452: }
453:
454: public void setXmlStandalone(boolean a) {
455: throw new UOException();
456: }
457:
458: public void setXmlVersion(String a) {
459: throw new UOException();
460: }
461:
462: }
|