T
- The type of the bean being populatedI
- Type of the index into a multivalued fieldpublic class BeanFieldSingleValue<T,I> extends AbstractBeanField<T,I>
Modifier and Type | Field and Description |
---|---|
protected Pattern |
capture
The regular expression to be used for capturing part of the input for
processing.
|
protected String |
writeFormat
The format string used for packaging values to be written.
|
converter, errorLocale, field, fieldAccess, required, type
Constructor and Description |
---|
BeanFieldSingleValue(Class<?> type,
Field field,
boolean required,
Locale errorLocale,
CsvConverter converter,
String capture,
String format)
Simply calls the same constructor in the base class.
|
Modifier and Type | Method and Description |
---|---|
protected Object |
convert(String value)
Passes the string to be converted to the converter.
|
protected String |
convertToWrite(Object value)
Passes the object to be converted to the converter.
|
assignValueToField, getErrorLocale, getField, getFieldValue, getType, indexAndSplitMultivaluedField, isFieldEmptyForWrite, isRequired, setErrorLocale, setField, setFieldValue, setRequired, setType, write
protected final Pattern capture
null
.protected final String writeFormat
null
or empty, it is ignored.public BeanFieldSingleValue(Class<?> type, Field field, boolean required, Locale errorLocale, CsvConverter converter, String capture, String format)
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
- A Field
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
- See CsvBindByName.capture()
format
- The format string used for packaging values to be written.
If null
or empty, it is ignored.AbstractBeanField(Class, Field, boolean, Locale, CsvConverter)
protected Object convert(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException
convert
in class AbstractBeanField<T,I>
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 typeCsvBadConverterException
- 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 fileprotected String convertToWrite(Object value) throws CsvDataTypeMismatchException
convertToWrite
in class AbstractBeanField<T,I>
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 nullCsvBadConverterException
- If the converter is nullCsvDataTypeMismatchException
- This implementation does not throw
this exceptionAbstractBeanField.write(java.lang.Object, java.lang.Object)
Copyright © 2005–2023. All rights reserved.