net.sf.saxon.tinytree
Class TinyTree

java.lang.Object
  extended bynet.sf.saxon.tinytree.TinyTree

public final class TinyTree
extends java.lang.Object

A data structure to hold the contents of a tree. As the name implies, this implementation of the data model is optimized for size, and for speed of creation: it minimizes the number of Java objects used.

It can be used to represent a tree that is rooted at a document node, or one that is rooted at an element node.


Field Summary
protected  int[] alpha
           
protected  int[] attCode
           
protected  int[] attParent
           
protected  int[] attTypeCode
           
protected  java.lang.CharSequence[] attValue
           
protected  int[] beta
           
protected  LargeStringBuffer charBuffer
           
protected  FastStringBuffer commentBuffer
           
protected  short[] depth
           
protected  int documentNumber
           
protected  int[] nameCode
           
protected  int[] namespaceCode
           
protected  int[] namespaceParent
           
protected  int[] next
           
 byte[] nodeKind
           
protected  int numberOfAttributes
           
protected  int numberOfNamespaces
           
protected  int numberOfNodes
           
protected  int[] prior
           
protected  int[] typeCodeArray
           
protected  boolean usesNamespaces
           
 
Constructor Summary
TinyTree()
           
TinyTree(int nodes, int attributes, int namespaces, int characters)
           
 
Method Summary
protected  void condense()
          Condense the tree: release unused memory.
 void diagnosticDump()
          Produce diagnostic print of main tree arrays
 int[] getAlphaArray()
           
 int[] getAttributeNameCodeArray()
           
 int[] getAttributeParentArray()
           
 int[] getAttributeTypeCodeArray()
           
 java.lang.CharSequence[] getAttributeValueArray()
           
 int[] getBetaArray()
           
 java.lang.CharSequence getCharacterBuffer()
           
 java.lang.CharSequence getCommentBuffer()
           
 Configuration getConfiguration()
          Get the configuration previously set using setConfiguration
 int getDocumentNumber()
          Get the document number (actually, the tree number)
 int getNameCode(int nodeNr)
          Get the nameCode for a given node, which must be a document, element, text, comment, or processing instruction node
 int[] getNameCodeArray()
           
 NamePool getNamePool()
          Get the name pool used for the names in this document
 int[] getNamespaceCodeArray()
           
 int[] getNamespaceParentArray()
           
 int[] getNextPointerArray()
           
 TinyNodeImpl getNode(int nr)
           
 short[] getNodeDepthArray()
           
 int getNodeKind(int nodeNr)
          Get the node kind of a given node, which must be a document, element, text, comment, or processing instruction node
 byte[] getNodeKindArray()
           
 int getNumberOfAttributes()
           
 int getNumberOfNamespaces()
           
 int getNumberOfNodes()
          Get the number of nodes in the tree, excluding attributes and namespace nodes
 int getTypeAnnotation(int nodeNr)
          Get the type annotation of a node.
 int[] getTypeCodeArray()
           
 void indexIDElement(NodeInfo root, int nodeNr, NameChecker checker)
          Index an element of type xs:ID
 boolean isIDCode(int typeCode)
          Test whether a type annotation code represents the type xs:ID or one of its subtypes
 boolean isNilled(int nodeNr)
          Determine whether a given node is nilled
 void setConfiguration(Configuration config)
          Set the Configuration that contains this document
 void setLineNumbering()
          Set line numbering on
 void showSize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

documentNumber

protected int documentNumber

charBuffer

protected LargeStringBuffer charBuffer

commentBuffer

protected FastStringBuffer commentBuffer

numberOfNodes

protected int numberOfNodes

nodeKind

public 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

typeCodeArray

protected int[] typeCodeArray

numberOfAttributes

protected int numberOfAttributes

attParent

protected int[] attParent

attCode

protected int[] attCode

attValue

protected java.lang.CharSequence[] attValue

attTypeCode

protected int[] attTypeCode

numberOfNamespaces

protected int numberOfNamespaces

namespaceParent

protected int[] namespaceParent

namespaceCode

protected int[] namespaceCode

usesNamespaces

protected boolean usesNamespaces
Constructor Detail

TinyTree

public TinyTree()

TinyTree

public TinyTree(int nodes,
                int attributes,
                int namespaces,
                int characters)
Method Detail

setConfiguration

public void setConfiguration(Configuration config)
Set the Configuration that contains this document


getConfiguration

public Configuration getConfiguration()
Get the configuration previously set using setConfiguration


getNamePool

public NamePool getNamePool()
Get the name pool used for the names in this document


condense

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


getTypeAnnotation

public int getTypeAnnotation(int nodeNr)
Get the type annotation of a node. Applies only to document, element, text, processing instruction, and comment nodes.

Returns:
-1 if the annotation is xdt:untyped or if the node is not an element.

getNodeKind

public int getNodeKind(int nodeNr)
Get the node kind of a given node, which must be a document, element, text, comment, or processing instruction node

Parameters:
nodeNr - the node number
Returns:
the node kind

getNameCode

public int getNameCode(int nodeNr)
Get the nameCode for a given node, which must be a document, element, text, comment, or processing instruction node

Parameters:
nodeNr - the node number
Returns:
the name code

indexIDElement

public void indexIDElement(NodeInfo root,
                           int nodeNr,
                           NameChecker checker)
Index an element of type xs:ID


isIDCode

public boolean isIDCode(int typeCode)
Test whether a type annotation code represents the type xs:ID or one of its subtypes


getNode

public TinyNodeImpl getNode(int nr)

setLineNumbering

public void setLineNumbering()
Set line numbering on


getDocumentNumber

public int getDocumentNumber()
Get the document number (actually, the tree number)


isNilled

public boolean isNilled(int nodeNr)
Determine whether a given node is nilled


diagnosticDump

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


showSize

public void showSize()

getNumberOfNodes

public int getNumberOfNodes()
Get the number of nodes in the tree, excluding attributes and namespace nodes

Returns:
the number of nodes.

getNumberOfAttributes

public int getNumberOfAttributes()

getNumberOfNamespaces

public int getNumberOfNamespaces()

getNodeKindArray

public byte[] getNodeKindArray()

getNodeDepthArray

public short[] getNodeDepthArray()

getNameCodeArray

public int[] getNameCodeArray()

getTypeCodeArray

public int[] getTypeCodeArray()

getNextPointerArray

public int[] getNextPointerArray()

getAlphaArray

public int[] getAlphaArray()

getBetaArray

public int[] getBetaArray()

getCharacterBuffer

public java.lang.CharSequence getCharacterBuffer()

getCommentBuffer

public java.lang.CharSequence getCommentBuffer()

getAttributeNameCodeArray

public int[] getAttributeNameCodeArray()

getAttributeTypeCodeArray

public int[] getAttributeTypeCodeArray()

getAttributeParentArray

public int[] getAttributeParentArray()

getAttributeValueArray

public java.lang.CharSequence[] getAttributeValueArray()

getNamespaceCodeArray

public int[] getNamespaceCodeArray()

getNamespaceParentArray

public int[] getNamespaceParentArray()