org.apache.commons.pipeline.stage
Class AddToCollectionStage<T>
java.lang.Object
org.apache.commons.pipeline.stage.BaseStage
org.apache.commons.pipeline.stage.AddToCollectionStage<T>
- All Implemented Interfaces:
- Stage
public class AddToCollectionStage<T>
- extends BaseStage
This is a simple stage in the pipeline which will add each processed object
to the specified collection.
For the purposes of validation, this stage is considered to be able to consume
objects of any class although the process() method may throw a ClassCastException
if a processed object cannot be added to the collection.
Method Summary |
Collection<T> |
getCollection()
Returns the collection to which elements have been added during
processing. |
void |
process(Object obj)
Adds the object to the underlying collection. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AddToCollectionStage
public AddToCollectionStage(Collection<T> collection)
- Creates a new instance of AddToCollectionStage. This constructor
will synchronized the collection by default.
AddToCollectionStage
public AddToCollectionStage(Collection<T> collection,
boolean synchronize)
- Creates a new instance of AddToCollectionStage.
- Parameters:
collection
- The collection in which to add objects tosynchronized
- A flag value that determines whether or not accesses
to the underlying collection are synchronized.
process
public void process(Object obj)
throws StageException
- Adds the object to the underlying collection.
- Specified by:
process
in interface Stage
- Overrides:
process
in class BaseStage
- Parameters:
obj
- Object to be passed to downstream pipeline.
- Throws:
ClassCastException
- if the object is not of a suitable type to be added
to the collection.
StageException
- an Exception thrown by an overriding implementation should
be wrapped in a StageException
getCollection
public Collection<T> getCollection()
- Returns the collection to which elements have been added during
processing.
Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.