## net.sf.saxon.tinytree
Class TinyDocumentImpl

    java.lang.Object
      |
      +--net.sf.saxon.om.AbstractNode
            |
            +--net.sf.saxon.tinytree.TinyNodeImpl
                  |
                  +--net.sf.saxon.tinytree.TinyParentNodeImpl
                        |
                        +--net.sf.saxon.tinytree.TinyDocumentImpl

All Implemented Interfaces:
  org.w3c.dom.Document, DocumentInfo, javax.xml.transform.dom.DOMLocator, FingerprintedNode, Item, org.w3c.dom.Node, NodeInfo, javax.xml.transform.Source, javax.xml.transform.SourceLocator

public final class TinyDocumentImpl
extends net.sf.saxon.tinytree.TinyParentNodeImpl
implements DocumentInfo, org.w3c.dom.Document

A node in the XML parse tree representing the Document itself (or equivalently, the root node of the Document).

Field Summary
`protected int[]` `alpha`
`protected int[]` `attCode`
`protected int[]` `attParent`
`protected java.lang.CharSequence[]` `attValue`
`protected int[]` `beta`
`protected char[]` `charBuffer`
`protected int` `charBufferLength`
`protected java.lang.StringBuffer` `commentBuffer`
`protected short[]` `depth`
`protected TinyDocumentImpl` `document`
`protected int[]` `nameCode`
`protected int[]` `namespaceCode`
`protected int[]` `namespaceParent`
`protected int[]` `next`
`protected byte[]` `nodeKind`
`protected int` `nodeNr`
`protected int` `numberOfAttributes`
`protected int` `numberOfNamespaces`
`protected int` `numberOfNodes`
`protected net.sf.saxon.tinytree.TinyNodeImpl` `parent`
`protected int[]` `prior`
`protected int` `rootNode`

Fields inherited from class net.sf.saxon.om.AbstractNode
`NODE_LETTER`

Fields inherited from interface net.sf.saxon.om.NodeInfo
`ALL_NAMESPACES, LOCAL_NAMESPACES, NO_NAMESPACES`

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`

Constructor Summary
`TinyDocumentImpl()`
`TinyDocumentImpl(int nodes, int attributes, int namespaces, int characters)`

Method Summary
`org.w3c.dom.Node` `adoptNode(org.w3c.dom.Node source)`
`int` `compareOrder(NodeInfo other)` Determine the relative position of this node and another node, in document order.
`void` `condense()` Condense the tree: release unused memory.
`void` `copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)` Copy this node to a given outputter
`void` `diagnosticDump()` Produce diagnostic print of main tree arrays
`java.lang.String` `generateId()` Get a character string that uniquely identifies this node
`java.lang.String` `getAttributeValue(int fingerprint)` Get the value of a given attribute of this node
`java.lang.String` `getBaseURI()` Get the base URI of this root node.
`Configuration` `getConfiguration()` Get the configuration previously set using setConfiguration
`java.lang.String` `getDisplayName()` Get the display name of this node.
`int` `getDocumentNumber()` Get the unique document number
`DocumentInfo` `getDocumentRoot()` Get the root (document) node
`java.lang.String` `getDocumentURI()`
`int` `getFingerprint()` Get the fingerprint of the node, used for matching names
`java.lang.String` `getInputEncoding()` The following methods are defined in DOM Level 3, and Saxon includes nominal implementations of these methods so that the code will compile when DOM Level 3 interfaces are installed.
`int` `getLineNumber()` Get the line number of this root node.
`java.lang.String` `getLocalPart()` Get the local name of this node.
`int` `getNameCode()` Get the name code of the node, used for matching names
`NamePool` `getNamePool()` Get the name pool used for the names in this document
`net.sf.saxon.tinytree.TinyNodeImpl` `getNode(int nr)`
`int` `getNodeKind()` Return the type of node.
`org.w3c.dom.Node` `getOriginatingNode()` Get the node corresponding to this javax.xml.transform.dom.DOMLocator
`NodeInfo` `getParent()` Find the parent node of this node.
`java.lang.String` `getPrefix()` Get the prefix part of the name of this node.
`NodeInfo` `getRoot()` Get the root node
`long` `getSequenceNumber()` Get the node sequence number (in document order).
`boolean` `getStrictErrorChecking()`
`java.lang.String` `getStringValue()` Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.
`java.lang.String` `getSystemId()` Get the system id of this root node
`java.lang.String[]` `getUnparsedEntity(java.lang.String name)` Get the unparsed entity with a given nameID if there is one, or null if not.
`java.lang.String` `getURI()` Get the URI part of the name of this node.
`java.lang.String` `getXmlEncoding()`
`boolean` `getXmlStandalone()`
`java.lang.String` `getXmlVersion()`
`boolean` `hasAttributes()` Returns whether this node has any attributes.
`boolean` `hasChildNodes()` Determine if the node has children.
`boolean` `isSameNodeInfo(NodeInfo other)` Determine whether this is the same node as another node
`AxisIterator` `iterateAxis(byte axisNumber)` Return an iterator over all the nodes reached by the given axis from this node
`AxisIterator` `iterateAxis(byte axisNumber, NodeTest nodeTest)` Return an iterator over the nodes reached by the given axis from this node
`void` `normalizeDocument()`
`void` `outputNamespaceNodes(Receiver out, boolean includeAncestors)` Output all namespace nodes associated with this element.
`org.w3c.dom.Node` `renameNode(org.w3c.dom.Node n, java.lang.String namespaceURI, java.lang.String qualifiedName)`
`NodeInfo` `selectID(java.lang.String id)` Get the element with a given ID.
`void` `setConfiguration(Configuration config)` Set the Configuration that contains this document
`void` `setDocumentURI(java.lang.String documentURI)`
`void` `setLineNumbering()` Set line numbering on
`protected void` `setParentNode(net.sf.saxon.tinytree.TinyNodeImpl parent)` Set the parent of this node.
`void` `setRootNode(NodeInfo root)` Set the root node.
`void` `setStrictErrorChecking(boolean strictErrorChecking)`
`void` `setSystemId(java.lang.String uri)` Set the system id of this node
`void` `setXmlStandalone(boolean xmlStandalone)`
`void` `setXmlVersion(java.lang.String xmlVersion)`
`void` `showSize()`

Methods inherited from class net.sf.saxon.om.AbstractNode

`appendChild, appendData, cloneNode, compareDocumentPosition, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getChildNodes, getColumnNumber, getData, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getFeature, getFirstChild, getImplementation, getLastChild, getLength, getLocalName, getName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getOwnerElement, getParentNode, getPreviousSibling, getPublicId, getSchemaTypeInfo, getSpecified, getTagName, getTextContent, getTypeAnnotation, getTypedValue, getUserData, getValue, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isDefaultNamespace, isEqualNode, isId, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setNodeValue, setPrefix, setTextContent, setValue, splitText, substringData, supports`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface net.sf.saxon.om.NodeInfo
`compareOrder, getAttributeValue, getDisplayName, getFingerprint, getLocalPart, getNameCode, getStringValue, getTypeAnnotation, getURI, hasChildNodes, isSameNodeInfo, iterateAxis, iterateAxis, outputNamespaceNodes`

Methods inherited from interface net.sf.saxon.om.Item
`getTypedValue`

Methods inherited from interface org.w3c.dom.Document
`createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, importNode`

Methods inherited from interface org.w3c.dom.Node
`appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix`

Field Detail

### rootNode

    protected int rootNode

### charBuffer

    protected char[] charBuffer

### charBufferLength

    protected int charBufferLength

### commentBuffer

    protected java.lang.StringBuffer commentBuffer

### numberOfNodes

    protected int numberOfNodes

### nodeKind

    protected byte[] nodeKind

### depth

    protected short[] depth

### next

    protected int[] next

### alpha

    protected int[] alpha

### beta

    protected int[] beta

### nameCode

    protected int[] nameCode

### prior

    protected int[] prior

### numberOfAttributes

    protected int numberOfAttributes

### attParent

    protected int[] attParent

### attCode

    protected int[] attCode

### attValue

    protected java.lang.CharSequence[] attValue

### numberOfNamespaces

    protected int numberOfNamespaces

### namespaceParent

    protected int[] namespaceParent

### namespaceCode

    protected int[] namespaceCode

### document

    protected TinyDocumentImpl document

### nodeNr

    protected int nodeNr

### parent

    protected net.sf.saxon.tinytree.TinyNodeImpl parent

Constructor Detail

### TinyDocumentImpl

    public TinyDocumentImpl()

### TinyDocumentImpl

    public TinyDocumentImpl(int nodes,
                            int attributes,
                            int namespaces,
                            int characters)

Method Detail

### setConfiguration

    public void setConfiguration(Configuration config)

  Set the Configuration that contains this document

  Specified by:
    `setConfiguration` in interface `DocumentInfo`
  Parameters:
    `config` - The configuration to be used

### getConfiguration

    public Configuration getConfiguration()

  Get the configuration previously set using setConfiguration

  Specified by:
    `getConfiguration` in interface `DocumentInfo`

### getNamePool

    public NamePool getNamePool()

  Get the name pool used for the names in this document

  Specified by:
    `getNamePool` in interface `DocumentInfo`
  Overrides:
    `getNamePool` in class `net.sf.saxon.tinytree.TinyNodeImpl`
  Returns:
    the name pool in which all the names used in this document are registered

### getDocumentNumber

    public int getDocumentNumber()

  Get the unique document number

  Specified by:
    `getDocumentNumber` in interface `DocumentInfo`
  Overrides:
    `getDocumentNumber` in class `net.sf.saxon.tinytree.TinyNodeImpl`
  Returns:
    the unique number identifying this document within the name pool

### setRootNode

    public void setRootNode(NodeInfo root)

  Set the root node. Parentless elements are implemented using a full tree structure containing a document node, but the document node is not regarded as part of the tree

### condense

    public void condense()

  Condense the tree: release unused memory. This is done after the full tree has been built. The method makes a pragmatic judgement as to whether it is worth reclaiming space; this is only done when the constructed tree is very small compared with the space allocated.

### getNode

    public net.sf.saxon.tinytree.TinyNodeImpl getNode(int nr)

### getSequenceNumber

    public long getSequenceNumber()

  Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive.

  Overrides:
    `getSequenceNumber` in class `net.sf.saxon.tinytree.TinyNodeImpl`

### setSystemId

    public void setSystemId(java.lang.String uri)

  Set the system id of this node

  Specified by:
    `setSystemId` in interface `javax.xml.transform.Source`
  Overrides:
    `setSystemId` in class `net.sf.saxon.tinytree.TinyNodeImpl`

### getSystemId

    public java.lang.String getSystemId()

  Get the system id of this root node

  Specified by:
    `getSystemId` in interface `NodeInfo`
  Overrides:
    `getSystemId` in class `net.sf.saxon.tinytree.TinyNodeImpl`
  Returns:
    the System Identifier of the entity in the source document containing the node, or null if not known. Note this is not the same as the base URI: the base URI can be modified by xml:base, but the system ID cannot.

### getBaseURI

    public java.lang.String getBaseURI()

  Get the base URI of this root node. For a root node the base URI is the same as the System ID.

  Specified by:
    `getBaseURI` in interface `NodeInfo`
  Overrides:
    `getBaseURI` in class `net.sf.saxon.tinytree.TinyNodeImpl`
  Returns:
    the base URI of the node

### setLineNumbering

    public void setLineNumbering()

  Set line numbering on

### getLineNumber

    public int getLineNumber()

  Get the line number of this root node.

  Specified by:
    `getLineNumber` in interface `NodeInfo`
  Overrides:
    `getLineNumber` in class `net.sf.saxon.tinytree.TinyNodeImpl`
  Returns:
    0 always

### getNodeKind

    public final int getNodeKind()

  Return the type of node.

  Specified by:
    `getNodeKind` in interface `NodeInfo`
  Returns:
    Type.DOCUMENT (always)
  See Also:
    `Type`

### getParent

    public NodeInfo getParent()

  Find the parent node of this node.

  Specified by:
    `getParent` in interface `NodeInfo`
  Overrides:
    `getParent` in class `net.sf.saxon.tinytree.TinyNodeImpl`
  Returns:
    The Node object describing the containing element or root node.

### getRoot

    public NodeInfo getRoot()

  Get the root node

  Specified by:
    `getRoot` in interface `NodeInfo`
  Overrides:
    `getRoot` in class `net.sf.saxon.tinytree.TinyNodeImpl`
  Returns:
    the NodeInfo that is the root of the tree - not necessarily a document node

### getDocumentRoot

    public DocumentInfo getDocumentRoot()

  Get the root (document) node

  Specified by:
    `getDocumentRoot` in interface `NodeInfo`
  Overrides:
    `getDocumentRoot` in class `net.sf.saxon.tinytree.TinyNodeImpl`
  Returns:
    the DocumentInfo representing the document node, or null if the root of the tree is not a document node

### generateId

    public java.lang.String generateId()

  Get a character string that uniquely identifies this node

  Specified by:
    `generateId` in interface `NodeInfo`
  Overrides:
    `generateId` in class `net.sf.saxon.tinytree.TinyNodeImpl`
  Returns:
    an identifier based on the document number

### selectID

    public NodeInfo selectID(java.lang.String id)

  Get the element with a given ID.

  Specified by:
    `selectID` in interface `DocumentInfo`
  Parameters:
    `id` - The unique ID of the required element, previously registered using registerID()
  Returns:
    The NodeInfo (always an Element) for the given ID if one has been registered, otherwise null.

### getUnparsedEntity

    public java.lang.String[] getUnparsedEntity(java.lang.String name)

  Get the unparsed entity with a given nameID if there is one, or null if not. If the entity does not exist, return null.

  Specified by:
    `getUnparsedEntity` in interface `DocumentInfo`
  Parameters:
    `name` - the name of the entity
  Returns:
    if the entity exists, return an array of two Strings, the first holding the system ID of the entity, the second holding the public

### getInputEncoding

    public java.lang.String getInputEncoding()

  The following methods are defined in DOM Level 3, and Saxon includes nominal implementations of these methods so that the code will compile when DOM Level 3 interfaces are installed.

### getXmlEncoding

    public java.lang.String getXmlEncoding()

### getXmlStandalone

    public boolean getXmlStandalone()

### setXmlStandalone

    public void setXmlStandalone(boolean xmlStandalone)
                          throws org.w3c.dom.DOMException

    `org.w3c.dom.DOMException`

### getXmlVersion

    public java.lang.String getXmlVersion()

### setXmlVersion

    public void setXmlVersion(java.lang.String xmlVersion)
                       throws org.w3c.dom.DOMException

    `org.w3c.dom.DOMException`

### getStrictErrorChecking

    public boolean getStrictErrorChecking()

### setStrictErrorChecking

    public void setStrictErrorChecking(boolean strictErrorChecking)

### getDocumentURI

    public java.lang.String getDocumentURI()

### setDocumentURI

    public void setDocumentURI(java.lang.String documentURI)

### adoptNode

    public org.w3c.dom.Node adoptNode(org.w3c.dom.Node source)
                               throws org.w3c.dom.DOMException

    `org.w3c.dom.DOMException`

### normalizeDocument

    public void normalizeDocument()

### renameNode

    public org.w3c.dom.Node renameNode(org.w3c.dom.Node n,
                                       java.lang.String namespaceURI,
                                       java.lang.String qualifiedName)
                                throws org.w3c.dom.DOMException

    `org.w3c.dom.DOMException`

### copy

    public void copy(Receiver out,
                     int whichNamespaces,
                     boolean copyAnnotations,
                     int locationId)
              throws XPathException

  Copy this node to a given outputter

  Specified by:
    `copy` in interface `NodeInfo`
  Parameters:
    `out` - the Receiver to which the node should be copied
    `whichNamespaces` - in the case of an element, controls which namespace nodes should be copied. Values are NO_NAMESPACES, LOCAL_NAMESPACES, ALL_NAMESPACES
    `copyAnnotations` - indicates whether the type annotations of element and attribute nodes should be copied
    `locationId` - Identifies the location of the instruction that requested this copy. Pass zero if no other information is available
  Throws:
    `XPathException`

### diagnosticDump

    public void diagnosticDump()

  Produce diagnostic print of main tree arrays

### showSize

    public void showSize()

### hasChildNodes

    public boolean hasChildNodes()

  Determine if the node has children.

  Specified by:
    `hasChildNodes` in interface `org.w3c.dom.Node`
  Overrides:
    `hasChildNodes` in class `net.sf.saxon.tinytree.TinyNodeImpl`
  Returns:
    `true` if this node has any attributes, `false` otherwise.

### getStringValue

    public java.lang.String getStringValue()

  Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.

  Specified by:
    `getStringValue` in interface `NodeInfo`
  Specified by:
    `getStringValue` in class `AbstractNode`
  Returns:
    the accumulated character content of the element, including descendant elements.

### setParentNode

    protected void setParentNode(net.sf.saxon.tinytree.TinyNodeImpl parent)

  Set the parent of this node. Providing this information is useful, if it is known, because otherwise getParent() has to search backwards through the document.

### isSameNodeInfo

    public boolean isSameNodeInfo(NodeInfo other)

  Determine whether this is the same node as another node

  Specified by:
    `isSameNodeInfo` in interface `NodeInfo`
  Specified by:
    `isSameNodeInfo` in class `AbstractNode`
  Parameters:
    `other` - the node to be compared with this node
  Returns:
    true if this Node object and the supplied Node object represent the same node in the tree.

### getOriginatingNode

    public org.w3c.dom.Node getOriginatingNode()

  Get the node corresponding to this javax.xml.transform.dom.DOMLocator

  Specified by:
    `getOriginatingNode` in interface `javax.xml.transform.dom.DOMLocator`
  Overrides:
    `getOriginatingNode` in class `AbstractNode`

### compareOrder

    public final int compareOrder(NodeInfo other)

  Determine the relative position of this node and another node, in document order. The other node will always be in the same document.

  Specified by:
    `compareOrder` in interface `NodeInfo`
  Specified by:
    `compareOrder` in class `AbstractNode`
  Parameters:
    `other` - The other node, whose position is to be compared with this node
  Returns:
    -1 if this node precedes the other node, +1 if it follows the other node, or 0 if they are the same node. (In this case, isSameNode() will always return true, and the two nodes will produce the same result for generateId())

### getFingerprint

    public int getFingerprint()

  Get the fingerprint of the node, used for matching names

  Specified by:
    `getFingerprint` in interface `NodeInfo`
  Specified by:
    `getFingerprint` in class `AbstractNode`
  Returns:
    an integer fingerprint; two nodes with the same fingerprint have the same expanded QName

### getNameCode

    public int getNameCode()

  Get the name code of the node, used for matching names

  Specified by:
    `getNameCode` in interface `NodeInfo`
  Specified by:
    `getNameCode` in class `AbstractNode`
  Returns:
    an integer name code, which may be used to obtain the actual node name from the name pool
  See Also:
    `allocate`, `getFingerprint`

### getPrefix

    public java.lang.String getPrefix()

  Get the prefix part of the name of this node. This is the name before the ":" if any.

  Returns:
    the prefix part of the name. For an unnamed node, return "".

### getURI

    public java.lang.String getURI()

  Get the URI part of the name of this node. This is the URI corresponding to the prefix, or the URI of the default namespace if appropriate.

  Specified by:
    `getURI` in interface `NodeInfo`
  Specified by:
    `getURI` in class `AbstractNode`
  Returns:
    The URI of the namespace of this node. For an unnamed node, or for an element or attribute in the default namespace, return an empty string.

### getDisplayName

    public java.lang.String getDisplayName()

  Get the display name of this node. For elements and attributes this is [prefix:]localname. For unnamed nodes, it is an empty string.

  Specified by:
    `getDisplayName` in interface `NodeInfo`
  Overrides:
    `getDisplayName` in class `AbstractNode`
  Returns:
    The display name of this node. For a node with no name, return an empty string.

### getLocalPart

    public java.lang.String getLocalPart()

  Get the local name of this node.

  Specified by:
    `getLocalPart` in interface `NodeInfo`
  Specified by:
    `getLocalPart` in class `AbstractNode`
  Returns:
    The local name of this node. For a node with no name, return "".

### iterateAxis

    public AxisIterator iterateAxis(byte axisNumber)

  Return an iterator over all the nodes reached by the given axis from this node

  Parameters:
    `axisNumber` - Identifies the required axis, eg. Axis.CHILD or Axis.PARENT
  Returns:
    a AxisIteratorImpl that scans the nodes reached by the axis in turn.
  See Also:
    `Axis`

### iterateAxis

    public AxisIterator iterateAxis(byte axisNumber,
                                    NodeTest nodeTest)

  Return an iterator over the nodes reached by the given axis from this node

  Specified by:
    `iterateAxis` in interface `NodeInfo`
  Specified by:
    `iterateAxis` in class `AbstractNode`
  Parameters:
    `axisNumber` - Identifies the required axis, eg. Axis.CHILD or Axis.PARENT
    `nodeTest` - A pattern to be matched by the returned nodes.
  Returns:
    a AxisIteratorImpl that scans the nodes reached by the axis in turn.

### hasAttributes

    public boolean hasAttributes()

  Returns whether this node has any attributes.

  Specified by:
    `hasAttributes` in interface `org.w3c.dom.Node`
  Specified by:
    `hasAttributes` in class `AbstractNode`
  Returns:
    `true` if this node has any attributes, `false` otherwise.
  Since:
    DOM Level 2

### getAttributeValue

    public java.lang.String getAttributeValue(int fingerprint)

  Get the value of a given attribute of this node

  Specified by:
    `getAttributeValue` in interface `NodeInfo`
  Specified by:
    `getAttributeValue` in class `AbstractNode`
  Parameters:
    `fingerprint` - The fingerprint of the attribute name
  Returns:
    the attribute value if it exists or null if not

### outputNamespaceNodes

    public void outputNamespaceNodes(Receiver out,
                                     boolean includeAncestors)
                              throws XPathException

  Output all namespace nodes associated with this element. Does nothing if the node is not an element.

  Specified by:
    `outputNamespaceNodes` in interface `NodeInfo`
  Overrides:
    `outputNamespaceNodes` in class `AbstractNode`
  Parameters:
    `out` - The relevant outputter
    `includeAncestors` - True if namespaces declared on ancestor elements must be output; false if it is known that these are already on the result tree
    `XPathException`