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 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).

Version:
26 April 1999
Author:
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  int lastLevelOneNode
           
protected  int[] length
           
protected  int[] nameCode
           
protected  int[] namespaceCode
           
protected  int[] namespaceParent
           
protected  int[] next
           
protected  byte[] nodeType
           
protected  int numberOfAttributes
           
protected  int numberOfNamespaces
           
protected  int numberOfNodes
           
protected  int[] offset
           
protected  int[] prior
           
 
Fields inherited from class com.icl.saxon.tinytree.TinyNodeImpl
document, nodeNr, parent
 
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)
           
 void copy(Outputter out)
          Copy 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  TinyAttributeImpl getAttributeNode(int nr)
          Make a (transient) attribute node from the array of attributes
 java.lang.String getBaseURI()
          Get the base URI of this root node.
 DocumentInfo getDocumentRoot()
          Get the root (document) node
 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.
 NamePool getNamePool()
          Get the name pool used for the names in this document
protected  TinyNamespaceImpl getNamespaceNode(int nr)
          Make a (transient) namespace node from the array of namespace declarations
 TinyNodeImpl getNode(int nr)
           
 short getNodeType()
          Return the type of node.
 NodeInfo getParent()
          Find the parent node of this node.
 long getSequenceNumber()
          Get the node sequence number (in document order).
 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
protected  boolean isUsingNamespaces()
          determine whether this document uses namespaces
 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.
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 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.tinytree.TinyParentNodeImpl
copyStringValue, getStringValue, hasChildNodes
 
Methods inherited from class com.icl.saxon.tinytree.TinyNodeImpl
compareOrder, getAttributeValue, getAttributeValue, getDisplayName, getEnumeration, getFingerprint, getLocalName, getNameCode, getOriginatingNode, getPrefix, getURI, hasAttributes, isSameNode, outputNamespaceNodes, setLineNumber, setParentNode
 
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
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 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 TinyNodeImpl

getAttributeNode

protected 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 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 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 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 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 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 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 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 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