|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jaggregate.CollectionStream<E,ReadOnlySequence<E>> jaggregate.ReadStream<E>
E
- a restriction on the types of elements being streamed overpublic class ReadStream<E>
Represents a stream that has a positionable sequence of values that can be read. The sequence values are provided by a sequenced collection that serves as the stream backing store.
Note that there is nothing to stop a caller to continue to manipulate the sequence being streamed over via another reference that allows such manipulations: adding to the sequence, replacing elements in the sequence, and so forth. However, the stream will still stop reading elements when it reaches the end of the sequence as it was set up at the time the stream was created.
Constructor Summary | |
---|---|
ReadStream(ReadOnlySequence<E> backingStore)
Creates a new stream over the given backing sequence. |
Method Summary | ||
---|---|---|
|
forEachDo(UnaryFunctor<? super E,? extends R> operation)
Evaluates the given operation with each of this stream's future sequence values, terminating evaluation when there are no more future sequence values. |
|
boolean |
isNextMatchFor(E target)
Reads the next object from this stream and tells whether the object is equivalent to the given target. |
|
boolean |
isPeekMatchFor(E target)
Peeks at the next object in this stream and tells whether it is equivalent to the given target. |
|
E |
next()
Answers the next object in this stream. |
|
OrderedCollection<E> |
next(int amount)
Answers a collection of the next given number of objects in this stream. |
|
E |
peek()
Answers the next object in this stream without advancing this stream's position. |
|
static
|
readStreamOver(ReadOnlySequence<T> backingStore)
Creates a new stream over the given backing sequence. |
|
void |
skip(int amount)
Skips the next given number of objects in this stream's future sequence values. |
|
boolean |
skipTo(E target)
Sets this stream to read the object just after the next occurrence of the given target and answers true . |
|
OrderedCollection<E> |
upTo(E target)
Answers a collection of all of the objects in this stream up to, but not including, the next occurrence of the given target. |
Methods inherited from class jaggregate.CollectionStream |
---|
atEnd, close, contents, isEmpty, position, position, reset, setToEnd |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ReadStream(ReadOnlySequence<E> backingStore)
backingStore
- the backing sequence to stream over
NullPointerException
- if backingStore
is null
Method Detail |
---|
public static <T> ReadStream<T> readStreamOver(ReadOnlySequence<T> backingStore)
T
- the type of elements in the backing sequencebackingStore
- the backing sequence to stream over
NullPointerException
- if backingStore
is null
public <R> void forEachDo(UnaryFunctor<? super E,? extends R> operation)
operation
. The number of evaluations is
equal to the initial size of the future sequence values. If initially there are
no future sequence values, operation
is not evaluated. The future
sequence values are used as arguments in their sequence order. The result is
undefined if any evaluation of operation
changes the future sequence
values.
forEachDo
in interface GettableStream<E,ReadOnlySequence<E>>
R
- a constraint on the return type of the operationoperation
- the operation to evaluatepublic E next()
next
in interface GettableStream<E,ReadOnlySequence<E>>
public OrderedCollection<E> next(int amount)
amount
are removed from the future sequence
values and appended, in order, to the end of the past sequence values.
A collection whose elements consist of those objects, in the same order,
is returned. If amount == 0
, an empty collection is returned.
next
in interface GettableStream<E,ReadOnlySequence<E>>
amount
- the number of objects to enumerate
public boolean isNextMatchFor(E target)
target
.
isNextMatchFor
in interface GettableStream<E,ReadOnlySequence<E>>
target
- the object against which to compare the next object from this
stream
true
if the next object is equivalent to target
;
false
otherwisepublic E peek()
null
if this stream has no future
sequence values. The answer will also be null
if the first future
sequence value is null
.
peek
in interface GettableStream<E,ReadOnlySequence<E>>
public boolean isPeekMatchFor(E target)
isPeekMatchFor
in interface GettableStream<E,ReadOnlySequence<E>>
target
- the object to match against
true
if the first object in this stream's future sequence values
is equivalent to target
, otherwise false
public void skip(int amount)
amount
and the size of the
future sequence values are removed from the future sequence values and appended,
in order, to the end of the past sequence values.
skip
in interface GettableStream<E,ReadOnlySequence<E>>
amount
- the number of objects to skippublic boolean skipTo(E target)
true
. If target
is not found before the end
of this stream is encountered, answers false
.
Each object in the future sequence values up to and including the first
occurrence of an object that is equivalent to
target
is removed from the future sequence values and appended to the
past sequence values. If an object that is equivalent to target
is not
found in the future sequence values, all of the objects in the future sequence
values are so appended.
skipTo
in interface GettableStream<E,ReadOnlySequence<E>>
target
- the object to skip to
true
if target
could be found, otherwise false
public OrderedCollection<E> upTo(E target)
target
. If target
is
not found and the end of this stream is encountered, a collection of the objects
read is returned.
Each object in the future sequence values up to and including the first
occurrence of an object that is equivalent
to target
is removed from the future sequence values and appended to the
past sequence values. A collection, containing, in order, all of the transferred
objects except the object (if any) that is equivalent to target
is returned. If the future sequence values is initially empty, an empty
collection is returned.
upTo
in interface GettableStream<E,ReadOnlySequence<E>>
target
- the object to seek
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |