Class WhitespaceTextImpl

java.lang.Object
net.sf.saxon.tree.tiny.TinyNodeImpl
net.sf.saxon.tree.tiny.WhitespaceTextImpl
All Implemented Interfaces:
Source, SourceLocator, PullEvent, FingerprintedNode, Item<NodeInfo>, NodeInfo, ValueRepresentation<NodeInfo>

public final class WhitespaceTextImpl extends TinyNodeImpl
A node in the XML parse tree representing a text node with compressed whitespace content
Author:
Michael H. Kay
  • Constructor Details

    • WhitespaceTextImpl

      public WhitespaceTextImpl(TinyTree tree, int nodeNr)
      Create a compressed whitespace text node
      Parameters:
      tree - the tree to contain the node
      nodeNr - the internal node number
  • Method Details

    • getStringValue

      public String getStringValue()
      Return the character value of the node.
      Returns:
      the string value of the node
      See Also:
    • getStringValueCS

      public 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. For a WhitespaceTextImpl node, it avoids the cost of decompressing the whitespace
      Specified by:
      getStringValueCS in interface Item<NodeInfo>
      Specified by:
      getStringValueCS in interface ValueRepresentation<NodeInfo>
      Overrides:
      getStringValueCS in class TinyNodeImpl
      Returns:
      the string value of the item
      See Also:
    • getStringValueCS

      public static CharSequence getStringValueCS(TinyTree tree, int nodeNr)
      Static method to get the string value of a text node without first constructing the node object
      Parameters:
      tree - the tree
      nodeNr - the node number of the text node
      Returns:
      the string value of the text node
    • appendStringValue

      public static void appendStringValue(TinyTree tree, int nodeNr, FastStringBuffer buffer)
      Static method to get the string value of a text node and append it to a supplied buffer without first constructing the node object
      Parameters:
      tree - the tree
      nodeNr - the node number of the text node
      buffer - a buffer to which the string value will be appended
    • 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.
      Returns:
      the typed value. This will either be a single AtomicValue or a Value whose items are atomic values.
      Throws:
      XPathException - if the node has no typed value, for example if it is an element node with element-only content
      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.

      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
    • getLongValue

      public static long getLongValue(TinyTree tree, int nodeNr)
      Static method to get the "long" value representing the content of a whitespace text node
      Parameters:
      tree - the TinyTree
      nodeNr - the internal node number
      Returns:
      a value representing the compressed whitespace content
      See Also:
    • getNodeKind

      public final int getNodeKind()
      Return the type of node.
      Returns:
      Type.TEXT
      See Also:
    • copy

      public void copy(Receiver out, int copyOptions, int locationId) throws XPathException
      Copy this node to a given outputter
      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 - if any downstream error occurs