jaggregate
Class CollectionStream<E,S extends ReadOnlySequence<E>>

java.lang.Object
  extended by jaggregate.CollectionStream<E,S>
Type Parameters:
E - the type of elements in the stream
S - the type of the stream's backing store
All Implemented Interfaces:
Stream<E,S>
Direct Known Subclasses:
ReadStream, WriteStream

public abstract class CollectionStream<E,S extends ReadOnlySequence<E>>
extends Object
implements Stream<E,S>

Represents a stream that has a ReadOnlySequence as its stream backing store.

Version:
$Id: CollectionStream.java,v 1.5 2008/10/03 19:01:23 pholser Exp $
Author:
Paul Holser

Method Summary
 boolean atEnd()
          Tells whether this stream is at the end of its values.
 void close()
          Disassociates this stream from its backing store.
 S contents()
          Answers a sequence containing the complete contents of this stream.

Answers this stream's backing store.

 boolean isEmpty()
          Tells whether there are any sequence values in this stream.
 int position()
          Answers the current position of this stream.
 void position(int amount)
          Sets the current position in this stream.
 void reset()
          Sets the position of this stream to be at the beginning of the stream of values.
 void setToEnd()
          Sets the position of this stream to be at the end of the stream of values.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

atEnd

public boolean atEnd()
Tells whether this stream is at the end of its values.

Specified by:
atEnd in interface Stream<E,S extends ReadOnlySequence<E>>
Returns:
true if this stream has no future sequence values available for reading; false otherwise.

contents

public S contents()
Answers a sequence containing the complete contents of this stream.

The returned sequence contains this stream's past and future sequence values, in order. The size of the collection is the sum of the sizes of the past and future sequence values.

Answers this stream's backing store.

Specified by:
contents in interface Stream<E,S extends ReadOnlySequence<E>>
Returns:
the contents of the receiving stream

close

public void close()
Disassociates this stream from its backing store. Any system resources associated with the association should be released.

This message is idempotent: sending it multiple times to this stream has no effect.

Specified by:
close in interface Stream<E,S extends ReadOnlySequence<E>>

isEmpty

public boolean isEmpty()
Tells whether there are any sequence values in this stream.

Specified by:
isEmpty in interface Stream<E,S extends ReadOnlySequence<E>>
Returns:
true if there are any sequence values in this stream

position

public int position()
Answers the current position of this stream.

Specified by:
position in interface Stream<E,S extends ReadOnlySequence<E>>
Returns:
current position

position

public void position(int amount)
Sets the current position in this stream.

If the number of past sequence values is smaller than amount, move objects in sequence from the front of the future sequence values to the back of the past sequence values until the number of past sequence values is equal to amount.

If the number of past sequence values is greater than amount, move objects in sequence from the back of the past sequence values to the front of the future sequence values until the number past sequence values is equal to amount.

If the number of past sequence values is equal to amount, no action is taken.

Specified by:
position in interface Stream<E,S extends ReadOnlySequence<E>>
Parameters:
amount - the new position

reset

public void reset()
Sets the position of this stream to be at the beginning of the stream of values.

Sets the future sequence values to be the current past sequence values appended with the current future sequence values--that is, makes this stream's past sequence values empty.

Specified by:
reset in interface Stream<E,S extends ReadOnlySequence<E>>

setToEnd

public void setToEnd()
Sets the position of this stream to be at the end of the stream of values.

Adds all of the future sequence values are appended, in sequence, to the past sequence values--that is, makes the future sequence values empty.

Specified by:
setToEnd in interface Stream<E,S extends ReadOnlySequence<E>>


© Copyright 2004-2008 Paul R. Holser, Jr. All rights reserved. Licensed under the Academic Free License version 3.0. pholser@alumni.rice.edu