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 |
|---|---|
| pack-priv final Class | |
| private ColumnMapping | |
| pack-priv final Constructor | |
| protected boolean | |
| private int | |
| private boolean | |
| protected final MethodFilter | |
| private FieldMapping[] | |
| private Map | |
| protected final Set | |
| private FieldMapping[] | |
| private Object[] | |
| pack-priv boolean | |
| private NormalizedString[] | |
| protected final HeaderTransformer | |
| private Object[] |
| Access | Constructor and Description |
|---|---|
| public | BeanConversionProcessor(Class<T>
the class annotated with one or more of the annotations provided in beanType)com..
Deprecated
Use the
Initializes the BeanConversionProcessor with the annotated bean class.
BeanConversionProcessor(Class, MethodFilter) constructor instead.
|
| public | BeanConversionProcessor(Class<T>
the class annotated with one or more of the annotations provided in beanType, MethodFilter com..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 methodFilter)Parsed, when both methods target the same field.Initializes the BeanConversionProcessor with the annotated bean class |
| pack-priv | BeanConversionProcessor(Class<T> beanType, HeaderTransformer transformer, MethodFilter methodFilter)
|
| Modifier and Type | Method and Description |
|---|---|
| protected void | addConversion(Conversion<I, O>
The conversion object that must be executed against the given field conversion, FieldMapping the helper object that contains information about how a field is mapped. mapping)Associates a conversion to a field of the java bean class. |
| private boolean | |
| protected FieldConversionMapping | Returns: a copy of the currently defined conversionsCreates a copy of the manually defined conversions to be applied over any columns. |
| public T | Returns: an instance of the java bean type defined in this class constructor.The values extracted from the parser row, Context The current state of the parsing process context)Converts a record with values extracted from the parser into a java bean instance. |
| pack-priv BeanConversionProcessor | createNestedProcessor(Annotation annotation, Class<T> nestedType, FieldMapping fieldMapping, HeaderTransformer transformer)
|
| pack-priv static String | |
| public Class | Returns: the class of the annotated java bean instances that will be manipulated by this processor.Returns the class of the annotated java bean instances that will be manipulated by this processor. |
| public final ColumnMapper | Returns: the column mapperReturns a mapper that allows users to manually define mappings from attributes/methods of a given class to columns to be parsed or written. |
| private Method | |
| pack-priv Map | |
| private void | |
| public final void | |
| protected final void | initialize(String[]
headers parsed from the input. headers)Identifies and extracts fields annotated with the |
| protected final void | initialize(NormalizedString[]
headers parsed from the input. headers)Identifies and extracts fields annotated with the |
| private void | |
| public boolean | Returns: flag indicating whether strict validation of headers is enabled.Returns a flag indicating whether all headers declared in the annotated class must be present in the input. |
| private void | mapFieldIndexes(Context context, Object[]
A row with values for the given java bean. row, NormalizedString[] The names of all fields of the record (including any header that is not mapped to the java bean). May be null if no headers have
been defined in headers, int[] CommonSettings#getHeaders()The indexes of the headers or row that are actually being used. May be null if no fields have been selected using
indexes, boolean CommonSettings#selectFields(String. or CommonSettings#selectIndexes(Integer.Indicates the indexes provided were reordered and do not match the original sequence of headers. columnsReordered)Identifies which fields are associated with which columns in a row. |
| private void | mapFieldsToValues(T
the java bean instance to be read instance, Object[] object array that will receive the values extracted from java bean row, NormalizedString[] The names of all fields of the record (including any header that is not mapped to the java bean). May be null if no headers have
been defined in headers, int[] CommonSettings#getHeaders()The indexes of the headers or row that are actually being used. May be null if no fields have been selected using
indexes, boolean CommonSettings#selectFields(String. or CommonSettings#selectIndexes(Integer.Indicates the indexes provided were reordered and do not match the original sequence of headers. columnsReordered)Iterates over all fields in the java bean instance and extracts its values. |
| pack-priv void | mapValuesToFields(T
the java bean instance that is going to have its properties set instance, Object[] the values to associate with each field of the javabean. row, Context information about the current parsing process. context)Goes through a list of objects and associates each value to a particular field of a java bean instance |
| private int | |
| private void | |
| pack-priv void | processField(AnnotatedElement element, String targetName, PropertyWrapper propertyDescriptor, NormalizedString[] headers)
|
| protected boolean | Returns: true if the given field should be processed, otherwise false.the field to be processed field)Determines whether or not an annotated field should be processed. |
| pack-priv void | |
| private void | processNestedField(Class<T> nestedType, AnnotatedElement element, String targetName, PropertyWrapper propertyDescriptor, NormalizedString[] headers, Nested nested)
|
| public final Object[] | Returns: a row of objects containing the values extracted from the java beanan instance of the type defined in this class constructor. bean, NormalizedString[] All field names used to produce records in a given destination. May be null if no headers have been defined in
headers, int[] CommonSettings#getHeaders()The indexes of the headers that are actually being written. May be null if no fields have been selected using
indexesToWrite)CommonSettings#selectFields(String. or CommonSettings#selectIndexes(Integer.Converts a java bean instance into a sequence of values for writing. |
| public void | setColumnMapper(ColumnMapper
the column mappings to use columnMapper)Copies the given column mappings over to this processor. |
| public void | setStrictHeaderValidationEnabled(boolean
flag indicating whether strict validation of headers is enabled. strictHeaderValidationEnabled)Defines whether all headers declared in the annotated class must be present in the input. |
| private void | setupConversions(AnnotatedElement
the field and method annotated with target, FieldMapping Parsed that must be associated with one or more Conversion objectsa helper class to store information how the field or method is mapped to a parsed record. mapping)Goes through each field and method annotated with |
| pack-priv void | |
| private void |
| beanClass | back to summary |
|---|---|
| pack-priv final Class<T> beanClass | |
| columnMapper | back to summary |
|---|---|
| private ColumnMapping columnMapper | |
| constructor | back to summary |
|---|---|
| pack-priv final Constructor<T> constructor | |
| initialized | back to summary |
|---|---|
| protected boolean initialized | |
| lastFieldIndexMapped | back to summary |
|---|---|
| private int lastFieldIndexMapped | |
| mappingsForWritingValidated | back to summary |
|---|---|
| private boolean mappingsForWritingValidated | |
| methodFilter | back to summary |
|---|---|
| protected final MethodFilter methodFilter | |
| missing | back to summary |
|---|---|
| private FieldMapping[] missing | |
| nestedAttributes | back to summary |
|---|---|
| private Map<FieldMapping, BeanConversionProcessor<?>> nestedAttributes | |
| parsedFields | back to summary |
|---|---|
| protected final Set<FieldMapping> parsedFields | |
| readOrder | back to summary |
|---|---|
| private FieldMapping[] readOrder | |
| row | back to summary |
|---|---|
| private Object[] row | |
| strictHeaderValidationEnabled | back to summary |
|---|---|
| pack-priv boolean strictHeaderValidationEnabled | |
| syntheticHeaders | back to summary |
|---|---|
| private NormalizedString[] syntheticHeaders | |
| transformer | back to summary |
|---|---|
| protected final HeaderTransformer transformer | |
| valuesForMissing | back to summary |
|---|---|
| private Object[] valuesForMissing | |
| BeanConversionProcessor | back to summary |
|---|---|
| public BeanConversionProcessor(Class<T> beanType)
Deprecated Use the Initializes the BeanConversionProcessor with the annotated bean class. If any method of the given class has annotations, only the setter methods will be used (getters will be ignored), making this processor useful mostly for parsing into instances of the given class.
| |
| BeanConversionProcessor | back to summary |
|---|---|
| public BeanConversionProcessor(Class<T> beanType, MethodFilter methodFilter) Initializes the BeanConversionProcessor with the annotated bean class
| |
| BeanConversionProcessor | back to summary |
|---|---|
| pack-priv BeanConversionProcessor(Class<T> beanType, HeaderTransformer transformer, MethodFilter methodFilter) | |
| addConversion | back to summary |
|---|---|
| protected void addConversion(Conversion<I, O> conversion, FieldMapping mapping) Associates a conversion to a field of the java bean class.
| |
| applyDefaultConversion | back to summary |
|---|---|
private boolean applyDefaultConversion(Conversion<I, O> lastConversionApplied, Conversion<I, O> defaultConversion)
| |
| cloneConversions | back to summary |
|---|---|
| protected FieldConversionMapping cloneConversions() Creates a copy of the manually defined conversions to be applied over any columns.
| |
| createBean | back to summary |
|---|---|
| public T createBean(String[] row, Context context) Converts a record with values extracted from the parser into a java bean instance. | |
| createNestedProcessor | back to summary |
|---|---|
| pack-priv BeanConversionProcessor | |
| describeField | back to summary |
|---|---|
| pack-priv static String describeField(AnnotatedElement target) | |
| getBeanClass | back to summary |
|---|---|
| public Class Returns the class of the annotated java bean instances that will be manipulated by this processor.
| |
| getColumnMapper | back to summary |
|---|---|
| public final ColumnMapper getColumnMapper() Returns a mapper that allows users to manually define mappings from
attributes/methods of a given class to columns to be parsed or written.
This allows users to use instances of classes that are not annotated with
| |
| getConversionMethod | back to summary |
|---|---|
private Method getConversionMethod(Conversion<I, O> conversion, String methodName)
| |
| getNestedAttributes | back to summary |
|---|---|
| pack-priv Map | |
| identifyLiterals | back to summary |
|---|---|
| private void identifyLiterals() | |
| initialize | back to summary |
|---|---|
| public final void initialize() Identifies and extracts fields annotated with the | |
| initialize | back to summary |
|---|---|
| protected final void initialize(String[] headers) Identifies and extracts fields annotated with the
| |
| initialize | back to summary |
|---|---|
| protected final void initialize(NormalizedString[] headers) Identifies and extracts fields annotated with the
| |
| initializeValuesForMissing | back to summary |
|---|---|
| private void initializeValuesForMissing() | |
| isStrictHeaderValidationEnabled | back to summary |
|---|---|
| public boolean isStrictHeaderValidationEnabled() Returns a flag indicating whether all headers declared in the annotated class must be present in the input. If enabled, an exception will be thrown in case the input data does not contain all headers required.
| |
| mapFieldIndexes | back to summary |
|---|---|
| private void mapFieldIndexes(Context context, Object[] row, NormalizedString[] headers, int[] indexes, boolean columnsReordered) Identifies which fields are associated with which columns in a row.
| |
| mapFieldsToValues | back to summary |
|---|---|
| private void mapFieldsToValues(T instance, Object[] row, NormalizedString[] headers, int[] indexes, boolean columnsReordered) Iterates over all fields in the java bean instance and extracts its values.
| |
| mapValuesToFields | back to summary |
|---|---|
| pack-priv void mapValuesToFields(T instance, Object[] row, Context context) Goes through a list of objects and associates each value to a particular field of a java bean instance | |
| nonNullReadOrderLength | back to summary |
|---|---|
| private int nonNullReadOrderLength() | |
| populateTargetMaps | back to summary |
|---|---|
| private void populateTargetMaps(Map<Object, Integer> targetCounts, Map<Object, String> targetSources) | |
| processField | back to summary |
|---|---|
| pack-priv void processField(AnnotatedElement element, String targetName, PropertyWrapper propertyDescriptor, NormalizedString[] headers) | |
| processField | back to summary |
|---|---|
| protected boolean processField(FieldMapping field) Determines whether or not an annotated field should be processed. Can be overridden by subclasses for fine grained control.
| |
| processNestedAttributes | back to summary |
|---|---|
| pack-priv void processNestedAttributes(String[] row, Object instance, Context context) | |
| processNestedField | back to summary |
|---|---|
| private void processNestedField(Class<T> nestedType, AnnotatedElement element, String targetName, PropertyWrapper propertyDescriptor, NormalizedString[] headers, Nested nested) | |
| reverseConversions | back to summary |
|---|---|
| public final Object[] reverseConversions(T bean, NormalizedString[] headers, int[] indexesToWrite) Converts a java bean instance into a sequence of values for writing.
| |
| setColumnMapper | back to summary |
|---|---|
| public void setColumnMapper(ColumnMapper columnMapper) Copies the given column mappings over to this processor. Further changes to the given object won't be reflected on the copy stored internally.
| |
| setStrictHeaderValidationEnabled | back to summary |
|---|---|
| public void setStrictHeaderValidationEnabled(boolean strictHeaderValidationEnabled) Defines whether all headers declared in the annotated class must be present in the input. If enabled, an exception will be thrown in case the input data does not contain all headers required.
| |
| setupConversions | back to summary |
|---|---|
| private void setupConversions(AnnotatedElement target, FieldMapping mapping) Goes through each field and method annotated with
| |
| validateMappings | back to summary |
|---|---|
| pack-priv void validateMappings() | |
| validateMappingsForWriting | back to summary |
|---|---|
| private void validateMappingsForWriting() | |