public abstract class AbstractCsvConverter extends Object implements CsvConverter
CsvConverter provides a reasonable default
for CsvConverter.convertToWrite(java.lang.Object) as well as a couple
of common fields.| Modifier and Type | Field and Description |
|---|---|
protected Locale |
errorLocale
The locale to be used for error messages.
|
protected Locale |
locale
The locale to be used when converting for reading, if a locale is relevant.
|
protected Class<?> |
type
The type to which (on reading) or from which (on writing) conversion
is being performed.
|
protected Locale |
writeLocale
The locale to be used when converting for writing, if a locale is
relevant.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCsvConverter()
Default nullary constructor, so derived classes aren't forced to create
a constructor identical to this one.
|
protected |
AbstractCsvConverter(Class<?> type,
String locale,
String writeLocale,
Locale errorLocale)
Currently the only constructor for this class.
|
| Modifier and Type | Method and Description |
|---|---|
String |
convertToWrite(Object value)
This implementation simply calls
toString() on value. |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconvertToReadprotected Class<?> type
protected Locale locale
protected Locale writeLocale
protected Locale errorLocale
protected AbstractCsvConverter()
protected AbstractCsvConverter(Class<?> type, String locale, String writeLocale, Locale errorLocale)
type - The type to which (on reading) or from which (on writing) is
being convertedlocale - The locale to be used when converting for reading, if a
locale is relevantwriteLocale - The locale to be used when converting for writing, if
a locale is relevanterrorLocale - The locale to be used for error messagespublic String convertToWrite(Object value) throws CsvDataTypeMismatchException
toString() on value.
For complex types, overriding the toString() method in the type
of the field in question would be an alternative to writing a conversion
routine in a class derived from this one.convertToWrite in interface CsvConvertervalue - 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 nullCsvDataTypeMismatchException - This implementation doesn't, but
subclasses do, so it must be declaredpublic void setErrorLocale(Locale errorLocale)
CsvConvertersetErrorLocale in interface CsvConvertererrorLocale - Locale for error messages. If null, the
default locale is used.public void setType(Class<?> type)
CsvConvertersetType in interface CsvConvertertype - The type of the data being processedpublic void setLocale(String locale)
CsvConvertersetLocale in interface CsvConverterlocale - The name of the locale for locale-sensitive datapublic void setWriteLocale(String writeLocale)
CsvConvertersetWriteLocale in interface CsvConverterwriteLocale - The name of the locale for locale-sensitive dataCopyright © 2005–2025. All rights reserved.