|
Copyright (C) 2003,2004 dr. Cristiano Sadun | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An object implementing this interface can decide whether or not the physical line currently available
for reading match or not a certain condition, in the FlatFileParser.Condition#holds(int, int, LineReader)
method.
A Condition is usually associated to a LineFormat
in a FlatFileParser
object.
The Condition object can read as many physical lines as required from the file before deciding whether or not the condition holds. It can check things like whether the current line number is lower than a certain number, or if two lines are available and the second contains a certain constant at a certain position, etc.
For example, if a file has ten lines of header with a certain format, followed by any number of lines with a second format, code like the following is a possible Condition identifying header lines.
public boolean holds(int logicalLineCount, int physicalLineCount, LineReader reader) throws IOException { // Check if we are in the file header return logicalLineCount < 10; }
Some implementations are provided by the library for common types of conditions.
Method Summary | |
boolean |
holds(int logicalLineCount,
int physicalLineCount,
FlatFileParser.LineReader reader)
Return true if a desired logical condition holds. |
java.lang.String |
toString()
Return a human-readable description of the condition. |
Method Detail |
public boolean holds(int logicalLineCount, int physicalLineCount, FlatFileParser.LineReader reader) throws java.io.IOException
Note that the implementation can use the reader object to read as many lines as necessary to verify if a certain condition holds - but should return false unless an IOException due to real i/o problems (and not, for example, that not enough lines exist on the file and therefore EOF is reached) is raised.
logicalLineCount
- the logical lines read so farphysicalLineCount
- the physical lines read so farreader
- an object allowing to read lines on the file
java.io.IOException
- if a I/O problem arises when reading linespublic java.lang.String toString()
|
Copyright (C) 2003,2004 dr. Cristiano Sadun | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |