Package net.sf.saxon.tinytree
Class TinyTree
- java.lang.Object
-
- net.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
Fields Modifier and Type Field Description 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
rootIndexUsed
protected int[]
typeCodeArray
protected boolean
usesNamespaces
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
diagnosticDump()
Produce diagnostic print of main tree arraysstatic void
diagnosticDump(NodeInfo node)
Create diagnostic dump of the tree containing a particular node.int[]
getAlphaArray()
Get the array holding alpha informationint[]
getAttributeNameCodeArray()
Get the array used to hold the name codes of all attributesint[]
getAttributeParentArray()
Get the array used to hold the parent pointers of all attributesint[]
getAttributeTypeCodeArray()
Get the array used to hold the type codes of all attributesjava.lang.CharSequence[]
getAttributeValueArray()
Get the array used to hold the name codes of all attributesint[]
getBetaArray()
Get the array holding beta informationjava.lang.CharSequence
getCharacterBuffer()
Get the character buffer used to hold all the text data of the documentjava.lang.CharSequence
getCommentBuffer()
Get the character buffer used to hold all the comment data of the documentConfiguration
getConfiguration()
Get the configuration previously set using setConfigurationint
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 nodeint[]
getNameCodeArray()
Get the array holding node name informationNamePool
getNamePool()
Get the name pool used for the names in this documentint[]
getNamespaceCodeArray()
Get the array used to hold the namespace codes of namespace declarationsint[]
getNamespaceParentArray()
Get the array used to hold the parent pointers of all namespace declarationsint[]
getNextPointerArray()
Get the array holding next-sibling pointersTinyNodeImpl
getNode(int nr)
Get the node at a given position in the treeshort[]
getNodeDepthArray()
Get the array holding node depth informationint
getNodeKind(int nodeNr)
Get the node kind of a given node, which must be a document, element, text, comment, or processing instruction nodebyte[]
getNodeKindArray()
Get the array holding node kind informationint
getNumberOfAttributes()
Get the number of attributes in the treeint
getNumberOfNamespaces()
Get the number of namespace declarations in the treeint
getNumberOfNodes()
Get the number of nodes in the tree, excluding attributes and namespace nodesint
getTypeAnnotation(int nodeNr)
Get the type annotation of a node.int[]
getTypeCodeArray()
Get the array holding node type informationvoid
indexIDElement(NodeInfo root, int nodeNr, NameChecker checker)
Index an element of type xs:IDboolean
isIdAttribute(int nr)
Determine whether an attribute is an IDREF/IDREFS attribute.boolean
isIdrefAttribute(int nr)
Determine whether an attribute is an IDREF/IDREFS attribute.boolean
isIdrefElement(int nr)
Ask whether an element is an IDREF/IDREFS element.boolean
isNilled(int nodeNr)
Ask whether a given node is nilledvoid
setConfiguration(Configuration config)
Set the Configuration that contains this documentvoid
setLineNumbering()
Set line numbering onvoid
showSize()
Output a statistical summary to System.err
-
-
-
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
-
rootIndexUsed
protected int rootIndexUsed
-
usesNamespaces
protected boolean usesNamespaces
-
-
Constructor Detail
-
TinyTree
public TinyTree()
Create a TinyTree. The initial size is based on the average size of trees previously built in this session
-
TinyTree
public TinyTree(int nodes, int attributes, int namespaces, int characters)
Create a tree with a specified initial size- Parameters:
nodes
- the expected number of (non attribute or namespace) nodesattributes
- the expected number of attributesnamespaces
- the expected number of namespace declarationscharacters
- the expected number of characters in the document (in text nodes)
-
-
Method Detail
-
setConfiguration
public void setConfiguration(Configuration config)
Set the Configuration that contains this document- Parameters:
config
- the Saxon configuration
-
getConfiguration
public Configuration getConfiguration()
Get the configuration previously set using setConfiguration- Returns:
- the Saxon configuration
-
getNamePool
public NamePool getNamePool()
Get the name pool used for the names in this document- Returns:
- the name pool
-
getTypeAnnotation
public int getTypeAnnotation(int nodeNr)
Get the type annotation of a node. Applies only to document, element, text, processing instruction, and comment nodes.- Parameters:
nodeNr
- the node whose type annotation is required- Returns:
- the fingerprint of the type annotation for elements and attributes, otherwise undefined.
-
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- Parameters:
root
- the root node of the documentnodeNr
- the element of type xs:IDchecker
- checks names against XML 1.0 or XML 1.1 rules
-
getNode
public final TinyNodeImpl getNode(int nr)
Get the node at a given position in the tree- Parameters:
nr
- the node number- Returns:
- the node at the given position
-
isIdAttribute
public boolean isIdAttribute(int nr)
Determine whether an attribute is an IDREF/IDREFS attribute. (The represents the is-idref property in the data model)- Parameters:
nr
- the node number of the attribute- Returns:
- true if this is an IDREF/IDREFS attribute
-
isIdrefAttribute
public boolean isIdrefAttribute(int nr)
Determine whether an attribute is an IDREF/IDREFS attribute. (The represents the is-idref property in the data model)- Parameters:
nr
- the node number of the attribute- Returns:
- true if this is an IDREF/IDREFS attribute
-
isIdrefElement
public boolean isIdrefElement(int nr)
Ask whether an element is an IDREF/IDREFS element. (The represents the is-idref property in the data model)- Parameters:
nr
- the element node whose is-idref property is required- Returns:
- true if the node has the is-idref property
-
setLineNumbering
public void setLineNumbering()
Set line numbering on
-
getDocumentNumber
public int getDocumentNumber()
Get the document number (actually, the tree number)- Returns:
- the unique number of this TinyTree structure
-
isNilled
public boolean isNilled(int nodeNr)
Ask whether a given node is nilled- Parameters:
nodeNr
- the node in question- Returns:
- true if the node has the nilled property
-
diagnosticDump
public void diagnosticDump()
Produce diagnostic print of main tree arrays
-
diagnosticDump
public static void diagnosticDump(NodeInfo node)
Create diagnostic dump of the tree containing a particular node. Designed to be called as an extension function for diagnostics.- Parameters:
node
- the node in question
-
showSize
public void showSize()
Output a statistical summary to System.err
-
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()
Get the number of attributes in the tree- Returns:
- the number of attributes
-
getNumberOfNamespaces
public int getNumberOfNamespaces()
Get the number of namespace declarations in the tree- Returns:
- the number of namespace declarations
-
getNodeKindArray
public byte[] getNodeKindArray()
Get the array holding node kind information- Returns:
- an array of bytes, byte N is the node kind of node number N
-
getNodeDepthArray
public short[] getNodeDepthArray()
Get the array holding node depth information- Returns:
- an array of shorts, byte N is the node depth of node number N
-
getNameCodeArray
public int[] getNameCodeArray()
Get the array holding node name information- Returns:
- an array of integers, integer N is the name code of node number N
-
getTypeCodeArray
public int[] getTypeCodeArray()
Get the array holding node type information- Returns:
- an array of integers, integer N is the type code of node number N
-
getNextPointerArray
public int[] getNextPointerArray()
Get the array holding next-sibling pointers- Returns:
- an array of integers, integer N is the next-sibling pointer for node number N
-
getAlphaArray
public int[] getAlphaArray()
Get the array holding alpha information- Returns:
- an array of integers, whose meaning depends on the node kind. For elements it is a pointer to the first attribute, for text, comment, and processing instruction nodes it is a pointer to the content
-
getBetaArray
public int[] getBetaArray()
Get the array holding beta information- Returns:
- an array of integers, whose meaning depends on the node kind. For elements it is a pointer to the first namespace declaration
-
getCharacterBuffer
public java.lang.CharSequence getCharacterBuffer()
Get the character buffer used to hold all the text data of the document- Returns:
- the character buffer
-
getCommentBuffer
public java.lang.CharSequence getCommentBuffer()
Get the character buffer used to hold all the comment data of the document- Returns:
- the character buffer used for comments
-
getAttributeNameCodeArray
public int[] getAttributeNameCodeArray()
Get the array used to hold the name codes of all attributes- Returns:
- an integer array; the Nth integer holds the attribute name code of attribute N
-
getAttributeTypeCodeArray
public int[] getAttributeTypeCodeArray()
Get the array used to hold the type codes of all attributes- Returns:
- an integer array; the Nth integer holds the attribute type code of attribute N
-
getAttributeParentArray
public int[] getAttributeParentArray()
Get the array used to hold the parent pointers of all attributes- Returns:
- an integer array; the Nth integer holds the pointer to the parent element of attribute N
-
getAttributeValueArray
public java.lang.CharSequence[] getAttributeValueArray()
Get the array used to hold the name codes of all attributes- Returns:
- an array of strings; the Nth string holds the string value of attribute N
-
getNamespaceCodeArray
public int[] getNamespaceCodeArray()
Get the array used to hold the namespace codes of namespace declarations- Returns:
- an array of integer namespace codes
-
getNamespaceParentArray
public int[] getNamespaceParentArray()
Get the array used to hold the parent pointers of all namespace declarations- Returns:
- an integer array; the Nth integer holds the pointer to the parent element of namespace N
-
-