001: /*
002: * @(#)DOMDocumentImpl.java 1.11 2000/08/16
003: *
004: */
005:
006: package org.w3c.tidy;
007:
008: import org.w3c.dom.DOMException;
009:
010: /**
011: *
012: * DOMDocumentImpl
013: *
014: * (c) 1998-2000 (W3C) MIT, INRIA, Keio University
015: * See Tidy.java for the copyright notice.
016: * Derived from <a href="http://www.w3.org/People/Raggett/tidy">
017: * HTML Tidy Release 4 Aug 2000</a>
018: *
019: * @author Dave Raggett <dsr@w3.org>
020: * @author Andy Quick <ac.quick@sympatico.ca> (translation to Java)
021: * @version 1.4, 1999/09/04 DOM Support
022: * @version 1.5, 1999/10/23 Tidy Release 27 Sep 1999
023: * @version 1.6, 1999/11/01 Tidy Release 22 Oct 1999
024: * @version 1.7, 1999/12/06 Tidy Release 30 Nov 1999
025: * @version 1.8, 2000/01/22 Tidy Release 13 Jan 2000
026: * @version 1.9, 2000/06/03 Tidy Release 30 Apr 2000
027: * @version 1.10, 2000/07/22 Tidy Release 8 Jul 2000
028: * @version 1.11, 2000/08/16 Tidy Release 4 Aug 2000
029: */
030:
031: public class DOMDocumentImpl extends DOMNodeImpl implements
032: org.w3c.dom.Document {
033:
034: private TagTable tt; // a DOM Document has its own TagTable.
035:
036: protected DOMDocumentImpl(Node adaptee) {
037: super (adaptee);
038: tt = new TagTable();
039: }
040:
041: public void setTagTable(TagTable tt) {
042: this .tt = tt;
043: }
044:
045: /* --------------------- DOM ---------------------------- */
046:
047: /**
048: * @see org.w3c.dom.Node#getNodeName
049: */
050: public String getNodeName() {
051: return "#document";
052: }
053:
054: /**
055: * @see org.w3c.dom.Node#getNodeType
056: */
057: public short getNodeType() {
058: return org.w3c.dom.Node.DOCUMENT_NODE;
059: }
060:
061: /**
062: * @see org.w3c.dom.Document#getDoctype
063: */
064: public org.w3c.dom.DocumentType getDoctype() {
065: Node node = adaptee.content;
066: while (node != null) {
067: if (node.type == Node.DocTypeTag)
068: break;
069: node = node.next;
070: }
071: if (node != null)
072: return (org.w3c.dom.DocumentType) node.getAdapter();
073: else
074: return null;
075: }
076:
077: /**
078: * @see org.w3c.dom.Document#getImplementation
079: */
080: public org.w3c.dom.DOMImplementation getImplementation() {
081: // NOT SUPPORTED
082: return null;
083: }
084:
085: /**
086: * @see org.w3c.dom.Document#getDocumentElement
087: */
088: public org.w3c.dom.Element getDocumentElement() {
089: Node node = adaptee.content;
090: while (node != null) {
091: if (node.type == Node.StartTag
092: || node.type == Node.StartEndTag)
093: break;
094: node = node.next;
095: }
096: if (node != null)
097: return (org.w3c.dom.Element) node.getAdapter();
098: else
099: return null;
100: }
101:
102: /**
103: * @see org.w3c.dom.Document#createElement
104: */
105: public org.w3c.dom.Element createElement(String tagName)
106: throws DOMException {
107: Node node = new Node(Node.StartEndTag, null, 0, 0, tagName, tt);
108: if (node != null) {
109: if (node.tag == null) // Fix Bug 121206
110: node.tag = tt.xmlTags;
111: return (org.w3c.dom.Element) node.getAdapter();
112: } else
113: return null;
114: }
115:
116: /**
117: * @see org.w3c.dom.Document#createDocumentFragment
118: */
119: public org.w3c.dom.DocumentFragment createDocumentFragment() {
120: // NOT SUPPORTED
121: return null;
122: }
123:
124: /**
125: * @see org.w3c.dom.Document#createTextNode
126: */
127: public org.w3c.dom.Text createTextNode(String data) {
128: byte[] textarray = Lexer.getBytes(data);
129: Node node = new Node(Node.TextNode, textarray, 0,
130: textarray.length);
131: if (node != null)
132: return (org.w3c.dom.Text) node.getAdapter();
133: else
134: return null;
135: }
136:
137: /**
138: * @see org.w3c.dom.Document#createComment
139: */
140: public org.w3c.dom.Comment createComment(String data) {
141: byte[] textarray = Lexer.getBytes(data);
142: Node node = new Node(Node.CommentTag, textarray, 0,
143: textarray.length);
144: if (node != null)
145: return (org.w3c.dom.Comment) node.getAdapter();
146: else
147: return null;
148: }
149:
150: /**
151: * @see org.w3c.dom.Document#createCDATASection
152: */
153: public org.w3c.dom.CDATASection createCDATASection(String data)
154: throws DOMException {
155: // NOT SUPPORTED
156: return null;
157: }
158:
159: /**
160: * @see org.w3c.dom.Document#createProcessingInstruction
161: */
162: public org.w3c.dom.ProcessingInstruction createProcessingInstruction(
163: String target, String data) throws DOMException {
164: throw new DOMExceptionImpl(DOMException.NOT_SUPPORTED_ERR,
165: "HTML document");
166: }
167:
168: /**
169: * @see org.w3c.dom.Document#createAttribute
170: */
171: public org.w3c.dom.Attr createAttribute(String name)
172: throws DOMException {
173: AttVal av = new AttVal(null, null, (int) '"', name, null);
174: if (av != null) {
175: av.dict = AttributeTable.getDefaultAttributeTable()
176: .findAttribute(av);
177: return (org.w3c.dom.Attr) av.getAdapter();
178: } else {
179: return null;
180: }
181: }
182:
183: /**
184: * @see org.w3c.dom.Document#createEntityReference
185: */
186: public org.w3c.dom.EntityReference createEntityReference(String name)
187: throws DOMException {
188: // NOT SUPPORTED
189: return null;
190: }
191:
192: /**
193: * @see org.w3c.dom.Document#getElementsByTagName
194: */
195: public org.w3c.dom.NodeList getElementsByTagName(String tagname) {
196: return new DOMNodeListByTagNameImpl(this .adaptee, tagname);
197: }
198:
199: /**
200: * DOM2 - not implemented.
201: * @exception org.w3c.dom.DOMException
202: */
203: public org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode,
204: boolean deep) throws org.w3c.dom.DOMException {
205: return null;
206: }
207:
208: /**
209: * DOM2 - not implemented.
210: * @exception org.w3c.dom.DOMException
211: */
212: public org.w3c.dom.Attr createAttributeNS(String namespaceURI,
213: String qualifiedName) throws org.w3c.dom.DOMException {
214: return null;
215: }
216:
217: /**
218: * DOM2 - not implemented.
219: * @exception org.w3c.dom.DOMException
220: */
221: public org.w3c.dom.Element createElementNS(String namespaceURI,
222: String qualifiedName) throws org.w3c.dom.DOMException {
223: return null;
224: }
225:
226: /**
227: * DOM2 - not implemented.
228: */
229: public org.w3c.dom.NodeList getElementsByTagNameNS(
230: String namespaceURI, String localName) {
231: return null;
232: }
233:
234: /**
235: * DOM2 - not implemented.
236: */
237: public org.w3c.dom.Element getElementById(String elementId) {
238: return null;
239: }
240:
241: public org.w3c.dom.Node adoptNode(org.w3c.dom.Node oNode) {
242: throw new UnsupportedOperationException(
243: "org.w3c.tidy.DOMDocumentImpl adoptNode() Not implemented");
244: }
245:
246: public short compareDocumentPosition(org.w3c.dom.Node oNode) {
247: throw new UnsupportedOperationException(
248: "org.w3c.tidy.DOMDocumentImpl compareDocumentPosition() Not implemented");
249: }
250:
251: public boolean isDefaultNamespace(String sStr1) {
252: throw new UnsupportedOperationException(
253: "org.w3c.tidy.DOMDocumentImpl isDefaultNamespace() Not implemented");
254: }
255:
256: public boolean isEqualNode(org.w3c.dom.Node oNode) {
257: throw new UnsupportedOperationException(
258: "org.w3c.tidy.DOMDocumentImpl isEqualNode() Not implemented");
259: }
260:
261: public boolean isSameNode(org.w3c.dom.Node oNode) {
262: throw new UnsupportedOperationException(
263: "org.w3c.tidy.DOMDocumentImpl isSameNode() Not implemented");
264: }
265:
266: public String lookupPrefix(String sStr1) {
267: throw new UnsupportedOperationException(
268: "org.w3c.tidy.DOMDocumentImpl lookupPreffix() Not implemented");
269: }
270:
271: public String lookupNamespaceURI(String sStr1) {
272: throw new UnsupportedOperationException(
273: "org.w3c.tidy.DOMDocumentImpl lookupNamespaceURI() Not implemented");
274: }
275:
276: public String getDocumentURI() {
277: throw new UnsupportedOperationException(
278: "org.w3c.tidy.DOMDocumentImpl getDocumentURI() Not implemented");
279: }
280:
281: public void setDocumentURI(String sStr1) {
282: throw new UnsupportedOperationException(
283: "org.w3c.tidy.DOMDocumentImpl setDocumentURI() Not implemented");
284: }
285:
286: public boolean getStrictErrorChecking() {
287: throw new UnsupportedOperationException(
288: "org.w3c.tidy.DOMDocumentImpl getStrictErrorChecking() Not implemented");
289: }
290:
291: public void setStrictErrorChecking(boolean bStrictCheck) {
292: throw new UnsupportedOperationException(
293: "org.w3c.tidy.DOMDocumentImpl setStrictErrorChecking() Not implemented");
294: }
295:
296: public boolean getXmlStandalone() {
297: throw new UnsupportedOperationException(
298: "org.w3c.tidy.DOMDocumentImpl getXmlStandalone() Not implemented");
299: }
300:
301: public void setXmlStandalone(boolean bXmlStandalone) {
302: throw new UnsupportedOperationException(
303: "org.w3c.tidy.DOMDocumentImpl setXmlStandalone() Not implemented");
304: }
305:
306: public Object getFeature(String sStr1, String sStr2) {
307: throw new UnsupportedOperationException(
308: "org.w3c.tidy.DOMDocumentImpl getFeature() Not implemented");
309: }
310:
311: public String getInputEncoding() {
312: throw new UnsupportedOperationException(
313: "org.w3c.tidy.DOMDocumentImpl getInputEncoding() Not implemented");
314: }
315:
316: public String getXmlEncoding() {
317: throw new UnsupportedOperationException(
318: "org.w3c.tidy.DOMDocumentImpl getXmlEncoding() Not implemented");
319: }
320:
321: public String getXmlVersion() {
322: throw new UnsupportedOperationException(
323: "org.w3c.tidy.DOMDocumentImpl getXmlVersion() Not implemented");
324: }
325:
326: public void setXmlVersion(String sStr1) {
327: throw new UnsupportedOperationException(
328: "org.w3c.tidy.DOMDocumentImpl setXmlVersion() Not implemented");
329: }
330:
331: public Object getUserData(String sStr1) {
332: throw new UnsupportedOperationException(
333: "org.w3c.tidy.DOMDocumentImpl getUserData() Not implemented");
334: }
335:
336: public Object setUserData(String sStr1, Object oObj2,
337: org.w3c.dom.UserDataHandler oHndlr) {
338: throw new UnsupportedOperationException(
339: "org.w3c.tidy.DOMDocumentImpl setUserData() Not implemented");
340: }
341:
342: public org.w3c.dom.DOMConfiguration getDomConfig() {
343: throw new UnsupportedOperationException(
344: "org.w3c.tidy.DOMDocumentImpl getDomConfig() Not implemented");
345: }
346:
347: public void normalizeDocument() {
348: throw new UnsupportedOperationException(
349: "org.w3c.tidy.DOMDocumentImpl normalizeDocument() Not implemented");
350: }
351:
352: public org.w3c.dom.Node renameNode(org.w3c.dom.Node oNode,
353: String sStr1, String sStr2) {
354: throw new UnsupportedOperationException(
355: "org.w3c.tidy.DOMDocumentImpl renameNode() Not implemented");
356: }
357:
358: public String getBaseURI() {
359: throw new UnsupportedOperationException(
360: "org.w3c.tidy.DOMDocumentImpl getBaseURI() Not implemented");
361: }
362:
363: public String getTextContent() {
364: throw new UnsupportedOperationException(
365: "org.w3c.tidy.DOMDocumentImpl getTextContent() Not implemented");
366: }
367:
368: public void setTextContent(String sStr1) {
369: throw new UnsupportedOperationException(
370: "org.w3c.tidy.DOMDocumentImpl setTextContent() Not implemented");
371: }
372:
373: }
|