T - The type of items delivered by the stream.public class XdmStream<T extends XdmItem> extends Object implements Stream<T>
Stream.
The extensions are:
List<XdmNode> or
an Optional<XdmNode> more conveniently than using the general-purpose
Collector interface.The implementation is customized to streams of XdmItems.
Stream.Builder<T>| Constructor and Description |
|---|
XdmStream(Optional<T> input)
Create an
XdmStream consisting of zero or one items, supplied in the form
of an Optional<XdmItem> |
XdmStream(Stream<T> base)
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
allMatch(Predicate<? super T> predicate) |
boolean |
anyMatch(Predicate<? super T> predicate) |
XdmAtomicValue |
asAtomic()
Return the result of the stream as an
XdmAtomicValue. |
List<T> |
asList()
Return the result of the stream as a
List<XdmItem>. |
List<XdmAtomicValue> |
asListOfAtomic()
Return the result of the stream as a
List<XdmAtomicValue>. |
List<XdmNode> |
asListOfNodes()
Return the result of the stream as a
List<XdmNode>. |
XdmNode |
asNode()
Return the result of the stream as an
XdmNode. |
Optional<XdmAtomicValue> |
asOptionalAtomic()
Return the result of the stream as an
Optional<XdmAtomicValue>. |
Optional<XdmNode> |
asOptionalNode()
Return the result of the stream as an
Optional<XdmNode>. |
Optional<String> |
asOptionalString()
Return the result of the stream as an
Optional<String>. |
String |
asString()
Return the result of the stream as an
String. |
XdmValue |
asXdmValue()
Return the result of the stream as an XdmValue.
|
Optional<T> |
at(int position)
Return the item at a given position in the stream.
|
void |
close() |
<R,A> R |
collect(Collector<? super T,A,R> collector) |
<R> R |
collect(Supplier<R> supplier,
BiConsumer<R,? super T> accumulator,
BiConsumer<R,R> combiner) |
long |
count() |
XdmStream<T> |
distinct() |
boolean |
exists()
Return true if the stream is non-empty.
|
XdmStream<T> |
filter(Predicate<? super T> predicate)
Filter a stream of items, to create a new stream containing only those items
that satisfy a supplied condition
|
Optional<T> |
findAny() |
Optional<T> |
findFirst() |
XdmStream<T> |
first()
Return the first item of this stream, if there is one, discarding the remainder.
|
<R> Stream<R> |
flatMap(Function<? super T,? extends Stream<? extends R>> mapper) |
DoubleStream |
flatMapToDouble(Function<? super T,? extends DoubleStream> mapper) |
IntStream |
flatMapToInt(Function<? super T,? extends IntStream> mapper) |
LongStream |
flatMapToLong(Function<? super T,? extends LongStream> mapper) |
<U extends XdmItem> |
flatMapToXdm(Step<U> mapper)
|
void |
forEach(Consumer<? super T> action) |
void |
forEachOrdered(Consumer<? super T> action) |
boolean |
isParallel() |
Iterator<T> |
iterator() |
XdmStream<T> |
last()
Return the last item of this stream, if there is one, discarding the remainder.
|
XdmStream<T> |
limit(long maxSize) |
<R> Stream<R> |
map(Function<? super T,? extends R> mapper) |
DoubleStream |
mapToDouble(ToDoubleFunction<? super T> mapper) |
IntStream |
mapToInt(ToIntFunction<? super T> mapper) |
LongStream |
mapToLong(ToLongFunction<? super T> mapper) |
Optional<T> |
max(Comparator<? super T> comparator) |
Optional<T> |
min(Comparator<? super T> comparator) |
boolean |
noneMatch(Predicate<? super T> predicate) |
Stream<T> |
onClose(Runnable closeHandler) |
Stream<T> |
parallel() |
XdmStream<T> |
peek(Consumer<? super T> action) |
Optional<T> |
reduce(BinaryOperator<T> accumulator) |
T |
reduce(T identity,
BinaryOperator<T> accumulator) |
<U> U |
reduce(U identity,
BiFunction<U,? super T,U> accumulator,
BinaryOperator<U> combiner) |
Stream<T> |
sequential() |
XdmStream<T> |
skip(long n) |
XdmStream<T> |
sorted() |
XdmStream<T> |
sorted(Comparator<? super T> comparator) |
Spliterator<T> |
spliterator() |
XdmStream<T> |
subStream(int start,
int end)
Return the items at a given range of positions in the stream.
|
Object[] |
toArray() |
<A> A[] |
toArray(IntFunction<A[]> generator) |
Stream<T> |
unordered() |
XdmStream<T> |
untilFirstExclusive(Predicate<? super XdmItem> predicate)
Experimental method to return the content of a stream up to the first item
that satisfies a given predicate, excluding that item
|
XdmStream<T> |
untilFirstInclusive(Predicate<? super XdmItem> predicate)
Experimental method to return the content of a stream up to the first item
that satisfies a given predicate, including that item
|
public XdmStream<T> filter(Predicate<? super T> predicate)
public IntStream mapToInt(ToIntFunction<? super T> mapper)
public LongStream mapToLong(ToLongFunction<? super T> mapper)
public DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper)
mapToDouble in interface Stream<T extends XdmItem>public <U extends XdmItem> XdmStream<U> flatMapToXdm(Step<U> mapper)
XdmStream by applying a mapping function (specifically, a Step)
to each item in the stream. The Step returns a sequence of items, which are inserted
into the result sequence in place of the original item.U - the type of items returned by the mapping functionmapper - the mapping functionpublic IntStream flatMapToInt(Function<? super T,? extends IntStream> mapper)
flatMapToInt in interface Stream<T extends XdmItem>public LongStream flatMapToLong(Function<? super T,? extends LongStream> mapper)
flatMapToLong in interface Stream<T extends XdmItem>public DoubleStream flatMapToDouble(Function<? super T,? extends DoubleStream> mapper)
flatMapToDouble in interface Stream<T extends XdmItem>public XdmStream<T> sorted(Comparator<? super T> comparator)
public void forEachOrdered(Consumer<? super T> action)
forEachOrdered in interface Stream<T extends XdmItem>public <A> A[] toArray(IntFunction<A[]> generator)
public T reduce(T identity, BinaryOperator<T> accumulator)
public Optional<T> reduce(BinaryOperator<T> accumulator)
public <U> U reduce(U identity,
BiFunction<U,? super T,U> accumulator,
BinaryOperator<U> combiner)
public <R> R collect(Supplier<R> supplier, BiConsumer<R,? super T> accumulator, BiConsumer<R,R> combiner)
public Optional<T> min(Comparator<? super T> comparator)
public Optional<T> max(Comparator<? super T> comparator)
public Spliterator<T> spliterator()
spliterator in interface BaseStream<T extends XdmItem,Stream<T extends XdmItem>>public boolean isParallel()
isParallel in interface BaseStream<T extends XdmItem,Stream<T extends XdmItem>>public Stream<T> sequential()
sequential in interface BaseStream<T extends XdmItem,Stream<T extends XdmItem>>public void close()
close in interface AutoCloseableclose in interface BaseStream<T extends XdmItem,Stream<T extends XdmItem>>public XdmValue asXdmValue()
public List<T> asList()
List<XdmItem>. This is a terminal operation.List<XdmItem>.public List<XdmNode> asListOfNodes()
List<XdmNode>. This is a terminal operation.ClassCastException - if the stream contains an item that is not a nodepublic Optional<XdmNode> asOptionalNode()
Optional<XdmNode>. This is a terminal operation.XdmCollectors.MultipleItemException - if the stream contains more than one nodeClassCastException - if the stream contains an item that is not a nodepublic XdmNode asNode()
XdmNode. This is a terminal operation.ClassCastException - if the stream contains an item that is not a nodeXdmCollectors.MultipleItemException - if the stream contains
more than one itemNoSuchElementException - if the stream is emptypublic List<XdmAtomicValue> asListOfAtomic()
List<XdmAtomicValue>. This is a terminal operation.ClassCastException - if the stream contains an item that is not an atomic valuepublic Optional<XdmAtomicValue> asOptionalAtomic()
Optional<XdmAtomicValue>. This is a terminal operation.XdmCollectors.MultipleItemException - if the stream contains more than one itemClassCastException - if the stream contains an item that is not an atomic valuepublic XdmAtomicValue asAtomic()
XdmAtomicValue. This is a terminal operation.ClassCastException - if the stream contains an item that is not atomicXdmCollectors.MultipleItemException - if the stream contains more than one itemNoSuchElementException - if the stream is emptypublic Optional<String> asOptionalString()
Optional<String>. This is a terminal operation.XdmCollectors.MultipleItemException - if the stream contains more than one itemUnsupportedOperationException - if the stream contains an item that has no string value,
for example a function itempublic String asString()
String. This is a terminal operation.UnsupportedOperationException - if the stream contains an item that has no string value,
for example a function itemXdmCollectors.MultipleItemException - if the stream contains more than one itemNoSuchElementException - if the stream is emptypublic XdmStream<T> first()
findFirst(), but it returns
XdmStream<T> rather than Optional<T> so that further operations such
as atomize() can be applied, and so that a typed result can be returned
using a method such as asOptionalNode() or asOptionalString()public boolean exists()
public XdmStream<T> last()
first(); it returns
XdmStream<T> rather than Optional<T> so that further operations such
atomize() can be applied, and so that a typed result can be returned
using a method such as asOptionalNode() or asOptionalString()public Optional<T> at(int position)
position - the required position; items in the stream are numbered from zero.Optional.empty()public XdmStream<T> subStream(int start, int end)
start - the position of the first required item; items in the stream are numbered from zero.end - the position immediately after the last required item.public XdmStream<T> untilFirstInclusive(Predicate<? super XdmItem> predicate)
predicate - a condition that determines when the stream should stoppublic XdmStream<T> untilFirstExclusive(Predicate<? super XdmItem> predicate)
predicate - a condition that determines when the stream should stop