Package com.opencsv.bean
Class BeanFieldSingleValue<T,I>
java.lang.Object
com.opencsv.bean.AbstractBeanField<T,I>
com.opencsv.bean.BeanFieldSingleValue<T,I>
- Type Parameters:
T
- The type of the bean being populatedI
- Type of the index into a multivalued field
- All Implemented Interfaces:
BeanField<T,
I>
- Direct Known Subclasses:
BeanFieldJoin
This class concerns itself with handling single-valued bean fields.
- Since:
- 4.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Pattern
The regular expression to be used for capturing part of the input for processing.protected final String
The format string used for packaging values to be written.Fields inherited from class com.opencsv.bean.AbstractBeanField
converter, errorLocale, field, fieldAccess, required, type
-
Constructor Summary
ConstructorsConstructorDescriptionBeanFieldSingleValue
(Class<?> type, Field field, boolean required, Locale errorLocale, CsvConverter converter, String capture, String format) Simply calls the same constructor in the base class. -
Method Summary
Methods inherited from class com.opencsv.bean.AbstractBeanField
assignValueToField, getErrorLocale, getField, getFieldValue, getType, indexAndSplitMultivaluedField, isFieldEmptyForWrite, isRequired, setErrorLocale, setField, setFieldValue, setRequired, setType, write
-
Field Details
-
capture
The regular expression to be used for capturing part of the input for processing. If there was no regular expression specified, this field isnull
. -
writeFormat
The format string used for packaging values to be written. Ifnull
or empty, it is ignored.
-
-
Constructor Details
-
BeanFieldSingleValue
public BeanFieldSingleValue(Class<?> type, Field field, boolean required, Locale errorLocale, CsvConverter converter, String capture, String format) Simply calls the same constructor in the base class.- Parameters:
type
- The type of the class in which this field is found. This is the type as instantiated by opencsv, and not necessarily the type in which the field is declared in the case of inheritance.field
- AField
object.required
- Whether or not this field is required in inputerrorLocale
- The errorLocale to use for error messages.converter
- The converter to be used to perform the actual data conversioncapture
- SeeCsvBindByName.capture()
format
- The format string used for packaging values to be written. Ifnull
or empty, it is ignored.- See Also:
-
-
Method Details
-
convert
protected Object convert(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException Passes the string to be converted to the converter.- Specified by:
convert
in classAbstractBeanField<T,
I> - Parameters:
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 toStringUtils.isBlank(java.lang.CharSequence)
- Returns:
- An
Object
representing the input data converted into the proper type - Throws:
CsvBadConverterException
- If the converter is nullCsvDataTypeMismatchException
- 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 file
-
convertToWrite
Passes the object to be converted to the converter.- 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:
- A string representation of the value of the field in question in
the bean passed in, or an empty string if
value
is null - Throws:
CsvBadConverterException
- If the converter is nullCsvDataTypeMismatchException
- This implementation does not throw this exception- See Also:
-