Class LazyString
- All Implemented Interfaces:
GroundedValue,Sequence
item instanceof AtomicValue will always be true if item
is atomic.
The class is currently used for the stack trace property in the map available in a catch block. This computed lazily because it's potentially a large string and expensive to construct, and it's likely that most catch blocks aren't interested in it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGet the size of the value (the number of items in the value, considered as a sequence)Get the string value of this sequence, as an instance ofString.Get the string value of this sequence, as an instance ofUnicodeString.head()Get the first item of the sequence.itemAt(int n) Get the n'th item in the value, counting from zero (0)iterate()Get an iterator over all the items in the sequence.subsequence(int start, int length) Get a subsequence of the valueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, effectiveBooleanValue, materialize, reduce, toShortStringMethods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Constructor Details
-
LazyString
-
-
Method Details
-
iterate
Get an iterator over all the items in the sequence. This differs from the superclass method in not allowing an exception, either during this method call, or in the subsequent processing of the returned iterator.- Specified by:
iteratein interfaceGroundedValue- Specified by:
iteratein interfaceSequence- Returns:
- an iterator (meaning a Saxon
SequenceIteratorrather than a JavaIterator) over all the items in this Sequence.
-
itemAt
Get the n'th item in the value, counting from zero (0)- Specified by:
itemAtin interfaceGroundedValue- Parameters:
n- the index of the required item, with zero (0) representing the first item in the sequence- Returns:
- the n'th item if it exists, or null if the requested position is out of range
-
head
Get the first item of the sequence. This differs from the parent interface in not allowing an exception- Specified by:
headin interfaceGroundedValue- Specified by:
headin interfaceSequence- Returns:
- the first item of the sequence, or null if the sequence is empty
-
subsequence
Get a subsequence of the value- Specified by:
subsequencein interfaceGroundedValue- Parameters:
start- the index of the first item to be included in the result, counting from zero. A negative value is taken as zero. If the value is beyond the end of the sequence, an empty sequence is returnedlength- the number of items to be included in the result. Specify Integer.MAX_VALUE to get the subsequence up to the end of the base sequence. If the value is negative, an empty sequence is returned. If the length goes off the end of the sequence, the result returns items up to the end of the sequence- Returns:
- the required subsequence.
-
getLength
public int getLength()Get the size of the value (the number of items in the value, considered as a sequence)- Specified by:
getLengthin interfaceGroundedValue- Returns:
- the number of items in the sequence. Note that for a single item, including a map or array, the result is always 1 (one).
-
getUnicodeStringValue
Get the string value of this sequence, as an instance ofUnicodeString. The string value of an item is the result of applying the XPath string() function. The string value of a sequence is the space-separated result of applying the string-join() function using a single space as the separatorThe result of this method is always equivalent to the result of the
getStringValue()method. Use this method in preference either (a) if you need to use the value in a context where aUnicodeStringis required, or (b) if the underlying value is held as aUnicodeString, or in a form that is readily converted to aUnicodeString. This is typically the case (i) when the value is a text or element node in a TinyTree, and (ii) when the value is aStringItem: that is, an atomic value of typexs:string.- Specified by:
getUnicodeStringValuein interfaceGroundedValue- Returns:
- the string value of the sequence.
- Throws:
XPathException- if the sequence contains items that have no string value (for example, function items)
-
getStringValue
Get the string value of this sequence, as an instance ofString. The string value of an item is the result of applying the XPath string() function. The string value of a sequence is the space-separated result of applying the string-join() function using a single space as the separator.The result of this method is always equivalent to the result of the
getUnicodeStringValue()method. Use this method in preference either (a) if you need to use the value in a context where aStringis required, or (b) if the underlying value is held as aString, or in a form that is readily converted to aString. This is typically the case (i) when the value is an attribute node in a TinyTree, or (ii) any kind of node in a third-party tree model such as DOM.- Specified by:
getStringValuein interfaceGroundedValue- Returns:
- the string value of the sequence.
- Throws:
XPathException- if the sequence contains items that have no string value (for example, function items)
-