public interface CsvConverter
This interface is used by BeanField to perform the actual data conversion.
Synchronization: All implementations of this interface must be thread-safe.
Modifier and Type | Method and Description |
---|---|
Object |
convertToRead(String value)
Method for converting from a string to the proper data type of the
destination field.
|
String |
convertToWrite(Object value)
Method for converting from the data type of the destination field to a
string.
|
void |
setErrorLocale(Locale errorLocale)
Sets the locale for all error messages.
|
void |
setLocale(String locale)
If not null or empty, specifies the locale used for converting
locale-specific data types for reading.
|
void |
setType(Class<?> type)
Sets the class of the type of the data being processed.
|
void |
setWriteLocale(String writeLocale)
If not null or empty, specifies the locale used for converting
locale-specific data types for writing.
|
Object convertToRead(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException
value
- The string from the selected field of the CSV file. If the
field is marked as required in the annotation, this value is guaranteed
not to be null
, empty or blank according to
StringUtils.isBlank(java.lang.CharSequence)
Object
representing the input data converted
into the proper typeCsvDataTypeMismatchException
- If the input string cannot be converted into
the proper typeCsvConstraintViolationException
- When the internal structure of
data would be violated by the data in the CSV fileString convertToWrite(Object value) throws CsvDataTypeMismatchException
value
- The contents of the field currently being processed from the
bean to be written. Can be null
if the field is not marked as
required.value
is
null
CsvDataTypeMismatchException
- If the input cannot be converted to
a string by this convertervoid setErrorLocale(Locale errorLocale)
errorLocale
- Locale for error messages. If null
, the
default locale is used.void setType(Class<?> type)
type
- The type of the data being processedvoid setLocale(String locale)
locale
- The name of the locale for locale-sensitive datavoid setWriteLocale(String writeLocale)
writeLocale
- The name of the locale for locale-sensitive dataCopyright © 2005–2023. All rights reserved.