T
- the annotated class type.public class BeanConversionProcessor<T> extends DefaultConversionProcessor
Processor
and RowWriterProcessor
implementations that support java beans annotated with the annotations provided in com.univocity.parsers.annotations
.Processor
,
RowWriterProcessor
Modifier and Type | Field and Description |
---|---|
protected boolean |
initialized |
protected Set<FieldMapping> |
parsedFields |
Constructor and Description |
---|
BeanConversionProcessor(Class<T> beanType)
Deprecated.
Use the
BeanConversionProcessor(Class, MethodFilter) constructor instead. |
BeanConversionProcessor(Class<T> beanType,
MethodFilter methodFilter)
Initializes the BeanConversionProcessor with the annotated bean class
|
Modifier and Type | Method and Description |
---|---|
protected void |
addConversion(Conversion conversion,
FieldMapping mapping)
Associates a conversion to a field of the java bean class.
|
T |
createBean(String[] row,
Context context)
Converts a record with values extracted from the parser into a java bean instance.
|
Class<T> |
getBeanClass()
Returns the class of the annotated java bean instances that will be manipulated by this processor.
|
void |
initialize()
Identifies and extracts fields annotated with the
Parsed annotation |
protected void |
initialize(String[] headers)
Identifies and extracts fields annotated with the
Parsed annotation |
boolean |
isStrictHeaderValidationEnabled()
Returns a flag indicating whether all headers declared in the annotated class must be present in the input.
|
protected boolean |
processField(FieldMapping field)
Determines whether or not an annotated field should be processed.
|
Object[] |
reverseConversions(T bean,
String[] headers,
int[] indexesToWrite)
Converts a java bean instance into a sequence of values for writing.
|
void |
setStrictHeaderValidationEnabled(boolean strictHeaderValidationEnabled)
Defines whether all headers declared in the annotated class must be present in the input.
|
applyConversions, convertAll, convertFields, convertIndexes, convertType, handleConversionError, initializeConversions, reverseConversions, toDataProcessingException
protected final Set<FieldMapping> parsedFields
protected boolean initialized
@Deprecated public BeanConversionProcessor(Class<T> beanType)
BeanConversionProcessor(Class, MethodFilter)
constructor instead.beanType
- the class annotated with one or more of the annotations provided in com.univocity.parsers.annotations
.public BeanConversionProcessor(Class<T> beanType, MethodFilter methodFilter)
beanType
- the class annotated with one or more of the annotations provided in com.univocity.parsers.annotations
.methodFilter
- filter to apply over annotated methods when the processor is reading data from beans (to write values to an output)
or writing values into beans (when parsing). It is used to choose either a "get" or a "set"
method annotated with Parsed
, when both methods target the same field.public boolean isStrictHeaderValidationEnabled()
public final void initialize()
Parsed
annotationprotected final void initialize(String[] headers)
Parsed
annotationheaders
- headers parsed from the input.public void setStrictHeaderValidationEnabled(boolean strictHeaderValidationEnabled)
strictHeaderValidationEnabled
- flag indicating whether strict validation of headers is enabled.protected boolean processField(FieldMapping field)
field
- the field to be processedtrue
if the given field should be processed, otherwise false
.protected void addConversion(Conversion conversion, FieldMapping mapping)
conversion
- The conversion object that must be executed against the given fieldmapping
- the helper object that contains information about how a field is mapped.public T createBean(String[] row, Context context)
row
- The values extracted from the parsercontext
- The current state of the parsing processpublic final Object[] reverseConversions(T bean, String[] headers, int[] indexesToWrite)
bean
- an instance of the type defined in this class constructor.headers
- All field names used to produce records in a given destination. May be null if no headers have been defined in CommonSettings.getHeaders()
indexesToWrite
- The indexes of the headers that are actually being written. May be null if no fields have been selected using CommonSettings.selectFields(String...)
or CommonSettings.selectIndexes(Integer...)
Copyright © 2024 uniVocity Software Pty Ltd. All rights reserved.