|
DataFile 1.4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.infomata.data.ItemPerLineFormat
Sample implementation of DataFormat
interface for data file with one item per line.
public class ItemPerLineFormat implements DataFormat { public DataRow parseLine(String line) { DataRow row = null; if (line != null) { row = new DataRow(); row.add(line); } return row; } public String format(DataRow row) { return row.getString(0); } }
Constructor Summary | |
ItemPerLineFormat()
|
Method Summary | |
java.lang.String |
format(DataRow row)
Converts the data contained in the DataRow object into a line of data. |
DataRow |
parseLine(java.lang.String line)
Parses a line of data into a DataRow object which contains each data item in individual cells. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ItemPerLineFormat()
Method Detail |
public DataRow parseLine(java.lang.String line)
DataFormat
Parses a line of data into a DataRow object
which contains each data item in individual cells.
If the line of data does not terminate properly,
the method must return null and keep the currently parsed
row in memory for further processing. Only when termination
requirements have been met, the method should return a
DataRow
object.
For example, a CSV formated cell may contain a new line character.
Since the each line is delimited using new line character,
the line may contain only a part of the CSV data cell content.
The CSVFormat
implementation does not return a
non-null reference to the DataRow
object until
that cell has been terminated properly.
parseLine
in interface DataFormat
line
- line containing data items.
DataRow
object containing
data items in individual cells.public java.lang.String format(DataRow row)
DataFormat
format
in interface DataFormat
row
- a DataRow
object containing data
|
DataFile 1.4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |