net.sf.saxon.tree.tiny
Class TinyDocumentImpl

java.lang.Object
  extended by net.sf.saxon.tree.tiny.TinyNodeImpl
      extended by net.sf.saxon.tree.tiny.TinyParentNodeImpl
          extended by net.sf.saxon.tree.tiny.TinyDocumentImpl
All Implemented Interfaces:
Source, SourceLocator, PullEvent, DocumentInfo, FingerprintedNode, Item, NodeInfo, ValueRepresentation

public final class TinyDocumentImpl
extends TinyParentNodeImpl
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.tree.tiny.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
TinyDocumentImpl(TinyTree tree)
           
 
Method Summary
 Value atomize()
          Get the typed value.
 void copy(Receiver out, int copyOptions, int locationId)
          Copy this node to a given outputter
 void generateId(FastStringBuffer buffer)
          Get a character string that uniquely identifies this node
 String getBaseURI()
          Get the base URI of this root node.
 Configuration getConfiguration()
          Get the configuration previously set using setConfiguration
 DocumentInfo getDocumentRoot()
          Get the root (document) node
 int getLineNumber()
          Get the line number of this root node.
 int getNodeKind()
          Return the type of node.
 NodeInfo getParent()
          Find the parent node of this node.
 NodeInfo getRoot()
          Get the root node
 String getSystemId()
          Get the system id of this root node
 TinyTree getTree()
          Get the tree containing this node
 int getTypeAnnotation()
          Get the type annotation of this node, if any.
 SequenceIterator getTypedValue()
          Get the typed value of the item.
 String[] getUnparsedEntity(String name)
          Get the unparsed entity with a given nameID if there is one, or null if not.
 Iterator<String> getUnparsedEntityNames()
          Get the list of unparsed entities defined in this document
 Object getUserData(String key)
          Get user data held in the document node.
 int hashCode()
          The hashCode() method obeys the contract for hashCode(): that is, if two objects are equal (represent the same node) then they must have the same hashCode()
 NodeInfo selectID(String id, boolean getParent)
          Get the element with a given ID.
 void setBaseURI(String uri)
          Set the base URI of this document node
 void setConfiguration(Configuration config)
          Set the Configuration that contains this document
 void setSystemId(String uri)
          Set the system id of this node
 void setUserData(String key, Object value)
          Set user data on the document node.
 void showSize()
           
 
Methods inherited from class net.sf.saxon.tree.tiny.TinyParentNodeImpl
getStringValue, getStringValueCS, getStringValueCS, hasChildNodes
 
Methods inherited from class net.sf.saxon.tree.tiny.TinyNodeImpl
compareOrder, equals, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getDisplayName, getDocumentNumber, getFingerprint, getLocalPart, getNameCode, getNamePool, getNodeNumber, getPrefix, getPublicId, getSequenceNumber, getURI, 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.NodeInfo
compareOrder, equals, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getDisplayName, getDocumentNumber, getFingerprint, getLocalPart, getNameCode, getNamePool, getPrefix, getStringValue, getURI, hasChildNodes, isId, isIdref, isNilled, isSameNodeInfo, iterateAxis, iterateAxis
 
Methods inherited from interface net.sf.saxon.om.Item
getStringValueCS
 

Constructor Detail

TinyDocumentImpl

public TinyDocumentImpl(TinyTree tree)
Method Detail

getTree

public TinyTree getTree()
Get the tree containing this node

Overrides:
getTree in class TinyNodeImpl
Returns:
the TinyTree. Note that this may also contain other unrelated trees

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:
getConfiguration in interface NodeInfo
Overrides:
getConfiguration in class TinyNodeImpl
Returns:
the Configuration

setSystemId

public void setSystemId(String uri)
Set the system id of this node

Specified by:
setSystemId in interface Source
Overrides:
setSystemId in class TinyNodeImpl

getSystemId

public String getSystemId()
Get the system id of this root node

Specified by:
getSystemId in interface Source
Specified by:
getSystemId in interface SourceLocator
Specified by:
getSystemId in interface NodeInfo
Overrides:
getSystemId in class TinyNodeImpl
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(String uri)
Set the base URI of this document node


getBaseURI

public String getBaseURI()
Get the base URI of this root node.

Specified by:
getBaseURI in interface NodeInfo
Overrides:
getBaseURI in class TinyNodeImpl
Returns:
the base URI of the node. This may be null if the base URI is unknown, including the case where the node has no parent.

getLineNumber

public int getLineNumber()
Get the line number of this root node.

Specified by:
getLineNumber in interface SourceLocator
Specified by:
getLineNumber in interface NodeInfo
Overrides:
getLineNumber in class TinyNodeImpl
Returns:
0 always

getNodeKind

public final int getNodeKind()
Return the type of node.

Specified by:
getNodeKind in interface NodeInfo
Returns:
Type.DOCUMENT (always)
See Also:
Type

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.

getRoot

public NodeInfo getRoot()
Get the root node

Specified by:
getRoot in interface NodeInfo
Overrides:
getRoot in class TinyNodeImpl
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:
getDocumentRoot in interface NodeInfo
Overrides:
getDocumentRoot in class TinyNodeImpl
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:
generateId in interface NodeInfo
Overrides:
generateId in class TinyNodeImpl
Parameters:
buffer - to contain an identifier based on the document number

atomize

public Value atomize()
              throws XPathException
Get the typed value. The result of this method will always be consistent with the method Item.getTypedValue(). However, this method is often more convenient and may be more efficient, especially in the common case where the value is expected to be a singleton.

Specified by:
atomize in interface NodeInfo
Returns:
the typed value. This will either be a single AtomicValue or a Value whose items are atomic values.
Throws:
XPathException
Since:
8.5

getTypedValue

public SequenceIterator getTypedValue()
                               throws XPathException
Get the typed value of the item.

For a node, this is the typed value as defined in the XPath 2.0 data model. Since a node may have a list-valued data type, the typed value is in general a sequence, and it is returned in the form of a SequenceIterator.

If the node has not been validated against a schema, the typed value will be the same as the string value, either as an instance of xs:string or as an instance of xs:untypedAtomic, depending on the node kind.

For an atomic value, this method returns an iterator over a singleton sequence containing the atomic value itself.

Specified by:
getTypedValue in interface Item
Returns:
an iterator over the items in the typed value of the node or atomic value. The items returned by this iterator will always be atomic values.
Throws:
XPathException - where no typed value is available, for example in the case of an element with complex content
Since:
8.4

selectID

public NodeInfo selectID(String id,
                         boolean getParent)
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()
getParent -
Returns:
The NodeInfo (always an Element) for the given ID if one has been registered, otherwise null.

getUnparsedEntityNames

public Iterator<String> getUnparsedEntityNames()
Get the list of unparsed entities defined in this document

Specified by:
getUnparsedEntityNames in interface DocumentInfo
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 String[] getUnparsedEntity(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:
getUnparsedEntity in interface DocumentInfo
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

getTypeAnnotation

public int getTypeAnnotation()
Get the type annotation of this node, if any.

Specified by:
getTypeAnnotation in interface NodeInfo
Overrides:
getTypeAnnotation in class TinyNodeImpl
Returns:
XS_UNTYPED if no validation has been done, XS_ANY_TYPE if the document has been validated

copy

public void copy(Receiver out,
                 int copyOptions,
                 int locationId)
          throws XPathException
Copy this node to a given outputter

Specified by:
copy in interface NodeInfo
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.
copyOptions - a selection of the options defined in CopyOptions
locationId - If non-zero, identifies the location of the instruction that requested this copy. If zero, indicates that the location information
Throws:
XPathException

showSize

public void showSize()

hashCode

public int hashCode()
The hashCode() method obeys the contract for hashCode(): that is, if two objects are equal (represent the same node) then they must have the same hashCode()

Specified by:
hashCode in interface NodeInfo
Overrides:
hashCode in class TinyNodeImpl
Since:
8.7 Previously, the effect of the equals() and hashCode() methods was not defined. Callers should therefore be aware that third party implementations of the NodeInfo interface may not implement the correct semantics.

setUserData

public void setUserData(String key,
                        Object value)
Set user data on the document node. The user data can be retrieved subsequently using getUserData(java.lang.String)

Specified by:
setUserData in interface DocumentInfo
Parameters:
key - A string giving the name of the property to be set. Clients are responsible for choosing a key that is likely to be unique. Must not be null. Keys used internally by Saxon are prefixed "saxon:".
value - The value to be set for the property. May be null, which effectively removes the existing value for the property.

getUserData

public Object getUserData(String key)
Get user data held in the document node. This retrieves properties previously set using setUserData(java.lang.String, java.lang.Object)

Specified by:
getUserData in interface DocumentInfo
Parameters:
key - A string giving the name of the property to be retrieved.
Returns:
the value of the property, or null if the property has not been defined.


Copyright (c) 2004-2010 Saxonica Limited. All rights reserved.