net.sf.saxon.value
Class TextFragmentValue

java.lang.Object
  extended by net.sf.saxon.om.AbstractNode
      extended by net.sf.saxon.value.TextFragmentValue
All Implemented Interfaces:
DOMLocator, Source, SourceLocator, DocumentInfo, Item, NodeInfo, Node

public final class TextFragmentValue
extends AbstractNode
implements DocumentInfo

This class represents a temporary tree whose root document node owns a single text node.


Field Summary
 
Fields inherited from class net.sf.saxon.om.AbstractNode
NODE_LETTER
 
Fields inherited from interface net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, LOCAL_NAMESPACES, NO_NAMESPACES
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
TextFragmentValue(String value, String systemId)
          Constructor: create a result tree fragment containing a single text node
 
Method Summary
 int compareOrder(NodeInfo other)
          Determine the relative position of this node and another node, in document order.
 void copy(Receiver out, int whichNamespaces, boolean copyAnnotations)
          Copy the result tree fragment value to a given Outputter
 String generateId()
          Get a character string that uniquely identifies this node
 String getAttributeValue(int fingerprint)
          Get the value of a given attribute of this node
 String getBaseURI()
          Get the base URI for the node.
 String getDisplayName()
          Get the display name of this node.
 int getDocumentNumber()
          Get the unique document number
 DocumentInfo getDocumentRoot()
          Get the root (document) node
 int getFingerprint()
          Get the fingerprint of the node, used for matching names
 String getLocalPart()
          Get the local name of this node.
 int getNameCode()
          Get the name code of the node, used for displaying names
 NamePool getNamePool()
          Get the name pool used for the names in this document
 int getNodeKind()
          Return the type of node.
 NodeInfo getParent()
          Find the parent node of this node.
 String getPrefix()
          Get the prefix part of the name of this node.
 NodeInfo getRoot()
          Get the root node
 String getStringValue()
          Get the String Value
 String getSystemId()
          Get the system ID for the entity containing the node.
 String[] getUnparsedEntity(String name)
          Get the unparsed entity with a given name
 String getURI()
          Get the URI part of the name of this node.
 boolean hasAttributes()
          Returns whether this node has any attributes.
 boolean hasChildNodes()
          Determine whether the node has any children.
 boolean isSameNode(NodeInfo other)
          Determine whether this is the same node as another node
 AxisIterator iterateAxis(byte axisNumber)
          Return an iteration over the nodes reached by the given axis from this node
 AxisIterator iterateAxis(byte axisNumber, NodeTest nodeTest)
          Return an enumeration over the nodes reached by the given axis from this node
 NodeInfo selectID(String id)
          Get the element with a given ID.
 void setNamePool(NamePool pool)
          Set the name pool used for all names in this document (actually, there aren't any, but we have to support the DocumentInfo interface...
 void setSystemId(String systemId)
          Set the system ID for the entity containing the node.
 
Methods inherited from class net.sf.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, getLineNumber, getLocalName, getName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOriginatingNode, getOwnerDocument, getOwnerElement, getParentNode, getPreviousSibling, getPublicId, getSpecified, getTagName, getTypeAnnotation, getTypedValue, getValue, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isSupported, normalize, outputNamespaceNodes, 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 net.sf.saxon.om.NodeInfo
getLineNumber, getTypeAnnotation, outputNamespaceNodes
 
Methods inherited from interface net.sf.saxon.om.Item
getTypedValue
 
Methods inherited from interface org.w3c.dom.Node
compareDocumentPosition, getFeature, getTextContent, getUserData, isDefaultNamespace, isEqualNode, isSameNode, lookupNamespaceURI, lookupPrefix, setTextContent, setUserData
 

Constructor Detail

TextFragmentValue

public TextFragmentValue(String value,
                         String systemId)
Constructor: create a result tree fragment containing a single text node

Parameters:
value: - a String containing the value
Method Detail

setNamePool

public void setNamePool(NamePool pool)
Set the name pool used for all names in this document (actually, there aren't any, but we have to support the DocumentInfo interface...

Specified by:
setNamePool in interface DocumentInfo
Parameters:
pool - The name pool to be used

getNamePool

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

Specified by:
getNamePool in interface DocumentInfo
Specified by:
getNamePool in interface NodeInfo
Returns:
the name pool in which all the names used in this document are registered

getDocumentNumber

public int getDocumentNumber()
Get the unique document number

Specified by:
getDocumentNumber in interface DocumentInfo
Specified by:
getDocumentNumber in interface NodeInfo
Overrides:
getDocumentNumber in class AbstractNode
Returns:
the unique number identifying this document within the name pool

getNodeKind

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

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

getStringValue

public String getStringValue()
Get the String Value

Specified by:
getStringValue in interface Item
Specified by:
getStringValue in interface NodeInfo
Specified by:
getStringValue in class AbstractNode
Returns:
the string value of the item

isSameNode

public boolean isSameNode(NodeInfo other)
Determine whether this is the same node as another node

Specified by:
isSameNode in interface NodeInfo
Specified by:
isSameNode in class AbstractNode
Parameters:
other - the node to be compared with this node
Returns:
true if this Node object and the supplied Node object represent the same node in the tree.

generateId

public String generateId()
Get a character string that uniquely identifies this node

Specified by:
generateId in interface NodeInfo
Specified by:
generateId in class AbstractNode
Returns:
a string.

setSystemId

public void setSystemId(String systemId)
Set the system ID for the entity containing the node.

Specified by:
setSystemId in interface Source

getSystemId

public String getSystemId()
Get the system ID for the entity containing the node.

Specified by:
getSystemId in interface Source
Specified by:
getSystemId in interface SourceLocator
Specified by:
getSystemId in interface NodeInfo
Specified by:
getSystemId in class AbstractNode
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 String getBaseURI()
Get the base URI for the node. Default implementation for child nodes gets the base URI of the parent node.

Specified by:
getBaseURI in interface NodeInfo
Specified by:
getBaseURI in interface Node
Specified by:
getBaseURI in class AbstractNode
Returns:
the base URI of the node

compareOrder

public int compareOrder(NodeInfo other)
Determine the relative position of this node and another node, in document order. The other node will always be in the same document.

Specified by:
compareOrder in interface NodeInfo
Specified by:
compareOrder in class AbstractNode
Parameters:
other - The other node, whose position is to be compared with this node
Returns:
-1 if this node precedes the other node, +1 if it follows the other node, or 0 if they are the same node. (In this case, isSameNode() will always return true, and the two nodes will produce the same result for generateId())

getNameCode

public int getNameCode()
Get the name code of the node, used for displaying names

Specified by:
getNameCode in interface NodeInfo
Specified by:
getNameCode in class AbstractNode
Returns:
an integer name code, which may be used to obtain the actual node name from the name pool
See Also:
allocate, getFingerprint

getFingerprint

public int getFingerprint()
Get the fingerprint of the node, used for matching names

Specified by:
getFingerprint in interface NodeInfo
Specified by:
getFingerprint in class AbstractNode
Returns:
an integer fingerprint; two nodes with the same fingerprint have the same expanded QName

getPrefix

public String getPrefix()
Get the prefix part of the name of this node. This is the name before the ":" if any.

Specified by:
getPrefix in interface Node
Returns:
the prefix part of the name. For an unnamed node, return "".

getURI

public String getURI()
Get the URI part of the name of this node. This is the URI corresponding to the prefix, or the URI of the default namespace if appropriate.

Specified by:
getURI in interface NodeInfo
Specified by:
getURI in class AbstractNode
Returns:
The URI of the namespace of this node. For an unnamed node, or for an element or attribute in the default namespace, return an empty string.

getDisplayName

public String getDisplayName()
Get the display name of this node. For elements and attributes this is [prefix:]localname. For unnamed nodes, it is an empty string.

Specified by:
getDisplayName in interface NodeInfo
Overrides:
getDisplayName in class AbstractNode
Returns:
The display name of this node. For a node with no name, return an empty string.

getLocalPart

public String getLocalPart()
Get the local name of this node.

Specified by:
getLocalPart in interface NodeInfo
Specified by:
getLocalPart in class AbstractNode
Returns:
The local name of this node. For a node with no name, return "".

hasChildNodes

public boolean hasChildNodes()
Determine whether the node has any children.

Specified by:
hasChildNodes in interface NodeInfo
Specified by:
hasChildNodes in interface Node
Specified by:
hasChildNodes in class AbstractNode
Returns:
true if this node has any attributes, false otherwise.

hasAttributes

public boolean hasAttributes()
Returns whether this node has any attributes.

Specified by:
hasAttributes in interface Node
Specified by:
hasAttributes in class AbstractNode
Returns:
true if this node has any attributes, false otherwise.
Since:
DOM Level 2

getAttributeValue

public String getAttributeValue(int fingerprint)
Get the value of a given attribute of this node

Specified by:
getAttributeValue in interface NodeInfo
Specified by:
getAttributeValue in class AbstractNode
Parameters:
fingerprint - The fingerprint of the attribute name
Returns:
the attribute value if it exists or null if not

iterateAxis

public AxisIterator iterateAxis(byte axisNumber)
Return an iteration over the nodes reached by the given axis from this node

Specified by:
iterateAxis in interface NodeInfo
Parameters:
axisNumber - The axis to be iterated over
Returns:
a AxisIterator that scans the nodes reached by the axis in turn.
See Also:
Axis

iterateAxis

public AxisIterator iterateAxis(byte axisNumber,
                                NodeTest nodeTest)
Return an enumeration over the nodes reached by the given axis from this node

Specified by:
iterateAxis in interface NodeInfo
Specified by:
iterateAxis in class AbstractNode
Parameters:
axisNumber - The axis to be iterated over
nodeTest - A pattern to be matched by the returned nodes
Returns:
a AxisIterator that scans the nodes reached by the axis in turn.
See Also:
Axis

getParent

public NodeInfo getParent()
Find the parent node of this node.

Specified by:
getParent in interface NodeInfo
Specified by:
getParent in class AbstractNode
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 AbstractNode
Returns:
the NodeInfo representing the root of this tree

getDocumentRoot

public DocumentInfo getDocumentRoot()
Get the root (document) node

Specified by:
getDocumentRoot in interface NodeInfo
Overrides:
getDocumentRoot in class AbstractNode
Returns:
the DocumentInfo representing the containing document

copy

public void copy(Receiver out,
                 int whichNamespaces,
                 boolean copyAnnotations)
          throws TransformerException
Copy the result tree fragment value to a given Outputter

Specified by:
copy in interface NodeInfo
Parameters:
out - the Receiver to which the node should be copied
whichNamespaces - in the case of an element, controls which namespace nodes should be copied. Values are NO_NAMESPACES, LOCAL_NAMESPACES, ALL_NAMESPACES
copyAnnotations - indicates whether the type annotations of element and attribute nodes should be copied
Throws:
TransformerException

selectID

public NodeInfo selectID(String id)
Get the element with a given ID.

Specified by:
selectID in interface DocumentInfo
Parameters:
id - The unique ID of the required element
Returns:
null (this kind of tree contains no elements)

getUnparsedEntity

public String[] getUnparsedEntity(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 and public ID of the entity if there is one, or null if not