KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > apache > xerces > dom > CoreDocumentImpl


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package org.enhydra.apache.xerces.dom;
59
60 import java.util.Enumeration JavaDoc;
61 import java.util.Hashtable JavaDoc;
62
63 import org.enhydra.apache.xerces.utils.XMLCharacterProperties;
64 import org.w3c.dom.Attr JavaDoc;
65 import org.w3c.dom.CDATASection JavaDoc;
66 import org.w3c.dom.Comment JavaDoc;
67 import org.w3c.dom.DOMConfiguration JavaDoc;
68 import org.w3c.dom.DOMException JavaDoc;
69 import org.w3c.dom.DOMImplementation JavaDoc;
70 import org.w3c.dom.Document JavaDoc;
71 import org.w3c.dom.DocumentFragment JavaDoc;
72 import org.w3c.dom.DocumentType JavaDoc;
73 import org.w3c.dom.Element JavaDoc;
74 import org.w3c.dom.Entity JavaDoc;
75 import org.w3c.dom.EntityReference JavaDoc;
76 import org.w3c.dom.NamedNodeMap JavaDoc;
77 import org.w3c.dom.Node JavaDoc;
78 import org.w3c.dom.NodeList JavaDoc;
79 import org.w3c.dom.Notation JavaDoc;
80 import org.w3c.dom.ProcessingInstruction JavaDoc;
81 import org.w3c.dom.Text JavaDoc;
82 import org.w3c.dom.events.Event JavaDoc;
83 import org.w3c.dom.events.EventListener JavaDoc;
84
85
86 /**
87  * The Document interface represents the entire HTML or XML document.
88  * Conceptually, it is the root of the document tree, and provides the
89  * primary access to the document's data.
90  * <P>
91  * Since elements, text nodes, comments, processing instructions,
92  * etc. cannot exist outside the context of a Document, the Document
93  * interface also contains the factory methods needed to create these
94  * objects. The Node objects created have a ownerDocument attribute
95  * which associates them with the Document within whose context they
96  * were created.
97  * <p>
98  * The CoreDocumentImpl class only implements the DOM Core. Additional modules
99  * are supported by the more complete DocumentImpl subclass.
100  * <p>
101  * <b>Note:</b> When any node in the document is serialized, the
102  * entire document is serialized along with it.
103  *
104  * @author Arnaud Le Hors, IBM
105  * @author Joe Kesselman, IBM
106  * @author Andy Clark, IBM
107  * @author Ralf Pfeiffer, IBM
108  * @version
109  * @since PR-DOM-Level-1-19980818.
110  */

111 public class CoreDocumentImpl
112     extends ParentNode implements Document JavaDoc {
113
114     //
115
// Constants
116
//
117

118     /** Serialization version. */
119     static final long serialVersionUID = 0;
120
121     //
122
// Data
123
//
124

125     // document information
126

127     /** Document type. */
128     protected DocumentTypeImpl docType;
129
130     /** Document element. */
131     protected ElementImpl docElement;
132
133
134     /**Experimental DOM Level 3 feature: Document encoding */
135     protected String JavaDoc encoding;
136
137     /**Experimental DOM Level 3 feature: Document version */
138     protected String JavaDoc version;
139
140     /**Experimental DOM Level 3 feature: Document standalone */
141     protected boolean standalone;
142
143
144     /** Identifiers. */
145     protected Hashtable JavaDoc identifiers;
146
147     /** Table for quick check of child insertion. */
148     protected static int[] kidOK;
149
150     /**
151      * Number of alterations made to this document since its creation.
152      * Serves as a "dirty bit" so that live objects such as NodeList can
153      * recognize when an alteration has been made and discard its cached
154      * state information.
155      * <p>
156      * Any method that alters the tree structure MUST cause or be
157      * accompanied by a call to changed(), to inform it that any outstanding
158      * NodeLists may have to be updated.
159      * <p>
160      * (Required because NodeList is simultaneously "live" and integer-
161      * indexed -- a bad decision in the DOM's design.)
162      * <p>
163      * Note that changes which do not affect the tree's structure -- changing
164      * the node's name, for example -- do _not_ have to call changed().
165      * <p>
166      * Alternative implementation would be to use a cryptographic
167      * Digest value rather than a count. This would have the advantage that
168      * "harmless" changes (those producing equal() trees) would not force
169      * NodeList to resynchronize. Disadvantage is that it's slightly more prone
170      * to "false negatives", though that's the difference between "wildly
171      * unlikely" and "absurdly unlikely". IF we start maintaining digests,
172      * we should consider taking advantage of them.
173      *
174      * Note: This used to be done a node basis, so that we knew what
175      * subtree changed. But since only DeepNodeList really use this today,
176      * the gain appears to be really small compared to the cost of having
177      * an int on every (parent) node plus having to walk up the tree all the
178      * way to the root to mark the branch as changed everytime a node is
179      * changed.
180      * So we now have a single counter global to the document. It means that
181      * some objects may flush their cache more often than necessary, but this
182      * makes nodes smaller and only the document needs to be marked as changed.
183      */

184     protected int changes = 0;
185
186     // experimental
187

188     /** Allow grammar access. */
189     protected boolean allowGrammarAccess;
190
191     /** Bypass error checking. */
192     protected boolean errorChecking = true;
193
194     //
195
// Static initialization
196
//
197

198     static {
199
200         kidOK = new int[13];
201
202         kidOK[DOCUMENT_NODE] =
203             1 << ELEMENT_NODE | 1 << PROCESSING_INSTRUCTION_NODE |
204             1 << COMMENT_NODE | 1 << DOCUMENT_TYPE_NODE;
205
206         kidOK[DOCUMENT_FRAGMENT_NODE] =
207         kidOK[ENTITY_NODE] =
208         kidOK[ENTITY_REFERENCE_NODE] =
209         kidOK[ELEMENT_NODE] =
210             1 << ELEMENT_NODE | 1 << PROCESSING_INSTRUCTION_NODE |
211             1 << COMMENT_NODE | 1 << TEXT_NODE |
212             1 << CDATA_SECTION_NODE | 1 << ENTITY_REFERENCE_NODE ;
213
214
215         kidOK[ATTRIBUTE_NODE] =
216             1 << TEXT_NODE | 1 << ENTITY_REFERENCE_NODE;
217
218         kidOK[DOCUMENT_TYPE_NODE] =
219         kidOK[PROCESSING_INSTRUCTION_NODE] =
220         kidOK[COMMENT_NODE] =
221         kidOK[TEXT_NODE] =
222         kidOK[CDATA_SECTION_NODE] =
223         kidOK[NOTATION_NODE] =
224             0;
225
226     } // static
227

228     //
229
// Constructors
230
//
231

232     /**
233      * NON-DOM: Actually creating a Document is outside the DOM's spec,
234      * since it has to operate in terms of a particular implementation.
235      */

236     public CoreDocumentImpl() {
237         this(false);
238         // make sure the XMLCharacterProperties class is initilialized
239
XMLCharacterProperties.initCharFlags();
240     }
241
242     /** Constructor. */
243     public CoreDocumentImpl(boolean grammarAccess) {
244         super(null);
245         ownerDocument = this;
246         allowGrammarAccess = grammarAccess;
247         // make sure the XMLCharacterProperties class is initilialized
248
XMLCharacterProperties.initCharFlags();
249     }
250
251     /**
252      * For DOM2 support.
253      * The createDocument factory method is in DOMImplementation.
254      */

255     public CoreDocumentImpl(DocumentType JavaDoc doctype)
256     {
257         this(doctype, false);
258         // make sure the XMLCharacterProperties class is initilialized
259
XMLCharacterProperties.initCharFlags();
260     }
261
262     /** For DOM2 support. */
263     public CoreDocumentImpl(DocumentType JavaDoc doctype, boolean grammarAccess) {
264         this(grammarAccess);
265         if (doctype != null) {
266             DocumentTypeImpl doctypeImpl;
267             try {
268                 doctypeImpl = (DocumentTypeImpl) doctype;
269             } catch (ClassCastException JavaDoc e) {
270                 throw new DOMException JavaDoc(DOMException.WRONG_DOCUMENT_ERR,
271                                        "DOM005 Wrong document");
272             }
273             doctypeImpl.ownerDocument = this;
274             appendChild(doctype);
275         }
276         // make sure the XMLCharacterProperties class is initilialized
277
XMLCharacterProperties.initCharFlags();
278     }
279
280     //
281
// Node methods
282
//
283

284     // even though ownerDocument refers to this in this implementation
285
// the DOM Level 2 spec says it must be null, so make it appear so
286
final public Document JavaDoc getOwnerDocument() {
287         return null;
288     }
289
290     /** Returns the node type. */
291     public short getNodeType() {
292         return Node.DOCUMENT_NODE;
293     }
294
295     /** Returns the node name. */
296     public String JavaDoc getNodeName() {
297         return "#document";
298     }
299
300     /**
301      * Deep-clone a document, including fixing ownerDoc for the cloned
302      * children. Note that this requires bypassing the WRONG_DOCUMENT_ERR
303      * protection. I've chosen to implement it by calling importNode
304      * which is DOM Level 2.
305      *
306      * @return org.w3c.dom.Node
307      * @param deep boolean, iff true replicate children
308      */

309     public Node JavaDoc cloneNode(boolean deep) {
310
311         CoreDocumentImpl newdoc = new CoreDocumentImpl();
312         cloneNode(newdoc, deep);
313
314         return newdoc;
315
316     } // cloneNode(boolean):Node
317

318
319     /**
320      * internal method to share code with subclass
321      **/

322     protected void cloneNode(CoreDocumentImpl newdoc, boolean deep) {
323
324         // clone the children by importing them
325
if (needsSyncChildren()) {
326             synchronizeChildren();
327         }
328
329         if (deep) {
330             Hashtable JavaDoc reversedIdentifiers = null;
331
332             if (identifiers != null) {
333                 // Build a reverse mapping from element to identifier.
334
reversedIdentifiers = new Hashtable JavaDoc();
335                 Enumeration JavaDoc elementIds = identifiers.keys();
336                 while (elementIds.hasMoreElements()) {
337                     Object JavaDoc elementId = elementIds.nextElement();
338                     reversedIdentifiers.put(identifiers.get(elementId),
339                                             elementId);
340                 }
341             }
342
343             // Copy children into new document.
344
for (ChildNode kid = firstChild; kid != null;
345                  kid = kid.nextSibling) {
346                 newdoc.appendChild(newdoc.importNode(kid, true,
347                                                      reversedIdentifiers));
348             }
349         }
350
351         // experimental
352
newdoc.allowGrammarAccess = allowGrammarAccess;
353         newdoc.errorChecking = errorChecking;
354
355     } // cloneNode(CoreDocumentImpl,boolean):void
356

357     /**
358      * Since a Document may contain at most one top-level Element child,
359      * and at most one DocumentType declaraction, we need to subclass our
360      * add-children methods to implement this constraint.
361      * Since appendChild() is implemented as insertBefore(,null),
362      * altering the latter fixes both.
363      * <p>
364      * While I'm doing so, I've taken advantage of the opportunity to
365      * cache documentElement and docType so we don't have to
366      * search for them.
367      *
368      * REVISIT: According to the spec it is not allowed to alter neither the
369      * document element nor the document type in any way
370      */

371     public Node JavaDoc insertBefore(Node JavaDoc newChild, Node JavaDoc refChild)
372         throws DOMException JavaDoc {
373
374         // Only one such child permitted
375
int type = newChild.getNodeType();
376         if (errorChecking) {
377             if((type == Node.ELEMENT_NODE && docElement != null) ||
378                (type == Node.DOCUMENT_TYPE_NODE && docType != null)) {
379                 throw new DOMException JavaDoc(DOMException.HIERARCHY_REQUEST_ERR,
380                                            "DOM006 Hierarchy request error");
381             }
382         }
383
384         super.insertBefore(newChild,refChild);
385
386         // If insert succeeded, cache the kid appropriately
387
if (type == Node.ELEMENT_NODE) {
388             docElement = (ElementImpl)newChild;
389         }
390         else if (type == Node.DOCUMENT_TYPE_NODE) {
391             docType=(DocumentTypeImpl)newChild;
392         }
393
394         return newChild;
395
396     } // insertBefore(Node,Node):Node
397

398     /**
399      * Since insertBefore caches the docElement (and, currently, docType),
400      * removeChild has to know how to undo the cache
401      *
402      * REVISIT: According to the spec it is not allowed to alter neither the
403      * document element nor the document type in any way
404      */

405     public Node JavaDoc removeChild(Node JavaDoc oldChild)
406         throws DOMException JavaDoc {
407         super.removeChild(oldChild);
408
409         // If remove succeeded, un-cache the kid appropriately
410
int type = oldChild.getNodeType();
411         if(type == Node.ELEMENT_NODE) {
412             docElement = null;
413         }
414         else if (type == Node.DOCUMENT_TYPE_NODE) {
415             docType=null;
416         }
417
418         return oldChild;
419
420     } // removeChild(Node):Node
421

422     /**
423      * Since we cache the docElement (and, currently, docType),
424      * replaceChild has to update the cache
425      *
426      * REVISIT: According to the spec it is not allowed to alter neither the
427      * document element nor the document type in any way
428      */

429     public Node JavaDoc replaceChild(Node JavaDoc newChild, Node JavaDoc oldChild)
430         throws DOMException JavaDoc {
431
432         super.replaceChild(newChild, oldChild);
433
434         int type = oldChild.getNodeType();
435         if(type == Node.ELEMENT_NODE) {
436             docElement = (ElementImpl)newChild;
437         }
438         else if (type == Node.DOCUMENT_TYPE_NODE) {
439             docType = (DocumentTypeImpl)newChild;
440         }
441         return oldChild;
442     } // replaceChild(Node,Node):Node
443

444     //
445
// Document methods
446
//
447

448     // factory methods
449

450     /**
451      * Factory method; creates an Attribute having this Document as its
452      * OwnerDoc.
453      *
454      * @param name The name of the attribute. Note that the attribute's value
455      * is _not_ established at the factory; remember to set it!
456      *
457      * @throws DOMException(INVALID_NAME_ERR) if the attribute name is not
458      * acceptable.
459      */

460     public Attr JavaDoc createAttribute(String JavaDoc name)
461         throws DOMException JavaDoc {
462
463         if (errorChecking && !isXMLName(name)) {
464             throw new DOMException JavaDoc(DOMException.INVALID_CHARACTER_ERR,
465                                    "DOM002 Illegal character");
466         }
467         return new AttrImpl(this, name);
468
469     } // createAttribute(String):Attr
470

471     /**
472      * Factory method; creates a CDATASection having this Document as
473      * its OwnerDoc.
474      *
475      * @param data The initial contents of the CDATA
476      *
477      * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents. (HTML
478      * not yet implemented.)
479      */

480     public CDATASection JavaDoc createCDATASection(String JavaDoc data)
481         throws DOMException JavaDoc {
482         return new CDATASectionImpl(this, data);
483     }
484
485     /**
486      * Factory method; creates a Comment having this Document as its
487      * OwnerDoc.
488      *
489      * @param data The initial contents of the Comment. */

490     public Comment JavaDoc createComment(String JavaDoc data) {
491         return new CommentImpl(this, data);
492     }
493
494     /**
495      * Factory method; creates a DocumentFragment having this Document
496      * as its OwnerDoc.
497      */

498     public DocumentFragment JavaDoc createDocumentFragment() {
499         return new DocumentFragmentImpl(this);
500     }
501
502     /**
503      * Factory method; creates an Element having this Document
504      * as its OwnerDoc.
505      *
506      * @param tagName The name of the element type to instantiate. For
507      * XML, this is case-sensitive. For HTML, the tagName parameter may
508      * be provided in any case, but it must be mapped to the canonical
509      * uppercase form by the DOM implementation.
510      *
511      * @throws DOMException(INVALID_NAME_ERR) if the tag name is not
512      * acceptable.
513      */

514     public Element JavaDoc createElement(String JavaDoc tagName)
515         throws DOMException JavaDoc {
516
517         if (errorChecking && !isXMLName(tagName)) {
518             throw new DOMException JavaDoc(DOMException.INVALID_CHARACTER_ERR,
519                                    "DOM002 Illegal character");
520         }
521         return new ElementImpl(this, tagName);
522
523     } // createElement(String):Element
524

525     /**
526      * Factory method; creates an EntityReference having this Document
527      * as its OwnerDoc.
528      *
529      * @param name The name of the Entity we wish to refer to
530      *
531      * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where
532      * nonstandard entities are not permitted. (HTML not yet
533      * implemented.)
534      */

535     public EntityReference JavaDoc createEntityReference(String JavaDoc name)
536         throws DOMException JavaDoc {
537
538         if (errorChecking && !isXMLName(name)) {
539             throw new DOMException JavaDoc(DOMException.INVALID_CHARACTER_ERR,
540                                    "DOM002 Illegal character");
541         }
542         return new EntityReferenceImpl(this, name);
543
544     } // createEntityReference(String):EntityReference
545

546     /**
547      * Factory method; creates a ProcessingInstruction having this Document
548      * as its OwnerDoc.
549      *
550      * @param target The target "processor channel"
551      * @param data Parameter string to be passed to the target.
552      *
553      * @throws DOMException(INVALID_NAME_ERR) if the target name is not
554      * acceptable.
555      *
556      * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents. (HTML
557      * not yet implemented.)
558      */

559     public ProcessingInstruction JavaDoc createProcessingInstruction(String JavaDoc target,
560                                                              String JavaDoc data)
561         throws DOMException JavaDoc {
562
563         if (errorChecking && !isXMLName(target)) {
564             throw new DOMException JavaDoc(DOMException.INVALID_CHARACTER_ERR,
565                                    "DOM002 Illegal character");
566         }
567         return new ProcessingInstructionImpl(this, target, data);
568
569     } // createProcessingInstruction(String,String):ProcessingInstruction
570

571     /**
572      * Factory method; creates a Text node having this Document as its
573      * OwnerDoc.
574      *
575      * @param data The initial contents of the Text.
576      */

577     public Text JavaDoc createTextNode(String JavaDoc data) {
578         return new TextImpl(this, data);
579     }
580
581     // other document methods
582

583     /**
584      * For XML, this provides access to the Document Type Definition.
585      * For HTML documents, and XML documents which don't specify a DTD,
586      * it will be null.
587      */

588     public DocumentType JavaDoc getDoctype() {
589         if (needsSyncChildren()) {
590             synchronizeChildren();
591         }
592         return docType;
593     }
594
595
596    /**
597     * DOM Level 3 WD - Experimental.
598     * The encoding of this document (part of XML Declaration)
599     */

600     public String JavaDoc getEncoding() {
601     return encoding;
602     }
603
604     /**
605      * DOM Level 3 WD - Experimental.
606      * The version of this document (part of XML Declaration)
607      */

608     public String JavaDoc getVersion() {
609     return version;
610     }
611
612     /**
613      * DOM Level 3 WD - Experimental.
614      * standalone that specifies whether this document is standalone
615      * (part of XML Declaration)
616      */

617     public boolean getStandalone() {
618         return standalone;
619     }
620
621
622     /**
623      * Convenience method, allowing direct access to the child node
624      * which is considered the root of the actual document content. For
625      * HTML, where it is legal to have more than one Element at the top
626      * level of the document, we pick the one with the tagName
627      * "HTML". For XML there should be only one top-level
628      *
629      * (HTML not yet supported.)
630      */

631     public Element JavaDoc getDocumentElement() {
632         if (needsSyncChildren()) {
633             synchronizeChildren();
634         }
635         return docElement;
636     }
637
638     /**
639      * Return a <em>live</em> collection of all descendent Elements (not just
640      * immediate children) having the specified tag name.
641      *
642      * @param tagname The type of Element we want to gather. "*" will be
643      * taken as a wildcard, meaning "all elements in the document."
644      *
645      * @see DeepNodeListImpl
646      */

647     public NodeList JavaDoc getElementsByTagName(String JavaDoc tagname) {
648         return new DeepNodeListImpl(this,tagname);
649     }
650
651     /**
652      * Retrieve information describing the abilities of this particular
653      * DOM implementation. Intended to support applications that may be
654      * using DOMs retrieved from several different sources, potentially
655      * with different underlying representations.
656      */

657     public DOMImplementation JavaDoc getImplementation() {
658         // Currently implemented as a singleton, since it's hardcoded
659
// information anyway.
660
return CoreDOMImplementationImpl.getDOMImplementation();
661     }
662
663     //
664
// Public methods
665
//
666

667     // properties
668

669     /**
670      * Sets whether the DOM implementation performs error checking
671      * upon operations. Turning off error checking only affects
672      * the following DOM checks:
673      * <ul>
674      * <li>Checking strings to make sure that all characters are
675      * legal XML characters
676      * <li>Hierarchy checking such as allowed children, checks for
677      * cycles, etc.
678      * </ul>
679      * <p>
680      * Turning off error checking does <em>not</em> turn off the
681      * following checks:
682      * <ul>
683      * <li>Read only checks
684      * <li>Checks related to DOM events
685      * </ul>
686      */

687
688     public void setErrorChecking(boolean check) {
689         errorChecking = check;
690     }
691
692     /*
693      * DOM Level 3 WD - Experimental.
694      */

695     public void setStrictErrorChecking(boolean check) {
696         errorChecking = check;
697     }
698
699
700     /**
701       * DOM Level 3 WD - Experimental.
702       * An attribute specifying, as part of the XML declaration,
703       * the encoding of this document. This is null when unspecified.
704       */

705     public void setEncoding(String JavaDoc value) {
706         encoding = value;
707     }
708
709     /**
710       * DOM Level 3 WD - Experimental.
711       * version - An attribute specifying, as part of the XML declaration,
712       * the version number of this document. This is null when unspecified
713       */

714     public void setVersion(String JavaDoc value) {
715        version = value;
716     }
717
718     /**
719       * DOM Level 3 WD - Experimental.
720       * standalone - An attribute specifying, as part of the XML declaration,
721       * whether this document is standalone
722       */

723     public void setStandalone(boolean value) {
724         standalone = value;
725     }
726
727
728     /**
729      * Returns true if the DOM implementation performs error checking.
730      */

731     public boolean getErrorChecking() {
732         return errorChecking;
733     }
734
735     /*
736      * DOM Level 3 WD - Experimental.
737      */

738     public boolean getStrictErrorChecking() {
739         return errorChecking;
740     }
741
742     /**
743      * Sets whether the DOM implementation generates mutation events
744      * upon operations.
745      */

746     void setMutationEvents(boolean set) {
747         // does nothing by default - overidden in subclass
748
}
749
750     /**
751      * Returns true if the DOM implementation generates mutation events.
752      */

753     boolean getMutationEvents() {
754         // does nothing by default - overriden in subclass
755
return false;
756     }
757
758
759
760     // non-DOM factory methods
761

762     /**
763      * NON-DOM
764      * Factory method; creates a DocumentType having this Document
765      * as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building
766      * DTD information unspecified.)
767      *
768      * @param name The name of the Entity we wish to provide a value for.
769      *
770      * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where
771      * DTDs are not permitted. (HTML not yet implemented.)
772      */

773     public DocumentType JavaDoc createDocumentType(String JavaDoc qualifiedName,
774                                            String JavaDoc publicID,
775                                            String JavaDoc systemID)
776         throws DOMException JavaDoc {
777
778         if (errorChecking && !isXMLName(qualifiedName)) {
779             throw new DOMException JavaDoc(DOMException.INVALID_CHARACTER_ERR,
780                                    "DOM002 Illegal character");
781         }
782         return new DocumentTypeImpl(this, qualifiedName, publicID, systemID);
783
784     } // createDocumentType(String):DocumentType
785

786     /**
787      * NON-DOM
788      * Factory method; creates an Entity having this Document
789      * as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building
790      * DTD information unspecified.)
791      *
792      * @param name The name of the Entity we wish to provide a value for.
793      *
794      * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where
795      * nonstandard entities are not permitted. (HTML not yet
796      * implemented.)
797      */

798     public Entity JavaDoc createEntity(String JavaDoc name)
799         throws DOMException JavaDoc {
800
801         if (errorChecking && !isXMLName(name)) {
802             throw new DOMException JavaDoc(DOMException.INVALID_CHARACTER_ERR,
803                                        "DOM002 Illegal character");
804         }
805         return new EntityImpl(this, name);
806
807     } // createEntity(String):Entity
808

809     /**
810      * NON-DOM
811      * Factory method; creates a Notation having this Document
812      * as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building
813      * DTD information unspecified.)
814      *
815      * @param name The name of the Notation we wish to describe
816      *
817      * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where
818      * notations are not permitted. (HTML not yet
819      * implemented.)
820      */

821     public Notation JavaDoc createNotation(String JavaDoc name)
822         throws DOMException JavaDoc {
823
824         if (errorChecking && !isXMLName(name)) {
825             throw new DOMException JavaDoc(DOMException.INVALID_CHARACTER_ERR,
826                                        "DOM002 Illegal character");
827         }
828         return new NotationImpl(this, name);
829
830     } // createNotation(String):Notation
831

832     /**
833      * NON-DOM Factory method: creates an element definition. Element
834      * definitions hold default attribute values.
835      */

836     public ElementDefinitionImpl createElementDefinition(String JavaDoc name)
837         throws DOMException JavaDoc {
838
839         if (errorChecking && !isXMLName(name)) {
840             throw new DOMException JavaDoc(DOMException.INVALID_CHARACTER_ERR,
841                                        "DOM002 Illegal character");
842         }
843         return new ElementDefinitionImpl(this, name);
844
845     } // createElementDefinition(String):ElementDefinitionImpl
846

847     // other non-DOM methods
848

849     /**
850      * Copies a node from another document to this document. The new nodes are
851      * created using this document's factory methods and are populated with the
852      * data from the source's accessor methods defined by the DOM interfaces.
853      * Its behavior is otherwise similar to that of cloneNode.
854      * <p>
855      * According to the DOM specifications, document nodes cannot be imported
856      * and a NOT_SUPPORTED_ERR exception is thrown if attempted.
857      */

858     public Node JavaDoc importNode(Node JavaDoc source, boolean deep)
859     throws DOMException JavaDoc {
860         return importNode(source, deep, null);
861     } // importNode(Node,boolean):Node
862

863     /**
864      * Overloaded implementation of DOM's importNode method. This method
865      * provides the core functionality for the public importNode and cloneNode
866      * methods.
867      *
868      * The reversedIdentifiers parameter is provided for cloneNode to
869      * preserve the document's identifiers. The Hashtable has Elements as the
870      * keys and their identifiers as the values. When an element is being
871      * imported, a check is done for an associated identifier. If one exists,
872      * the identifier is registered with the new, imported element. If
873      * reversedIdentifiers is null, the parameter is not applied.
874      */

875     private Node JavaDoc importNode(Node JavaDoc source, boolean deep,
876                             Hashtable JavaDoc reversedIdentifiers)
877     throws DOMException JavaDoc {
878         Node JavaDoc newnode=null;
879
880         // Sigh. This doesn't work; too many nodes have private data that
881
// would have to be manually tweaked. May be able to add local
882
// shortcuts to each nodetype. Consider ?????
883
// if(source instanceof NodeImpl &&
884
// !(source instanceof DocumentImpl))
885
// {
886
// // Can't clone DocumentImpl since it invokes us...
887
// newnode=(NodeImpl)source.cloneNode(false);
888
// newnode.ownerDocument=this;
889
// }
890
// else
891

892         // get source implementation
893

894         int type = source.getNodeType();
895
896         switch (type) {
897             case ELEMENT_NODE: {
898                 Element JavaDoc newElement;
899                 boolean domLevel20 = source.getOwnerDocument().getImplementation().hasFeature("XML", "2.0");
900                 // Create element according to namespace support/qualification.
901
if(domLevel20 == false || source.getLocalName() == null)
902                     newElement = createElement(source.getNodeName());
903                 else
904                     newElement = createElementNS(source.getNamespaceURI(),
905                                                  source.getNodeName());
906
907                 // Copy element's attributes, if any.
908
NamedNodeMap JavaDoc sourceAttrs = source.getAttributes();
909                 if (sourceAttrs != null) {
910                     int length = sourceAttrs.getLength();
911                     for (int index = 0; index < length; index++) {
912                         Attr JavaDoc attr = (Attr JavaDoc)sourceAttrs.item(index);
913
914                         // Copy the attribute only if it is not a default.
915
if (attr.getSpecified()) {
916                             Attr JavaDoc newAttr = (Attr JavaDoc)importNode(attr, true,
917                                                           reversedIdentifiers);
918
919                             // Attach attribute according to namespace
920
// support/qualification.
921
if (domLevel20 == false ||
922                                 attr.getLocalName() == null)
923                                 newElement.setAttributeNode(newAttr);
924                             else
925                                 newElement.setAttributeNodeNS(newAttr);
926                         }
927                     }
928                 }
929
930                 // Register element identifier.
931
if (reversedIdentifiers != null) {
932                     // Does element have an associated identifier?
933
Object JavaDoc elementId = reversedIdentifiers.get(source);
934                     if (elementId != null) {
935                         if (identifiers == null)
936                             identifiers = new Hashtable JavaDoc();
937
938                         identifiers.put(elementId, newElement);
939                     }
940                 }
941
942                 newnode = newElement;
943                 break;
944             }
945
946             case ATTRIBUTE_NODE: {
947
948                 if(source.getOwnerDocument().getImplementation().hasFeature("XML", "2.0")){
949                     if (source.getLocalName() == null) {
950                     newnode = createAttribute(source.getNodeName());
951                 } else {
952                     newnode = createAttributeNS(source.getNamespaceURI(),
953                                                     source.getNodeName());
954                 }
955                 }
956                 else {
957                     newnode = createAttribute(source.getNodeName());
958                 }
959                 // if source is an AttrImpl from this very same implementation
960
// avoid creating the child nodes if possible
961
if (source instanceof AttrImpl) {
962                     AttrImpl attr = (AttrImpl) source;
963                     if (attr.hasStringValue()) {
964                         AttrImpl newattr = (AttrImpl) newnode;
965                         newattr.setValue(attr.getValue());
966                         deep = false;
967                     }
968                     else {
969                         deep = true;
970                     }
971                 }
972                 else {
973                     // According to the DOM spec the kids carry the value.
974
// However, there are non compliant implementations out
975
// there that fail to do so. To avoid ending up with no
976
// value at all, in this case we simply copy the text value
977
// directly.
978
if (source.getFirstChild() == null) {
979                         newnode.setNodeValue(source.getNodeValue());
980                         deep = false;
981                     } else {
982                         deep = true;
983                     }
984                 }
985         break;
986             }
987
988         case TEXT_NODE: {
989         newnode = createTextNode(source.getNodeValue());
990         break;
991             }
992
993         case CDATA_SECTION_NODE: {
994         newnode = createCDATASection(source.getNodeValue());
995         break;
996             }
997
998             case ENTITY_REFERENCE_NODE: {
999         newnode = createEntityReference(source.getNodeName());
1000                // allow deep import temporarily
1001
((EntityReferenceImpl)newnode).isReadOnly(false);
1002        break;
1003            }
1004
1005            case ENTITY_NODE: {
1006        Entity JavaDoc srcentity = (Entity JavaDoc)source;
1007        EntityImpl newentity =
1008            (EntityImpl)createEntity(source.getNodeName());
1009        newentity.setPublicId(srcentity.getPublicId());
1010        newentity.setSystemId(srcentity.getSystemId());
1011        newentity.setNotationName(srcentity.getNotationName());
1012        // Kids carry additional value
1013
newentity.isReadOnly(false); // allow deep import temporarily
1014
newnode = newentity;
1015        break;
1016            }
1017
1018            case PROCESSING_INSTRUCTION_NODE: {
1019        newnode = createProcessingInstruction(source.getNodeName(),
1020                              source.getNodeValue());
1021        break;
1022            }
1023
1024            case COMMENT_NODE: {
1025        newnode = createComment(source.getNodeValue());
1026        break;
1027            }
1028
1029            case DOCUMENT_FRAGMENT_NODE: {
1030        newnode = createDocumentFragment();
1031        // No name, kids carry value
1032
break;
1033            }
1034
1035            case NOTATION_NODE: {
1036        Notation JavaDoc srcnotation = (Notation JavaDoc)source;
1037        NotationImpl newnotation =
1038            (NotationImpl)createNotation(source.getNodeName());
1039        newnotation.setPublicId(srcnotation.getPublicId());
1040        newnotation.setSystemId(srcnotation.getSystemId());
1041        // Kids carry additional value
1042
newnode = newnotation;
1043        // No name, no value
1044
break;
1045            }
1046            case DOCUMENT_TYPE_NODE:
1047            case DOCUMENT_NODE : // Can't import document nodes
1048
default: { // Unknown node type
1049
throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR,
1050                                  "Node type being imported is not supported");
1051            }
1052        }
1053
1054        // If deep, replicate and attach the kids.
1055
if (deep) {
1056        for (Node JavaDoc srckid = source.getFirstChild();
1057                 srckid != null;
1058                 srckid = srckid.getNextSibling()) {
1059        newnode.appendChild(importNode(srckid, true,
1060                                               reversedIdentifiers));
1061        }
1062        }
1063        if (newnode.getNodeType() == Node.ENTITY_REFERENCE_NODE
1064            || newnode.getNodeType() == Node.ENTITY_NODE) {
1065          ((NodeImpl)newnode).setReadOnly(true, true);
1066        }
1067        return newnode;
1068
1069    } // importNode(Node,boolean,Hashtable):Node
1070

1071    /**
1072     * DOM Level 3 WD - Experimental
1073     * Change the node's ownerDocument, and its subtree, to this Document
1074     *
1075     * @param source The node to adopt.
1076     * @see DocumentImpl.importNode
1077     **/

1078    public Node JavaDoc adoptNode(Node JavaDoc source) throws DOMException JavaDoc {
1079        NodeImpl node;
1080        try {
1081            node = (NodeImpl) source;
1082        } catch (ClassCastException JavaDoc e) {
1083            // source node comes from a different DOMImplementation
1084
return null;
1085        }
1086        switch (node.getNodeType()) {
1087            case ATTRIBUTE_NODE: {
1088                AttrImpl attr = (AttrImpl) node;
1089                // remove node from wherever it is
1090
attr.getOwnerElement().removeAttributeNode(attr);
1091                // mark it as specified
1092
attr.isSpecified(true);
1093                // change ownership
1094
attr.setOwnerDocument(this);
1095                break;
1096            }
1097            case DOCUMENT_NODE:
1098            case DOCUMENT_TYPE_NODE: {
1099                throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR,
1100                                       "cannot adopt this type of node.");
1101            }
1102            case ENTITY_REFERENCE_NODE: {
1103                // remove node from wherever it is
1104
Node JavaDoc parent = node.getParentNode();
1105                if (parent != null) {
1106                    parent.removeChild(source);
1107                }
1108                // discard its replacement value
1109
Node JavaDoc child;
1110                while ((child = node.getFirstChild()) != null) {
1111                    node.removeChild(child);
1112                }
1113                // change ownership
1114
node.setOwnerDocument(this);
1115                // set its new replacement value if any
1116
if (docType == null) {
1117                    break;
1118                }
1119                NamedNodeMap JavaDoc entities = docType.getEntities();
1120                Node JavaDoc entityNode = entities.getNamedItem(node.getNodeName());
1121                if (entityNode == null) {
1122                    break;
1123                }
1124                EntityImpl entity = (EntityImpl) entityNode;
1125                for (child = entityNode.getFirstChild();
1126                     child != null; child = child.getNextSibling()) {
1127                    Node JavaDoc childClone = child.cloneNode(true);
1128                    node.appendChild(childClone);
1129                }
1130                break;
1131            }
1132            case ELEMENT_NODE: {
1133                // remove node from wherever it is
1134
Node JavaDoc parent = node.getParentNode();
1135                if (parent != null) {
1136                    parent.removeChild(source);
1137                }
1138                // change ownership
1139
node.setOwnerDocument(this);
1140                // reconcile default attributes
1141
((ElementImpl)node).reconcileDefaultAttributes();
1142                break;
1143            }
1144            default: {
1145                // remove node from wherever it is
1146
Node JavaDoc parent = node.getParentNode();
1147                if (parent != null) {
1148                    parent.removeChild(source);
1149                }
1150                // change ownership
1151
node.setOwnerDocument(this);
1152            }
1153        }
1154        return node;
1155    }
1156
1157    // identifier maintenence
1158
/**
1159     * Introduced in DOM Level 2
1160     * Returns the Element whose ID is given by elementId. If no such element
1161     * exists, returns null. Behavior is not defined if more than one element
1162     * has this ID.
1163     * <p>
1164     * Note: The DOM implementation must have information that says which
1165     * attributes are of type ID. Attributes with the name "ID" are not of type
1166     * ID unless so defined. Implementations that do not know whether
1167     * attributes are of type ID or not are expected to return null.
1168     * @see #getIdentifier
1169     */

1170    public Element JavaDoc getElementById(String JavaDoc elementId) {
1171        return getIdentifier(elementId);
1172    }
1173
1174    /**
1175     * Registers an identifier name with a specified element node.
1176     * If the identifier is already registered, the new element
1177     * node replaces the previous node. If the specified element
1178     * node is null, removeIdentifier() is called.
1179     *
1180     * @see #getIdentifier
1181     * @see #removeIdentifier
1182     */

1183    public void putIdentifier(String JavaDoc idName, Element JavaDoc element) {
1184
1185        if (element == null) {
1186            removeIdentifier(idName);
1187            return;
1188        }
1189
1190        if (needsSyncData()) {
1191            synchronizeData();
1192        }
1193
1194        if (identifiers == null) {
1195            identifiers = new Hashtable JavaDoc();
1196        }
1197
1198        identifiers.put(idName, element);
1199
1200    } // putIdentifier(String,Element)
1201

1202    /**
1203     * Returns a previously registered element with the specified
1204     * identifier name, or null if no element is registered.
1205     *
1206     * @see #putIdentifier
1207     * @see #removeIdentifier
1208     */

1209    public Element JavaDoc getIdentifier(String JavaDoc idName) {
1210
1211        if (needsSyncData()) {
1212            synchronizeData();
1213        }
1214
1215        if (identifiers == null) {
1216            return null;
1217        }
1218
1219        return (Element JavaDoc)identifiers.get(idName);
1220
1221    } // getIdentifier(String):Element
1222

1223    /**
1224     * Removes a previously registered element with the specified
1225     * identifier name.
1226     *
1227     * @see #putIdentifier
1228     * @see #getIdentifier
1229     */

1230    public void removeIdentifier(String JavaDoc idName) {
1231
1232        if (needsSyncData()) {
1233            synchronizeData();
1234        }
1235
1236        if (identifiers == null) {
1237            return;
1238        }
1239
1240        identifiers.remove(idName);
1241
1242    } // removeIdentifier(String)
1243

1244    /** Returns an enumeration registered of identifier names. */
1245    public Enumeration JavaDoc getIdentifiers() {
1246
1247        if (needsSyncData()) {
1248            synchronizeData();
1249        }
1250
1251        if (identifiers == null) {
1252            identifiers = new Hashtable JavaDoc();
1253        }
1254
1255        return identifiers.keys();
1256
1257    } // getIdentifiers():Enumeration
1258

1259    //
1260
// DOM2: Namespace methods
1261
//
1262

1263    /**
1264     * Introduced in DOM Level 2. <p>
1265     * Creates an element of the given qualified name and namespace URI.
1266     * If the given namespaceURI is null or an empty string and the
1267     * qualifiedName has a prefix that is "xml", the created element
1268     * is bound to the predefined namespace
1269     * "http://www.w3.org/XML/1998/namespace" [Namespaces].
1270     * @param namespaceURI The namespace URI of the element to
1271     * create.
1272     * @param qualifiedName The qualified name of the element type to
1273     * instantiate.
1274     * @return Element A new Element object with the following attributes:
1275     * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified
1276                            name contains an invalid character.
1277     * @throws DOMException NAMESPACE_ERR: Raised if the qualifiedName has a
1278     * prefix that is "xml" and the namespaceURI is
1279     * neither null nor an empty string nor
1280     * "http://www.w3.org/XML/1998/namespace", or
1281     * if the qualifiedName has a prefix different
1282     * from "xml" and the namespaceURI is null or an
1283     * empty string.
1284     * @since WD-DOM-Level-2-19990923
1285     */

1286    public Element JavaDoc createElementNS(String JavaDoc namespaceURI, String JavaDoc qualifiedName)
1287        throws DOMException JavaDoc
1288    {
1289        if (errorChecking && !isXMLName(qualifiedName)) {
1290            throw new DOMException JavaDoc(DOMException.INVALID_CHARACTER_ERR,
1291                                   "DOM002 Illegal character");
1292        }
1293        return new ElementNSImpl(this, namespaceURI, qualifiedName);
1294    }
1295
1296    /**
1297     * Introduced in DOM Level 2. <p>
1298     * Creates an attribute of the given qualified name and namespace URI.
1299     * If the given namespaceURI is null or an empty string and the
1300     * qualifiedName has a prefix that is "xml", the created element
1301     * is bound to the predefined namespace
1302     * "http://www.w3.org/XML/1998/namespace" [Namespaces].
1303     *
1304     * @param namespaceURI The namespace URI of the attribute to
1305     * create. When it is null or an empty string,
1306     * this method behaves like createAttribute.
1307     * @param qualifiedName The qualified name of the attribute to
1308     * instantiate.
1309     * @return Attr A new Attr object.
1310     * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified
1311                            name contains an invalid character.
1312     * @since WD-DOM-Level-2-19990923
1313     */

1314    public Attr JavaDoc createAttributeNS(String JavaDoc namespaceURI, String JavaDoc qualifiedName)
1315        throws DOMException JavaDoc
1316    {
1317        if (errorChecking && !isXMLName(qualifiedName)) {
1318            throw new DOMException JavaDoc(DOMException.INVALID_CHARACTER_ERR,
1319                                   "DOM002 Illegal character");
1320        }
1321        return new AttrNSImpl(this, namespaceURI, qualifiedName);
1322    }
1323
1324    /**
1325     * Introduced in DOM Level 2. <p>
1326     * Returns a NodeList of all the Elements with a given local name and
1327     * namespace URI in the order in which they would be encountered in a
1328     * preorder traversal of the Document tree.
1329     * @param namespaceURI The namespace URI of the elements to match
1330     * on. The special value "*" matches all
1331     * namespaces. When it is null or an empty
1332     * string, this method behaves like
1333     * getElementsByTagName.
1334     * @param localName The local name of the elements to match on.
1335     * The special value "*" matches all local names.
1336     * @return NodeList A new NodeList object containing all the matched
1337     * Elements.
1338     * @since WD-DOM-Level-2-19990923
1339     */

1340    public NodeList JavaDoc getElementsByTagNameNS(String JavaDoc namespaceURI,
1341                                           String JavaDoc localName)
1342    {
1343        return new DeepNodeListImpl(this, namespaceURI, localName);
1344    }
1345
1346    //
1347
// Object methods
1348
//
1349

1350    /** Clone. */
1351    public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
1352        CoreDocumentImpl newdoc = (CoreDocumentImpl) super.clone();
1353        newdoc.docType = null;
1354        newdoc.docElement = null;
1355        return newdoc;
1356    }
1357
1358    //
1359
// Public static methods
1360
//
1361

1362    /**
1363     * Check the string against XML's definition of acceptable names for
1364     * elements and attributes and so on using the XMLCharacterProperties
1365     * utility class
1366     */

1367    public static boolean isXMLName(String JavaDoc s) {
1368
1369        if (s == null) {
1370            return false;
1371        }
1372        return XMLCharacterProperties.validName(s);
1373
1374    } // isXMLName(String):boolean
1375

1376    //
1377
// Protected methods
1378
//
1379

1380    /**
1381     * Uses the kidOK lookup table to check whether the proposed
1382     * tree structure is legal.
1383     */

1384    protected boolean isKidOK(Node JavaDoc parent, Node JavaDoc child) {
1385        if (allowGrammarAccess &&
1386            parent.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
1387            return child.getNodeType() == Node.ELEMENT_NODE;
1388        }
1389        return 0 != (kidOK[parent.getNodeType()] & 1 << child.getNodeType());
1390    }
1391
1392    /**
1393     * Denotes that this node has changed.
1394     */

1395    protected void changed() {
1396        changes++;
1397    }
1398
1399    /**
1400     * Returns the number of changes to this node.
1401     */

1402    protected int changes() {
1403        return changes;
1404    }
1405
1406    /**
1407     * Store user data related to a given node
1408     * This is a place where we could use weak references! Indeed, the node
1409     * here won't be GC'ed as long as some user data is attached to it, since
1410     * the userData table will have a reference to the node.
1411     */

1412    protected void setUserData(NodeImpl n, Object JavaDoc data) {
1413        // does nothing by default - overidden in subclass
1414
}
1415
1416    /**
1417     * Retreive user data related to a given node
1418     */

1419    protected Object JavaDoc getUserData(NodeImpl n) {
1420        // does nothing by default - overidden in subclass
1421
return null;
1422    }
1423
1424    protected void addEventListener(NodeImpl node, String JavaDoc type,
1425                                    EventListener JavaDoc listener,
1426                                    boolean useCapture) {
1427        // does nothing by default - overidden in subclass
1428
}
1429
1430    protected void removeEventListener(NodeImpl node, String JavaDoc type,
1431                                       EventListener JavaDoc listener,
1432                                       boolean useCapture) {
1433        // does nothing by default - overidden in subclass
1434
}
1435
1436    protected boolean dispatchEvent(NodeImpl node, Event JavaDoc event) {
1437        // does nothing by default - overidden in subclass
1438
return false;
1439    }
1440
1441    // Notification methods overidden in subclasses
1442

1443    /**
1444     * A method to be called when some text was changed in a text node,
1445     * so that live objects can be notified.
1446     */

1447    void replacedText(NodeImpl node) {
1448    }
1449
1450    /**
1451     * A method to be called when some text was deleted from a text node,
1452     * so that live objects can be notified.
1453     */

1454    void deletedText(NodeImpl node, int offset, int count) {
1455    }
1456
1457    /**
1458     * A method to be called when some text was inserted into a text node,
1459     * so that live objects can be notified.
1460     */

1461    void insertedText(NodeImpl node, int offset, int count) {
1462    }
1463
1464    /**
1465     * A method to be called when a character data node has been modified
1466     */

1467    void modifyingCharacterData(NodeImpl node) {
1468    }
1469
1470    /**
1471     * A method to be called when a character data node has been modified
1472     */

1473    void modifiedCharacterData(NodeImpl node, String JavaDoc oldvalue, String JavaDoc value) {
1474    }
1475
1476    /**
1477     * A method to be called when a node is about to be inserted in the tree.
1478     */

1479    void insertingNode(NodeImpl node, boolean replace) {
1480    }
1481
1482    /**
1483     * A method to be called when a node has been inserted in the tree.
1484     */

1485    void insertedNode(NodeImpl node, NodeImpl newInternal, boolean replace) {
1486    }
1487
1488    /**
1489     * A method to be called when a node is about to be removed from the tree.
1490     */

1491    void removingNode(NodeImpl node, NodeImpl oldChild, boolean replace) {
1492    }
1493
1494    /**
1495     * A method to be called when a node has been removed from the tree.
1496     */

1497    void removedNode(NodeImpl node, boolean replace) {
1498    }
1499
1500    /**
1501     * A method to be called when a node is about to be replaced in the tree.
1502     */

1503    void replacingNode(NodeImpl node) {
1504    }
1505
1506    /**
1507     * A method to be called when a node has been replaced in the tree.
1508     */

1509    void replacedNode(NodeImpl node) {
1510    }
1511
1512    /**
1513     * A method to be called when an attribute value has been modified
1514     */

1515    void modifiedAttrValue(AttrImpl attr, String JavaDoc oldvalue) {
1516    }
1517
1518    /**
1519     * A method to be called when an attribute node has been set
1520     */

1521    void setAttrNode(AttrImpl attr, AttrImpl previous) {
1522    }
1523
1524    /**
1525     * A method to be called when an attribute node has been removed
1526     */

1527    void removedAttrNode(AttrImpl attr, NodeImpl oldOwner, String JavaDoc name) {
1528    }
1529
1530
1531    /* (non-Javadoc)
1532     * @see org.w3c.dom.Document#getInputEncoding()
1533     */

1534    public String JavaDoc getInputEncoding() {
1535        // TODO Auto-generated method stub
1536
return null;
1537    }
1538    /* (non-Javadoc)
1539     * @see org.w3c.dom.Document#getXmlEncoding()
1540     */

1541    public String JavaDoc getXmlEncoding() {
1542        // TODO Auto-generated method stub
1543
return null;
1544    }
1545    /* (non-Javadoc)
1546     * @see org.w3c.dom.Document#getXmlStandalone()
1547     */

1548    public boolean getXmlStandalone() {
1549        // TODO Auto-generated method stub
1550
return false;
1551    }
1552    /* (non-Javadoc)
1553     * @see org.w3c.dom.Document#setXmlStandalone(boolean)
1554     */

1555    public void setXmlStandalone(boolean xmlStandalone) throws DOMException JavaDoc {
1556        // TODO Auto-generated method stub
1557

1558    }
1559    /* (non-Javadoc)
1560     * @see org.w3c.dom.Document#getXmlVersion()
1561     */

1562    public String JavaDoc getXmlVersion() {
1563        // TODO Auto-generated method stub
1564
return null;
1565    }
1566    /* (non-Javadoc)
1567     * @see org.w3c.dom.Document#setXmlVersion(java.lang.String)
1568     */

1569    public void setXmlVersion(String JavaDoc xmlVersion) throws DOMException JavaDoc {
1570        // TODO Auto-generated method stub
1571

1572    }
1573    /* (non-Javadoc)
1574     * @see org.w3c.dom.Document#getDocumentURI()
1575     */

1576    public String JavaDoc getDocumentURI() {
1577        // TODO Auto-generated method stub
1578
return null;
1579    }
1580    /* (non-Javadoc)
1581     * @see org.w3c.dom.Document#setDocumentURI(java.lang.String)
1582     */

1583    public void setDocumentURI(String JavaDoc documentURI) {
1584        // TODO Auto-generated method stub
1585

1586    }
1587    /* (non-Javadoc)
1588     * @see org.w3c.dom.Document#getDomConfig()
1589     */

1590    public DOMConfiguration JavaDoc getDomConfig() {
1591        // TODO Auto-generated method stub
1592
return null;
1593    }
1594    /* (non-Javadoc)
1595     * @see org.w3c.dom.Document#normalizeDocument()
1596     */

1597    public void normalizeDocument() {
1598        // TODO Auto-generated method stub
1599

1600    }
1601    /* (non-Javadoc)
1602     * @see org.w3c.dom.Document#renameNode(org.w3c.dom.Node, java.lang.String, java.lang.String)
1603     */

1604    public Node JavaDoc renameNode(Node JavaDoc n, String JavaDoc namespaceURI, String JavaDoc qualifiedName) throws DOMException JavaDoc {
1605        // TODO Auto-generated method stub
1606
return null;
1607    }
1608
1609} // class CoreDocumentImpl
1610
Popular Tags