Package com.opencsv.bean.customconverter
Class ConvertGermanToBoolean<T,I>
- java.lang.Object
-
- com.opencsv.bean.AbstractBeanField<T,I>
-
- com.opencsv.bean.customconverter.ConvertGermanToBoolean<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>
public class ConvertGermanToBoolean<T,I> extends AbstractBeanField<T,I>
This class converts common German representations of boolean values into a Boolean. This class also demonstrates how to localize booleans for any other language.- Since:
- 3.8
- Author:
- Andrew Rucker Jones
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
FALSCH
protected static java.lang.String
WAHR
-
Fields inherited from class com.opencsv.bean.AbstractBeanField
converter, errorLocale, field, fieldAccess, required, type
-
-
Constructor Summary
Constructors Constructor Description ConvertGermanToBoolean()
Silence code style checker by adding a useless constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object
convert(java.lang.String value)
Converts German text into a Boolean.protected java.lang.String
convertToWrite(java.lang.Object value)
This method takes the current value of the field in question in the bean passed in and converts it to a string.-
Methods inherited from class com.opencsv.bean.AbstractBeanField
assignValueToField, getErrorLocale, getField, getFieldValue, getType, indexAndSplitMultivaluedField, isFieldEmptyForWrite, isRequired, setErrorLocale, setField, setFieldValue, setRequired, setType, write
-
-
-
-
Field Detail
-
WAHR
protected static final java.lang.String WAHR
- See Also:
- Constant Field Values
-
FALSCH
protected static final java.lang.String FALSCH
- See Also:
- Constant Field Values
-
-
Method Detail
-
convert
protected java.lang.Object convert(java.lang.String value) throws CsvDataTypeMismatchException
Converts German text into a Boolean. The comparisons are case-insensitive. The recognized pairs are wahr/falsch, w/f, ja/nein, j/n, 1/0.- 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
protected java.lang.String convertToWrite(java.lang.Object value) throws CsvDataTypeMismatchException
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 German.- 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:
- "wahr" if true, "falsch" if false
- Throws:
CsvDataTypeMismatchException
- If the field is not aboolean
orBoolean
- See Also:
AbstractBeanField.write(java.lang.Object, java.lang.Object)
-
-