: Class TinyDocumentImpl

com.icl.saxon.tinytree
Class TinyDocumentImpl


java.lang.Object

  |

  +--com.icl.saxon.om.AbstractNode

        |

        +--com.icl.saxon.tinytree.TinyNodeImpl

              |

              +--com.icl.saxon.tinytree.TinyParentNodeImpl

                    |

                    +--com.icl.saxon.tinytree.TinyDocumentImpl

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

public final class TinyDocumentImpl
extends com.icl.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[] attCode
           
protected  int[] attParent
           
protected  java.lang.String[] attValue
           
protected  char[] charBuffer
           
protected  int charBufferLength
           
protected  java.lang.StringBuffer commentBuffer
           
protected  short[] depth
           
protected  TinyDocumentImpl document
           
protected  int lastLevelOneNode
           
protected  int[] length
           
protected  int[] nameCode
           
protected  int[] namespaceCode
           
protected  int[] namespaceParent
           
protected  int[] next
           
protected  int nodeNr
           
protected  byte[] nodeType
           
protected  int numberOfAttributes
           
protected  int numberOfNamespaces
           
protected  int numberOfNodes
           
protected  int[] offset
           
protected  com.icl.saxon.tinytree.TinyNodeImpl parent
           
protected  int[] prior
           
 
Fields inherited from class com.icl.saxon.om.AbstractNode
NODE_LETTER
 
Fields inherited from interface com.icl.saxon.om.NodeInfo
ATTRIBUTE, COMMENT, ELEMENT, NAMESPACE, NODE, NONE, NUMBER_OF_TYPES, PI, ROOT, TEXT
 
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()
           
 
Method Summary
protected  void addAttribute(int parent0, int code0, java.lang.String type0, java.lang.String value0)
           
protected  void addNamespace(int parent0, int nscode0)
           
protected  void addNode(short type0, int depth0, int offset0, int length0, int nameCode0)
           
protected  void appendChars(char[] chars, int start, int length)
           
 int compareOrder(NodeInfo other)
          Determine the relative position of this node and another node, in document order.
 void copy(Outputter out)
          Copy this node to a given outputter
 void copyStringValue(Outputter out)
          Copy the string-value of this node to a given outputter
 void diagnosticDump()
          Produce diagnostic print of main tree arrays
protected  void ensureAttributeCapacity()
           
protected  void ensureNamespaceCapacity()
           
protected  void ensureNodeCapacity()
           
protected  void ensurePriorIndex()
          On demand, make an index for quick access to preceding-sibling nodes
 java.lang.String generateId()
          Get a character string that uniquely identifies this node within the document
protected  AxisEnumeration getAllElements(int fingerprint)
          Get a list of all elements with a given name.
protected  com.icl.saxon.tinytree.TinyAttributeImpl getAttributeNode(int nr)
          Make a (transient) attribute node from the array of attributes
 java.lang.String getAttributeValue(int fingerprint)
          Get the value of a given attribute of this node
 java.lang.String getAttributeValue(java.lang.String uri, java.lang.String localName)
          Find the value of a given attribute of this node.
 java.lang.String getBaseURI()
          Get the base URI of this root node.
 java.lang.String getDisplayName()
          Get the display name of this node.
 DocumentInfo getDocumentRoot()
          Get the root (document) node
 AxisEnumeration getEnumeration(byte axisNumber, NodeTest nodeTest)
          Return an enumeration over the nodes reached by the given axis from this node
 int getFingerprint()
          Get the fingerprint of the node, used for matching names
 java.util.Hashtable getKeyIndex(KeyManager keymanager, int fingerprint)
          Get the index for a given key
 int getLineNumber()
          Get the line number of this root node.
protected  int getLineNumber(int sequence)
          Get the line number for an element.
 java.lang.String getLocalName()
          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
protected  com.icl.saxon.tinytree.TinyNamespaceImpl getNamespaceNode(int nr)
          Make a (transient) namespace node from the array of namespace declarations
 com.icl.saxon.tinytree.TinyNodeImpl getNode(int nr)
           
 short getNodeType()
          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.
 long getSequenceNumber()
          Get the node sequence number (in document order).
 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
protected  java.lang.String getSystemId(int seq)
          Get the system id of an element in the document
 java.lang.String getUnparsedEntity(java.lang.String name)
          Get the unparsed entity with a given name
 java.lang.String getURI()
          Get the URI part of the name of this node.
 boolean hasAttributes()
          Returns whether this node has any attributes.
 boolean hasChildNodes()
          Determine if the node has children.
 boolean isSameNode(NodeInfo other)
          Determine whether this is the same node as another node
protected  boolean isUsingNamespaces()
          determine whether this document uses namespaces
 void outputNamespaceNodes(Outputter out, boolean includeAncestors)
          Output all namespace nodes associated with this element.
 NodeInfo selectID(java.lang.String id)
          Get the element with a given ID.
 void setKeyIndex(KeyManager keymanager, int fingerprint, java.util.Hashtable keyindex)
          Set the index for a given key.
 void setLineNumber(int line)
          Set the line number of the node within its source document entity
protected  void setLineNumber(int sequence, int line)
          Set the line number for an element.
 void setLineNumbering()
          Set line numbering on
 void setNamePool(NamePool pool)
          Set the name pool used for all names in this document
protected  void setParentNode(com.icl.saxon.tinytree.TinyNodeImpl parent)
          Set the parent of this node.
protected  void setSystemId(int seq, java.lang.String uri)
          Set the system id of an element in the document
 void setSystemId(java.lang.String uri)
          Set the system id of this node
protected  void setUnparsedEntity(java.lang.String name, java.lang.String uri)
          Set an unparsed entity URI associated with this document.
protected  void truncate(int nodes)
          Truncate the tree: used in preview mode to delete an element after it has been processed
 
Methods inherited from class com.icl.saxon.om.AbstractNode
appendChild, appendData, cloneNode, 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, getFirstChild, getImplementation, getLastChild, getLength, getName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getOwnerElement, getParentNode, getPreviousSibling, getPublicId, getSpecified, getTagName, getValue, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isSupported, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setNodeValue, setPrefix, 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 com.icl.saxon.om.NodeInfo
compareOrder, copyStringValue, getAttributeValue, getAttributeValue, getDisplayName, getEnumeration, getFingerprint, getLocalName, getNameCode, getPrefix, getStringValue, getURI, hasChildNodes, isSameNode, outputNamespaceNodes
 
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, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

charBuffer


protected char[] charBuffer

charBufferLength


protected int charBufferLength

commentBuffer


protected java.lang.StringBuffer commentBuffer

numberOfNodes


protected int numberOfNodes

lastLevelOneNode


protected int lastLevelOneNode

nodeType


protected byte[] nodeType

depth


protected short[] depth

next


protected int[] next

offset


protected int[] offset

length


protected int[] length

nameCode


protected int[] nameCode

prior


protected int[] prior

numberOfAttributes


protected int numberOfAttributes

attParent


protected int[] attParent

attCode


protected int[] attCode

attValue


protected java.lang.String[] attValue

numberOfNamespaces


protected int numberOfNamespaces

namespaceParent


protected int[] namespaceParent

namespaceCode


protected int[] namespaceCode

document


protected TinyDocumentImpl document

nodeNr


protected int nodeNr

parent


protected com.icl.saxon.tinytree.TinyNodeImpl parent
Constructor Detail

TinyDocumentImpl


public TinyDocumentImpl()
Method Detail

setNamePool


public void setNamePool(NamePool pool)
Set the name pool used for all names in this document
Specified by:
setNamePool in interface DocumentInfo

getNamePool


public NamePool getNamePool()
Get the name pool used for the names in this document
Specified by:
getNamePool in interface DocumentInfo

ensureNodeCapacity


protected void ensureNodeCapacity()

ensureAttributeCapacity


protected void ensureAttributeCapacity()

ensureNamespaceCapacity


protected void ensureNamespaceCapacity()

addNode


protected void addNode(short type0,
                       int depth0,
                       int offset0,
                       int length0,
                       int nameCode0)

appendChars


protected void appendChars(char[] chars,
                           int start,
                           int length)

truncate


protected void truncate(int nodes)
Truncate the tree: used in preview mode to delete an element after it has been processed

ensurePriorIndex


protected void ensurePriorIndex()
On demand, make an index for quick access to preceding-sibling nodes

addAttribute


protected void addAttribute(int parent0,
                            int code0,
                            java.lang.String type0,
                            java.lang.String value0)

addNamespace


protected void addNamespace(int parent0,
                            int nscode0)

getNode


public com.icl.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 com.icl.saxon.tinytree.TinyNodeImpl

getAttributeNode


protected com.icl.saxon.tinytree.TinyAttributeImpl getAttributeNode(int nr)
Make a (transient) attribute node from the array of attributes

isUsingNamespaces


protected boolean isUsingNamespaces()
determine whether this document uses namespaces

getNamespaceNode


protected com.icl.saxon.tinytree.TinyNamespaceImpl getNamespaceNode(int nr)
Make a (transient) namespace node from the array of namespace declarations

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 com.icl.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 com.icl.saxon.tinytree.TinyNodeImpl
Following copied from interface: com.icl.saxon.om.NodeInfo
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 com.icl.saxon.tinytree.TinyNodeImpl

setSystemId


protected void setSystemId(int seq,
                           java.lang.String uri)
Set the system id of an element in the document

getSystemId


protected java.lang.String getSystemId(int seq)
Get the system id of an element in the document

setLineNumbering


public void setLineNumbering()
Set line numbering on

setLineNumber


protected void setLineNumber(int sequence,
                             int line)
Set the line number for an element. Ignored if line numbering is off.

getLineNumber


protected int getLineNumber(int sequence)
Get the line number for an element. Return -1 if line numbering is off.

getLineNumber


public int getLineNumber()
Get the line number of this root node.
Specified by:
getLineNumber in interface NodeInfo
Overrides:
getLineNumber in class com.icl.saxon.tinytree.TinyNodeImpl
Returns:
0 always

getNodeType


public final short getNodeType()
Return the type of node.
Specified by:
getNodeType in interface NodeInfo
Returns:
NodeInfo.ROOT (always)

getParent


public NodeInfo getParent()
Find the parent node of this node.
Specified by:
getParent in interface NodeInfo
Overrides:
getParent in class com.icl.saxon.tinytree.TinyNodeImpl
Returns:
The Node object describing the containing element or root node.

getDocumentRoot


public DocumentInfo getDocumentRoot()
Get the root (document) node
Specified by:
getDocumentRoot in interface NodeInfo
Overrides:
getDocumentRoot in class com.icl.saxon.tinytree.TinyNodeImpl
Returns:
the DocumentInfo representing this document

generateId


public java.lang.String generateId()
Get a character string that uniquely identifies this node within the document
Specified by:
generateId in interface NodeInfo
Overrides:
generateId in class com.icl.saxon.tinytree.TinyNodeImpl
Returns:
the empty string

getAllElements


protected AxisEnumeration getAllElements(int fingerprint)
Get a list of all elements with a given name. This is implemented as a memo function: the first time it is called for a particular element type, it remembers the result for next time.

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.

getKeyIndex


public java.util.Hashtable getKeyIndex(KeyManager keymanager,
                                       int fingerprint)
Get the index for a given key
Specified by:
getKeyIndex in interface DocumentInfo
Parameters:
keymanager - The key manager managing this key
Returns:
The index, if one has been built, in the form of a Hashtable that maps the key value to a set of nodes having that key value. If no index has been built, returns null.

setKeyIndex


public void setKeyIndex(KeyManager keymanager,
                        int fingerprint,
                        java.util.Hashtable keyindex)
Set the index for a given key. The method is synchronized because the same document can be used by several stylesheets at the same time.
Specified by:
setKeyIndex in interface DocumentInfo
Parameters:
keymanager - The key manager managing this key
fingerprint - The fingerprint of the name of the key (unique with the key manager)
keyindex - the index, in the form of a Hashtable that maps the key value to a set of nodes having that key value. Or the String "under construction", indicating that the index is being built.

setUnparsedEntity


protected void setUnparsedEntity(java.lang.String name,
                                 java.lang.String uri)
Set an unparsed entity URI associated with this document. For system use only, while building the document.

getUnparsedEntity


public java.lang.String getUnparsedEntity(java.lang.String name)
Get the unparsed entity with a given name
Specified by:
getUnparsedEntity in interface DocumentInfo
Parameters:
name - the name of the entity
Returns:
the URI of the entity if there is one, or empty string if not

copy


public void copy(Outputter out)
          throws javax.xml.transform.TransformerException
Copy this node to a given outputter
Specified by:
copy in interface NodeInfo

diagnosticDump


public void diagnosticDump()
Produce diagnostic print of main tree arrays

hasChildNodes


public boolean hasChildNodes()
Determine if the node has children.
Overrides:
hasChildNodes in class com.icl.saxon.tinytree.TinyNodeImpl
Following copied from class: com.icl.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.
Returns:
the accumulated character content of the element, including descendant elements.

copyStringValue


public void copyStringValue(Outputter out)
                     throws javax.xml.transform.TransformerException
Copy the string-value of this node to a given outputter
Overrides:
copyStringValue in class AbstractNode

setParentNode


protected void setParentNode(com.icl.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.

isSameNode


public boolean isSameNode(NodeInfo other)
Determine whether this is the same node as another node
Overrides:
isSameNode in class AbstractNode
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
Overrides:
getOriginatingNode in class AbstractNode

setLineNumber


public void setLineNumber(int line)
Set the line number of the node within its source document entity

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.
Overrides:
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
Overrides:
getFingerprint in class AbstractNode

getNameCode


public int getNameCode()
Get the name code of the node, used for matching names
Overrides:
getNameCode in class AbstractNode
Following copied from interface: com.icl.saxon.om.NodeInfo
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.
Overrides:
getPrefix in class AbstractNode
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.
Overrides:
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.
Overrides:
getDisplayName in class AbstractNode
Returns:
The display name of this node. For a node with no name, return an empty string.

getLocalName


public java.lang.String getLocalName()
Get the local name of this node.
Overrides:
getLocalName in class AbstractNode
Returns:
The local name of this node. For a node with no name, return an empty string.

getEnumeration


public AxisEnumeration getEnumeration(byte axisNumber,
                                      NodeTest nodeTest)
Return an enumeration over the nodes reached by the given axis from this node
Overrides:
getEnumeration 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 AxisEnumeration that scans the nodes reached by the axis in turn.

hasAttributes


public boolean hasAttributes()
Returns whether this node has any attributes.
Overrides:
hasAttributes in class AbstractNode
Returns:
true if this node has any attributes, false otherwise.
Since:
DOM Level 2

getAttributeValue


public java.lang.String getAttributeValue(java.lang.String uri,
                                          java.lang.String localName)
Find the value of a given attribute of this node.
This method is defined on all nodes to meet XSL requirements, but for nodes other than elements it will always return null.
Overrides:
getAttributeValue in class AbstractNode
Parameters:
uri - the namespace uri of an attribute
localName - the local name of an attribute
Returns:
the value of the attribute, if it exists, otherwise null

getAttributeValue


public java.lang.String getAttributeValue(int fingerprint)
Get the value of a given attribute of this node
Overrides:
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(Outputter out,
                                 boolean includeAncestors)
                          throws javax.xml.transform.TransformerException
Output all namespace nodes associated with this element. Does nothing if the node is not an element.
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