public class CharacterConverter extends Object implements Converter<Character,Boolean>
The CsvColumn.converterFlags()
parameter can be set to PARSE_ERROR_IF_MORE_THAN_ONE_CHAR
to throw a
parse error if the input has more than one character.
Modifier and Type | Field and Description |
---|---|
static long |
PARSE_ERROR_IF_MORE_THAN_ONE_CHAR
Use this flag if you want a parse error generated when the input has more than one character.
|
Constructor and Description |
---|
CharacterConverter() |
Modifier and Type | Method and Description |
---|---|
Boolean |
configure(String format,
long flags,
ColumnInfo<Character> fieldInfo)
Configure this instance of the converter based on the associated params.
|
static CharacterConverter |
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(Boolean parseErrorOnMoreThanOne)
Returns true if the field needs to be quoted in the CSV output.
|
String |
javaToString(ColumnInfo<Character> columnInfo,
Character value)
Converts from a Java representation to string.
|
Character |
stringToJava(String line,
int lineNumber,
int linePos,
ColumnInfo<Character> columnInfo,
String value,
ParseError parseError)
Converts from a string representation to Java.
|
public static final long PARSE_ERROR_IF_MORE_THAN_ONE_CHAR
public static CharacterConverter getSingleton()
public Boolean configure(String format, long flags, ColumnInfo<Character> fieldInfo)
Converter
configure
in interface Converter<Character,Boolean>
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(Boolean parseErrorOnMoreThanOne)
Converter
isNeedsQuotes
in interface Converter<Character,Boolean>
public boolean isAlwaysTrimInput()
Converter
Converter.stringToJava(String, int, int, ColumnInfo, String, ParseError)
.isAlwaysTrimInput
in interface Converter<Character,Boolean>
public String javaToString(ColumnInfo<Character> columnInfo, Character value)
Converter
javaToString
in interface Converter<Character,Boolean>
columnInfo
- Information about the column we are processing.value
- Value of the field that we are converting.public Character stringToJava(String line, int lineNumber, int linePos, ColumnInfo<Character> columnInfo, String value, ParseError parseError)
Converter
stringToJava
in interface Converter<Character,Boolean>
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.