com.univocity.parsers.common.processor
Class BeanWriterProcessor<T>

java.lang.Object
  extended by com.univocity.parsers.common.DefaultConversionProcessor
      extended by com.univocity.parsers.common.processor.core.AbstractBeanConversionProcessor<T>
          extended by 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 AbstractBeanConversionProcessor<T>
implements RowWriterProcessor<T>

A RowWriterProcessor implementation for converting annotated java objects into object arrays suitable for writing in any implementation of AbstractWriter.

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.

Author:
uniVocity Software Pty Ltd - parsers@univocity.com
See Also:
AbstractWriter, RowWriterProcessor, AbstractBeanConversionProcessor

Field Summary
 
Fields inherited from class com.univocity.parsers.common.processor.core.AbstractBeanConversionProcessor
initialized, parsedFields
 
Constructor Summary
BeanWriterProcessor(Class<T> beanType)
          Initializes the BeanWriterProcessor with the annotated bean class
 
Method Summary
 Object[] write(T input, 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.AbstractBeanConversionProcessor
createBean, getBeanClass, initialize, isStrictHeaderValidationEnabled, processField, reverseConversions, setStrictHeaderValidationEnabled
 
Methods inherited from class com.univocity.parsers.common.DefaultConversionProcessor
applyConversions, convertAll, convertFields, convertIndexes, convertType, handleConversionError, reverseConversions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanWriterProcessor

public BeanWriterProcessor(Class<T> beanType)
Initializes the BeanWriterProcessor with the annotated bean class

Parameters:
beanType - the class annotated with one or more of the annotations provided in com.univocity.parsers.annotations.
Method Detail

write

public Object[] write(T input,
                      String[] headers,
                      int[] indexesToWrite)
Converts the java bean instance into a sequence of values for writing.

Specified by:
write in interface RowWriterProcessor<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 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...)
Returns:
a row of objects containing the values extracted from the java bean
See Also:
CsvWriter, FixedWidthWriter, CommonSettings, AbstractWriter


Copyright © 2016 uniVocity Software Pty Ltd. All rights reserved.