net.fortytwo.flow
Class Collector<T>
java.lang.Object
net.fortytwo.flow.Collector<T>
- All Implemented Interfaces:
- Iterable<T>, Collection<T>, Sink<T>, Source<T>
- Direct Known Subclasses:
- Buffer
public class Collector<T>
- extends Object
- implements Sink<T>, Source<T>
A data collector which stores data items in the order it receives them.
Note: while this class is not actually thread-safe, put() may safely be
called while writeTo() is in progress.
- Author:
- Joshua Shinavier (http://fortytwo.net)
|
Constructor Summary |
Collector()
Constructs a new collector |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Collector
public Collector()
- Constructs a new collector
put
public void put(T t)
throws RippleException
- Receives the next data item to be stored
- Specified by:
put in interface Sink<T>
- Parameters:
t - the data item being passed
- Throws:
RippleException - if a data handling error occurs
writeTo
public void writeTo(Sink<T> sink)
throws RippleException
- Pushes the collected items to the specified sink.
This operation does not cause this collector to become empty.
- Specified by:
writeTo in interface Source<T>
- Parameters:
sink - the downstream sink to receive the data in this collector
- Throws:
RippleException - if a data handling error occurs
size
public int size()
- Specified by:
size in interface Collection<T>
- Returns:
- the number of items in this collection
iterator
public Iterator<T> iterator()
- Specified by:
iterator in interface Iterable<T>- Specified by:
iterator in interface Collection<T>
- Returns:
- an iterator over the items in this collection
clear
public void clear()
- Specified by:
clear in interface Collection<T>
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.