org.apache.xerces.dom

Class DeferredDocumentImpl

public class DeferredDocumentImpl extends DocumentImpl implements DeferredNode

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.

Since: PR-DOM-Level-1-19980818.

Version: $Id: DeferredDocumentImpl.java,v 1.58 2005/03/07 23:28:40 mrglavas Exp $

UNKNOWN:

Field Summary
protected static intCHUNK_MASK
Chunk mask.
protected static intCHUNK_SHIFT
Chunk shift.
protected static intCHUNK_SIZE
Chunk size.
protected intfIdCount
Identifier count.
protected int[]fIdElement
Identifier element indexes.
protected String[]fIdName
Identifier name indexes.
protected booleanfNamespacesEnabled
DOM2: For namespace support in the deferred case.
protected intfNodeCount
Node count.
protected int[][]fNodeExtra
Extra data.
protected int[][]fNodeLastChild
Node first children.
protected Object[][]fNodeName
Node names.
protected int[][]fNodeParent
Node parents.
protected int[][]fNodePrevSib
Node prev siblings.
protected int[][]fNodeType
Node types.
protected Object[][]fNodeURI
Node namespace URI.
protected Object[][]fNodeValue
Node values.
protected static intINITIAL_CHUNK_COUNT
Initial chunk size.
Constructor Summary
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(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
voidappendChild(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.
intcreateDeferredCDATASection(String data)
Creates a CDATA section node in the table.
intcreateDeferredComment(String data)
Creates a comment node in the table.
intcreateDeferredDocument()
Creates a document node in the table.
intcreateDeferredDocumentType(String rootElementName, String publicId, String systemId)
Creates a doctype.
intcreateDeferredElement(String elementURI, String elementName, Object type)
Creates an element node with a URI in the table and type information.
intcreateDeferredElement(String elementName)
intcreateDeferredElement(String elementURI, String elementName)
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.
StringgetAttribute(int elemIndex, String name)
Returns the attribute value of the given name.
StringgetDeferredEntityBaseURI(int entityIndex)
DOMImplementationgetImplementation()
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.
intgetNodeIndex()
Returns the node index.
StringgetNodeName(int nodeIndex)
Returns the name of the given node.
StringgetNodeName(int nodeIndex, boolean free)
Returns the name of the given node.
DeferredNodegetNodeObject(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.
StringgetNodeURI(int nodeIndex)
Returns the URI of the given node.
StringgetNodeURI(int nodeIndex, boolean free)
Returns the URI of the given node.
StringgetNodeValue(int nodeIndex)
Returns the value of the given node.
StringgetNodeValue(int nodeIndex, boolean free)
Returns the value of the given node.
StringgetNodeValueString(int nodeIndex)
Returns the real value of the given node.
StringgetNodeValueString(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.
ObjectgetTypeInfo(int nodeIndex)
Clears the type info that is stored in the fNodeValue array
intinsertBefore(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, boolean id, Object type)
This method is used by the DOMParser to create attributes.
intsetDeferredAttribute(int elementNodeIndex, String attrName, String attrURI, String attrValue, boolean specified)
voidsetEntityInfo(int currentEntityDecl, String version, String encoding)
voidsetIdAttribute(int attrIndex)
Sets type of attribute
voidsetIdAttributeNode(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)
protected voidsynchronizeChildren()
Synchronizes the node's children with the internal structure.
protected voidsynchronizeChildren(AttrImpl a, int nodeIndex)
Synchronizes the node's children with the internal structure.
protected voidsynchronizeChildren(ParentNode p, int nodeIndex)
Synchronizes the node's children with the internal structure.
protected voidsynchronizeData()
Synchronizes the node's data.

Field Detail

CHUNK_MASK

protected static final int CHUNK_MASK
Chunk mask.

CHUNK_SHIFT

protected static final int CHUNK_SHIFT
Chunk shift.

CHUNK_SIZE

protected static final int CHUNK_SIZE
Chunk size.

fIdCount

protected transient int fIdCount
Identifier count.

fIdElement

protected transient int[] fIdElement
Identifier element indexes.

fIdName

protected transient String[] fIdName
Identifier name indexes.

fNamespacesEnabled

protected boolean fNamespacesEnabled
DOM2: For namespace support in the deferred case.

fNodeCount

protected transient int fNodeCount
Node count.

fNodeExtra

protected transient int[][] fNodeExtra
Extra data.

fNodeLastChild

protected transient int[][] fNodeLastChild
Node first children.

fNodeName

protected transient Object[][] fNodeName
Node names.

fNodeParent

protected transient int[][] fNodeParent
Node parents.

fNodePrevSib

protected transient int[][] fNodePrevSib
Node prev siblings.

fNodeType

protected transient int[][] fNodeType
Node types.

fNodeURI

protected transient Object[][] fNodeURI
Node namespace URI.

fNodeValue

protected transient Object[][] fNodeValue
Node values.

INITIAL_CHUNK_COUNT

protected static final int INITIAL_CHUNK_COUNT
Initial chunk size.

Constructor Detail

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 Detail

appendChild

public void appendChild(int parentIndex, int childIndex)
Appends a child to the specified parent in the table.

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.

cloneNode

public int cloneNode(int nodeIndex, boolean deep)
Creates a clone of the specified node.

createDeferredAttribute

public int createDeferredAttribute(String attrName, String attrValue, boolean specified)
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.

createDeferredCDATASection

public int createDeferredCDATASection(String data)
Creates a CDATA section node in the table.

createDeferredComment

public int createDeferredComment(String data)
Creates a comment node in the table.

createDeferredDocument

public int createDeferredDocument()
Creates a document node in the table.

createDeferredDocumentType

public int createDeferredDocumentType(String rootElementName, String publicId, String systemId)
Creates a doctype.

createDeferredElement

public int createDeferredElement(String elementURI, String elementName, Object type)
Creates an element node with a URI in the table and type information.

createDeferredElement

public int createDeferredElement(String elementName)

UNKNOWN: Creates an element node in the table.

createDeferredElement

public int createDeferredElement(String elementURI, String elementName)

UNKNOWN: Creates an element node with a URI in the table.

createDeferredElementDefinition

public int createDeferredElementDefinition(String elementName)
Creates an element definition in the table.

createDeferredEntity

public int createDeferredEntity(String entityName, String publicId, String systemId, String notationName, String baseURI)
Creates an entity in the table.

createDeferredEntityReference

public int createDeferredEntityReference(String name, String baseURI)
Creates an entity reference node in the table.

createDeferredNotation

public int createDeferredNotation(String notationName, String publicId, String systemId, String baseURI)
Creates a notation in the table.

createDeferredProcessingInstruction

public int createDeferredProcessingInstruction(String target, String data)
Creates a processing instruction node in the table.

createDeferredTextNode

public int createDeferredTextNode(String data, boolean ignorableWhitespace)
Creates a text node in the table.

createNode

protected int createNode(short nodeType)
Creates a node of the specified type.

ensureCapacity

protected void ensureCapacity(int chunk)
Ensures that the internal tables are large enough.

getAttribute

public String getAttribute(int elemIndex, String name)
Returns the attribute value of the given name.

getDeferredEntityBaseURI

public String getDeferredEntityBaseURI(int entityIndex)

getImplementation

public DOMImplementation 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.

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.

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.

getNodeIndex

public int getNodeIndex()
Returns the node index.

getNodeName

public String getNodeName(int nodeIndex)
Returns the name of the given node.

getNodeName

public String getNodeName(int nodeIndex, boolean free)
Returns the name of the given node.

Parameters: free True to free the string index.

getNodeObject

public DeferredNode getNodeObject(int nodeIndex)
Instantiates the requested node object.

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.

getNodeURI

public String getNodeURI(int nodeIndex)
Returns the URI of the given node.

getNodeURI

public String getNodeURI(int nodeIndex, boolean free)
Returns the URI of the given node.

Parameters: free True to free URI index.

getNodeValue

public String getNodeValue(int nodeIndex)
Returns the value of the given node.

getNodeValue

public String getNodeValue(int nodeIndex, boolean free)
Returns the value of the given node.

Parameters: free True to free the value index.

getNodeValueString

public String getNodeValueString(int nodeIndex)
Returns the real value of the given node.

getNodeValueString

public String getNodeValueString(int nodeIndex, boolean free)
Returns the real value of the given node.

Parameters: free True to free the string index.

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.

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.

getTypeInfo

public Object getTypeInfo(int nodeIndex)
Clears the type info that is stored in the fNodeValue array

Parameters: nodeIndex

Returns: Object - type information for the attribute/element node

insertBefore

public int insertBefore(int parentIndex, int newChildIndex, int refChildIndex)
Inserts a child before the specified node in the table.

lookupElementDefinition

public int lookupElementDefinition(String elementName)
Returns the index of the element definition in the table with the specified name index, or -1 if no such definition exists.

print

public void print()
Prints out the tables.

putIdentifier

public void putIdentifier(String name, int elementNodeIndex)
Registers an identifier name with a specified element node.

setAsLastChild

public void setAsLastChild(int parentIndex, int childIndex)
Sets the last child of the parentIndex to childIndex.

setAttributeNode

public int setAttributeNode(int elemIndex, int attrIndex)
Adds an attribute node to the specified element.

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)

UNKNOWN: Sets an attribute on an element node.

setEntityInfo

public void setEntityInfo(int currentEntityDecl, String version, String encoding)

setIdAttribute

public void setIdAttribute(int attrIndex)
Sets type of attribute

setIdAttributeNode

public void setIdAttributeNode(int elemIndex, int attrIndex)
Adds an attribute node to the specified element.

setInputEncoding

public void setInputEncoding(int currentEntityDecl, String value)
DOM Internal An attribute specifying the actual encoding of this document. This is null otherwise.
This attribute represents the property [character encoding scheme] defined in .

setInternalSubset

public void setInternalSubset(int doctypeIndex, String subset)

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.

synchronizeChildren

protected final void synchronizeChildren(AttrImpl a, int nodeIndex)
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

protected final void synchronizeChildren(ParentNode p, int nodeIndex)
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.

synchronizeData

protected void synchronizeData()
Synchronizes the node's data.
Copyright B) 1999-2005 Apache XML Project. All Rights Reserved.