001: package com.rimfaxe.xml.compatibility;
002:
003: import org.w3c.dom.Attr;
004: import org.w3c.dom.CDATASection;
005: import org.w3c.dom.Comment;
006: import org.w3c.dom.DocumentFragment;
007: import org.w3c.dom.EntityReference;
008: import org.w3c.dom.ProcessingInstruction;
009: import org.w3c.dom.DocumentType;
010: import org.w3c.dom.NodeList;
011: import org.w3c.dom.DOMImplementation;
012: import org.w3c.dom.Node;
013: import org.w3c.dom.NamedNodeMap;
014: import org.w3c.dom.DOMException;
015: import org.w3c.dom.DOMErrorHandler;
016: import org.w3c.dom.UserDataHandler;
017:
018: /**
019: * Standard wrapper around sparta Document.
020:
021: <blockquote><small> Copyright (C) 2002 Hewlett-Packard Company.
022: This file is part of Sparta, an XML Parser, DOM, and XPath library.
023: This library is free software; you can redistribute it and/or
024: modify it under the terms of the <a href="doc-files/LGPL.txt">GNU
025: Lesser General Public License</a> as published by the Free Software
026: Foundation; either version 2.1 of the License, or (at your option)
027: any later version. This library is distributed in the hope that it
028: will be useful, but WITHOUT ANY WARRANTY; without even the implied
029: warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
030: PURPOSE. </small></blockquote>
031: @version $Date: 2002/08/21 20:18:42 $ $Revision: 1.2 $
032: @author Eamonn O'Brien-Strain
033: * @stereotype factory
034: */
035:
036: public class DocumentImpl implements org.w3c.dom.Document {
037:
038: public Attr createAttribute(String parm1) throws DOMException {
039: /**@todo: Implement this org.w3c.dom.Document method*/
040: throw new Error("not implemented: createAttribute");
041: }
042:
043: public Attr createAttributeNS(String parm1, String parm2)
044: throws DOMException {
045: /**@todo: Implement this org.w3c.dom.Document method*/
046: throw new Error("not implemented: createAttributeNS");
047: }
048:
049: public CDATASection createCDATASection(String data)
050: throws DOMException {
051: return new TextImpl(this , new com.rimfaxe.xml.xmlreader.Text(
052: data));
053: }
054:
055: public Comment createComment(String parm1) {
056: /**@todo: Implement this org.w3c.dom.Document method*/
057: throw new Error("not implemented: createComment");
058: }
059:
060: public DocumentFragment createDocumentFragment() {
061: /**@todo: Implement this org.w3c.dom.Document method*/
062: throw new Error("not implemented: createDocumentFragment");
063: }
064:
065: public org.w3c.dom.Element createElement(String tagName)
066: throws DOMException {
067: return new ElementImpl(this , tagName);
068: }
069:
070: public org.w3c.dom.Element createElementNS(String parm1,
071: String parm2) throws DOMException {
072: /**@todo: Implement this org.w3c.dom.Document method*/
073: throw new Error("not implemented: createElementNS");
074: }
075:
076: public EntityReference createEntityReference(String parm1)
077: throws DOMException {
078: /**@todo: Implement this org.w3c.dom.Document method*/
079: throw new Error("not implemented: createEntityReference");
080: }
081:
082: public ProcessingInstruction createProcessingInstruction(String a,
083: String b) throws DOMException {
084: /**@todo: Implement this org.w3c.dom.Document method*/
085: throw new Error("not implemented: createProcessingInstruction");
086: }
087:
088: public org.w3c.dom.Text createTextNode(String data) {
089: return new TextImpl(this , new com.rimfaxe.xml.xmlreader.Text(
090: data));
091: }
092:
093: public DocumentType getDoctype() {
094: /**@todo: Implement this org.w3c.dom.Document method*/
095: throw new Error("not implemented: getDoctype");
096: }
097:
098: public org.w3c.dom.Element getDocumentElement() {
099: return spartan_.getDocumentElement() == null ? null
100: : wrapper(spartan_.getDocumentElement());
101: }
102:
103: public org.w3c.dom.Element getElementById(String parm1) {
104: /**@todo: Implement this org.w3c.dom.Document method*/
105: throw new Error("not implemented: getElementById");
106: }
107:
108: public NodeList getElementsByTagName(String parm1) {
109: /**@todo: Implement this org.w3c.dom.Document method*/
110: throw new Error("not implemented: getElementsByTagName");
111: }
112:
113: public NodeList getElementsByTagNameNS(String parm1, String parm2) {
114: /**@todo: Implement this org.w3c.dom.Document method*/
115: throw new Error("not implemented: getElementsByTagNameNS");
116: }
117:
118: public DOMImplementation getImplementation() {
119: /**@todo: Implement this org.w3c.dom.Document method*/
120: throw new Error("not implemented: getImplementation");
121: }
122:
123: public Node importNode(Node parm1, boolean parm2)
124: throws DOMException {
125: /**@todo: Implement this org.w3c.dom.Document method*/
126: throw new Error("not implemented: importNode");
127: }
128:
129: public Node appendChild(Node node) throws DOMException {
130: if (node instanceof ElementImpl) {
131: ElementImpl element = (ElementImpl) node;
132: spartan_.setDocumentElement(element.getSpartanElement());
133: return element;
134: } else
135: throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
136: "can only add root element to document");
137:
138: }
139:
140: public Node cloneNode(boolean parm1) {
141: /**@todo: Implement this org.w3c.dom.Node method*/
142: throw new Error("not implemented: cloneNode");
143: }
144:
145: public NamedNodeMap getAttributes() {
146: /**@todo: Implement this org.w3c.dom.Node method*/
147: throw new Error("not implemented: getAttributes");
148: }
149:
150: public NodeList getChildNodes() {
151: /**@todo: Implement this org.w3c.dom.Node method*/
152: throw new Error("not implemented: getChildNodes");
153: }
154:
155: public Node getFirstChild() {
156: return wrapper(spartan_.getDocumentElement());
157: }
158:
159: public Node getLastChild() {
160: /**@todo: Implement this org.w3c.dom.Node method*/
161: throw new Error("not implemented: getLastChild");
162: }
163:
164: /** Always return null */
165: public String getLocalName() {
166: return null;
167: }
168:
169: /** Always return null */
170: public String getNamespaceURI() {
171: return null;
172: }
173:
174: public Node getNextSibling() {
175: /**@todo: Implement this org.w3c.dom.Node method*/
176: throw new Error("not implemented: getNextSibling");
177: }
178:
179: public String getNodeName() {
180: /**@todo: Implement this org.w3c.dom.Node method*/
181: throw new Error("not implemented: getNodeName");
182: }
183:
184: public short getNodeType() {
185: return Node.DOCUMENT_NODE;
186: }
187:
188: public String getNodeValue() throws DOMException {
189: /**@todo: Implement this org.w3c.dom.Node method*/
190: throw new Error("not implemented: getNodeValue");
191: }
192:
193: public org.w3c.dom.Document getOwnerDocument() {
194: /**@todo: Implement this org.w3c.dom.Node method*/
195: throw new Error("not implemented: getOwnerDocument");
196: }
197:
198: public Node getParentNode() {
199: return null;
200: }
201:
202: public String getPrefix() {
203: /**@todo: Implement this org.w3c.dom.Node method*/
204: throw new Error("not implemented: getPrefix");
205: }
206:
207: public Node getPreviousSibling() {
208: /**@todo: Implement this org.w3c.dom.Node method*/
209: throw new Error("not implemented: getPreviousSibling");
210: }
211:
212: public boolean hasAttributes() {
213: /**@todo: Implement this org.w3c.dom.Node method*/
214: throw new Error("not implemented: hasAttributes");
215: }
216:
217: public boolean hasChildNodes() {
218: return spartan_.getDocumentElement() != null;
219: }
220:
221: public Node insertBefore(Node parm1, Node parm2)
222: throws DOMException {
223: /**@todo: Implement this org.w3c.dom.Node method*/
224: throw new Error("not implemented: insertBefore");
225: }
226:
227: public boolean isSupported(String feature, String version) {
228: if (feature.equals("NodeTestFilter"))
229: return false;
230: throw new Error("isSupported(" + feature + "," + version
231: + ") not known.");
232: }
233:
234: public void normalize() {
235: /**@todo: Implement this org.w3c.dom.Node method*/
236: throw new Error("not implemented: normalize");
237: }
238:
239: public Node removeChild(Node parm1) throws DOMException {
240: /**@todo: Implement this org.w3c.dom.Node method*/
241: throw new Error("not implemented: removeChild");
242: }
243:
244: public Node replaceChild(Node parm1, Node parm2)
245: throws DOMException {
246: /**@todo: Implement this org.w3c.dom.Node method*/
247: throw new Error("not implemented: replaceChild");
248: }
249:
250: public void setNodeValue(String parm1) throws DOMException {
251: /**@todo: Implement this org.w3c.dom.Node method*/
252: throw new Error("not implemented: setNodeValue");
253: }
254:
255: public void setPrefix(String parm1) throws DOMException {
256: /**@todo: Implement this org.w3c.dom.Node method*/
257: throw new Error("not implemented: setPrefix");
258: }
259:
260: //////////////////////////////////////////////////////////////////
261: // BEGIN DOM3
262:
263: public String getBaseURI() {
264: throw new Error("not implemented");
265: }
266:
267: public short compareTreePosition(Node other) {
268: throw new Error("not implemented");
269: }
270:
271: public String getTextContent() throws org.w3c.dom.DOMException {
272: throw new Error("not implemented");
273: }
274:
275: public void setTextContent(String textContent)
276: throws org.w3c.dom.DOMException {
277: throw new Error("not implemented");
278: }
279:
280: public boolean isSameNode(Node other) {
281: throw new Error("not implemented");
282: }
283:
284: public String lookupNamespacePrefix(String namespaceURI) {
285: throw new Error("not implemented");
286: }
287:
288: public String lookupNamespaceURI(String prefix) {
289: throw new Error("not implemented");
290: }
291:
292: public boolean isEqualNode(Node arg, boolean deep) {
293: throw new Error("not implemented");
294: }
295:
296: public Node getInterface(String feature) {
297: throw new Error("not implemented");
298: }
299:
300: public Object setUserData(String key, Object data,
301: UserDataHandler handler) {
302: throw new Error("not implemented");
303: }
304:
305: public Object getUserData(String key) {
306: throw new Error("not implemented");
307: }
308:
309: ///////////////////////////////////////////////////
310:
311: public Node adoptNode(Node source) throws DOMException {
312: /**@todo: Implement this org.w3c.dom.Node method*/
313: throw new Error("not implemented: setPrefix");
314: }
315:
316: public String getActualEncoding() {
317: return actualEncoding_;
318: }
319:
320: public void setActualEncoding(String actualEncoding) {
321: actualEncoding_ = actualEncoding;
322: }
323:
324: public String getEncoding() {
325: return encoding_;
326: }
327:
328: public void setEncoding(String encoding) {
329: encoding_ = encoding;
330: }
331:
332: public String getVersion() {
333: return version_;
334: }
335:
336: public void setVersion(String version) {
337: version_ = version;
338: }
339:
340: public boolean getStandalone() {
341: return standalone_;
342: }
343:
344: public void setStandalone(boolean standalone) {
345: standalone_ = standalone;
346: }
347:
348: public boolean getStrictErrorChecking() {
349: return strictErrorChecking_;
350: }
351:
352: public void setStrictErrorChecking(boolean strictErrorChecking) {
353: strictErrorChecking_ = strictErrorChecking;
354: }
355:
356: public DOMErrorHandler getErrorHandler() {
357: throw new Error("not implemented");
358: }
359:
360: public void setErrorHandler(DOMErrorHandler errorHandler) {
361: throw new Error("not implemented");
362: }
363:
364: public String getDocumentURI() {
365: throw new Error("not implemented");
366: }
367:
368: public void setDocumentURI(String documentURI) {
369: throw new Error("not implemented");
370: }
371:
372: public void normalizeDocument() {
373: throw new Error("not implemented");
374: }
375:
376: public boolean canSetNormalizationFeature(String name, boolean state) {
377: throw new Error("not implemented");
378: }
379:
380: public void setNormalizationFeature(String name, boolean state)
381: throws DOMException {
382: throw new Error("not implemented");
383: }
384:
385: public boolean getNormalizationFeature(String name)
386: throws DOMException {
387: throw new Error("not implemented");
388: }
389:
390: public Node renameNode(Node n, String namespaceURI, String name)
391: throws DOMException {
392: throw new Error("not implemented");
393: }
394:
395: private String encoding_ = null;
396: private String actualEncoding_ = null;
397: private String version_ = null;
398: private boolean standalone_ = true;
399: private boolean strictErrorChecking_ = true;
400:
401: // END DOM3
402: //////////////////////////////////////////////////////////////////
403: public boolean equals(Object obj) {
404: if (obj instanceof DocumentImpl) {
405: DocumentImpl that = (DocumentImpl) obj;
406: return this .spartan_.equals(that.spartan_);
407: } else
408: return false;
409: }
410:
411: com.rimfaxe.xml.xmlreader.Document getSpartan() {
412: return spartan_;
413: }
414:
415: NodeImpl wrapper(com.rimfaxe.xml.xmlreader.Node spartan) {
416: if (spartan instanceof com.rimfaxe.xml.xmlreader.Element)
417: return wrapper((com.rimfaxe.xml.xmlreader.Element) spartan);
418: else
419: return wrapper((com.rimfaxe.xml.xmlreader.Text) spartan);
420: }
421:
422: private ElementImpl wrapper(
423: com.rimfaxe.xml.xmlreader.Element spartan) {
424: ElementImpl result = (ElementImpl) spartan.getAnnotation();
425: if (result == null) {
426: result = new ElementImpl(this , spartan);
427: spartan.setAnnotation(result);
428: }
429: return result;
430: }
431:
432: private TextImpl wrapper(com.rimfaxe.xml.xmlreader.Text spartan) {
433: TextImpl result = (TextImpl) spartan.getAnnotation();
434: if (result == null) {
435: result = new TextImpl(this , spartan);
436: spartan.setAnnotation(result);
437: }
438: return result;
439: }
440:
441: private DocumentImpl(com.rimfaxe.xml.xmlreader.Document spartan) {
442: spartan_ = spartan;
443: }
444:
445: /**
446: * @link aggregation
447: * @label spartan
448: */
449: private final com.rimfaxe.xml.xmlreader.Document spartan_;
450:
451: /////////////////////////////////////////////////////
452:
453: static public DocumentImpl wrapper(
454: com.rimfaxe.xml.xmlreader.Document spartan) {
455: DocumentImpl result = (DocumentImpl) spartan.getAnnotation();
456: if (result == null) {
457: result = new DocumentImpl(spartan);
458: spartan.setAnnotation(result);
459: }
460: return result;
461: }
462:
463: }
464:
465: // $Log: DocumentImpl.java,v $
466: // Revision 1.2 2002/08/21 20:18:42 eobrain
467: // Implement createCDATASection
468: //
469: // Revision 1.1.1.1 2002/08/19 05:04:17 eobrain
470: // import from HP Labs internal CVS
471: //
472: // Revision 1.12 2002/08/19 00:38:32 eob
473: // Tweak javadoc comment.
474: //
475: // Revision 1.11 2002/08/18 05:45:37 eob
476: // Add copyright and other formatting and commenting in preparation for
477: // release to SourceForge.
478: //
479: // Revision 1.10 2002/08/15 22:21:09 eob
480: // Constructor no longer needs document
481: //
482: // Revision 1.9 2002/06/21 00:32:16 eob
483: // Make work with old JDK 1.1.*
484: //
485: // Revision 1.8 2002/02/23 02:09:29 eob
486: // Make wrapper method public. Implement some methods that had been stubs.
487: //
488: // Revision 1.7 2002/02/08 20:33:29 eob
489: // Added extra DOM3 stuff.
490: //
491: // Revision 1.6 2002/02/01 22:00:47 eob
492: // Add DOM level 3 methods.
493: //
494: // Revision 1.5 2002/01/09 00:54:45 eob
495: // Handle null documentElement
496: //
497: // Revision 1.4 2002/01/05 07:58:54 eob
498: // Implement missing functionality.
499: //
500: // Revision 1.3 2002/01/04 00:49:35 eob
501: // Formatting change only
502: //
503: // Revision 1.2 2002/01/04 00:48:19 eob
504: // Store wrapper as annotation of spartan object to avoid creating
505: // uncecessary wrapper objects, while still allowing garbage collection
506: // to clean the wrappers up.
507: //
508: // Revision 1.1 2002/01/04 18:49:27 eob
509: // initial
|