|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jmonks.batch.io.FileReader
org.jmonks.batch.io.flat.FlatFileReader
FlatFileReader reads the specified fixed width flat file according to the given file spec and returns the recrods on the needed basis. Each field value from the record should be read using readField method by passing the fieldName mentioned in the file spec. To find out how to read each record from the file and to read the each field from the record, refer to the FileReader javadoc.
Nested Class Summary | |
class |
FlatFileReader.FlatFileReaderRecord
FixedWidthFlatFileReaderRecord implements ReaderRecord by maintaing the field names and values as a map and provides the methods with proper access privileges to read into and write from the record. |
Field Summary | |
protected FileSpec |
fileSpec
File spec to be used to read the flat file. |
Constructor Summary | |
FlatFileReader(java.io.InputStream fileInputStream,
FileSpec fileSpec)
Constructs and initializes the flat file reader with the given file path and file spec. |
|
FlatFileReader(java.io.Reader reader,
FileSpec fileSpec)
Constructs and initializes the flat file reader with the given file path and file spec. |
Method Summary | |
void |
close()
Closes the reader and all the resources it is using. |
ReaderRecord |
getNextRecord()
Gets the next available record from the file and returns it wrapped with the appropriate ReaderRecod object to easily access the data fields from the record. |
protected abstract ReaderRecord |
parseRecord(java.lang.String recordString)
Parses the given record string based on the record spec, translates it into the appropriate ReaderRecord and returns that reader record. |
Methods inherited from class org.jmonks.batch.io.FileReader |
getFileReader, getFileReader, getFileReader, getFileReader |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected FileSpec fileSpec
Constructor Detail |
public FlatFileReader(java.io.InputStream fileInputStream, FileSpec fileSpec)
fileInputStream
- Input stream to the file.fileSpec
- File spec to be used to read the file.public FlatFileReader(java.io.Reader reader, FileSpec fileSpec)
reader
- Reader to the file.fileSpec
- File spec to be used to read the file.Method Detail |
public ReaderRecord getNextRecord()
Gets the next available record from the file and returns it wrapped with the appropriate ReaderRecod object to easily access the data fields from the record. If you defined multiple record specs, make sure to verify the recrod type before you read the values.
getNextRecord
in class FileReader
FileParseException
- Problems while parsing the
next record. This includes unable to identify the recod with the availble record specs.public void close()
close
in class FileReader
protected abstract ReaderRecord parseRecord(java.lang.String recordString)
recordString
- Next available line read from the file.
FileParseException
- Problems while parsing the
next record. This includes unable to identify the recod with the availble record specs.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |