Package net.sf.saxon.tinytree
Class TinyDocumentImpl
- java.lang.Object
-
- net.sf.saxon.tinytree.TinyNodeImpl
-
- net.sf.saxon.tinytree.TinyDocumentImpl
-
- All Implemented Interfaces:
javax.xml.transform.Source,javax.xml.transform.SourceLocator,PullEvent,DocumentInfo,FingerprintedNode,Item,NodeInfo,ValueRepresentation
public final class TinyDocumentImpl extends TinyNodeImpl implements DocumentInfo
A node in the XML parse tree representing the Document itself (or equivalently, the root node of the Document).
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.tinytree.TinyNodeImpl
NODE_LETTER, nodeNr, parent, tree
-
Fields inherited from interface net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, EMPTY_NAMESPACE_LIST, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
-
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
-
-
Constructor Summary
Constructors Constructor Description TinyDocumentImpl(TinyTree tree)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)Copy this node to a given outputtervoidgenerateId(FastStringBuffer buffer)Get a character string that uniquely identifies this nodejava.lang.StringgetBaseURI()Get the base URI of this root node.ConfigurationgetConfiguration()Get the configuration previously set using setConfigurationDocumentInfogetDocumentRoot()Get the root (document) nodeintgetLineNumber()Get the line number of this root node.intgetNodeKind()Return the type of node.NodeInfogetParent()Find the parent node of this node.NodeInfogetRoot()Get the root nodejava.lang.StringgetStringValue()Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.static java.lang.CharSequencegetStringValue(TinyTree tree, int nodeNr)Get the string value of a node.java.lang.CharSequencegetStringValueCS()Get the value of the item as a CharSequence.java.lang.StringgetSystemId()Get the system id of this root nodeTinyTreegetTree()Get the tree containing this nodejava.lang.String[]getUnparsedEntity(java.lang.String name)Get the unparsed entity with a given nameID if there is one, or null if not.java.util.IteratorgetUnparsedEntityNames()Get the list of unparsed entities defined in this documentbooleanhasChildNodes()Determine if the node has children.NodeInfoselectID(java.lang.String id)Get the element with a given ID.voidsetBaseURI(java.lang.String uri)Set the base URI of this document nodevoidsetConfiguration(Configuration config)Set the Configuration that contains this documentvoidsetSystemId(java.lang.String uri)Set the system id of this nodevoidshowSize()-
Methods inherited from class net.sf.saxon.tinytree.TinyNodeImpl
atomize, compareOrder, equals, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getDisplayName, getDocumentNumber, getFingerprint, getLocalPart, getNameCode, getNamePool, getNodeNumber, getPrefix, getPublicId, getSequenceNumber, getTypeAnnotation, getTypedValue, getURI, hashCode, isAncestorOrSelf, isId, isIdref, isNilled, isSameNodeInfo, iterateAxis, iterateAxis, setParentNode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.om.Item
getStringValueCS, getTypedValue
-
Methods inherited from interface net.sf.saxon.om.NodeInfo
atomize, compareOrder, equals, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getDisplayName, getDocumentNumber, getFingerprint, getLocalPart, getNameCode, getNamePool, getPrefix, getStringValue, getTypeAnnotation, getURI, hasChildNodes, hashCode, isId, isIdref, isNilled, isSameNodeInfo, iterateAxis, iterateAxis
-
-
-
-
Constructor Detail
-
TinyDocumentImpl
public TinyDocumentImpl(TinyTree tree)
-
-
Method Detail
-
getTree
public TinyTree getTree()
Get the tree containing this node
-
setConfiguration
public void setConfiguration(Configuration config)
Set the Configuration that contains this document
-
getConfiguration
public Configuration getConfiguration()
Get the configuration previously set using setConfiguration- Specified by:
getConfigurationin interfaceNodeInfo- Overrides:
getConfigurationin classTinyNodeImpl- Returns:
- the Configuration
-
setSystemId
public void setSystemId(java.lang.String uri)
Set the system id of this node- Specified by:
setSystemIdin interfacejavax.xml.transform.Source- Overrides:
setSystemIdin classTinyNodeImpl
-
getSystemId
public java.lang.String getSystemId()
Get the system id of this root node- Specified by:
getSystemIdin interfaceNodeInfo- Specified by:
getSystemIdin interfacejavax.xml.transform.Source- Specified by:
getSystemIdin interfacejavax.xml.transform.SourceLocator- Overrides:
getSystemIdin classTinyNodeImpl- Returns:
- the System Identifier of the entity in the source document containing the node, or null if not known or not applicable.
-
setBaseURI
public void setBaseURI(java.lang.String uri)
Set the base URI of this document node
-
getBaseURI
public java.lang.String getBaseURI()
Get the base URI of this root node.- Specified by:
getBaseURIin interfaceNodeInfo- Overrides:
getBaseURIin classTinyNodeImpl- Returns:
- the base URI of the node. This may be null if the base URI is unknown.
-
getLineNumber
public int getLineNumber()
Get the line number of this root node.- Specified by:
getLineNumberin interfaceNodeInfo- Specified by:
getLineNumberin interfacejavax.xml.transform.SourceLocator- Overrides:
getLineNumberin classTinyNodeImpl- Returns:
- 0 always
-
getNodeKind
public final int getNodeKind()
Return the type of node.- Specified by:
getNodeKindin interfaceNodeInfo- Returns:
- Type.DOCUMENT (always)
- See Also:
Type
-
getParent
public NodeInfo getParent()
Find the parent node of this node.- Specified by:
getParentin interfaceNodeInfo- Overrides:
getParentin classTinyNodeImpl- Returns:
- The Node object describing the containing element or root node.
-
getRoot
public NodeInfo getRoot()
Get the root node- Specified by:
getRootin interfaceNodeInfo- Overrides:
getRootin classTinyNodeImpl- 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:
getDocumentRootin interfaceNodeInfo- Overrides:
getDocumentRootin classTinyNodeImpl- Returns:
- the DocumentInfo representing the document node, or null if the root of the tree is not a document node
-
generateId
public void generateId(FastStringBuffer buffer)
Get a character string that uniquely identifies this node- Specified by:
generateIdin interfaceNodeInfo- Overrides:
generateIdin classTinyNodeImpl- Parameters:
buffer- to contain an identifier based on the document number
-
selectID
public NodeInfo selectID(java.lang.String id)
Get the element with a given ID.- Specified by:
selectIDin interfaceDocumentInfo- 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.
-
getUnparsedEntityNames
public java.util.Iterator getUnparsedEntityNames()
Get the list of unparsed entities defined in this document- Specified by:
getUnparsedEntityNamesin interfaceDocumentInfo- Returns:
- an Iterator, whose items are of type String, containing the names of all unparsed entities defined in this document. If there are no unparsed entities or if the information is not available then an empty iterator is returned
-
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:
getUnparsedEntityin interfaceDocumentInfo- 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
-
copy
public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId) throws XPathException
Copy this node to a given outputter- Specified by:
copyin interfaceNodeInfo- Parameters:
out- the Receiver to which the node should be copied. It is the caller's responsibility to ensure that this Receiver is open before the method is called (or that it is self-opening), and that it is closed after use.whichNamespaces- in the case of an element, controls which namespace nodes should be copied. Values areNodeInfo.NO_NAMESPACES,NodeInfo.LOCAL_NAMESPACES,NodeInfo.ALL_NAMESPACEScopyAnnotations- indicates whether the type annotations of element and attribute nodes should be copiedlocationId- If non-zero, identifies the location of the instruction that requested this copy. If zero, indicates that the location information for the original node is to be copied; in this case the Receiver must be a LocationCopier- Throws:
XPathException
-
showSize
public void showSize()
-
hasChildNodes
public final boolean hasChildNodes()
Determine if the node has children.- Specified by:
hasChildNodesin interfaceNodeInfo- Overrides:
hasChildNodesin classTinyNodeImpl- Returns:
trueif this node has any attributes,falseotherwise.
-
getStringValue
public final 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.
- See Also:
Item.getStringValueCS()
-
getStringValueCS
public java.lang.CharSequence getStringValueCS()
Get the value of the item as a CharSequence. This is in some cases more efficient than the version of the method that returns a String.- Specified by:
getStringValueCSin interfaceItem- Specified by:
getStringValueCSin interfaceValueRepresentation- Overrides:
getStringValueCSin classTinyNodeImpl- Returns:
- the string value of the item
- See Also:
Item.getStringValue()
-
getStringValue
public static java.lang.CharSequence getStringValue(TinyTree tree, int nodeNr)
Get the string value of a node. This static method allows the string value of a node to be obtained without instantiating the node as a Java object. The method also returns a CharSequence rather than a string, which means it can sometimes avoid copying the data.- Parameters:
tree- The containing documentnodeNr- identifies the node whose string value is required. This must be a document or element node. The caller is trusted to ensure this.- Returns:
- the string value of the node, as a CharSequence
-
-