+

Search Tips   |   Advanced Search

FileReaderPattern

The FileReaderPattern pattern is used to read text data from a file.


Supporting classes

The TextFileReader class provides the logic to open and read text data line by line.


Required properties

The following properties are required for the pattern.

Property name Value
PATTERN_IMPL_CLASS Class implementing FileReaderPattern interface
FILENAME Complete path to the input file


Optional properties

The following properties are optional for the pattern.

Property name Value Description
debug true or false (default is false) Enable detailed tracing on this batch datastream.
EnablePerformanceMeasurement true or false (default is false) Calculates the total time spent in the batch data-streams and the processRecord method, if we are using the GenericXDBatchStep.
EnableDetailedPerformanceMeasurement true or false (default is false) Provides a more detailed breakdown of time spent in each method of the batch data-streams.
file.encoding Encoding of the file. For example, 8859_1
AppendJobldToFileName true or false (default is false) Appends the JobID to the file name before loading the file.


Interface definition

public interface FileReaderPattern {

	/**
	 * Invoked during the step setup phase
	 * @param props
	 */
	public void initialize(Properties props);
	/**
	 * This method is invoked only once. It should be used
	 * to read any header data if necessary.
	 * @param reader
	 * @throws IOException
	 */
	public void processHeader(BufferedReader reader) throws IOException;
	
	/**
	 * This method should read the next line from the reader
	 * and return the data in suitable form to be processed
	 * by the step.
	 * @param reader
	 * @return
	 * @throws IOException
	 */
	public Object fetchRecord(BufferedReader reader) throws IOException;
  
   /**
 	  * This method can be optionally invoked from the process step 
    * to obtain the header data that was previously obtained during the processHeader 
    * call 
    * @return 
    */
    
     public Object fetchHeader(); 
}


xJCL example

<batch-data-streams>
<bds>
<logical-name>inputStream</logical-name>
<props>
     <prop name="PATTERN_IMPL_CLASS" value="com.ibm.websphere.batch.samples.tests.bds.EchoReader"/>
     <prop name="file.encoding" value="8859_1"/>
     <prop name="FILENAME" value="/opt/txlist.txt" />
     <prop name="debug" value="true"/>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.TextFileReader</impl-class>
</bds>
</batch-data-streams>


Related:

  • Batch data stream framework and patterns
  • Use the batch data stream framework
  • JDBCReaderPattern
  • JDBCWriterPattern
  • ByteReaderPattern
  • ByteWriterPattern
  • FileWriterPattern
  • (ZOS) RecordOrientedDatasetReaderPattern
  • (ZOS) RecordOrientedDataSetWriterPattern
  • JPAReaderPattern
  • JPAWriterPattern