|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jmonks.batch.io.FileWriter
FileWriter writes the specified file based on the given file spec with the data written in the form of WriterRecord's. This provides the methods to create the required records and write them into the file writer. Once finished writing of all the records file writer should be closed by calling the appropriate methods. This provides the factory method to create the file writer based on the file spec. Here is a sample code snippet to use the file writer.
InputStream fileSpecInputStream=...; OutputStream fileOutputStream=...; FileWriter fileWriter=FileWriter.getFileWriter(fileOutputStream,fileSpecInputStream); WriterRecord record=fileWriter.createWriterRecord(RecordType.DETAIL); record.writeField("consumer-id","123456"); //Write the other field values. fileWriter.writeRecord(record); fileWriter.close();
Constructor Summary | |
FileWriter()
|
Method Summary | |
abstract void |
close()
Closes the writer and releases all the resources associated with the writer. |
abstract WriterRecord |
createWriterRecord(RecordType recordType)
Creates the writer record to be used to fill all the field values and submit to the file writer to write the record into the file. |
static FileWriter |
getFileWriter(java.io.OutputStream outputStream,
FileSpec fileSpec)
Factory method to get the file writer. |
static FileWriter |
getFileWriter(java.io.OutputStream outputStream,
java.io.InputStream fileSpecInputStream)
Factory method to get the file writer. |
static FileWriter |
getFileWriter(java.io.Writer writer,
FileSpec fileSpec)
Factory method to get the file writer. |
static FileWriter |
getFileWriter(java.io.Writer writer,
java.io.InputStream fileSpecInputStream)
Factory method to get the file writer. |
abstract void |
writeRecord(WriterRecord record)
Writes the given record into the file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FileWriter()
Method Detail |
public abstract void writeRecord(WriterRecord record)
createWriterRecord
method.
record
- WriterRecord that you want to write into the file.
FileParseException
- Problems while writing the record into file.public abstract void close()
public abstract WriterRecord createWriterRecord(RecordType recordType)
recordType
- Type of record.
java.lang.IllegalArgumentException
- If given record type is not associated with any record spec.public static FileWriter getFileWriter(java.io.OutputStream outputStream, java.io.InputStream fileSpecInputStream)
Factory method to get the file writer. This method returns the appropriate file writer based on the file type specified in the file spec.
outputStream
- Output stream to write the records.fileSpecInputStream
- Input stream to read the file spec.
java.lang.IllegalArgumentException
- If the given file output stream or file spec input stream is null.
FileSpecException
- If the configured file type in file spec doesnt
exist in FileType class.public static FileWriter getFileWriter(java.io.OutputStream outputStream, FileSpec fileSpec)
Factory method to get the file writer. This method returns the appropriate file writer based on the file type specified in the file spec.
outputStream
- Output stream to write the records.fileSpec
- File spec to be used to create the writer.
java.lang.IllegalArgumentException
- If the given file output stream or file spec is null.
FileSpecException
- If the configured file type in file spec doesnt
exist in FileType class.public static FileWriter getFileWriter(java.io.Writer writer, java.io.InputStream fileSpecInputStream)
Factory method to get the file writer. This method returns the appropriate file writer based on the file type specified in the file spec.
writer
- Writer to write the records.fileSpecInputStream
- Input stream to read the file spec.
java.lang.IllegalArgumentException
- If the given file output stream or file spec input stream is null.
FileSpecException
- If the configured file type in file spec doesnt
exist in FileType class.public static FileWriter getFileWriter(java.io.Writer writer, FileSpec fileSpec)
Factory method to get the file writer. This method returns the appropriate file writer based on the file type specified in the file spec.
writer
- Writer to write the records.fileSpec
- File spec to be used to create the writer.
java.lang.IllegalArgumentException
- If the given file output stream or file spec is null.
FileSpecException
- If the configured file type in file spec doesnt
exist in FileType class.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |