net.fortytwo.flow
Class Buffer<T>

java.lang.Object
  extended by net.fortytwo.flow.Collector<T>
      extended by net.fortytwo.flow.Buffer<T>
Type Parameters:
T - the type of data being passed
All Implemented Interfaces:
Iterable<T>, Collection<T>, Sink<T>, Source<T>

public class Buffer<T>
extends Collector<T>

A collection of data items which grows until "flushed" to a downstream sink.

Author:
Joshua Shinavier (http://fortytwo.net)

Constructor Summary
Buffer(Sink<T> sink)
          Constructs a new buffer of the given type
 
Method Summary
 boolean add(T t)
           
 boolean addAll(Collection<? extends T> ts)
           
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> objects)
           
 void flush()
          Empties the buffer, pushing the collected data items in FIFO order to the downstream sink
 boolean isEmpty()
           
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> objects)
           
 boolean retainAll(Collection<?> objects)
           
 T[] toArray()
           
<U> U[]
toArray(U[] array)
           
 
Methods inherited from class net.fortytwo.flow.Collector
clear, iterator, put, size, writeTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

Buffer

public Buffer(Sink<T> sink)
Constructs a new buffer of the given type

Parameters:
sink - the downstream sink to which to pass the received data items when the buffer is flushed
Method Detail

flush

public void flush()
           throws RippleException
Empties the buffer, pushing the collected data items in FIFO order to the downstream sink

Throws:
RippleException

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<T>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<T>

toArray

public T[] toArray()
Specified by:
toArray in interface Collection<T>

toArray

public <U> U[] toArray(U[] array)
Specified by:
toArray in interface Collection<T>

add

public boolean add(T t)
Specified by:
add in interface Collection<T>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<T>

containsAll

public boolean containsAll(Collection<?> objects)
Specified by:
containsAll in interface Collection<T>

addAll

public boolean addAll(Collection<? extends T> ts)
Specified by:
addAll in interface Collection<T>

removeAll

public boolean removeAll(Collection<?> objects)
Specified by:
removeAll in interface Collection<T>

retainAll

public boolean retainAll(Collection<?> objects)
Specified by:
retainAll in interface Collection<T>


Copyright © 2007-2014. All Rights Reserved.