Top Description Fields Constructors Methods
com.opencsv.bean

public Class BeanFieldSingleValue<T, I>

extends AbstractBeanField<T, I>
Class Inheritance
Known Direct Subclasses
com.opencsv.bean.BeanFieldJoin
Type Parameters
<T>
The type of the bean being populated
<I>
Type of the index into a multivalued field
Imports
com.opencsv.ICSVParser, com.opencsv.bean.util.OpencsvUtils, com.opencsv.exceptions.CsvBadConverterException, .CsvConstraintViolationException, .CsvDataTypeMismatchException, org.apache.commons.lang3.StringUtils, java.lang.reflect.Field, java.util.Locale, .ResourceBundle, java.util.regex.Matcher, .Pattern

This class concerns itself with handling single-valued bean fields.
Author
Andrew Rucker Jones
Since
4.2

Field Summary

Modifier and TypeField and Description
protected final Pattern
capture

The regular expression to be used for capturing part of the input for processing.

protected final String
writeFormat

The format string used for packaging values to be written.

Inherited from com.opencsv.bean.AbstractBeanField:
convertererrorLocalefieldfieldAccessrequiredtype

Constructor Summary

AccessConstructor and Description
public
BeanFieldSingleValue(Class<?>
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.
type
,
Field field, boolean
Whether or not this field is required in input
required
,
Locale
The errorLocale to use for error messages.
errorLocale
,
CsvConverter
The converter to be used to perform the actual data conversion
converter
,
String capture, String
The format string used for packaging values to be written. If null or empty, it is ignored.
format
)

Simply calls the same constructor in the base class.

Method Summary

Modifier and TypeMethod and Description
protected Object
convert(String value)

Implements abstract com.opencsv.bean.AbstractBeanField.convert.

Passes the string to be converted to the converter.

protected String
convertToWrite(Object value)

Overrides com.opencsv.bean.AbstractBeanField.convertToWrite.

Passes the object to be converted to the converter.

Inherited from com.opencsv.bean.AbstractBeanField:
assignValueToFieldgetErrorLocalegetFieldgetFieldValuegetTypeindexAndSplitMultivaluedFieldisFieldEmptyForWriteisRequiredsetErrorLocalesetFieldsetFieldValuesetRequiredsetTypewrite

Field Detail

captureback to summary
protected final Pattern capture

The regular expression to be used for capturing part of the input for processing. If there was no regular expression specified, this field is null.

writeFormatback to summary
protected final String writeFormat

The format string used for packaging values to be written. If null or empty, it is ignored.

Constructor Detail

BeanFieldSingleValueback to summary
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:Class<?>

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:Field

A java.lang.reflect.Field object.

required:boolean

Whether or not this field is required in input

errorLocale:Locale

The errorLocale to use for error messages.

converter:CsvConverter

The converter to be used to perform the actual data conversion

capture:String

See CsvBindByName#capture()

format:String

The format string used for packaging values to be written. If null or empty, it is ignored.

See Also
AbstractBeanField#AbstractBeanField(Class, Field, boolean, Locale, CsvConverter)

Method Detail

convertback to summary
protected Object convert(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException

Implements abstract com.opencsv.bean.AbstractBeanField.convert.

Passes the string to be converted to the converter.

Annotations
@Override
Exceptions
CsvDataTypeMismatchException:

Doc from com.opencsv.bean.AbstractBeanField.convert.

If the input string cannot be converted into the proper type

CsvConstraintViolationException:

Doc from com.opencsv.bean.AbstractBeanField.convert.

When the internal structure of data would be violated by the data in the CSV file

CsvBadConverterException:
If the converter is null
convertToWriteback to summary
protected String convertToWrite(Object value) throws CsvDataTypeMismatchException

Overrides com.opencsv.bean.AbstractBeanField.convertToWrite.

Passes the object to be converted to the converter.

Annotations
@Override
Exceptions
CsvDataTypeMismatchException:

Doc from com.opencsv.bean.AbstractBeanField.convertToWrite.

This implementation does not throw this exception

CsvBadConverterException:
If the converter is null