Xindice API
version 1.2m1

org.apache.xindice.xml.dom
Class DocumentImpl

java.lang.Object
  extended byorg.apache.xindice.xml.dom.NodeImpl
      extended byorg.apache.xindice.xml.dom.ContainerNodeImpl
          extended byorg.apache.xindice.xml.dom.DocumentImpl
All Implemented Interfaces:
CompressedDocument, CompressedNode, DBDocument, DBNode, org.w3c.dom.Document, org.w3c.dom.traversal.DocumentTraversal, org.w3c.dom.Node

public final class DocumentImpl
extends ContainerNodeImpl
implements CompressedDocument, DBDocument, org.w3c.dom.traversal.DocumentTraversal

DocumentImpl

Version:
$Revision: 571948 $, $Date: 2007-09-02 06:51:37 -0400 (Sun, 02 Sep 2007) $

Field Summary
 
Fields inherited from class org.apache.xindice.xml.dom.ContainerNodeImpl
childNodes
 
Fields inherited from class org.apache.xindice.xml.dom.NodeImpl
data, dirty, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, EX_DOMSTRING_SIZE, EX_HIERARCHY_REQUEST, EX_INDEX_SIZE, EX_INUSE_ATTRIBUTE, EX_INVALID_STATE, EX_NO_DATA_ALLOWED, EX_NO_MODIFICATION_ALLOWED, EX_NOT_FOUND, EX_WRONG_DOCUMENT, handlers, key, len, loaded, nodeName, nodeValue, nsURI, OBJECT_HREF, OBJECT_NS, OBJECT_TYPE, ownerDocument, parentNode, pos, source, TYPE_APPEND, TYPE_CONTENT, TYPE_INSERT, TYPE_REPLACE, userData, XMLNS_PREFIX, XMLNS_URI
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Fields inherited from interface org.apache.xindice.xml.dom.DBDocument
CACHE, CACHE_CONTROL, NOCACHE
 
Constructor Summary
DocumentImpl()
          Create empty dirty document.
DocumentImpl(byte[] data, SymbolTable symbols)
          Create document from the compressed data.
DocumentImpl(byte[] data, SymbolTable symbols, NodeSource source)
          Create document from the compressed data.
DocumentImpl(byte[] data, SymbolTable symbols, NodeSource source, boolean readOnly)
          Create document from the compressed data with specified read only state.
DocumentImpl(org.w3c.dom.Document doc)
          Create a compressed document out of another document.
 
Method Summary
 org.w3c.dom.Node adoptNode(org.w3c.dom.Node src)
           
protected  void checkLoaded()
           
 org.w3c.dom.Attr createAttribute(String name)
          Creates an Attr of the given name.
 org.w3c.dom.Attr createAttributeNS(String namespaceURI, String qualifiedName)
           
 org.w3c.dom.CDATASection createCDATASection(String data)
          Creates a CDATASection node whose value is the specified string.
 org.w3c.dom.Comment createComment(String data)
          Creates a Comment node given the specified string.
 org.w3c.dom.DocumentFragment createDocumentFragment()
          Creates an empty DocumentFragment object.
 org.w3c.dom.Element createElement(String tagName)
          Creates an element of the type specified.
 org.w3c.dom.Element createElementNS(String namespaceURI, String qualifiedName)
           
 org.w3c.dom.EntityReference createEntityReference(String name)
          Creates an EntityReference object.
 org.w3c.dom.traversal.NodeIterator createNodeIterator(org.w3c.dom.Node root, int whatToShow, org.w3c.dom.traversal.NodeFilter filter, boolean entityReferenceExpansion)
           
 org.w3c.dom.ProcessingInstruction createProcessingInstruction(String target, String data)
          Creates a ProcessingInstruction node given the specified name and data strings.
 org.w3c.dom.Text createTextNode(String data)
          Creates a Text node given the specified string.
 org.w3c.dom.traversal.TreeWalker createTreeWalker(org.w3c.dom.Node root, int whatToShow, org.w3c.dom.traversal.NodeFilter filter, boolean entityReferenceExpansion)
           
 void expandSource()
          expandSource expands the source into the Node as a namespace and a set of attributes.
 org.w3c.dom.DocumentType getDoctype()
          The Document Type Declaration (see DocumentType) associated with this document.
 org.w3c.dom.Element getDocumentElement()
          This is a convenience method that allows direct access to the child node that is the root element of the document.
 String getDocumentURI()
           
 org.w3c.dom.DOMConfiguration getDomConfig()
           
 org.w3c.dom.DOMImplementation getImplementation()
          The DOMImplementation object that handles this document.
 String getInputEncoding()
           
 org.w3c.dom.Node getNodeAtPos(int pos)
          getNodeAtPos returns the Node that exists at the specified byte data position in the compressed stream.
 String getNodeName()
          The name of this node, depending on its type; see the table above.
 short getNodeType()
          A code representing the type of the underlying object, as defined above.
 boolean getStrictErrorChecking()
           
 SymbolTable getSymbols()
          getSymbols returns the Symbol table for this Document.
 String getTextContent()
          This method returns the text content of this node and its descendants.
 String getXmlEncoding()
           
 boolean getXmlStandalone()
           
 String getXmlVersion()
           
 org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode, boolean deep)
           
 boolean isCaching()
          getCaching returns whether or not this Document should be cached by some sort of caching mechanism.
 boolean isReadOnly()
           
 void normalizeDocument()
           
 org.w3c.dom.Node renameNode(org.w3c.dom.Node n, String namespaceURI, String qualifiedName)
          Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE.
 void setCaching(boolean caching)
          setCaching sets whether or not this Document should be cached by some sort of caching mechanism.
 void setDoctype(org.w3c.dom.DocumentType docType)
           
 void setDocumentURI(String documentURI)
           
 void setInputEncoding(String inputEncoding)
           
 void setStrictErrorChecking(boolean strictErrorChecking)
           
 void setSymbols(SymbolTable symbols)
          setSymbols sets the Symbol table for this Document.
 void setXmlEncoding(String xmlEncoding)
           
 void setXmlStandalone(boolean standalone)
           
 void setXmlVersion(String version)
           
 
Methods inherited from class org.apache.xindice.xml.dom.ContainerNodeImpl
appendChild, getChildNodes, getElementById, getElementsByTagName, getElementsByTagNameNS, getFirstChild, getLastChild, getNextSibling, getPreviousSibling, hasChildNodes, insertBefore, isEqualNode, isNodeTypeValid, loadChildren, normalize, removeChild, replaceChild
 
Methods inherited from class org.apache.xindice.xml.dom.NodeImpl
checkReadOnly, cloneNode, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getDataBytes, getDataLen, getDataPos, getFeature, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getSource, getSymbolID, getUserData, hasAttributes, invokeHandlers, invokeHandlers, isDefaultNamespace, isDefined, isDirty, isLoaded, isSameNode, isSupported, load, lookupDefaultNamespaceURI, lookupNamespaceURI, lookupPrefix, setDataBytes, setDataBytes, setDataLen, setDataPos, setDirty, setNodeName, setNodeValue, setParentNode, setPrefix, setSource, setTextContent, setUserData, toString, unload
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.xindice.xml.dom.CompressedNode
getDataBytes, getDataLen, getDataPos, getSymbolID, isDirty, isLoaded, load, setDataBytes, setDataBytes, setDataLen, setDataPos, unload
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 
Methods inherited from interface org.w3c.dom.Document
getElementById, getElementsByTagName, getElementsByTagNameNS
 
Methods inherited from interface org.apache.xindice.xml.dom.DBNode
getSource, setSource
 

Constructor Detail

DocumentImpl

public DocumentImpl()
Create empty dirty document.


DocumentImpl

public DocumentImpl(byte[] data,
                    SymbolTable symbols)
Create document from the compressed data.

Parameters:
data - compressed document data
symbols - symbol table used to compress a document

DocumentImpl

public DocumentImpl(byte[] data,
                    SymbolTable symbols,
                    NodeSource source)
Create document from the compressed data.

Parameters:
data - compressed document data
symbols - symbol table used to compress a document
source - identifies document origin

DocumentImpl

public DocumentImpl(byte[] data,
                    SymbolTable symbols,
                    NodeSource source,
                    boolean readOnly)
Create document from the compressed data with specified read only state.

Parameters:
data - compressed document data
symbols - symbol table used to compress a document
source - identifies document origin
readOnly - if true, document will be marked read only.

DocumentImpl

public DocumentImpl(org.w3c.dom.Document doc)
Create a compressed document out of another document.

Parameters:
doc - document to copy
Method Detail

isReadOnly

public boolean isReadOnly()

checkLoaded

protected void checkLoaded()
Overrides:
checkLoaded in class ContainerNodeImpl

isCaching

public boolean isCaching()
Description copied from interface: DBDocument
getCaching returns whether or not this Document should be cached by some sort of caching mechanism.

Specified by:
isCaching in interface DBDocument
Returns:
Whether or not the Document can be cached

setCaching

public void setCaching(boolean caching)
Description copied from interface: DBDocument
setCaching sets whether or not this Document should be cached by some sort of caching mechanism.

Specified by:
setCaching in interface DBDocument
Parameters:
caching - Whether or not the Document can be cached

getSymbols

public SymbolTable getSymbols()
Description copied from interface: CompressedDocument
getSymbols returns the Symbol table for this Document. A new Document may not have a Symbol table as Symbol tables only come into play when a Document has been compressed or decompressed.

Specified by:
getSymbols in interface CompressedDocument
Returns:
The Symbol table

setSymbols

public void setSymbols(SymbolTable symbols)
Description copied from interface: CompressedDocument
setSymbols sets the Symbol table for this Document. Setting the Symbol table for a Document that already has a Symbol table could be VERY BAD. Generally, an implementation should throw a DOMException if an attempt is made to reassign a Symbol table.

Specified by:
setSymbols in interface CompressedDocument
Parameters:
symbols - The Symbol table

expandSource

public void expandSource()
Description copied from interface: DBNode
expandSource expands the source into the Node as a namespace and a set of attributes. This method will only work on a Document or an Element, and should silently fail on all other Node types.

Specified by:
expandSource in interface DBNode
Overrides:
expandSource in class NodeImpl

getNodeAtPos

public org.w3c.dom.Node getNodeAtPos(int pos)
Description copied from interface: CompressedDocument
getNodeAtPos returns the Node that exists at the specified byte data position in the compressed stream. This method should only be used on an unmodified Document as the underlying compressed stream of a document will become invalid as the Document is modified.

Specified by:
getNodeAtPos in interface CompressedDocument
Parameters:
pos - The compressed stream position
Returns:
The Node (or null if not found)

getNodeType

public short getNodeType()
Description copied from class: NodeImpl
A code representing the type of the underlying object, as defined above.

Specified by:
getNodeType in interface org.w3c.dom.Node
Specified by:
getNodeType in class NodeImpl

getNodeName

public String getNodeName()
Description copied from class: NodeImpl
The name of this node, depending on its type; see the table above.

Specified by:
getNodeName in interface org.w3c.dom.Node
Overrides:
getNodeName in class NodeImpl

getDoctype

public org.w3c.dom.DocumentType getDoctype()
The Document Type Declaration (see DocumentType) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns null. The DOM Level 1 does not support editing the Document Type Declaration, therefore docType cannot be altered in any way.

Specified by:
getDoctype in interface org.w3c.dom.Document

setDoctype

public void setDoctype(org.w3c.dom.DocumentType docType)

getImplementation

public org.w3c.dom.DOMImplementation getImplementation()
The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.

Specified by:
getImplementation in interface org.w3c.dom.Document

createTextNode

public org.w3c.dom.Text createTextNode(String data)
Creates a Text node given the specified string.

Specified by:
createTextNode in interface org.w3c.dom.Document
Parameters:
data - The data for the node.
Returns:
The new Text object.

getDocumentElement

public org.w3c.dom.Element getDocumentElement()
This is a convenience method that allows direct access to the child node that is the root element of the document. For HTML documents, this is the element with the tagName "HTML".

Specified by:
getDocumentElement in interface org.w3c.dom.Document

createCDATASection

public org.w3c.dom.CDATASection createCDATASection(String data)
                                            throws org.w3c.dom.DOMException
Creates a CDATASection node whose value is the specified string.

Specified by:
createCDATASection in interface org.w3c.dom.Document
Parameters:
data - The data for the CDATASection contents.
Returns:
The new CDATASection object.
Throws:
org.w3c.dom.DOMException - NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

createElement

public org.w3c.dom.Element createElement(String tagName)
                                  throws org.w3c.dom.DOMException
Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.

Specified by:
createElement in interface org.w3c.dom.Document
Parameters:
tagName - The name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the tagName parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.
Returns:
A new Element object.
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.

createDocumentFragment

public org.w3c.dom.DocumentFragment createDocumentFragment()
Creates an empty DocumentFragment object.

Specified by:
createDocumentFragment in interface org.w3c.dom.Document
Returns:
A new DocumentFragment.

createAttribute

public org.w3c.dom.Attr createAttribute(String name)
                                 throws org.w3c.dom.DOMException
Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttribute method.

Specified by:
createAttribute in interface org.w3c.dom.Document
Parameters:
name - The name of the attribute.
Returns:
A new Attr object.
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.

createComment

public org.w3c.dom.Comment createComment(String data)
Creates a Comment node given the specified string.

Specified by:
createComment in interface org.w3c.dom.Document
Parameters:
data - The data for the node.
Returns:
The new Comment object.

createProcessingInstruction

public org.w3c.dom.ProcessingInstruction createProcessingInstruction(String target,
                                                                     String data)
                                                              throws org.w3c.dom.DOMException
Creates a ProcessingInstruction node given the specified name and data strings.

Specified by:
createProcessingInstruction in interface org.w3c.dom.Document
Parameters:
target - The target part of the processing instruction.
data - The data for the node.
Returns:
The new ProcessingInstruction object.
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if an invalid character is specified.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

createEntityReference

public org.w3c.dom.EntityReference createEntityReference(String name)
                                                  throws org.w3c.dom.DOMException
Creates an EntityReference object.

Specified by:
createEntityReference in interface org.w3c.dom.Document
Parameters:
name - The name of the entity to reference.
Returns:
The new EntityReference object.
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

importNode

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

createElementNS

public org.w3c.dom.Element createElementNS(String namespaceURI,
                                           String qualifiedName)
Specified by:
createElementNS in interface org.w3c.dom.Document

createAttributeNS

public org.w3c.dom.Attr createAttributeNS(String namespaceURI,
                                          String qualifiedName)
Specified by:
createAttributeNS in interface org.w3c.dom.Document

createNodeIterator

public org.w3c.dom.traversal.NodeIterator createNodeIterator(org.w3c.dom.Node root,
                                                             int whatToShow,
                                                             org.w3c.dom.traversal.NodeFilter filter,
                                                             boolean entityReferenceExpansion)
                                                      throws org.w3c.dom.DOMException
Specified by:
createNodeIterator in interface org.w3c.dom.traversal.DocumentTraversal
Throws:
org.w3c.dom.DOMException

createTreeWalker

public org.w3c.dom.traversal.TreeWalker createTreeWalker(org.w3c.dom.Node root,
                                                         int whatToShow,
                                                         org.w3c.dom.traversal.NodeFilter filter,
                                                         boolean entityReferenceExpansion)
                                                  throws org.w3c.dom.DOMException
Specified by:
createTreeWalker in interface org.w3c.dom.traversal.DocumentTraversal
Throws:
org.w3c.dom.DOMException

adoptNode

public org.w3c.dom.Node adoptNode(org.w3c.dom.Node src)
Since:
DOM Level 3

getStrictErrorChecking

public boolean getStrictErrorChecking()
Since:
DOM Level 3

setStrictErrorChecking

public void setStrictErrorChecking(boolean strictErrorChecking)
Since:
DOM Level 3

getDocumentURI

public String getDocumentURI()
Since:
DOM Level 3

setDocumentURI

public void setDocumentURI(String documentURI)
Since:
DOM Level 3

getInputEncoding

public String getInputEncoding()
Since:
DOM Level 3

setInputEncoding

public void setInputEncoding(String inputEncoding)

getXmlEncoding

public String getXmlEncoding()
Since:
DOM Level 3

setXmlEncoding

public void setXmlEncoding(String xmlEncoding)

getXmlStandalone

public boolean getXmlStandalone()
Since:
DOM Level 3

setXmlStandalone

public void setXmlStandalone(boolean standalone)
                      throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException
Since:
DOM Level 3

getXmlVersion

public String getXmlVersion()
Since:
DOM Level 3

setXmlVersion

public void setXmlVersion(String version)
                   throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException
Since:
DOM Level 3

getDomConfig

public org.w3c.dom.DOMConfiguration getDomConfig()
Since:
DOM Level 3

normalizeDocument

public void normalizeDocument()
Since:
DOM Level 3

renameNode

public org.w3c.dom.Node renameNode(org.w3c.dom.Node n,
                                   String namespaceURI,
                                   String qualifiedName)
                            throws org.w3c.dom.DOMException
Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE.

When possible this simply changes the name of the given node, otherwise this creates a new node with the specified name and replaces the existing node with the new node as described below.

If simply changing the name of the given node is not possible, the following operations are performed: a new node is created, any registered event listener is registered on the new node, any user data attached to the old node is removed from that node, the old node is removed from its parent if it has one, the children are moved to the new node, if the renamed node is an Element its attributes are moved to the new node, the new node is inserted at the position the old node used to have in its parent's child nodes list if it has one, the user data that was attached to the old node is attached to the new node.

When the node being renamed is an Element only the specified attributes are moved, default attributes originated from the DTD are updated according to the new element name. In addition, the implementation may update default attributes from other schemas. Applications should use Document.normalizeDocument() to guarantee these attributes are up-to-date.

When the node being renamed is an Attr that is attached to an Element, the node is first removed from the Element attributes map. Then, once renamed, either by modifying the existing node or creating a new one as described above, it is put back.

In addition,

Parameters:
n - The node to rename.
namespaceURI - The new namespace URI.
qualifiedName - The new qualified name.
Returns:
The renamed node. This is either the specified node or the new node that was created to replace the specified node.
Throws:
org.w3c.dom.DOMException - NOT_SUPPORTED_ERR: Raised when the type of the specified node is neither ELEMENT_NODE nor ATTRIBUTE_NODE, or if the implementation does not support the renaming of the document element.
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the new qualified name is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute.
org.w3c.dom.DOMException - WRONG_DOCUMENT_ERR: Raised when the specified node was created from a different document than this document.
org.w3c.dom.DOMException - NAMESPACE_ERR: Raised if the qualifiedName is a malformed qualified name, if the qualifiedName has a prefix and the namespaceURI is null, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace" [XML Namespaces]. Also raised, when the node being renamed is an attribute, if the qualifiedName, or its prefix, is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/".
Since:
DOM Level 3

getTextContent

public String getTextContent()
Description copied from class: NodeImpl
This method returns the text content of this node and its descendants. No serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed and the returned string does not contain the white spaces in element content (see the attribute Text.isElementContentWhitespace).
The string returned is made of the text content of this node depending on its type, as defined below:
Node typeContent
ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE concatenation of the textContent attribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children.
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODEnodeValue
DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null

Overrides:
getTextContent in class ContainerNodeImpl
Since:
DOM Level 3

Xindice API
version 1.2m1

Copyright (c) 1999-2007 The Apache Software Foundation. All Rights Reserved.