|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jdbcexporter.formatter.CSVDelimiterFormatter
The CSVDelimiterFormatter class implements the DelimiterFormatter interface to format column values in a character delimiter format. Each column value is separated from another column value by a character or set of characters (ex. ','). In addition, the CSVDelimiterFormatter supports the ability to enclose each column value with a character or set of characters (ex. '"' ).
Field Summary | |
protected java.lang.String |
columnDelimiter
The character(s) that separate each column value. |
protected int[] |
emptyPositions
Sets the positions, in the csv, to place empty strings as their values. |
protected java.lang.String |
enclosedDelimiter
The character(s) that enclose each column value. |
protected boolean |
enclosedOptional
The flag indicating each column value must be enclosed by the set of characters defined. |
protected java.lang.String |
header
The initial contents of the file. |
protected boolean |
writeHeader
Flag to indicate that the header should be written before the next row is. |
Constructor Summary | |
CSVDelimiterFormatter()
|
Method Summary | |
void |
finish()
Finishs the writing of rows to the output source. |
java.lang.String |
formatValues(ColumnValue[] values)
Creates a string representing the row of column values. |
java.lang.String |
getColumnDelimiter()
Returns the character(s) that separate each column value. |
java.lang.String |
getEnclosedDelimiter()
Returns the character(s) that enclose each column value. |
java.lang.String |
getHeader()
Returns the header of the output file. |
boolean |
isEnclosedOptional()
Returns whether each column value must be enclosed by the set of characters defined. |
void |
setColumnDelimiter(java.lang.String delimiter)
Sets the character(s) that separate each column value. |
void |
setEmptyPositions(int[] positions)
Sets the positions, in the csv, to place empty strings as their values. |
void |
setEnclosedDelimiter(java.lang.String delimiter)
Sets the character(s) that enclose each column value. |
void |
setEnclosedOptional(boolean optional)
Sets that each column value must be enclosed by the set of characters defined. |
void |
setHeader(java.lang.String header)
Sets the header of the output file. |
void |
setWriter(java.io.Writer output)
Sets the output source for the formatter. |
void |
writeNextRow(java.lang.String row)
Writes the next row to the output source. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String columnDelimiter
protected java.lang.String enclosedDelimiter
protected boolean enclosedOptional
protected int[] emptyPositions
protected java.lang.String header
protected boolean writeHeader
Constructor Detail |
public CSVDelimiterFormatter()
Method Detail |
public void setColumnDelimiter(java.lang.String delimiter)
delimiter
- the column value delimiter.public java.lang.String getColumnDelimiter()
public void setEnclosedDelimiter(java.lang.String delimiter)
delimiter
- the enclose delimiterpublic java.lang.String getEnclosedDelimiter()
public void setEnclosedOptional(boolean optional)
optional
- boolean flag indicating that each column
value must be enclosed.public boolean isEnclosedOptional()
public void setHeader(java.lang.String header)
header
- The initial contents of the filepublic java.lang.String getHeader()
public void setWriter(java.io.Writer output)
DelimiterFormatter
setWriter
in interface DelimiterFormatter
output
- the destination of the dataDelimiterFormatter.setWriter(java.io.Writer)
public void setEmptyPositions(int[] positions)
positions
- a comma-separated list of positions (first position = 1)public java.lang.String formatValues(ColumnValue[] values)
DelimiterFormatter
formatValues
in interface DelimiterFormatter
values
- the column values
DelimiterFormatter.formatValues(net.sourceforge.jdbcimporter.ColumnValue[])
public void writeNextRow(java.lang.String row) throws java.io.IOException
DelimiterFormatter
writeNextRow
in interface DelimiterFormatter
row
- the next row
java.io.IOException
- if an error occurs while writing the next rowDelimiterFormatter.writeNextRow(java.lang.String)
public void finish() throws java.io.IOException
DelimiterFormatter
finish
in interface DelimiterFormatter
java.io.IOException
DelimiterFormatter.finish()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |