XML for Java 2.0.15

com.ibm.xml.dom
Class DeferredDocumentImpl

java.lang.Object
  |
  +--com.ibm.xml.dom.NodeImpl
        |
        +--com.ibm.xml.dom.DocumentImpl
              |
              +--com.ibm.xml.dom.DeferredDocumentImpl

public class DeferredDocumentImpl
extends DocumentImpl

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:
34 1.3 src/com/ibm/xml/dom/DeferredDocumentImpl.java, parser, xml4j2, xml4j2_0_15
See Also:
Serialized Form

Field Summary
protected static int CHUNK_MASK
          Chunk mask.
protected static int CHUNK_SHIFT
          Chunk shift.
protected static int CHUNK_SIZE
          Chunk size.
protected  int fIdCount
          Identifier count.
protected  int[] fIdElement
          Identifier element indexes.
protected  int[] fIdName
          Identifier name indexes.
protected  int fNodeCount
          Node count.
protected  int[][] fNodeFirstChild
          Node first children.
protected  int[][] fNodeLastChild
          Node last children.
protected  int[][] fNodeName
          Node names.
protected  int[][] fNodeNextSib
          Node next siblings.
protected  int[][] fNodeParent
          Node parents.
protected  int[][] fNodePrevSib
          Node previous siblings.
protected  byte[][] fNodeType
          Node types.
protected  int[][] fNodeValue
          Node values.
protected  ParserState fParserState
          Parser state.
protected  StringPool fStringPool
          String pool cache.
protected static int INITIAL_CHUNK_COUNT
          Initial chunk size.
 
Fields inherited from class com.ibm.xml.dom.DocumentImpl
docElement, docType, identifiers
 
Fields inherited from class com.ibm.xml.dom.NodeImpl
ELEMENT_DEFINITION_NODE, firstChild, kidOK, lastChild, name, nextSibling, ownerDocument, parentNode, previousSibling, readOnly, syncChildren, syncData, userData, value
 
Constructor Summary
DeferredDocumentImpl(ParserState state)
          NON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation.
 
Method Summary
 void appendChild(int parentIndex, int childIndex)
          Appends a child to the specified parent in the table.
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.
 int createAttribute(int attrNameIndex, int attrValueIndex, boolean specified)
          Creates an attributes in the table.
 int createCDATASection(int dataIndex)
          Creates a CDATA section node in the table.
 int createComment(int dataIndex)
          Creates a comment node in the table.
 int createDocument()
          Creates a document node in the table.
 int createDocumentType(int rootElementNameIndex)
          Creates a doctype.
 int createElement(int elementNameIndex, int attrListIndex)
          Creates an element node in the table.
 int createElementDefinition(int elementNameIndex)
          Creates an element definition in the table.
 int createEntity(int entityIndex)
          Creates an entity in the table.
 int createEntityReference(int entityRefIndex)
          Creates an entity reference node in the table.
protected  int createNode(short nodeType)
          Creates a node of the specified type.
 int createNotation(int notationIndex)
          Creates a notation in the table.
 int createProcessingInstruction(int targetIndex, int dataIndex)
          Creates a processing instruction node in the table.
 int createTextNode(int dataIndex, boolean ignorableWhitespace)
          Creates a text node in the table.
protected  boolean ensureCapacity(int chunk, int index)
          Ensures that the internal tables are large enough.
 int getAttributeList(int elementNodeIndex)
          Returns the attribute list index for elements.
 int getFirstChild(int nodeIndex)
          Returns the first child of the given node.
 int getLastChild(int nodeIndex)
          Returns the last child of the given node.
 int getNextSibling(int nodeIndex)
          Returns the next sibling of the given node.
 int getNodeName(int nodeIndex)
          Returns the real int name of the given node.
 java.lang.String getNodeNameString(int nodeIndex)
          Returns the name of the given node.
 DeferredNode getNodeObject(int nodeIndex)
          Instantiates the requested node object.
 short getNodeType(int nodeIndex)
          Returns the type of the given node.
 int getNodeValue(int nodeIndex)
          Returns the real int value of the given node.
 java.lang.String getNodeValueString(int nodeIndex)
          Returns the value of the given node.
 int getParentNode(int nodeIndex)
          Returns the parent node of the given node.
 int getPreviousSibling(int nodeIndex)
          Returns the previous sibling of the given node.
 int getRealNextSibling(int nodeIndex)
          Returns the real next sibling of the given node, directly from the data structures.
 int lookupElementDefinition(int elementNameIndex)
          Returns the index of the element definition in the table with the specified name index, or -1 if no such definition exists.
 void print()
          Prints out the tables.
 void putIdentifier(int nameIndex, int elementNodeIndex)
          Registers an identifier name with a specified element node.
 void setAsFirstChild(int parentIndex, int childIndex)
          Sets the first child of the parentIndex to childIndex.
protected  void synchronizeChildren()
          Synchronizes the node's children with the internal structure.
protected  void synchronizeData()
          Synchronizes the node's data.
 
Methods inherited from class com.ibm.xml.dom.DocumentImpl
cloneNode, createAttribute, createCDATASection, createComment, createDocumentFragment, createDocumentType, createElement, createElementDefinition, createEntity, createEntityReference, createNotation, createProcessingInstruction, createTextNode, getDoctype, getDocumentElement, getElementsByTagName, getIdentifier, getIdentifiers, getImplementation, getNodeName, getNodeType, getNodeValue, importNode, insertBefore, isXMLName, putIdentifier, removeChild, removeIdentifier, setNodeValue
 
Methods inherited from class com.ibm.xml.dom.NodeImpl
appendChild, changed, getAttributes, getChildNodes, getFirstChild, getLastChild, getLength, getNextSibling, getOwnerDocument, getParentNode, getPreviousSibling, getReadOnly, getUserData, hasChildNodes, isKidOK, item, replaceChild, setReadOnly, setUserData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CHUNK_SHIFT

protected static final int CHUNK_SHIFT
Chunk shift.

CHUNK_SIZE

protected static final int CHUNK_SIZE
Chunk size.

CHUNK_MASK

protected static final int CHUNK_MASK
Chunk mask.

INITIAL_CHUNK_COUNT

protected static final int INITIAL_CHUNK_COUNT
Initial chunk size.

fNodeCount

protected transient int fNodeCount
Node count.

fNodeType

protected transient byte[][] fNodeType
Node types.

fNodeName

protected transient int[][] fNodeName
Node names.

fNodeValue

protected transient int[][] fNodeValue
Node values.

fNodeParent

protected transient int[][] fNodeParent
Node parents.

fNodeFirstChild

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

fNodeLastChild

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

fNodePrevSib

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

fNodeNextSib

protected transient int[][] fNodeNextSib
Node next siblings.

fIdCount

protected transient int fIdCount
Identifier count.

fIdName

protected transient int[] fIdName
Identifier name indexes.

fIdElement

protected transient int[] fIdElement
Identifier element indexes.

fParserState

protected transient ParserState fParserState
Parser state.

fStringPool

protected transient StringPool fStringPool
String pool cache.
Constructor Detail

DeferredDocumentImpl

public DeferredDocumentImpl(ParserState state)
NON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation.
Method Detail

createDocument

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

createDocumentType

public int createDocumentType(int rootElementNameIndex)
Creates a doctype.

createNotation

public int createNotation(int notationIndex)
Creates a notation in the table.

createEntity

public int createEntity(int entityIndex)
Creates an entity in the table.

createEntityReference

public int createEntityReference(int entityRefIndex)
Creates an entity reference node in the table.

createElement

public int createElement(int elementNameIndex,
                         int attrListIndex)
Creates an element node in the table.

createAttribute

public int createAttribute(int attrNameIndex,
                           int attrValueIndex,
                           boolean specified)
Creates an attributes in the table.

createElementDefinition

public int createElementDefinition(int elementNameIndex)
Creates an element definition in the table.

createTextNode

public int createTextNode(int dataIndex,
                          boolean ignorableWhitespace)
Creates a text node in the table.

createCDATASection

public int createCDATASection(int dataIndex)
Creates a CDATA section node in the table.

createProcessingInstruction

public int createProcessingInstruction(int targetIndex,
                                       int dataIndex)
Creates a processing instruction node in the table.

createComment

public int createComment(int dataIndex)
Creates a comment node in the table.

appendChild

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

setAsFirstChild

public void setAsFirstChild(int parentIndex,
                            int childIndex)
Sets the first child of the parentIndex to childIndex.

getParentNode

public int getParentNode(int nodeIndex)
Returns the parent node of the given node.

getFirstChild

public int getFirstChild(int nodeIndex)
Returns the first child of the given node.

getLastChild

public int getLastChild(int nodeIndex)
Returns the last child of the given node.

getPreviousSibling

public int getPreviousSibling(int nodeIndex)
Returns the previous sibling of the given node.

getNextSibling

public int getNextSibling(int nodeIndex)
Returns the next sibling of the given node. This is post-normalization of Text Nodes.

getRealNextSibling

public int getRealNextSibling(int nodeIndex)
Returns the real next sibling of the given node, directly from the data structures. Used by TextImpl#getNodeValue() to normalize values.

lookupElementDefinition

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

getAttributeList

public int getAttributeList(int elementNodeIndex)
Returns the attribute list index for elements.

getNodeObject

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

getNodeNameString

public java.lang.String getNodeNameString(int nodeIndex)
Returns the name of the given node.

getNodeValueString

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

getNodeName

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

getNodeValue

public int getNodeValue(int nodeIndex)
Returns the real int value of the given node. Used by AttrImpl to store specified value (1 == true).

getNodeType

public short getNodeType(int nodeIndex)
Returns the type of the given node.

putIdentifier

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

print

public void print()
Prints out the tables.

synchronizeData

protected void synchronizeData()
Synchronizes the node's data.
Overrides:
synchronizeData in class NodeImpl

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:
synchronizeChildren in class NodeImpl

ensureCapacity

protected boolean ensureCapacity(int chunk,
                                 int index)
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.

XML for Java 2.0.15