public class DelimiterSeparatedValues
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_COMMENT_TEXT
The default comment text.
|
static char |
DEFAULT_DELIMITER_CHAR
The default delimiter character.
|
static char |
DEFAULT_ESCAPE_CHAR
The default escape character.
|
static java.lang.String |
DEFAULT_ESCAPED_CHARS
The default characters that should be escaped.
|
static java.lang.String |
DEFAULT_LINE_SEPARATOR
The default line separator.
|
static java.lang.String |
STANDARD_COMMENT_TEXT
The standard comment text.
|
static int |
USE_QUOTES_ALWAYS
Use quotes value to specify that quotes should always be used.
|
static int |
USE_QUOTES_AS_NEEDED
Use quotes value to specify that quotes should be used as needed.
|
static int |
USE_QUOTES_NEVER
Use quotes value to specify that quotes should never be used.
|
Constructor and Description |
---|
DelimiterSeparatedValues()
Creates comma-separated values (CSV) without comment text.
|
DelimiterSeparatedValues(java.lang.String commentText)
Creates comma-separated values (CSV) with optional comment text.
|
DelimiterSeparatedValues(java.lang.String commentText,
char delimiterChar,
java.lang.String escapeChars,
char escapeChar)
Creates delimiter-separated values.
|
DelimiterSeparatedValues(java.lang.String commentText,
char delimiterChar,
java.lang.String escapedChars,
char escapeChar,
java.lang.String reservedChars)
Creates delimiter-separated values.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getLineSeparator()
Gets the line separator.
|
java.lang.String |
getQuotedText(java.lang.String valueStr)
Gets a quoted string where all quote characters are replaced
by double quote characters.
|
static java.lang.String |
getReservedChars(char delimiterChar)
Gets the reserverd characters.
|
int |
getUseQuotesValue()
Gets the use quotes value.
|
int |
getUseQuotesValue(int column)
Gets the use quotes value for the specified column.
|
java.lang.String |
getValueStr(java.lang.Object valueObj)
Gets the value string for the value object.
|
static void |
main(java.lang.String[] args) |
void |
readNext(java.io.BufferedReader br,
java.util.List valueList,
java.lang.StringBuffer valueBuffer)
Read the next set of fields.
|
void |
setLineSeparator(java.lang.String lineSeparator)
Sets the line separator.
|
void |
setUseQuotesValue(int v)
Sets the use quotes value.
|
void |
setUseQuotesValue(int[] v)
Sets the use quotes value array.
|
boolean |
shouldBeQuoted(java.lang.String valueStr,
int column)
Determines if the value should be quoted.
|
void |
writeNext(java.io.Writer w,
java.util.List valueList)
Write the values.
|
public static final java.lang.String DEFAULT_COMMENT_TEXT
public static final java.lang.String STANDARD_COMMENT_TEXT
public static final char DEFAULT_DELIMITER_CHAR
public static final java.lang.String DEFAULT_ESCAPED_CHARS
public static final char DEFAULT_ESCAPE_CHAR
public static final java.lang.String DEFAULT_LINE_SEPARATOR
public static final int USE_QUOTES_NEVER
public static final int USE_QUOTES_AS_NEEDED
public static final int USE_QUOTES_ALWAYS
public DelimiterSeparatedValues()
public DelimiterSeparatedValues(java.lang.String commentText)
commentText
- the text that starts comment lines or null if none.STANDARD_COMMENT_TEXT
public DelimiterSeparatedValues(java.lang.String commentText, char delimiterChar, java.lang.String escapeChars, char escapeChar)
commentText
- the text that starts comment lines or null if none.delimiterChar
- the delimiter character.escapeChars
- the characters that should be escaped.
This should always contain the escape character.escapeChar
- the escape character.public DelimiterSeparatedValues(java.lang.String commentText, char delimiterChar, java.lang.String escapedChars, char escapeChar, java.lang.String reservedChars)
commentText
- the text that starts comment lines or null if none.delimiterChar
- the delimiter character.escapedChars
- the characters that should be escaped.
This should always contain the escape character.escapeChar
- the escape character.reservedChars
- the reserved characters that should be quoted.getReservedChars
public java.lang.String getLineSeparator()
public java.lang.String getQuotedText(java.lang.String valueStr)
valueStr
- the value string or null if none.public static java.lang.String getReservedChars(char delimiterChar)
delimiterChar
- the delimiter character.public int getUseQuotesValue()
USE_QUOTES_NEVER, USE_QUOTES_AS_NEEDED, USE_QUOTES_ALWAYS
public int getUseQuotesValue(int column)
column
- the column.USE_QUOTES_NEVER, USE_QUOTES_AS_NEEDED, USE_QUOTES_ALWAYS
public java.lang.String getValueStr(java.lang.Object valueObj)
valueObj
- the value object or null if none.public void readNext(java.io.BufferedReader br, java.util.List valueList, java.lang.StringBuffer valueBuffer) throws java.io.IOException
br
- the buffered reader.valueBuffer
- the value buffer.valueList
- the list of string values. This list is normally empty
when this method is called and is filled by this method.java.io.IOException
- if error.public void setLineSeparator(java.lang.String lineSeparator)
lineSeparator
- the line separator.public void setUseQuotesValue(int v)
v
- the use quotes value.USE_QUOTES_NEVER, USE_QUOTES_AS_NEEDED, USE_QUOTES_ALWAYS
public void setUseQuotesValue(int[] v)
v
- the use quotes value array or null if none.USE_QUOTES_NEVER, USE_QUOTES_AS_NEEDED, USE_QUOTES_ALWAYS
public boolean shouldBeQuoted(java.lang.String valueStr, int column)
valueStr
- the value string or null if none.column
- the column where 0 is the first column.public void writeNext(java.io.Writer w, java.util.List valueList) throws java.io.IOException
w
- the writer.valueList
- the list of values.java.io.IOException
- if error.public static void main(java.lang.String[] args)