public class StringConverter extends Object implements Converter<String,com.j256.simplecsv.converter.StringConverter.ConfigInfo>
The CsvColumn.converterFlags()
parameter can be set to TRIM_OUTPUT
for trimming before a column is
printed and/or BLANK_IS_NULL
to have a blank-string interpreted as a null value.
Modifier and Type | Field and Description |
---|---|
static long |
BLANK_IS_NULL
If enabled, a blank string will be interpreted as a null value.
|
static long |
TRIM_OUTPUT
If enabled, trim() to be called on the string before it is printed.
|
Constructor and Description |
---|
StringConverter() |
Modifier and Type | Method and Description |
---|---|
com.j256.simplecsv.converter.StringConverter.ConfigInfo |
configure(String format,
long flags,
ColumnInfo<String> fieldInfo)
Configure this instance of the converter based on the associated params.
|
static StringConverter |
getSingleton()
Get singleton for class.
|
boolean |
isAlwaysTrimInput()
Returns true if the field should trim the string before it is passed to
Converter.stringToJava(String, int, int, ColumnInfo, String, ParseError) . |
boolean |
isNeedsQuotes(com.j256.simplecsv.converter.StringConverter.ConfigInfo configInfo)
Returns true if the field needs to be quoted in the CSV output.
|
String |
javaToString(ColumnInfo<String> columnInfo,
String value)
Converts from a Java representation to string.
|
String |
stringToJava(String line,
int lineNumber,
int linePos,
ColumnInfo<String> columnInfo,
String value,
ParseError parseError)
Converts from a string representation to Java.
|
public static final long TRIM_OUTPUT
public static final long BLANK_IS_NULL
public static StringConverter getSingleton()
public com.j256.simplecsv.converter.StringConverter.ConfigInfo configure(String format, long flags, ColumnInfo<String> fieldInfo)
Converter
configure
in interface Converter<String,com.j256.simplecsv.converter.StringConverter.ConfigInfo>
format
- Optional string format which affects the output and parsing of the field. Null if none supplied in
which case the default format is used.flags
- Optional numerical flags which affect the output and parsing of the field. 0 if no flags supplied.fieldInfo
- Information about the field associated with this converter.public boolean isNeedsQuotes(com.j256.simplecsv.converter.StringConverter.ConfigInfo configInfo)
Converter
isNeedsQuotes
in interface Converter<String,com.j256.simplecsv.converter.StringConverter.ConfigInfo>
public boolean isAlwaysTrimInput()
Converter
Converter.stringToJava(String, int, int, ColumnInfo, String, ParseError)
.isAlwaysTrimInput
in interface Converter<String,com.j256.simplecsv.converter.StringConverter.ConfigInfo>
public String javaToString(ColumnInfo<String> columnInfo, String value)
Converter
javaToString
in interface Converter<String,com.j256.simplecsv.converter.StringConverter.ConfigInfo>
columnInfo
- Information about the column we are processing.value
- Value of the field that we are converting.public String stringToJava(String line, int lineNumber, int linePos, ColumnInfo<String> columnInfo, String value, ParseError parseError)
Converter
stringToJava
in interface Converter<String,com.j256.simplecsv.converter.StringConverter.ConfigInfo>
line
- Line we are processing for logging purposes.lineNumber
- Number of the line we are processing for logging purposes.linePos
- Position in the line that we are converting to identify what part of the line contains the value.columnInfo
- Information about the column we are processing.value
- Value of the field that we are converting.parseError
- Parse error which can we use to set information about parse errors here. If there are no parse errors
then just ignore this field. Any exceptions thrown will also be caught and interpreted as errors.ParseError.ErrorType.NONE
.This documentation content is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.