DataFile 1.4

com.infomata.data
Class SimpleDelimiterFormat

java.lang.Object
  extended bycom.infomata.data.SimpleDelimiterFormat
All Implemented Interfaces:
DataFormat

public class SimpleDelimiterFormat
extends java.lang.Object
implements DataFormat

SimpleDelimiterFormat is configurable data format that uses simple delimiter and escape sequence scheme to encode data into a text file.

Examples:

Format Instantiation
Tab separated new SimpleDelimiterFormat("\t", null)
Pipe separated new SimpleDelimiterFormat("|", "\")

Version:
$Revision: 1.1 $
Author:
Sam Kim

Constructor Summary
SimpleDelimiterFormat(java.lang.String delimiter, java.lang.String escape)
          Creates a new instance of SimpleDelimiterFormat with specified delimiter and escape sequence.
 
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

SimpleDelimiterFormat

public SimpleDelimiterFormat(java.lang.String delimiter,
                             java.lang.String escape)
                      throws java.lang.IllegalArgumentException
Creates a new instance of SimpleDelimiterFormat with specified delimiter and escape sequence.

Parameters:
delimiter - - character sequence used to separate one element from another. delimiter CANNOT be NULL or empty string.
escape - - character sequence used to signal that next character sequence (either delimiter or escape) is part of data.
Method Detail

parseLine

public DataRow parseLine(java.lang.String line)
Description copied from interface: 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.

Specified by:
parseLine in interface DataFormat
Parameters:
line - line containing data items.
Returns:
a DataRow object containing data items in individual cells.

format

public java.lang.String format(DataRow row)
Description copied from interface: DataFormat
Converts the data contained in the DataRow object into a line of data.

Specified by:
format in interface DataFormat
Parameters:
row - a DataRow object containing data
Returns:
String representing data items contained in DataRow object.

DataFile 1.4

Copyright © 2004 Infomata. All Rights Reserved.