FileReaderPattern
FileReaderPattern 模式用于从文件读取文本数据。
支持类
TextFileReader 类提供用于打开文本数据并逐行读取的逻辑。
必需属性
以下属性对于该模式是必需的。
属性名称 | 值 |
---|---|
PATTERN_IMPL_CLASS | 实现 FileReaderPattern 接口的类 |
FILENAME | 输入文件的完整路径 |
可选属性
以下属性对于该模式是可选的。
属性名称 | 值 | 描述 |
---|---|---|
debug | true 或 false(缺省值为 false) | 在此批处理数据流上启用详细跟踪。 |
EnablePerformanceMeasurement | true 或 false(缺省值为 false) | 如果正使用 GenericXDBatchStep,那么计算批处理数据流和 processRecord 方法中所花的总时间。 |
EnableDetailedPerformanceMeasurement | true 或 false(缺省值为 false) | 提供在批处理数据流的每个方法中花费的更为详细的时间细目。 |
file.encoding | 文件的编码。 | 例如,8859_1 |
AppendJobldToFileName | true 或 false(缺省值为 false) | 加载文件之前,将作业标识附加到文件名。 |
接口定义
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 示例
<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>