Top Description Fields Constructors Methods
com.univocity.parsers.common.processor.core

public abstract Class AbstractMultiBeanProcessor<C extends Context>

extends Object
implements Processor<C extends Context>, ConversionProcessor
Class Inheritance
All Implemented Interfaces
com.univocity.parsers.common.ConversionProcessor, com.univocity.parsers.common.processor.core.Processor
Known Direct Subclasses
com.univocity.parsers.common.processor.core.AbstractMultiBeanRowProcessor, com.univocity.parsers.common.processor.MultiBeanProcessor
Imports
com.univocity.parsers.annotations.helpers.*, com.univocity.parsers.common.*, com.univocity.parsers.common.fields.*, com.univocity.parsers.conversions.*, java.util.*

A Processor implementation for converting rows extracted from any implementation of AbstractParser into java objects.

The class types passed to the constructor of this class must contain the annotations provided in com.univocity.parsers.annotations.

For each row processed, one or more java bean instances of any given class will be created with their fields populated.

Each individual instance will then be sent to the AbstractMultiBeanProcessor#beanProcessed(Class, Object, Context) method, where the user can access the beans parsed for each row.

Author
Univocity Software Pty Ltd - [email protected]
See Also
AbstractParser, Processor, com.univocity.parsers.common.processor.BeanProcessor

Field Summary

Modifier and TypeField and Description
private final AbstractBeanProcessor<?, C>[]
private final Map<Class<T>, AbstractBeanProcessor<T, C extends Context>>

Constructor Summary

AccessConstructor and Description
public
AbstractMultiBeanProcessor(Class<T>...
the classes with their attributes mapped to fields of records parsed by an AbstractParser or written by an AbstractWriter.
beanTypes
)

Creates a processor for java beans of multiple types

Method Summary

Modifier and TypeMethod and Description
public abstract void
beanProcessed(Class<?>
the type of the object created by the parser using the information collected for an individual record.
beanType
,
Object
java object created with the information extracted by the parser for an individual record.
beanInstance
,
C
A contextual object with information and controls over the current state of the parsing process
context
)

Invoked by the processor after all values of a valid record have been processed and converted into a java object.

public void
convertAll(Conversion<I, O>...
The sequence of conversions to be executed in all elements of a record
conversions
)

Implements com.univocity.parsers.common.ConversionProcessor.convertAll.

Applies a set of Conversion objects over all elements of a record
public FieldSet<String>
convertFields(Conversion<I, O>...
The sequence of conversions to be executed in a set of field indexes.
conversions
)

Implements com.univocity.parsers.common.ConversionProcessor.convertFields.

Applies a set of Conversion objects over fields of a record by name.
public FieldSet<Integer>
convertIndexes(Conversion<I, O>...
The sequence of conversions to be executed in a set of field indexes.
conversions
)

Implements com.univocity.parsers.common.ConversionProcessor.convertIndexes.

Applies a set of Conversion objects over indexes of a record.
public void
convertType(Class<?>
the type over which a sequence of conversions should be applied
type
,
Conversion<I, O>...
the sequence of conversions to apply over values of the given type.
conversions
)

Implements com.univocity.parsers.common.ConversionProcessor.convertType.

Applies a sequence of conversions over values of a given type.
public final Class<T>[]
public <
the type of java bean being processed
T
>
AbstractBeanProcessor<T, C>

Returns:

the com.univocity.parsers.common.processor.BeanProcessor that handles java beans of the given class.
getProcessorOfType
(Class<T>
the type of java bean being processed
type
)

Returns the com.univocity.parsers.common.processor.BeanProcessor responsible for processing a given class

public void
processEnded(C
A contextual object with information and controls over the state of the parsing process
context
)

Implements com.univocity.parsers.common.processor.core.Processor.processEnded.

This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.
public void
processStarted(C
A contextual object with information and controls over the current state of the parsing process
context
)

Implements com.univocity.parsers.common.processor.core.Processor.processStarted.

This method will by invoked by the parser once, when it is ready to start processing the input.
public final void
rowProcessed(String[]
the data extracted by the parser for an individual record. Note that:
row
,
C
A contextual object with information and controls over the current state of the parsing process
context
)

Implements com.univocity.parsers.common.processor.core.Processor.rowProcessed.

Invoked by the parser after all values of a valid record have been processed.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beanProcessorsback to summary
private final AbstractBeanProcessor<?, C>[] beanProcessors
processorMapback to summary
private final Map<Class<T>, AbstractBeanProcessor<T, C extends Context>> processorMap

Constructor Detail

AbstractMultiBeanProcessorback to summary
public AbstractMultiBeanProcessor(Class<T>... beanTypes)

Creates a processor for java beans of multiple types

Parameters
beanTypes:Class<T>[]

the classes with their attributes mapped to fields of records parsed by an AbstractParser or written by an AbstractWriter.

Method Detail

beanProcessedback to summary
public abstract void beanProcessed(Class<?> beanType, Object beanInstance, C context)

Invoked by the processor after all values of a valid record have been processed and converted into a java object.

Parameters
beanType:Class<?>

the type of the object created by the parser using the information collected for an individual record.

beanInstance:Object

java object created with the information extracted by the parser for an individual record.

context:C

A contextual object with information and controls over the current state of the parsing process

convertAllback to summary
public void convertAll(Conversion<I, O>... conversions)

Implements com.univocity.parsers.common.ConversionProcessor.convertAll.

Doc from com.univocity.parsers.common.ConversionProcessor.convertAll.

Applies a set of Conversion objects over all elements of a record

Parameters
conversions:Conversion<I, O>[]

The sequence of conversions to be executed in all elements of a record

Annotations
@Override
convertFieldsback to summary
public FieldSet<String> convertFields(Conversion<I, O>... conversions)

Implements com.univocity.parsers.common.ConversionProcessor.convertFields.

Doc from com.univocity.parsers.common.ConversionProcessor.convertFields.

Applies a set of Conversion objects over fields of a record by name.

The idiom to define which fields should have these conversions applied is as follows:



processor.convertFields(Conversions.trim(), Conversions.toUpperCase()).add("name", "position"); // applies trim and uppercase conversions to fields with headers "name" and "position"

Parameters
conversions:Conversion<I, O>[]

The sequence of conversions to be executed in a set of field indexes.

Returns:FieldSet<String>

A FieldSet for field names.

Annotations
@Override
convertIndexesback to summary
public FieldSet<Integer> convertIndexes(Conversion<I, O>... conversions)

Implements com.univocity.parsers.common.ConversionProcessor.convertIndexes.

Doc from com.univocity.parsers.common.ConversionProcessor.convertIndexes.

Applies a set of Conversion objects over indexes of a record.

The idiom to define which indexes should have these conversions applies is as follows:



processor.convertIndexes(Conversions.trim(), Conversions.toUpperCase()).add(2, 5); // applies trim and uppercase conversions to fields in indexes 2 and 5

Parameters
conversions:Conversion<I, O>[]

The sequence of conversions to be executed in a set of field indexes.

Returns:FieldSet<Integer>

A FieldSet for indexes.

Annotations
@Override
convertTypeback to summary
public void convertType(Class<?> type, Conversion<I, O>... conversions)

Implements com.univocity.parsers.common.ConversionProcessor.convertType.

Doc from com.univocity.parsers.common.ConversionProcessor.convertType.

Applies a sequence of conversions over values of a given type. Used for writing.

Parameters
type:Class<?>

the type over which a sequence of conversions should be applied

conversions:Conversion<I, O>[]

the sequence of conversions to apply over values of the given type.

Annotations
@Override
getBeanClassesback to summary
public final Class<T>[] getBeanClasses()
getProcessorOfTypeback to summary
public <T> AbstractBeanProcessor<T, C> getProcessorOfType(Class<T> type)

Returns the com.univocity.parsers.common.processor.BeanProcessor responsible for processing a given class

Parameters
<T>
the type of java bean being processed
type:Class<T>

the type of java bean being processed

Returns:AbstractBeanProcessor<T, C>

the com.univocity.parsers.common.processor.BeanProcessor that handles java beans of the given class.

processEndedback to summary
public void processEnded(C context)

Implements com.univocity.parsers.common.processor.core.Processor.processEnded.

Doc from com.univocity.parsers.common.processor.core.Processor.processEnded.

This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.

It will always be called by the parser: in case of errors, if the end of the input us reached, or if the user stopped the process manually using ParsingContext#stop().

Parameters
context:C

A contextual object with information and controls over the state of the parsing process

Annotations
@Override
processStartedback to summary
public void processStarted(C context)

Implements com.univocity.parsers.common.processor.core.Processor.processStarted.

Doc from com.univocity.parsers.common.processor.core.Processor.processStarted.

This method will by invoked by the parser once, when it is ready to start processing the input.

Parameters
context:C

A contextual object with information and controls over the current state of the parsing process

Annotations
@Override
rowProcessedback to summary
public final void rowProcessed(String[] row, C context)

Implements com.univocity.parsers.common.processor.core.Processor.rowProcessed.

Doc from com.univocity.parsers.common.processor.core.Processor.rowProcessed.

Invoked by the parser after all values of a valid record have been processed.

Parameters
row:String[]

the data extracted by the parser for an individual record. Note that:

context:C

A contextual object with information and controls over the current state of the parsing process

Annotations
@Override