FileReaderPattern
FileReaderPattern パターンは、ファイルからテキスト・データを読み取るために使用されます。
サポートされるクラス
TextFileReader クラスは、テキスト・データを開いて 1 行ずつ読み取るためのロジックを提供します。
必須プロパティー
以下は、このパターンの必須のプロパティーです。
プロパティー名 | 値 |
---|---|
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) | ファイルをロードする前にファイル名にジョブ ID を付加します。 |
インターフェース定義
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>