T
- ファイル行オブジェクト。public abstract class AbstractFileLineIterator<T> extends Object implements FileLineIterator<T>
ファイルアクセス(データ取得)を行う3つのクラス(CSV、固定長、可変長) に共通する処理をまとめた抽象クラス。 ファイルの種類に対応するサブクラスが処理を行う。
使用例はFileLineIterator
を参照のこと。
IllegalStateExceptionが発生します。
コンストラクタと説明 |
---|
AbstractFileLineIterator(String fileName,
Class<T> clazz,
Map<String,ColumnParser> columnParserMap)
コンストラクタ。
|
修飾子とタイプ | メソッドと説明 |
---|---|
void |
closeFile()
ファイル閉塞処理を行う。
|
protected int[] |
getColumnBytes()
各カラムのバイト数を取得する。
|
protected char[] |
getColumnEncloseChar()
カラムの囲み文字を取得する。
|
int |
getCurrentLineCount()
現在ファイル入力処理済みのデータ部内の行数を取得する。
|
protected abstract char |
getDelimiter()
区切り文字を取得する。
|
protected abstract char |
getEncloseChar()
囲み文字を取得する。
|
protected Field[] |
getFields()
ファイル行オブジェクトのField情報(Annotation)を格納する変数を取得する。
|
protected String |
getFileEncoding()
ファイルエンコーディング取得する。
|
protected String |
getFileName()
ファイル名を取得する。
|
List<String> |
getHeader()
ヘッダ部のデータを取得する。
|
protected int |
getHeaderLineCount()
ヘッダ行数を取得する。
|
protected String |
getLineFeedChar()
行区切り文字を取得する。
|
protected int |
getTotalBytes()
1行分のバイト数を取得する。
|
List<String> |
getTrailer()
トレイラ部のデータを取得する。
|
protected int |
getTrailerLineCount()
トレイラ行数を取得する。
|
boolean |
hasNext()
次の行のレコードがあるかどうか確認する。
|
protected void |
init()
初期化処理を行う。
|
protected boolean |
isCheckByte(InputFileColumn inputFileColumn)
対象カラムに対するバイト数チェックを行うかを返す。
|
protected boolean |
isCheckByte(int columnByte)
対象カラムに対するバイト数チェックを行うかを返す。
|
protected boolean |
isCheckColumnAnnotationCount()
ファイル行オブジェクトにアノテーションが設定されている事をチェックするかどうかを返す。
|
protected boolean |
isCheckEncloseChar()
囲み文字が設定されていない事をチェックするかどうかを返す。
|
protected boolean |
isEnclosed()
囲み文字が設定されているかを返す。
|
T |
next()
繰り返し処理でファイル行オブジェクトを返却する。
|
protected String |
readLine()
ファイルからデータ部のデータを1行分読み取り、文字列として呼出元に返却する。
|
void |
remove()
サポートしない。
|
protected abstract String[] |
separateColumns(String fileLineString)
データ部のデータ1行分をファイル行オブジェクトのアノテーションの記述に 従いカラムに分割する。
|
protected void |
setLineFeedChar(String lineFeedChar)
行区切り文字を設定する。
|
void |
skip(int skipLines)
データ部のデータを読み飛ばす処理を行う。
|
public AbstractFileLineIterator(String fileName, Class<T> clazz, Map<String,ColumnParser> columnParserMap)
fileName
- ファイル名最後に移動clazz
- ファイル行オブジェクトクラスcolumnParserMap
- フォーマット処理リストFileException
- 初期化処理で失敗した場合。public boolean hasNext()
hasNext
インタフェース内 Iterator
hasNext
インタフェース内 FileLineIterator<T>
true
FileException
- リーダからIOExceptionが発生した場合。public T next()
次の行のレコードの情報をファイル行オブジェクトに格納して返却します。
繰り返し処理で次の要素を返します。
next
インタフェース内 Iterator
next
インタフェース内 FileLineIterator<T>
FileException
- ファイル行オブジェクトの生成に失敗した場合。FileLineException
- ファイル行オブジェクトの取得に失敗した場合。public void remove()
remove
インタフェース内 Iterator
UnsupportedOperationException
- このメソッドはサポートしない。protected void init()
FileException
- 初期化処理で失敗した場合。FileLineException
- カラムに関連する初期化処理で失敗した場合。public void closeFile()
closeFile
インタフェース内 FileLineIterator<T>
FileException
- ファイル閉塞処理で失敗した場合。public List<String> getHeader()
getHeader
インタフェース内 FileLineIterator<T>
public List<String> getTrailer()
getTrailer
インタフェース内 FileLineIterator<T>
FileException
- データ行取得処理で失敗した場合。protected String readLine()
FileException
- データ行取得処理で失敗した場合。public void skip(int skipLines)
skip
インタフェース内 FileLineIterator<T>
skipLines
- 読み飛ばす行数。protected abstract char getDelimiter()
protected abstract char getEncloseChar()
protected abstract String[] separateColumns(String fileLineString)
fileLineString
がnull
もしくは 空文字の場合は、要素を持たないString
配列を返します。fileLineString
- データ部のデータ1行分protected boolean isCheckByte(InputFileColumn inputFileColumn)
inputFileColumn
- 対象カラムのInputFileColumn情報protected boolean isCheckByte(int columnByte)
columnByte
- 対象カラムのバイト数protected String getLineFeedChar()
protected void setLineFeedChar(String lineFeedChar)
行区切り文字
- protected String getFileEncoding()
protected int getHeaderLineCount()
protected int getTrailerLineCount()
public int getCurrentLineCount()
protected Field[] getFields()
protected String getFileName()
protected char[] getColumnEncloseChar()
protected boolean isEnclosed()
protected int[] getColumnBytes()
protected int getTotalBytes()
protected boolean isCheckEncloseChar()
protected boolean isCheckColumnAnnotationCount()
Copyright © 2014 NTT DATA Corporation.