Package org.zkoss.idom

## Class Document

- java.lang.Object
- - org.zkoss.idom.impl.AbstractItem
  - - org.zkoss.idom.impl.AbstractGroup
    - - org.zkoss.idom.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

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `protected class` | `Document.ChildArray` |

    - ### Nested classes/interfaces inherited from class org.zkoss.idom.impl.AbstractGroup

      `AbstractGroup.ElementMap`

  - ### Field Summary

    - ### Fields inherited from class org.zkoss.idom.impl.AbstractGroup

      `_children`

    - ### Fields inherited from interface org.zkoss.idom.Item

      `FIND_BY_PREFIX, FIND_BY_REGEX, FIND_BY_TAGNAME, FIND_IGNORE_CASE, FIND_RECURSIVE`

    - ### Fields inherited from interface org.w3c.dom.Node

      `ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Document()` | Constructor.
    `Document​(Element root)` | Constructor.
    `Document​(Element root, DocType dt)` | Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `org.w3c.dom.Node` | `adoptNode​(org.w3c.dom.Node source)` |
    `org.w3c.dom.Attr` | `createAttribute​(java.lang.String lname)` |
    `org.w3c.dom.Attr` | `createAttributeNS​(java.lang.String nsURI, java.lang.String tname)` |
    `org.w3c.dom.CDATASection` | `createCDATASection​(java.lang.String data)` |
    `org.w3c.dom.Comment` | `createComment​(java.lang.String data)` |
    `org.w3c.dom.DocumentFragment` | `createDocumentFragment()` |
    `org.w3c.dom.Element` | `createElement​(java.lang.String lname)` |
    `org.w3c.dom.Element` | `createElementNS​(java.lang.String nsURI, java.lang.String tname)` |
    `org.w3c.dom.EntityReference` | `createEntityReference​(java.lang.String name)` |
    `org.w3c.dom.ProcessingInstruction` | `createProcessingInstruction​(java.lang.String target, java.lang.String data)` |
    `org.w3c.dom.Text` | `createTextNode​(java.lang.String data)` |
    `org.w3c.dom.DocumentType` | `getDoctype()` |
    `DocType` | `getDocType()` | Gets the document type.
    `org.w3c.dom.Element` | `getDocumentElement()` |
    `java.lang.String` | `getDocumentURI()` |
    `org.w3c.dom.DOMConfiguration` | `getDomConfig()` |
    `org.w3c.dom.Element` | `getElementById​(java.lang.String elementId)` |
    `org.w3c.dom.NodeList` | `getElementsByTagName​(java.lang.String tname)` | Gets elements that matches the tag name.
    `org.w3c.dom.NodeList` | `getElementsByTagNameNS​(java.lang.String nsURI, java.lang.String lname)` | Gets elements that matches the tag name and namespace.
    `org.w3c.dom.DOMImplementation` | `getImplementation()` |
    `java.lang.String` | `getInputEncoding()` |
    `java.lang.String` | `getName()` | Gets the name of the item.
    `short` | `getNodeType()` |
    `Element` | `getRootElement()` | Gets the root element.
    `boolean` | `getStrictErrorChecking()` |
    `java.lang.String` | `getXmlEncoding()` |
    `boolean` | `getXmlStandalone()` |
    `java.lang.String` | `getXmlVersion()` |
    `org.w3c.dom.Node` | `importNode​(org.w3c.dom.Node importedNode, boolean deep)` |
    `protected java.util.List<Item>` | `newChildren()` | Creates a list to hold child vertices.
    `void` | `normalizeDocument()` |
    `org.w3c.dom.Node` | `renameNode​(org.w3c.dom.Node n, java.lang.String namespaceURI, java.lang.String qualifiedName)` |
    `void` | `setDocType​(DocType docType)` | Sets the document type.
    `void` | `setDocumentURI​(java.lang.String documentURI)` |
    `void` | `setRootElement​(Element root)` | Sets the root element.
    `void` | `setStrictErrorChecking​(boolean strictErrorChecking)` |
    `void` | `setXmlStandalone​(boolean xmlStandalone)` |
    `void` | `setXmlVersion​(java.lang.String xmlVersion)` |
    `java.lang.String` | `toString()` |

    - ### Methods inherited from class org.zkoss.idom.impl.AbstractGroup

      `anyElement, appendChild, clone, coalesce, detachChildren, getChildNodes, getChildren, getElement, getElement, getElementIndex, getElementIndex, getElementNames, getElements, getElements, getElements, getElementValue, getElementValue, getFirstChild, getLastChild, hasChildNodes, insertBefore, removeChild, replaceChild`

    - ### Methods inherited from class org.zkoss.idom.impl.AbstractItem

      `cloneNode, compareDocumentPosition, detach, equals, getAttributes, getBaseURI, getDocument, getFeature, getLocalName, getLocator, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParent, getParentNode, getPrefix, getPreviousSibling, getText, getTextContent, getUserData, hasAttributes, hashCode, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, match, normalize, setLocator, setName, setNodeValue, setParent, setPrefix, setText, setTextContent, setUserData`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.zkoss.idom.Item

      `detach, getDocument, getLocator, getParent, getText, setLocator, setName, setParent, setText`

    - ### Methods inherited from interface org.w3c.dom.Node

      `appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData`

- - ### 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`