Package org.apache.xerces.dom
Class DeferredDocumentImpl
java.lang.Object
org.apache.xerces.dom.NodeImpl
org.apache.xerces.dom.ChildNode
org.apache.xerces.dom.ParentNode
org.apache.xerces.dom.CoreDocumentImpl
org.apache.xerces.dom.DocumentImpl
org.apache.xerces.dom.DeferredDocumentImpl
- All Implemented Interfaces:
Serializable,Cloneable,DeferredNode,Document,DocumentEvent,EventTarget,Node,NodeList,DocumentRange,DocumentTraversal
The Document interface represents the entire HTML or XML document.
Conceptually, it is the root of the document tree, and provides the
primary access to the document's data.
Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a Document, the Document interface also contains the factory methods needed to create these objects. The Node objects created have a ownerDocument attribute which associates them with the Document within whose context they were created.
INTERNAL:
- Usage of this class is not supported. It may be altered or removed at any time.
- Since:
- PR-DOM-Level-1-19980818.
- Version:
- $Id: DeferredDocumentImpl.java 965320 2010-07-18 23:25:54Z mrglavas $
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intChunk mask.protected static final intChunk shift.protected static final intChunk size.protected intIdentifier count.protected int[]Identifier element indexes.protected String[]Identifier name indexes.protected booleanDOM2: For namespace support in the deferred case.protected intNode count.protected int[][]Extra data.protected int[][]Node first children.protected Object[][]Node names.protected int[][]Node parents.protected int[][]Node prev siblings.protected int[][]Node types.protected Object[][]Node namespace URI.protected Object[][]Node values.protected static final intInitial chunk size.Fields inherited from class org.apache.xerces.dom.DocumentImpl
eventListeners, iteratorReferenceQueue, iterators, mutationEvents, rangeReferenceQueue, rangesFields inherited from class org.apache.xerces.dom.CoreDocumentImpl
actualEncoding, allowGrammarAccess, changes, docElement, docType, encoding, errorChecking, fDocumentURI, identifiers, standalone, userData, version, xmlVersionChangedFields inherited from class org.apache.xerces.dom.ParentNode
firstChild, fNodeListCache, ownerDocumentFields inherited from class org.apache.xerces.dom.ChildNode
nextSibling, previousSiblingFields inherited from class org.apache.xerces.dom.NodeImpl
DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_IS_CONTAINED, DOCUMENT_POSITION_PRECEDING, ELEMENT_DEFINITION_NODE, FIRSTCHILD, flags, HASSTRING, ID, IGNORABLEWS, NORMALIZED, OWNED, ownerNode, READONLY, SPECIFIED, SYNCCHILDREN, SYNCDATA, TREE_POSITION_ANCESTOR, TREE_POSITION_DESCENDANT, TREE_POSITION_DISCONNECTED, TREE_POSITION_EQUIVALENT, TREE_POSITION_FOLLOWING, TREE_POSITION_PRECEDING, TREE_POSITION_SAME_NODEFields inherited from interface org.apache.xerces.dom.DeferredNode
TYPE_NODEFields 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
ConstructorsConstructorDescriptionNON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation.DeferredDocumentImpl(boolean namespacesEnabled) NON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation.DeferredDocumentImpl(boolean namespaces, boolean grammarAccess) Experimental constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendChild(int parentIndex, int childIndex) Appends a child to the specified parent in the table.protected static intbinarySearch(int[] values, int start, int end, int target) Performs a binary search for a target value in an array of values.intcloneNode(int nodeIndex, boolean deep) Creates a clone of the specified node.intcreateDeferredAttribute(String attrName, String attrValue, boolean specified) Creates an attribute in the table.intcreateDeferredAttribute(String attrName, String attrURI, String attrValue, boolean specified) Creates an attribute with a URI in the table.intCreates a CDATA section node in the table.intcreateDeferredComment(String data) Creates a comment node in the table.intCreates a document node in the table.intcreateDeferredDocumentType(String rootElementName, String publicId, String systemId) Creates a doctype.intcreateDeferredElement(String elementName) Deprecated.intcreateDeferredElement(String elementURI, String elementName) Creates an element node with a URI in the table.intcreateDeferredElement(String elementURI, String elementName, Object type) Deprecated.intcreateDeferredElementDefinition(String elementName) Creates an element definition in the table.intcreateDeferredEntity(String entityName, String publicId, String systemId, String notationName, String baseURI) Creates an entity in the table.intcreateDeferredEntityReference(String name, String baseURI) Creates an entity reference node in the table.intcreateDeferredNotation(String notationName, String publicId, String systemId, String baseURI) Creates a notation in the table.intcreateDeferredProcessingInstruction(String target, String data) Creates a processing instruction node in the table.intcreateDeferredTextNode(String data, boolean ignorableWhitespace) Creates a text node in the table.protected intcreateNode(short nodeType) Creates a node of the specified type.protected voidensureCapacity(int chunk) Ensures that the internal tables are large enough.getAttribute(int elemIndex, String name) Returns the attribute value of the given name.getDeferredEntityBaseURI(int entityIndex) Retrieve information describing the abilities of this particular DOM implementation.intgetLastChild(int nodeIndex) Returns the last child of the given node.intgetLastChild(int nodeIndex, boolean free) Returns the last child of the given node.intgetNodeExtra(int nodeIndex) Returns the extra info of the given node.intgetNodeExtra(int nodeIndex, boolean free) Returns the extra info of the given node.intReturns the node index.getNodeName(int nodeIndex) Returns the name of the given node.getNodeName(int nodeIndex, boolean free) Returns the name of the given node.getNodeObject(int nodeIndex) Instantiates the requested node object.shortgetNodeType(int nodeIndex) Returns the type of the given node.shortgetNodeType(int nodeIndex, boolean free) Returns the type of the given node.getNodeURI(int nodeIndex) Returns the URI of the given node.getNodeURI(int nodeIndex, boolean free) Returns the URI of the given node.getNodeValue(int nodeIndex) Returns the value of the given node.getNodeValue(int nodeIndex, boolean free) Returns the value of the given node.getNodeValueString(int nodeIndex) Returns the real value of the given node.getNodeValueString(int nodeIndex, boolean free) Returns the real value of the given node.intgetParentNode(int nodeIndex) Returns the parent node of the given node.intgetParentNode(int nodeIndex, boolean free) Returns the parent node of the given node.intgetPrevSibling(int nodeIndex) Returns the prev sibling of the given node.intgetPrevSibling(int nodeIndex, boolean free) Returns the prev sibling of the given node.intgetRealPrevSibling(int nodeIndex) Returns the real prev sibling of the given node, directly from the data structures.intgetRealPrevSibling(int nodeIndex, boolean free) Returns the real prev sibling of the given node.getTypeInfo(int nodeIndex) Clears the type info that is stored in the fNodeValue arrayintinsertBefore(int parentIndex, int newChildIndex, int refChildIndex) Inserts a child before the specified node in the table.intlookupElementDefinition(String elementName) Returns the index of the element definition in the table with the specified name index, or -1 if no such definition exists.voidprint()Prints out the tables.voidputIdentifier(String name, int elementNodeIndex) Registers an identifier name with a specified element node.voidsetAsLastChild(int parentIndex, int childIndex) Sets the last child of the parentIndex to childIndex.intsetAttributeNode(int elemIndex, int attrIndex) Adds an attribute node to the specified element.intsetDeferredAttribute(int elementNodeIndex, String attrName, String attrURI, String attrValue, boolean specified) Deprecated.intsetDeferredAttribute(int elementNodeIndex, String attrName, String attrURI, String attrValue, boolean specified, boolean id, Object type) This method is used by the DOMParser to create attributes.voidsetEntityInfo(int currentEntityDecl, String version, String encoding) voidsetIdAttribute(int attrIndex) Sets type of attributevoidsetIdAttributeNode(int elemIndex, int attrIndex) Adds an attribute node to the specified element.voidsetInputEncoding(int currentEntityDecl, String value) DOM Internal An attribute specifying the actual encoding of this document.voidsetInternalSubset(int doctypeIndex, String subset) voidsetTypeInfo(int elementNodeIndex, Object type) protected voidSynchronizes the node's children with the internal structure.protected final voidsynchronizeChildren(AttrImpl a, int nodeIndex) Synchronizes the node's children with the internal structure.protected final voidsynchronizeChildren(ParentNode p, int nodeIndex) Synchronizes the node's children with the internal structure.protected voidSynchronizes the node's data.Methods inherited from class org.apache.xerces.dom.DocumentImpl
addEventListener, cloneNode, copyEventListeners, createEvent, createNodeIterator, createNodeIterator, createRange, createTreeWalker, createTreeWalker, dispatchAggregateEvents, dispatchAggregateEvents, dispatchEvent, dispatchEventToSubtree, dispatchingEventToSubtree, getEventListeners, removeEventListener, saveEnclosingAttr, setEventListenersMethods inherited from class org.apache.xerces.dom.CoreDocumentImpl
abort, adoptNode, callUserDataHandlers, canRenameElements, changed, changes, checkDOMNSErr, checkNamespaceWF, checkQName, clearIdentifiers, clone, cloneNode, createAttribute, createAttributeNS, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createDocumentType, createElement, createElementDefinition, createElementNS, createElementNS, createEntity, createEntityReference, createNotation, createProcessingInstruction, createTextNode, getAsync, getBaseURI, getDoctype, getDocumentElement, getDocumentURI, getDomConfig, getElementById, getElementsByTagName, getElementsByTagNameNS, getEncoding, getErrorChecking, getFeature, getIdentifier, getIdentifiers, getInputEncoding, getNodeName, getNodeNumber, getNodeNumber, getNodeType, getOwnerDocument, getStandalone, getStrictErrorChecking, getTextContent, getUserData, getUserData, getUserDataRecord, getVersion, getXmlEncoding, getXmlStandalone, getXmlVersion, importNode, insertBefore, isKidOK, isValidQName, isXMLName, load, loadXML, normalizeDocument, putIdentifier, removeChild, removeIdentifier, renameNode, replaceChild, saveXML, setAsync, setDocumentURI, setEncoding, setErrorChecking, setInputEncoding, setStandalone, setStrictErrorChecking, setTextContent, setUserData, setUserData, setVersion, setXmlEncoding, setXmlStandalone, setXmlVersion, undeferChildrenMethods inherited from class org.apache.xerces.dom.ParentNode
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, isEqualNode, item, normalize, setOwnerDocument, setReadOnlyMethods inherited from class org.apache.xerces.dom.ChildNode
getNextSibling, getParentNode, getPreviousSiblingMethods inherited from class org.apache.xerces.dom.NodeImpl
addEventListener, appendChild, compareDocumentPosition, compareTreePosition, dispatchEvent, getAttributes, getContainer, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, getUserData, getUserDataRecord, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, removeEventListener, setNodeValue, setPrefix, setUserData, setUserData, toStringMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
-
Field Details
-
CHUNK_SHIFT
protected static final int CHUNK_SHIFTChunk shift.- See Also:
-
CHUNK_SIZE
protected static final int CHUNK_SIZEChunk size.- See Also:
-
CHUNK_MASK
protected static final int CHUNK_MASKChunk mask.- See Also:
-
INITIAL_CHUNK_COUNT
protected static final int INITIAL_CHUNK_COUNTInitial chunk size.- See Also:
-
fNodeCount
protected transient int fNodeCountNode count. -
fNodeType
protected transient int[][] fNodeTypeNode types. -
fNodeName
Node names. -
fNodeValue
Node values. -
fNodeParent
protected transient int[][] fNodeParentNode parents. -
fNodeLastChild
protected transient int[][] fNodeLastChildNode first children. -
fNodePrevSib
protected transient int[][] fNodePrevSibNode prev siblings. -
fNodeURI
Node namespace URI. -
fNodeExtra
protected transient int[][] fNodeExtraExtra data. -
fIdCount
protected transient int fIdCountIdentifier count. -
fIdName
Identifier name indexes. -
fIdElement
protected transient int[] fIdElementIdentifier element indexes. -
fNamespacesEnabled
protected boolean fNamespacesEnabledDOM2: For namespace support in the deferred case.
-
-
Constructor Details
-
DeferredDocumentImpl
public DeferredDocumentImpl()NON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation. -
DeferredDocumentImpl
public DeferredDocumentImpl(boolean namespacesEnabled) NON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation. -
DeferredDocumentImpl
public DeferredDocumentImpl(boolean namespaces, boolean grammarAccess) Experimental constructor.
-
-
Method Details
-
getImplementation
Retrieve information describing the abilities of this particular DOM implementation. Intended to support applications that may be using DOMs retrieved from several different sources, potentially with different underlying representations.- Specified by:
getImplementationin interfaceDocument- Overrides:
getImplementationin classDocumentImpl
-
createDeferredDocument
public int createDeferredDocument()Creates a document node in the table. -
createDeferredDocumentType
Creates a doctype. -
setInternalSubset
-
createDeferredNotation
public int createDeferredNotation(String notationName, String publicId, String systemId, String baseURI) Creates a notation in the table. -
createDeferredEntity
public int createDeferredEntity(String entityName, String publicId, String systemId, String notationName, String baseURI) Creates an entity in the table. -
getDeferredEntityBaseURI
-
setEntityInfo
-
setTypeInfo
-
setInputEncoding
DOM Internal An attribute specifying the actual encoding of this document. This isnullotherwise.
This attribute represents the property [character encoding scheme] defined in . -
createDeferredEntityReference
Creates an entity reference node in the table. -
createDeferredElement
Deprecated.Creates an element node with a URI in the table and type information. -
createDeferredElement
Deprecated.Creates an element node in the table. -
createDeferredElement
Creates an element node with a URI in the table. -
setDeferredAttribute
public int setDeferredAttribute(int elementNodeIndex, String attrName, String attrURI, String attrValue, boolean specified, boolean id, Object type) This method is used by the DOMParser to create attributes.- Parameters:
elementNodeIndex-attrName-attrURI-attrValue-specified-id-type-- Returns:
- int
-
setDeferredAttribute
public int setDeferredAttribute(int elementNodeIndex, String attrName, String attrURI, String attrValue, boolean specified) Deprecated.Sets an attribute on an element node. -
createDeferredAttribute
Creates an attribute in the table. -
createDeferredAttribute
public int createDeferredAttribute(String attrName, String attrURI, String attrValue, boolean specified) Creates an attribute with a URI in the table. -
createDeferredElementDefinition
Creates an element definition in the table. -
createDeferredTextNode
Creates a text node in the table. -
createDeferredCDATASection
Creates a CDATA section node in the table. -
createDeferredProcessingInstruction
Creates a processing instruction node in the table. -
createDeferredComment
Creates a comment node in the table. -
cloneNode
public int cloneNode(int nodeIndex, boolean deep) Creates a clone of the specified node. -
appendChild
public void appendChild(int parentIndex, int childIndex) Appends a child to the specified parent in the table. -
setAttributeNode
public int setAttributeNode(int elemIndex, int attrIndex) Adds an attribute node to the specified element. -
setIdAttributeNode
public void setIdAttributeNode(int elemIndex, int attrIndex) Adds an attribute node to the specified element. -
setIdAttribute
public void setIdAttribute(int attrIndex) Sets type of attribute -
insertBefore
public int insertBefore(int parentIndex, int newChildIndex, int refChildIndex) Inserts a child before the specified node in the table. -
setAsLastChild
public void setAsLastChild(int parentIndex, int childIndex) Sets the last child of the parentIndex to childIndex. -
getParentNode
public int getParentNode(int nodeIndex) Returns the parent node of the given node. Calling this method does not free the parent index. -
getParentNode
public int getParentNode(int nodeIndex, boolean free) Returns the parent node of the given node.- Parameters:
free- True to free parent node.
-
getLastChild
public int getLastChild(int nodeIndex) Returns the last child of the given node. -
getLastChild
public int getLastChild(int nodeIndex, boolean free) Returns the last child of the given node.- Parameters:
free- True to free child index.
-
getPrevSibling
public int getPrevSibling(int nodeIndex) Returns the prev sibling of the given node. This is post-normalization of Text Nodes. -
getPrevSibling
public int getPrevSibling(int nodeIndex, boolean free) Returns the prev sibling of the given node.- Parameters:
free- True to free sibling index.
-
getRealPrevSibling
public int getRealPrevSibling(int nodeIndex) Returns the real prev sibling of the given node, directly from the data structures. Used by TextImpl#getNodeValue() to normalize values. -
getRealPrevSibling
public int getRealPrevSibling(int nodeIndex, boolean free) Returns the real prev sibling of the given node.- Parameters:
free- True to free sibling index.
-
lookupElementDefinition
Returns the index of the element definition in the table with the specified name index, or -1 if no such definition exists. -
getNodeObject
Instantiates the requested node object. -
getNodeName
Returns the name of the given node. -
getNodeName
Returns the name of the given node.- Parameters:
free- True to free the string index.
-
getNodeValueString
Returns the real value of the given node. -
getNodeValueString
Returns the real value of the given node.- Parameters:
free- True to free the string index.
-
getNodeValue
Returns the value of the given node. -
getTypeInfo
Clears the type info that is stored in the fNodeValue array- Parameters:
nodeIndex-- Returns:
- Object - type information for the attribute/element node
-
getNodeValue
Returns the value of the given node.- Parameters:
free- True to free the value index.
-
getNodeExtra
public int getNodeExtra(int nodeIndex) Returns the extra info of the given node. Used by AttrImpl to store specified value (1 == true). -
getNodeExtra
public int getNodeExtra(int nodeIndex, boolean free) Returns the extra info of the given node.- Parameters:
free- True to free the value index.
-
getNodeType
public short getNodeType(int nodeIndex) Returns the type of the given node. -
getNodeType
public short getNodeType(int nodeIndex, boolean free) Returns the type of the given node.- Parameters:
free- True to free type index.
-
getAttribute
Returns the attribute value of the given name. -
getNodeURI
Returns the URI of the given node. -
getNodeURI
Returns the URI of the given node.- Parameters:
free- True to free URI index.
-
putIdentifier
Registers an identifier name with a specified element node. -
print
public void print()Prints out the tables. -
getNodeIndex
public int getNodeIndex()Returns the node index.- Specified by:
getNodeIndexin interfaceDeferredNode
-
synchronizeData
protected void synchronizeData()Synchronizes the node's data.- Overrides:
synchronizeDatain classNodeImpl
-
synchronizeChildren
protected void synchronizeChildren()Synchronizes the node's children with the internal structure. Fluffing the children at once solves a lot of work to keep the two structures in sync. The problem gets worse when editing the tree -- this makes it a lot easier.- Overrides:
synchronizeChildrenin classParentNode
-
synchronizeChildren
Synchronizes the node's children with the internal structure. Fluffing the children at once solves a lot of work to keep the two structures in sync. The problem gets worse when editing the tree -- this makes it a lot easier. This is not directly used in this class but this method is here so that it can be shared by all deferred subclasses of AttrImpl. -
synchronizeChildren
Synchronizes the node's children with the internal structure. Fluffing the children at once solves a lot of work to keep the two structures in sync. The problem gets worse when editing the tree -- this makes it a lot easier. This is not directly used in this class but this method is here so that it can be shared by all deferred subclasses of ParentNode. -
ensureCapacity
protected void ensureCapacity(int chunk) Ensures that the internal tables are large enough. -
createNode
protected int createNode(short nodeType) Creates a node of the specified type. -
binarySearch
protected static int binarySearch(int[] values, int start, int end, int target) Performs a binary search for a target value in an array of values. The array of values must be in ascending sorted order before calling this method and all array values must be non-negative.- Parameters:
values- The array of values to search.start- The starting offset of the search.end- The ending offset of the search.target- The target value.- Returns:
- This function will return the first occurrence of the target value, or -1 if the target value cannot be found.
-