Class Document

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.w3c.dom.Document, org.w3c.dom.Node, Group, Item

    public class Document
    extends AbstractGroup
    implements org.w3c.dom.Document
    Represents Document which is also W3C/DOM's document, i.e., org.w3c.dom.Document.
    Author:
    tomyeh
    See Also:
    Element, Serialized Form
    • Constructor Detail

      • Document

        public Document​(Element root,
                        DocType dt)
        Constructor.
      • Document

        public Document​(Element root)
        Constructor.
      • Document

        public Document()
        Constructor.
    • Method Detail

      • getRootElement

        public final Element getRootElement()
        Gets the root element.
      • setRootElement

        public final void setRootElement​(Element root)
        Sets the root element.
      • getDocType

        public final DocType getDocType()
        Gets the document type.
      • setDocType

        public final void setDocType​(DocType docType)
        Sets the document type.
      • newChildren

        protected final java.util.List<Item> newChildren()
        Description copied from class: AbstractGroup
        Creates a list to hold child vertices. Note: the list must be able to protect itself from adding unexpected child -- read-only, wrong type, undetached...

        The default implementation obeys the semantic of Element, i.e., it doesn't allow any child that cannot be a child of Element.

        For performance issue, we introduced a map to improve the search speed for Element node associated with a tag name.

        Overrides:
        newChildren in class AbstractGroup
      • getName

        public final java.lang.String getName()
        Description copied from interface: Item
        Gets the name of the item. For vertices that support namespace (implements Namespaceable), it is the same as getTagName.
        Specified by:
        getName in interface Item
        See Also:
        Namespaceable.getTagName()
      • getNodeType

        public final short getNodeType()
        Specified by:
        getNodeType in interface org.w3c.dom.Node
      • getDoctype

        public final org.w3c.dom.DocumentType getDoctype()
        Specified by:
        getDoctype in interface org.w3c.dom.Document
      • getDocumentElement

        public final org.w3c.dom.Element getDocumentElement()
        Specified by:
        getDocumentElement in interface org.w3c.dom.Document
      • getImplementation

        public final org.w3c.dom.DOMImplementation getImplementation()
        Specified by:
        getImplementation in interface org.w3c.dom.Document
      • createElement

        public final org.w3c.dom.Element createElement​(java.lang.String lname)
        Specified by:
        createElement in interface org.w3c.dom.Document
      • createElementNS

        public final org.w3c.dom.Element createElementNS​(java.lang.String nsURI,
                                                         java.lang.String tname)
        Specified by:
        createElementNS in interface org.w3c.dom.Document
      • createAttribute

        public final org.w3c.dom.Attr createAttribute​(java.lang.String lname)
        Specified by:
        createAttribute in interface org.w3c.dom.Document
      • createAttributeNS

        public final org.w3c.dom.Attr createAttributeNS​(java.lang.String nsURI,
                                                        java.lang.String tname)
        Specified by:
        createAttributeNS in interface org.w3c.dom.Document
      • createDocumentFragment

        public final org.w3c.dom.DocumentFragment createDocumentFragment()
        Specified by:
        createDocumentFragment in interface org.w3c.dom.Document
      • createTextNode

        public final org.w3c.dom.Text createTextNode​(java.lang.String data)
        Specified by:
        createTextNode in interface org.w3c.dom.Document
      • createComment

        public final org.w3c.dom.Comment createComment​(java.lang.String data)
        Specified by:
        createComment in interface org.w3c.dom.Document
      • createCDATASection

        public final org.w3c.dom.CDATASection createCDATASection​(java.lang.String data)
        Specified by:
        createCDATASection in interface org.w3c.dom.Document
      • createProcessingInstruction

        public final org.w3c.dom.ProcessingInstruction createProcessingInstruction​(java.lang.String target,
                                                                                   java.lang.String data)
        Specified by:
        createProcessingInstruction in interface org.w3c.dom.Document
      • createEntityReference

        public final org.w3c.dom.EntityReference createEntityReference​(java.lang.String name)
        Specified by:
        createEntityReference in interface org.w3c.dom.Document
      • getElementsByTagName

        public final org.w3c.dom.NodeList getElementsByTagName​(java.lang.String tname)
        Gets elements that matches the tag name.

        Unlike other implementations (Xerces or Crimson), the returned list is a snapshot of the current tree -- not a "live" representation.

        Specified by:
        getElementsByTagName in interface org.w3c.dom.Document
      • getElementsByTagNameNS

        public final org.w3c.dom.NodeList getElementsByTagNameNS​(java.lang.String nsURI,
                                                                 java.lang.String lname)
        Gets elements that matches the tag name and namespace.

        Unlike other implementations (Xerces or Crimson), the returned list is a snapshot of the current tree -- not a "live" representation.

        Specified by:
        getElementsByTagNameNS in interface org.w3c.dom.Document
      • getElementById

        public final org.w3c.dom.Element getElementById​(java.lang.String elementId)
        Specified by:
        getElementById in interface org.w3c.dom.Document
      • importNode

        public final org.w3c.dom.Node importNode​(org.w3c.dom.Node importedNode,
                                                 boolean deep)
        Specified by:
        importNode in interface org.w3c.dom.Document
      • getInputEncoding

        public java.lang.String getInputEncoding()
        Specified by:
        getInputEncoding in interface org.w3c.dom.Document
      • getXmlEncoding

        public java.lang.String getXmlEncoding()
        Specified by:
        getXmlEncoding in interface org.w3c.dom.Document
      • getXmlStandalone

        public boolean getXmlStandalone()
        Specified by:
        getXmlStandalone in interface org.w3c.dom.Document
      • setXmlStandalone

        public void setXmlStandalone​(boolean xmlStandalone)
                              throws DOMException
        Specified by:
        setXmlStandalone in interface org.w3c.dom.Document
        Throws:
        DOMException
      • getXmlVersion

        public java.lang.String getXmlVersion()
        Specified by:
        getXmlVersion in interface org.w3c.dom.Document
      • setXmlVersion

        public void setXmlVersion​(java.lang.String xmlVersion)
                           throws DOMException
        Specified by:
        setXmlVersion in interface org.w3c.dom.Document
        Throws:
        DOMException
      • getStrictErrorChecking

        public boolean getStrictErrorChecking()
        Specified by:
        getStrictErrorChecking in interface org.w3c.dom.Document
      • setStrictErrorChecking

        public void setStrictErrorChecking​(boolean strictErrorChecking)
        Specified by:
        setStrictErrorChecking in interface org.w3c.dom.Document
      • getDocumentURI

        public java.lang.String getDocumentURI()
        Specified by:
        getDocumentURI in interface org.w3c.dom.Document
      • setDocumentURI

        public void setDocumentURI​(java.lang.String documentURI)
        Specified by:
        setDocumentURI in interface org.w3c.dom.Document
      • adoptNode

        public org.w3c.dom.Node adoptNode​(org.w3c.dom.Node source)
                                   throws DOMException
        Specified by:
        adoptNode in interface org.w3c.dom.Document
        Throws:
        DOMException
      • getDomConfig

        public org.w3c.dom.DOMConfiguration getDomConfig()
        Specified by:
        getDomConfig in interface org.w3c.dom.Document
      • normalizeDocument

        public void normalizeDocument()
        Specified by:
        normalizeDocument in interface org.w3c.dom.Document
      • renameNode

        public org.w3c.dom.Node renameNode​(org.w3c.dom.Node n,
                                           java.lang.String namespaceURI,
                                           java.lang.String qualifiedName)
                                    throws DOMException
        Specified by:
        renameNode in interface org.w3c.dom.Document
        Throws:
        DOMException
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object