net.sf.bacchus.spring
Class RecordProcessorSupport<I extends Record,O>

java.lang.Object
  extended by org.springframework.batch.item.ItemStreamSupport
      extended by net.sf.bacchus.spring.RecordProcessorSupport<I,O>
Type Parameters:
I - the type of input Record this processes.
O - the type of output this emits.
All Implemented Interfaces:
org.springframework.batch.item.ItemProcessor<I,O>, org.springframework.batch.item.ItemStream
Direct Known Subclasses:
RecordSpecializer

public class RecordProcessorSupport<I extends Record,O>
extends org.springframework.batch.item.ItemStreamSupport
implements org.springframework.batch.item.ItemProcessor<I,O>

Base ItemProcessor that takes ACH records as input. The base processing method dispatches each item to a method that is specialized for the record type. The default implementations of those methods delegate to the default processing, which returns null. Therefore, a simple instantiation of this class will return null for every record.


Constructor Summary
RecordProcessorSupport()
           
 
Method Summary
 boolean isAllowUnrecognized()
          Gets whether unrecognized records should be passed through untouched.
protected  String key(String base)
          Generates a name that uniquely identifies an entry for this instance in the ExecutionContext.
 O process(I item)
          Dispatches each input item to the appropriate processXXX method.
protected  O processAddenda(I item)
          Processes an addenda record.
protected  O processCompanyBatchControl(I item)
          Processes a company/batch control record.
protected  O processCompanyBatchHeader(I item)
          Processes a company/batch header record.
protected  O processDefault(I item)
          Perform default processing on an item.
protected  O processDetail(I item)
          Processes a detail record.
protected  O processFileControl(I item)
          Processes a file control record.
protected  O processFileHeader(I item)
          Processes a file header record.
protected  O processFiller(I item)
          Processes a filler record.
 void setAllowUnrecognized(boolean allowUnrecognized)
          Sets whether unrecognized records should be passed through untouched.
 void setName(String name)
          Sets name used to uniquely identify this instance's entries in shared ExecutionContext.
 
Methods inherited from class org.springframework.batch.item.ItemStreamSupport
close, open, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecordProcessorSupport

public RecordProcessorSupport()
Method Detail

isAllowUnrecognized

public boolean isAllowUnrecognized()
Gets whether unrecognized records should be passed through untouched. If this value is true then null input records will result in null output records and records that return an unrecognized record type will be passed to the default processor. If this value is {code false} then null records will result in NullPointerException and records that do not return a recognized record type will result in InvalidRecordException. The default value is false.

Returns:
whether unrecognized records should be passed through untouched.

setAllowUnrecognized

public void setAllowUnrecognized(boolean allowUnrecognized)
Sets whether unrecognized records should be passed through untouched.

Parameters:
allowUnrecognized - whether unrecognized records should be passed through untouched.

process

public O process(I item)
          throws InvalidRecordException
Dispatches each input item to the appropriate processXXX method.

Specified by:
process in interface org.springframework.batch.item.ItemProcessor<I extends Record,O>
Parameters:
item -
Returns:
the result of the corresponding processXXX method.
Throws:
InvalidRecordException - if the record is not recognized and isAllowUnrecognized() is false.
NullPointerException - if the record is null and isAllowUnrecognized() is false.

processDefault

protected O processDefault(I item)
                    throws InvalidRecordException
Perform default processing on an item.

Parameters:
item - the item to process.
Returns:
always returns null.
Throws:
InvalidRecordException - if the record is invalid and cannot be processed.

processFileHeader

protected O processFileHeader(I item)
                       throws InvalidRecordException
Processes a file header record.

Parameters:
item - the item, where item.getRecordType() is guaranteed always to return Header.FILE_HEADER_RECORD.
Returns:
the processed file header.
Throws:
InvalidRecordException - if the record is invalid and cannot be processed.

processCompanyBatchHeader

protected O processCompanyBatchHeader(I item)
                               throws InvalidRecordException
Processes a company/batch header record.

Parameters:
item - the item, where item.getRecordType() is guaranteed always to return Header.BATCH_HEADER_RECORD.
Returns:
the processed company/batch header.
Throws:
InvalidRecordException - if the record is invalid and cannot be processed.

processDetail

protected O processDetail(I item)
                   throws InvalidRecordException
Processes a detail record.

Parameters:
item - the item, where item.getRecordType() is guaranteed always to return Detail.DETAIL_RECORD.
Returns:
the processed company/batch header.
Throws:
InvalidRecordException - if the record is invalid and cannot be processed.

processAddenda

protected O processAddenda(I item)
                    throws InvalidRecordException
Processes an addenda record.

Parameters:
item - the item, where item.getRecordType() is guaranteed always to return Addenda.ADDENDA_RECORD.
Returns:
the processed company/batch header.
Throws:
InvalidRecordException - if the record is invalid and cannot be processed.

processCompanyBatchControl

protected O processCompanyBatchControl(I item)
                                throws InvalidRecordException
Processes a company/batch control record.

Parameters:
item - the item, where item.getRecordType() is guaranteed always to return Control.BATCH_CONTROL_RECORD.
Returns:
the processed company/batch control.
Throws:
InvalidRecordException - if the record is invalid and cannot be processed.

processFileControl

protected O processFileControl(I item)
                        throws InvalidRecordException
Processes a file control record.

Parameters:
item - the item, where item.getRecordType() is guaranteed always to return Control.FILE_CONTROL_RECORD.
Returns:
the processed file control.
Throws:
InvalidRecordException - if the record is invalid and cannot be processed.

processFiller

protected O processFiller(I item)
                   throws InvalidRecordException
Processes a filler record.

Parameters:
item - the item.
Returns:
the processed filler.
Throws:
InvalidRecordException - if the record is invalid and cannot be processed.

setName

public void setName(String name)
Sets name used to uniquely identify this instance's entries in shared ExecutionContext.

Parameters:
name - the name of this instance.

key

protected String key(String base)
Generates a name that uniquely identifies an entry for this instance in the ExecutionContext.

Parameters:
base - the base key name shared by all instances.
Returns:
the unique name for this instance.


Copyright © 2008-2009 Bacchus Development Team. All Rights Reserved.