com.ibm.streams.flow.handlers
Class StreamCollector<C extends java.util.Collection<T>,T>
- java.lang.Object
-
- com.ibm.streams.flow.handlers.StreamCollector<C,T>
-
- Type Parameters:
C- Collection typeT- Type for the tuples on the stream
- All Implemented Interfaces:
- StreamHandler<T>
public class StreamCollector<C extends java.util.Collection<T>,T> extends java.lang.Object implements StreamHandler<T>
Collect tuples seen on a stream.
Useful for testing graphs to verify the output of an operator produced the correct tuples.- Since:
- InfoSphere® Streams Version 3.1
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringIBM_COPYRIGHT
-
Constructor Summary
Constructors Constructor and Description StreamCollector(C tuples)Construct aStreamCollectorthat will usetuplesto collect tuples seen on the stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description intgetTupleCount()Get the number of tuples in the collection returned bygetTuples().CgetTuples()Get the tuple collection.voidmark(StreamingData.Punctuation mark)No action is taken with punctuation marks.static StreamCollector<java.util.LinkedList<Tuple>,Tuple>newLinkedListCollector()Create a newStreamCollectorthat uses aLinkedListto collect tuples.voidtuple(T tuple)Add the tuple to the collection.
-
-
-
Field Detail
-
IBM_COPYRIGHT
public static final java.lang.String IBM_COPYRIGHT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StreamCollector
public StreamCollector(C tuples)
Construct aStreamCollectorthat will usetuplesto collect tuples seen on the stream.
-
-
Method Detail
-
newLinkedListCollector
public static StreamCollector<java.util.LinkedList<Tuple>,Tuple> newLinkedListCollector()
Create a newStreamCollectorthat uses aLinkedListto collect tuples. Access to the collection returned bygetTuples()must be synchronized using the collection's reference.- Returns:
- A new
StreamCollectorthat uses aLinkedListto collect tuples.
-
getTuples
public C getTuples()
Get the tuple collection.- Returns:
- The tuple collection
-
getTupleCount
public int getTupleCount()
Get the number of tuples in the collection returned bygetTuples(). Note that if tuples have been removed from or added to the collection outside of this class then the returned value does not represent the number of tuples seen on the stream.- Returns:
- Number of collected tuples.
-
tuple
public void tuple(T tuple) throws java.lang.Exception
Add the tuple to the collection. Addition oftupleis synchronized using the referent to the collection passed into the constructor and returned bygetTuples().- Specified by:
tuplein interfaceStreamHandler<T>- Parameters:
tuple- Tuple seen on stream- Throws:
java.lang.Exception- Failure to process the tuple.
-
mark
public void mark(StreamingData.Punctuation mark) throws java.lang.Exception
No action is taken with punctuation marks. Sub-classes may override this method to perform specific checks of the contents of thecollected tupleswhen a punctuation mark is seen.- Specified by:
markin interfaceStreamHandler<T>- Parameters:
mark- The punctuation mark.- Throws:
java.lang.Exception- Failure to process the punctuation mark.
-
-