|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectjp.terasoluna.fw.file.dao.standard.AbstractFileLineWriter<T>
T - ファイル行オブジェクト。public abstract class AbstractFileLineWriter<T>
ファイルアクセス(データ書込)用の共通クラス。
ファイルアクセス(データ書込)を行う3つのクラス(CSV、固定長、可変長) に共通する処理をまとめた抽象クラス。 ファイルの種類に対応するサブクラスが処理を行う。
使用例はFileLineWriterを参照のこと。
ファイル取得処理は下記の手順で呼び出されるように実装すること。
FileLineWriter,
CSVFileLineWriter,
FixedFileLineWriter,
VariableFileLineWriter,
PlainFileLineWriter| コンストラクタの概要 | |
|---|---|
AbstractFileLineWriter(String fileName,
Class<T> clazz,
Map<String,ColumnFormatter> columnFormatterMap)
コンストラクタ。 |
|
| メソッドの概要 | |
|---|---|
protected void |
checkWriteTrailer()
トレイラ部の処理が終わっているかどうかを判定する。 |
void |
closeFile()
ファイルクローズ処理。 |
protected String |
getColumn(T t,
int index)
ファイル行オブジェクトからカラムインデックスと一致する属性の値を取得する。 |
protected char[] |
getColumnEncloseChar()
カラムの囲み文字を取得する。 |
abstract char |
getDelimiter()
区切り文字を取得する。 |
abstract char |
getEncloseChar()
囲み文字を取得する。 |
protected Field[] |
getFields()
ファイル行オブジェクトのField情報(Annotation)を格納する変数を取得する。 |
String |
getFileName()
ファイル名を取得する。 |
protected String |
getLineFeedChar()
行区切り文字を設定する。 |
protected Method[] |
getMethods()
ファイル行オブジェクトのField情報に対応するgetterメソッドを格納する変数を取得する。 |
protected Writer |
getWriter()
ファイルアクセス(出力)用の文字ストリームを取得する。 |
protected void |
init()
初期化処理を行う。 |
protected boolean |
isCheckByte(int columnByte)
対象カラムに対するバイト数チェックを行うかを返す。 |
protected boolean |
isCheckByte(OutputFileColumn outputFileColumn)
対象カラムに対するバイト数チェックを行うかを返す。 |
protected boolean |
isCheckColumnAnnotationCount()
ファイル行オブジェクトにアノテーションが設定されている事をチェックするかどうかを返す。 |
protected boolean |
isCheckEncloseChar()
囲み文字が設定されていない事をチェックするかどうかを返す。 |
void |
printDataLine(T t)
データ部への書き込み処理。 |
void |
printHeaderLine(List<String> headerLine)
ヘッダ部への書込み処理。 |
void |
printTrailerLine(List<String> trailerLine)
トレイラ部への書込み処理。 |
void |
setColumnFormatterMap(Map<String,ColumnFormatter> columnFormatterMap)
カラムフォーマット(ファイル書込)処理を格納するマップを取得する。 |
protected void |
setLineFeedChar(String lineFeedChar)
行区切り文字を設定する。 |
protected void |
setWriteData(boolean writeData)
データ部の出力が開始されているかどうかを判定するフラグ。 |
| クラス java.lang.Object から継承されたメソッド |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| コンストラクタの詳細 |
|---|
public AbstractFileLineWriter(String fileName,
Class<T> clazz,
Map<String,ColumnFormatter> columnFormatterMap)
@FileFormatアノテーションの設定チェックする。 @FileFormatアノテーションが設定されていない場合は非検査例外をスローする。
fileName - ファイル名clazz - パラメータクラスcolumnFormatterMap - テキスト取得ルール| メソッドの詳細 |
|---|
protected void init()
public void printHeaderLine(List<String> headerLine)
FileLineWriter<T> 内の printHeaderLineheaderLine - ヘッダ部へ書き込む文字列のリストpublic void printDataLine(T t)
FileLineWriter<T> 内の printDataLinet - データ部へ書き込むファイル行オブジェクトpublic void printTrailerLine(List<String> trailerLine)
FileLineWriter<T> 内の printTrailerLinetrailerLine - トレイラ部へ書き込む文字列のリストpublic void closeFile()
FileLineWriter<T> 内の closeFile
protected String getColumn(T t,
int index)
ファイル行オブジェクトからカラムインデックスと一致する属性の値を取得する。
属性を取得する際、ファイル行オブジェクトのアノテーションの記述により 以下の処理を行う。
t - ファイル行オブジェクトindex - カラムのインデックス
public String getFileName()
protected String getLineFeedChar()
protected void setLineFeedChar(String lineFeedChar)
行区切り文字 - public void setColumnFormatterMap(Map<String,ColumnFormatter> columnFormatterMap)
columnFormatterMap - カラムフォーマット(ファイル書込)を格納するマップprotected Writer getWriter()
protected Field[] getFields()
protected Method[] getMethods()
protected void setWriteData(boolean writeData)
writeData - フラグprotected void checkWriteTrailer()
public abstract char getDelimiter()
public abstract char getEncloseChar()
protected boolean isCheckByte(OutputFileColumn outputFileColumn)
固定長ファイル形式の場合は常にtrueを返却してバイト数チェックを行う。
可変長、CSV形式でbytesが指定されているときには trueを返却しバイト数チェックを行う。
outputFileColumn - 対象カラムのOutputFileColumn情報
protected boolean isCheckByte(int columnByte)
columnByte - 対象カラムのバイト数
protected boolean isCheckEncloseChar()
protected boolean isCheckColumnAnnotationCount()
protected char[] getColumnEncloseChar()
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||