|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.jdbcimporter.parser.CSVDelimiterParser
The CSVDelimiterParser class implements the DelimiterParser interface to parse character delimited column values. Each column value is separated from another column value by a character or set of characters (ex. ','). In addition, the CSVDelimiterParser 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 java.lang.String |
enclosedDelimiter
The character(s) that enclose each column value. |
protected boolean |
enclosedOptional
Flag indicating that all column values are enclosed by the enclosed delimiter. |
protected boolean |
firstLine
Flag indicating that the first line has been read from the input reader. |
protected int[] |
ignoredPositions
The column indices in the file that should be skipped. |
protected boolean |
ignoreFirstLine
Flag indicating that the first line should be ignored. |
protected java.io.BufferedReader |
inputReader
The input reader. |
protected static org.apache.commons.logging.Log |
LOG
The log for debug information. |
protected boolean |
multiline
Flag indicating that rows could be multi-line. |
| Constructor Summary | |
CSVDelimiterParser()
|
|
| Method Summary | |
java.lang.String |
getColumnDelimiter()
Returns the character(s) that separate each column value. |
protected java.lang.String |
getColumnEnclosedNextRow()
Returns the next row which may span multiple lines. |
java.lang.String |
getEnclosedDelimiter()
Returns the character(s) that enclose each column value. |
java.lang.String |
getNextRow()
Returns the next row to be imported as a String. |
ColumnValue[] |
getValues(java.lang.String nextRow)
Returns the column values for the row specified. |
boolean |
isEnclosedOptional()
Returns whether each column value must be enclosed by the set of characters defined. |
protected ColumnValue[] |
parseColumnDelimitedLine(java.lang.String line)
Parse the character delimited line into ColumnValues. |
protected ColumnValue[] |
parseColumnEnclosedDelimitedLine(java.lang.String line)
Parse the character delimited line, whose values are also enclosed, into ColumnValues. |
void |
setColumnDelimiter(java.lang.String delimiter)
Sets the character(s) that separate each column value. |
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 |
setIgnoredPositions(int[] positions)
Sets the positions, in the csv, to ignore and not return as values. |
void |
setIgnoreFirstLine(boolean flag)
Sets the flag to indicate that the first line should be ignored. |
void |
setMultiline(boolean flag)
Sets the flag to indicate that the csv may contain rows that span multiple lines. |
void |
setReader(java.io.Reader reader)
Sets the input source for the parser. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static org.apache.commons.logging.Log LOG
protected java.lang.String columnDelimiter
protected java.lang.String enclosedDelimiter
protected boolean enclosedOptional
protected int[] ignoredPositions
protected java.io.BufferedReader inputReader
protected boolean multiline
protected boolean ignoreFirstLine
protected boolean firstLine
| Constructor Detail |
public CSVDelimiterParser()
| 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 setIgnoredPositions(int[] positions)
positions - a comma-separated list of positions (first position = 1)public void setMultiline(boolean flag)
flag - flag to indicate that rows may span multiple linespublic void setIgnoreFirstLine(boolean flag)
flag - flag to indicate that the first line should be ignoredpublic void setReader(java.io.Reader reader)
DelimiterParser
setReader in interface DelimiterParserreader - the source of the data to import.DelimiterParser.setReader(Reader)
public java.lang.String getNextRow()
throws java.io.IOException
DelimiterParser
getNextRow in interface DelimiterParserjava.io.IOException - if an error occurs while retrieving the next rowDelimiterParser.getNextRow()
public ColumnValue[] getValues(java.lang.String nextRow)
throws MalformedDataException
DelimiterParser
getValues in interface DelimiterParsernextRow - the row to be parsed into column values
MalformedDataException - if the row is not formatted properlyDelimiterParser.getValues(String nextRow)protected ColumnValue[] parseColumnDelimitedLine(java.lang.String line)
line - the line
protected ColumnValue[] parseColumnEnclosedDelimitedLine(java.lang.String line)
throws MalformedDataException
line - the line
MalformedDataException
protected java.lang.String getColumnEnclosedNextRow()
throws java.io.IOException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||