Package com.opencsv.bean.customconverter
Class ConverterLanguageToBoolean<T,I>
java.lang.Object
com.opencsv.bean.AbstractBeanField<T,I>
com.opencsv.bean.customconverter.ConverterLanguageToBoolean<T,I>
- Type Parameters:
T
- Type of the bean to be manipulatedI
- Type of the index into multivalued fields
- All Implemented Interfaces:
BeanField<T,
I>
- Direct Known Subclasses:
ConvertFrenchToBoolean
,ConvertGermanToBoolean
A base class for any converter to and from booleans when the string
values have been or should be localized to a specific language.
-
Field Summary
Fields inherited from class com.opencsv.bean.AbstractBeanField
converter, errorLocale, field, fieldAccess, required, type
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
Converts localized text into aBoolean
.protected String
convertToWrite
(Object value) This method takes the current value of the field in question in the bean passed in and converts it to a string.protected abstract String[]
This represents a list of all values accepted as "false".protected abstract String[]
This represents a list of all values accepted as "true".protected abstract String
This is the string for "false" in the localized language.protected abstract String
This is the string for "true" in the localized language.Methods inherited from class com.opencsv.bean.AbstractBeanField
assignValueToField, getErrorLocale, getField, getFieldValue, getType, indexAndSplitMultivaluedField, isFieldEmptyForWrite, isRequired, setErrorLocale, setField, setFieldValue, setRequired, setType, write
-
Constructor Details
-
ConverterLanguageToBoolean
public ConverterLanguageToBoolean()
-
-
Method Details
-
getLocalizedTrue
This is the string for "true" in the localized language. This value will be used on converting from a boolean to a string.- Returns:
- The canonical name of
true
in this language
-
getLocalizedFalse
This is the string for "false" in the localized language. This value will be used on converting from a boolean to a string.- Returns:
- The canonical name of
false
in this language
-
getAllLocalizedTrueValues
This represents a list of all values accepted as "true". Any language will have more than one way to say "true", such as "yes", "y", or "1". This array should list all possibilities. Comparison is done in a case-insensitive fashion.- Returns:
- An array of all "true" strings
-
getAllLocalizedFalseValues
This represents a list of all values accepted as "false". Any language will have more than one way to say "false", such as "no", "n", or "0". This array should list all possibilities. Comparison is done in a case-insensitive fashion.- Returns:
- An array of all "false" strings
-
convert
Converts localized text into aBoolean
. The comparisons are case-insensitive.- Specified by:
convert
in classAbstractBeanField<T,
I> - Parameters:
value
- String that should represent a Boolean- Returns:
- Boolean
- Throws:
CsvDataTypeMismatchException
- If anything other than the explicitly translated pairs is found
-
convertToWrite
This method takes the current value of the field in question in the bean passed in and converts it to a string. This implementation returns true/false values in the localized language.- Overrides:
convertToWrite
in classAbstractBeanField<T,
I> - Parameters:
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.- Returns:
- Localized text value for "true" or "false"
- Throws:
CsvDataTypeMismatchException
- If the field is not aboolean
orBoolean
- See Also:
-