org.zkoss.idom
Class Document

java.lang.Object
  extended by org.zkoss.idom.impl.AbstractItem
      extended by org.zkoss.idom.impl.AbstractGroup
          extended by org.zkoss.idom.Document
All Implemented Interfaces:
Serializable, Cloneable, Document, Node, Group, Item

public class Document
extends AbstractGroup
implements Document

Represents Document which is also W3C/DOM's document, ie, org.w3c.dom.Document.

Author:
tomyeh
See Also:
Element, Serialized Form

Nested Class Summary
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.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
 
Fields inherited from interface org.zkoss.idom.Item
FIND_BY_PREFIX, FIND_BY_REGEX, FIND_BY_TAGNAME, FIND_IGNORE_CASE, FIND_RECURSIVE
 
Constructor Summary
Document()
          Constructor.
Document(Element root)
          Constructor.
Document(Element root, DocType dt)
          Constructor.
 
Method Summary
 Node adoptNode(Node source)
           
 Attr createAttribute(String lname)
           
 Attr createAttributeNS(String nsURI, String tname)
           
 CDATASection createCDATASection(String data)
           
 Comment createComment(String data)
           
 DocumentFragment createDocumentFragment()
           
 Element createElement(String lname)
           
 Element createElementNS(String nsURI, String tname)
           
 EntityReference createEntityReference(String name)
           
 ProcessingInstruction createProcessingInstruction(String target, String data)
           
 Text createTextNode(String data)
           
 DocumentType getDoctype()
           
 DocType getDocType()
          Gets the document type.
 Element getDocumentElement()
           
 String getDocumentURI()
           
 DOMConfiguration getDomConfig()
           
 Element getElementById(String elementId)
           
 NodeList getElementsByTagName(String tname)
          Gets elements that matches the tag name.
 NodeList getElementsByTagNameNS(String nsURI, String lname)
          Gets elements that matches the tag name and namespace.
 DOMImplementation getImplementation()
           
 String getInputEncoding()
           
 String getName()
          Gets the name of the item.
 short getNodeType()
           
 Element getRootElement()
          Gets the root element.
 boolean getStrictErrorChecking()
           
 String getXmlEncoding()
           
 boolean getXmlStandalone()
           
 String getXmlVersion()
           
 Node importNode(Node importedNode, boolean deep)
           
protected  List<Item> newChildren()
          Creates a list to hold child vertices.
 void normalizeDocument()
           
 Node renameNode(Node n, String namespaceURI, String qualifiedName)
           
 void setDocType(DocType docType)
          Sets the document type.
 void setDocumentURI(String documentURI)
           
 void setRootElement(Element root)
          Sets the root element.
 void setStrictErrorChecking(boolean strictErrorChecking)
           
 void setXmlStandalone(boolean xmlStandalone)
           
 void setXmlVersion(String xmlVersion)
           
 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.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
 
Methods inherited from interface org.zkoss.idom.Item
detach, getDocument, getLocator, getParent, getText, setLocator, setName, setParent, setText
 

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 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 sematic of Element, i.e., it doen'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 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 Node

getDoctype

public final DocumentType getDoctype()
Specified by:
getDoctype in interface Document

getDocumentElement

public final Element getDocumentElement()
Specified by:
getDocumentElement in interface Document

getImplementation

public final DOMImplementation getImplementation()
Specified by:
getImplementation in interface Document

createElement

public final Element createElement(String lname)
Specified by:
createElement in interface Document

createElementNS

public final Element createElementNS(String nsURI,
                                     String tname)
Specified by:
createElementNS in interface Document

createAttribute

public final Attr createAttribute(String lname)
Specified by:
createAttribute in interface Document

createAttributeNS

public final Attr createAttributeNS(String nsURI,
                                    String tname)
Specified by:
createAttributeNS in interface Document

createDocumentFragment

public final DocumentFragment createDocumentFragment()
Specified by:
createDocumentFragment in interface Document

createTextNode

public final Text createTextNode(String data)
Specified by:
createTextNode in interface Document

createComment

public final Comment createComment(String data)
Specified by:
createComment in interface Document

createCDATASection

public final CDATASection createCDATASection(String data)
Specified by:
createCDATASection in interface Document

createProcessingInstruction

public final ProcessingInstruction createProcessingInstruction(String target,
                                                               String data)
Specified by:
createProcessingInstruction in interface Document

createEntityReference

public final EntityReference createEntityReference(String name)
Specified by:
createEntityReference in interface Document

getElementsByTagName

public final NodeList getElementsByTagName(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 Document

getElementsByTagNameNS

public final NodeList getElementsByTagNameNS(String nsURI,
                                             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 Document

getElementById

public final Element getElementById(String elementId)
Specified by:
getElementById in interface Document

importNode

public final Node importNode(Node importedNode,
                             boolean deep)
Specified by:
importNode in interface Document

getInputEncoding

public String getInputEncoding()
Specified by:
getInputEncoding in interface Document

getXmlEncoding

public String getXmlEncoding()
Specified by:
getXmlEncoding in interface Document

getXmlStandalone

public boolean getXmlStandalone()
Specified by:
getXmlStandalone in interface Document

setXmlStandalone

public void setXmlStandalone(boolean xmlStandalone)
                      throws DOMException
Specified by:
setXmlStandalone in interface Document
Throws:
DOMException

getXmlVersion

public String getXmlVersion()
Specified by:
getXmlVersion in interface Document

setXmlVersion

public void setXmlVersion(String xmlVersion)
                   throws DOMException
Specified by:
setXmlVersion in interface Document
Throws:
DOMException

getStrictErrorChecking

public boolean getStrictErrorChecking()
Specified by:
getStrictErrorChecking in interface Document

setStrictErrorChecking

public void setStrictErrorChecking(boolean strictErrorChecking)
Specified by:
setStrictErrorChecking in interface Document

getDocumentURI

public String getDocumentURI()
Specified by:
getDocumentURI in interface Document

setDocumentURI

public void setDocumentURI(String documentURI)
Specified by:
setDocumentURI in interface Document

adoptNode

public Node adoptNode(Node source)
               throws DOMException
Specified by:
adoptNode in interface Document
Throws:
DOMException

getDomConfig

public DOMConfiguration getDomConfig()
Specified by:
getDomConfig in interface Document

normalizeDocument

public void normalizeDocument()
Specified by:
normalizeDocument in interface Document

renameNode

public Node renameNode(Node n,
                       String namespaceURI,
                       String qualifiedName)
                throws DOMException
Specified by:
renameNode in interface Document
Throws:
DOMException

toString

public final String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.