org.apache.commons.pipeline.stage
Class AddToCollectionStage<T>

java.lang.Object
  extended by org.apache.commons.pipeline.stage.BaseStage
      extended by 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.


Field Summary
 
Fields inherited from class org.apache.commons.pipeline.stage.BaseStage
context
 
Constructor Summary
AddToCollectionStage(Collection<T> collection)
          Creates a new instance of AddToCollectionStage.
AddToCollectionStage(Collection<T> collection, boolean synchronize)
          Creates a new instance of AddToCollectionStage.
 
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 org.apache.commons.pipeline.stage.BaseStage
emit, emit, init, postprocess, preprocess, release
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 to
synchronized - A flag value that determines whether or not accesses to the underlying collection are synchronized.
Method Detail

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.