Top Description Fields Constructors Methods
com.opencsv.bean

public Class BeanFieldSplit<T, I>

extends AbstractBeanField<T, I>
Class Inheritance
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, .CsvBeanIntrospectionException, .CsvConstraintViolationException, .CsvDataTypeMismatchException, org.apache.commons.collections4.Bag, .SortedBag, org.apache.commons.collections4.bag.HashBag, .TreeBag, org.apache.commons.lang3.ArrayUtils, .StringUtils, java.lang.reflect.Field, .InvocationTargetException, java.util.*, java.util.regex.Matcher, .Pattern

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

Field Summary

Modifier and TypeField and Description
private final Pattern
private final Class<? extends Collection<E>>
private final Class<?>
private final Pattern
private final String
private final String
Inherited from com.opencsv.bean.AbstractBeanField:
convertererrorLocalefieldfieldAccessrequiredtype

Constructor Summary

AccessConstructor and Description
public
BeanFieldSplit(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 splitOn, String writeDelimiter, Class<? extends Collection<E>> collectionType, Class<?> elementType, String capture, String
The format string used for packaging values to be written. If null or empty, it is ignored.
format
)

The only valid constructor.

Method Summary

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

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

This method manages the collection being created as well as splitting the data.

protected String
convertToWrite(Object value)

Overrides com.opencsv.bean.AbstractBeanField.convertToWrite.

Manages converting a collection of values into a single string.

protected boolean
isFieldEmptyForWrite(Object value)

Overrides com.opencsv.bean.AbstractBeanField.isFieldEmptyForWrite.

Checks that value is not null and not an empty java.util.Collection.

Inherited from com.opencsv.bean.AbstractBeanField:
assignValueToFieldgetErrorLocalegetFieldgetFieldValuegetTypeindexAndSplitMultivaluedFieldisRequiredsetErrorLocalesetFieldsetFieldValuesetRequiredsetTypewrite

Field Detail

captureback to summary
private final Pattern capture
collectionTypeback to summary
private final Class<? extends Collection<E>> collectionType
elementTypeback to summary
private final Class<?> elementType
splitOnback to summary
private final Pattern splitOn
writeDelimiterback to summary
private final String writeDelimiter
writeFormatback to summary
private final String writeFormat

Constructor Detail

BeanFieldSplitback to summary
public BeanFieldSplit(Class<?> type, Field field, boolean required, Locale errorLocale, CsvConverter converter, String splitOn, String writeDelimiter, Class<? extends Collection<E>> collectionType, Class<?> elementType, String capture, String format)

The only valid constructor.

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

splitOn:String

See CsvBindAndSplitByName#splitOn()

writeDelimiter:String

See CsvBindAndSplitByName#writeDelimiter()

collectionType:Class<? extends Collection<E>>

See CsvBindAndSplitByName#collectionType()

elementType:Class<?>

See CsvBindAndSplitByName#elementType()

capture:String

See CsvBindAndSplitByName#capture()

format:String

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

Method Detail

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

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

This method manages the collection being created as well as splitting the data. Once the data are split, they are sent to the converter for the actual conversion.

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

See Also
ConverterPrimitiveTypes#convertToRead(java.lang.String), ConverterDate#convertToRead(java.lang.String), ConverterNumber#convertToRead(String)
convertToWriteback to summary
protected String convertToWrite(Object value) throws CsvDataTypeMismatchException

Overrides com.opencsv.bean.AbstractBeanField.convertToWrite.

Manages converting a collection of values into a single string. The conversion of each individual value is performed by the converter.

Annotations
@Override
Exceptions
CsvDataTypeMismatchException:

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

This implementation does not throw this exception

isFieldEmptyForWriteback to summary
protected boolean isFieldEmptyForWrite(Object value)

Overrides com.opencsv.bean.AbstractBeanField.isFieldEmptyForWrite.

Checks that value is not null and not an empty java.util.Collection.

Annotations
@SuppressWarnings:unchecked
@Override