jaggregate
Class WriteStream<E>

java.lang.Object
  extended by jaggregate.CollectionStream<E,Sequence<E>>
      extended by jaggregate.WriteStream<E>
Type Parameters:
E - a restriction on the types of elements being streamed over
All Implemented Interfaces:
PuttableStream<E>, Stream<E,Sequence<E>>

public class WriteStream<E>
extends CollectionStream<E,Sequence<E>>
implements PuttableStream<E>

Represents a stream that has a positionable sequence of values to which new values may be written. The initial sequence values are provided by a sequenced collection that serves as the stream backing store.

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

Constructor Summary
WriteStream(Sequence<E> backingStore)
          Creates a new stream over the given backing sequence.
 
Method Summary
 void nextPut(E newElement)
          Writes the given new element to this stream.
 void nextPutAll(Collection<? extends E> newElements)
          Enumerates the given collection, adding each new element to this stream.
static
<T> WriteStream<T>
writeStreamOver(Sequence<T> backingStore)
          Creates a new stream over the given backing sequence.
 
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

WriteStream

public WriteStream(Sequence<E> backingStore)
Creates a new stream over the given backing sequence.

Parameters:
backingStore - the backing sequence to stream over
Throws:
NullPointerException - if backingStore is null
Method Detail

writeStreamOver

public static <T> WriteStream<T> writeStreamOver(Sequence<T> backingStore)
Creates a new stream over the given backing sequence.

Type Parameters:
T - the type of elements in the backing sequence
Parameters:
backingStore - the backing sequence to stream over
Returns:
the new stream
Throws:
NullPointerException - if backingStore is null

nextPut

public void nextPut(E newElement)
Writes the given new element to this stream.

Appends newElement to the past sequence values. If the future sequence values is not empty, removes its first object.

Specified by:
nextPut in interface PuttableStream<E>
Parameters:
newElement - the element to add

nextPutAll

public void nextPutAll(Collection<? extends E> newElements)
Enumerates the given collection, adding each new element to this stream.

This message has the effect of enumerating newElements with forEachDo and adding each element to this stream with nextPut.

Specified by:
nextPutAll in interface PuttableStream<E>
Parameters:
newElements - the elements to add


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