Class BeanWriterProcessor<T>
- java.lang.Object
-
- com.univocity.parsers.common.DefaultConversionProcessor
-
- com.univocity.parsers.common.processor.core.BeanConversionProcessor<T>
-
- com.univocity.parsers.common.processor.BeanWriterProcessor<T>
-
- Type Parameters:
T
- the annotated class type.
- All Implemented Interfaces:
ConversionProcessor
,RowWriterProcessor<T>
public class BeanWriterProcessor<T> extends BeanConversionProcessor<T> implements RowWriterProcessor<T>
ARowWriterProcessor
implementation for converting annotated java objects into object arrays suitable for writing in any implementation ofAbstractWriter
.The class type of the object must contain the annotations provided in
com.univocity.parsers.annotations
.For any given java bean instance, this processor will read and convert annotated fields into an object array.
- See Also:
AbstractWriter
,RowWriterProcessor
,BeanConversionProcessor
-
-
Field Summary
Fields Modifier and Type Field Description private NormalizedString[]
normalizedHeaders
private java.lang.String[]
previousHeaders
-
Fields inherited from class com.univocity.parsers.common.processor.core.BeanConversionProcessor
initialized, methodFilter, parsedFields, transformer
-
Fields inherited from class com.univocity.parsers.common.DefaultConversionProcessor
conversions
-
-
Constructor Summary
Constructors Constructor Description BeanWriterProcessor(java.lang.Class<T> beanType)
Initializes the BeanWriterProcessor with the annotated bean class
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected FieldConversionMapping
cloneConversions()
Creates a copy of the manually defined conversions to be applied over any columns.java.lang.Object[]
write(T input, NormalizedString[] headers, int[] indexesToWrite)
Converts the java bean instance into a sequence of values for writing.java.lang.Object[]
write(T input, java.lang.String[] headers, int[] indexesToWrite)
Converts the java bean instance into a sequence of values for writing.-
Methods inherited from class com.univocity.parsers.common.processor.core.BeanConversionProcessor
addConversion, createBean, getBeanClass, getColumnMapper, initialize, initialize, initialize, isStrictHeaderValidationEnabled, processField, reverseConversions, setColumnMapper, setStrictHeaderValidationEnabled
-
Methods inherited from class com.univocity.parsers.common.DefaultConversionProcessor
applyConversions, convertAll, convertFields, convertIndexes, convertType, handleConversionError, initializeConversions, reverseConversions, toDataProcessingException
-
-
-
-
Field Detail
-
normalizedHeaders
private NormalizedString[] normalizedHeaders
-
previousHeaders
private java.lang.String[] previousHeaders
-
-
Constructor Detail
-
BeanWriterProcessor
public BeanWriterProcessor(java.lang.Class<T> beanType)
Initializes the BeanWriterProcessor with the annotated bean class- Parameters:
beanType
- the class annotated with one or more of the annotations provided incom.univocity.parsers.annotations
.
-
-
Method Detail
-
write
public java.lang.Object[] write(T input, java.lang.String[] headers, int[] indexesToWrite)
Converts the java bean instance into a sequence of values for writing.- Parameters:
input
- 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 inCommonSettings.getHeaders()
indexesToWrite
- The indexes of the headers that are actually being written. May be null if no fields have been selected usingCommonSettings.selectFields(String...)
orCommonSettings.selectIndexes(Integer...)
- Returns:
- a row of objects containing the values extracted from the java bean
-
write
public java.lang.Object[] write(T input, NormalizedString[] headers, int[] indexesToWrite)
Converts the java bean instance into a sequence of values for writing.- Specified by:
write
in interfaceRowWriterProcessor<T>
- Parameters:
input
- 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 inCommonSettings.getHeaders()
indexesToWrite
- The indexes of the headers that are actually being written. May be null if no fields have been selected usingCommonSettings.selectFields(String...)
orCommonSettings.selectIndexes(Integer...)
- Returns:
- a row of objects containing the values extracted from the java bean
- See Also:
CsvWriter
,FixedWidthWriter
,CommonSettings
,AbstractWriter
-
cloneConversions
protected FieldConversionMapping cloneConversions()
Description copied from class:BeanConversionProcessor
Creates a copy of the manually defined conversions to be applied over any columns.- Overrides:
cloneConversions
in classBeanConversionProcessor<T>
- Returns:
- a copy of the currently defined conversions
-
-