T
- (inherited from Sequence): the type of items that can exist in the sequence.
This is a bit of a curiosity because the only item that can exist
in a singleton sequence is the item itself. This leads to some strange abuses
of the Java generics mechanisms.public interface Item<T extends Item<?>> extends GroundedValue<T>
This interface is part of the public Saxon API. As such (starting from Saxon 8.4), methods that form part of the stable API are labelled with a JavaDoc "since" tag to identify the Saxon release at which they were introduced.
Note: there is no method getItemType(). This is to avoid having to implement it on every implementation of NodeInfo. Instead, use the static method Type.getItemType(Item).
Modifier and Type | Method and Description |
---|---|
AtomicSequence |
atomize()
Atomize the item.
|
Genre |
getGenre()
Get the genre of this item (to distinguish the top-level categories of item,
such as nodes, atomic values, and functions)
|
default int |
getLength()
Get the size of the value (the number of items)
|
java.lang.String |
getStringValue()
Get the value of the item as a string.
|
java.lang.CharSequence |
getStringValueCS()
Get the string value of the item as a CharSequence.
|
default T |
head()
Get the first item in the sequence.
|
default boolean |
isStreamed()
Ask whether this is a node in a streamed document
|
default T |
itemAt(int n)
Get the n'th item in the value, counting from 0
|
default UnfailingIterator<T> |
iterate()
Get an iterator over all the items in the sequence
|
default java.util.Iterator<T> |
iterator()
Get the contents of this value in the form of a Java
Iterator ,
so that the sequence value can be used in a for-each expression |
default GroundedValue<T> |
reduce()
Reduce the sequence to its simplest form.
|
default GroundedValue<T> |
subsequence(int start,
int length)
Get a subsequence of the value
|
static <T extends Item<?>> |
toGroundedValue(Item<T> item) |
default java.lang.String |
toShortString()
Provide a short string showing the contents of the item, suitable
for use in error messages
|
asIterable, effectiveBooleanValue, materialize
makeRepeatable
Genre getGenre()
default T head()
Sequence
in that
* no exception is thrown.java.lang.String getStringValue()
If the calling code can handle any CharSequence, the method getStringValueCS()
should
be used. If the caller requires a string, this method is preferred.
getStringValue
in interface GroundedValue<T extends Item<?>>
java.lang.UnsupportedOperationException
- if the item is a function item (an unchecked exception
is used here to avoid introducing exception handling to a large number of paths where it is not
needed)getStringValueCS()
java.lang.CharSequence getStringValueCS()
X.getStringValueCS().toString()
returns a string that is equal to
X.getStringValue()
.
Note that two CharSequence values of different types should not be compared using equals(), and for the same reason they should not be used as a key in a hash table.
If the calling code can handle any CharSequence, this method should
be used. If the caller requires a string, the getStringValue()
method is preferred.
getStringValueCS
in interface GroundedValue<T extends Item<?>>
java.lang.UnsupportedOperationException
- if the item is a function item (an unchecked exception
is used here to avoid introducing exception handling to a large number of paths where it is not
needed)getStringValue()
AtomicSequence atomize() throws XPathException
XPathException
- if atomization is not allowed
for this kind of itemdefault java.lang.String toShortString()
toShortString
in interface GroundedValue<T extends Item<?>>
default java.util.Iterator<T> iterator()
Iterator
,
so that the sequence value can be used in a for-each expressiondefault T itemAt(int n)
itemAt
in interface GroundedValue<T extends Item<?>>
n
- the index of the required item, with 0 representing the first item in the sequencedefault GroundedValue<T> subsequence(int start, int length)
subsequence
in interface GroundedValue<T extends Item<?>>
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 sequencedefault int getLength()
getLength
in interface GroundedValue<T extends Item<?>>
default UnfailingIterator<T> iterate()
default GroundedValue<T> reduce()
reduce
in interface GroundedValue<T extends Item<?>>
static <T extends Item<?>> GroundedValue<T> toGroundedValue(Item<T> item)
default boolean isStreamed()
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.