Package net.sf.saxon.om
Class ZeroOrMore<T extends Item>
java.lang.Object
net.sf.saxon.om.ZeroOrMore<T>
- All Implemented Interfaces:
Iterable<T>,GroundedValue,Sequence
A value that is a sequence containing one or more items. The main use is in declarations of reflexive extension
functions, where declaring an argument of type <ZeroOrMore<IntegerValue>> triggers automatic type
checking in the same way as for a native XSLT/XQuery function declaring the type as xs:integer*.
-
Constructor Summary
ConstructorsConstructorDescriptionZeroOrMore(List<T> content) ZeroOrMore(SequenceIterator iter) ZeroOrMore(T[] content) Create a sequence containing zero or one items -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet the effective boolean value of this sequenceintGet the size of the value (the number of items)Get the string value of this sequence.Get the string value of this sequence.head()Get the first item of the sequence.itemAt(int n) Get the n'th item in the value, counting from 0iterate()Get an iterator over all the items in the sequence.iterator()reduce()Reduce the sequence to its simplest form.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, materialize, toShortStringMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Constructor Details
-
ZeroOrMore
Create a sequence containing zero or one items- Parameters:
content- The content of the sequence
-
ZeroOrMore
-
ZeroOrMore
- Throws:
XPathException
-
-
Method Details
-
head
Description copied from interface:GroundedValueGet 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
-
iterate
Description copied from interface:GroundedValueGet 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.
-
iterator
-
itemAt
Get the n'th item in the value, counting from 0- Specified by:
itemAtin interfaceGroundedValue- Parameters:
n- the index of the required item, with 0 representing the first item in the sequence- Returns:
- the n'th item if it exists, or null otherwise
-
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 value 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)- Specified by:
getLengthin interfaceGroundedValue- Returns:
- the number of items in the sequence
-
effectiveBooleanValue
Get the effective boolean value of this sequence- Specified by:
effectiveBooleanValuein interfaceGroundedValue- Returns:
- the effective boolean value
- Throws:
XPathException- if the sequence has no effective boolean value (for example a sequence of two integers)
-
getStringValue
Get the string value of this sequence. The string value of an item is the result of applying the 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- 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)
-
getStringValueCS
Get the string value of this sequence. The string value of an item is the result of applying the 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- Specified by:
getStringValueCSin interfaceGroundedValue- Returns:
- the string value of the sequence.
- Throws:
XPathException- if the sequence contains items that have no string value (for example, function items)
-
reduce
Reduce the sequence to its simplest form. If the value is an empty sequence, the result will be EmptySequence.getInstance(). If the value is a single atomic value, the result will be an instance ofAtomicValue. If the value is a single item of any other kind, the result will be an instance ofOne. Otherwise, the result will typically be unchanged.- Specified by:
reducein interfaceGroundedValue- Returns:
- the simplified sequence
-