org.jmonks.batch.io.flat
Class FixedWidthFlatFileWriter

java.lang.Object
  extended byorg.jmonks.batch.io.FileWriter
      extended byorg.jmonks.batch.io.flat.FlatFileWriter
          extended byorg.jmonks.batch.io.flat.FixedWidthFlatFileWriter

public class FixedWidthFlatFileWriter
extends FlatFileWriter

FixedWidthFlatFileWriter writes the file according to the given file spec with the data submitted in the form of WriterRecord's. This provides the methods to create the required writer records and write the writer record into the file writer. Once finished writing of all the records file writer should be closed by calling the "close" method.

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Nested Class Summary
 
Nested classes inherited from class org.jmonks.batch.io.flat.FlatFileWriter
FlatFileWriter.FlatFileWriterRecord
 
Field Summary
 
Fields inherited from class org.jmonks.batch.io.flat.FlatFileWriter
fileSpec
 
Constructor Summary
FixedWidthFlatFileWriter(java.io.OutputStream outputStream, FileSpec fileSpec)
          Constructs and initializes the writer with the given values.
FixedWidthFlatFileWriter(java.io.Writer writer, FileSpec fileSpec)
          Constructs and initializes the writer with the given values.
 
Method Summary
protected  java.lang.String generateRecord(WriterRecord writerRecord)
          Writes the given record into the file/writer.
 
Methods inherited from class org.jmonks.batch.io.flat.FlatFileWriter
close, createWriterRecord, writeRecord
 
Methods inherited from class org.jmonks.batch.io.FileWriter
getFileWriter, getFileWriter, getFileWriter, getFileWriter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedWidthFlatFileWriter

public FixedWidthFlatFileWriter(java.io.OutputStream outputStream,
                                FileSpec fileSpec)
Constructs and initializes the writer with the given values.

Parameters:
outputStream - Output stream to write the records.
fileSpec - File spec to be used to generate the file.

FixedWidthFlatFileWriter

public FixedWidthFlatFileWriter(java.io.Writer writer,
                                FileSpec fileSpec)
Constructs and initializes the writer with the given values.

Parameters:
writer - Writer to write the records.
fileSpec - File spec to be used to generate the file.
Method Detail

generateRecord

protected java.lang.String generateRecord(WriterRecord writerRecord)
                                   throws java.io.IOException
Writes the given record into the file/writer.

Specified by:
generateRecord in class FlatFileWriter
Parameters:
writerRecord - Record consist of field names and values.
Returns:
Returns the string representation of the record.
Throws:
java.lang.IllegalStateException - If writer is closed and trying to write the recrod.
java.lang.IllegalArgumentException - If writer record is null.
FileParseException - Problems while trying to write the record.
java.io.IOException