olg.csv.bean.annotations.processor
Class RowBeanProcessor<T>

Package class diagram package RowBeanProcessor
java.lang.Object
  extended by olg.csv.bean.annotations.processor.RowBeanProcessor<T>
Type Parameters:
T - the type this processor deals with

public final class RowBeanProcessor<T>
extends Object

This class is responsible for processing the @RowBean annotation.


Nested Class Summary
private static class RowBeanProcessor.CSVPropertyType
          CSV Property list.
private static class RowBeanProcessor.ODSPropertyType
          ODS Property list.
 
Field Summary
private  Class<T> clazz
          The class of the type.
private  ColumnProcessor<T> columnProcessor
          Processor responsible for processing @Column annotations placed on the fields of the class.
private  RowBeanProcessor.CSVPropertyType[] CSVReadingProperties
          CSV Properties allowed on Reading.
private  RowBeanProcessor.CSVPropertyType[] CSVWritingProperties
          CSV Properties allowed on Writing.
private  EmbeddedProcessor<T> embeddedProcessor
          Processor responsible for processing @Embedded annotations placed on the fields of the class.
private static org.slf4j.Logger LOGGER
          Class logger.
private  RowBeanProcessor.ODSPropertyType[] ODSReadingProperties
          ODSProperties allowed on Reading process.
private  RowBeanProcessor.ODSPropertyType[] ODSWritingProperties
          ODS Properties allowed on Writing process.
 
Constructor Summary
RowBeanProcessor(Class<T> clazz)
          Constructor.
 
Method Summary
private  boolean checkField(Field field, Class<? super T> beanClass)
          Check if a field hasn't both column annotation and Embedded annotation.
 IBeanProcessor<T> getBeanProcessor()
          Build a BeanProcessor from annotations setted on the class this processor deals with.
private  CSVSettings getCSVSettings(Param[] csvParams, RowBeanProcessor.CSVPropertyType[] properties, String type)
          Products the CSVSettings corresponding to params of a process.
private  ODSSettings getODSSettings(Param[] odsParams, RowBeanProcessor.ODSPropertyType[] properties, String type)
          Returns ODSSettings corresponding to ODS params of a process.
 CSVSettings getReadingCSVSettings()
          Returns CSVSettings for reading identified from the RowBean annotation of the class otherwise default Reading CSV settings.
 ODSSettings getReadingODSSettings()
          Returns ODSSettings for reading identified from the RowBean annotation of the class otherwise default Reading ODS settings.
private  boolean getReadingProcessor(Class<? super T> beanClass, int translate, List<IPropertyProcessor<T>> processors, Map<Integer,Integer> map)
          Find the property processors identified on a class if annoted with @RowBean and from its super class if annoted with @RowBean.
protected  boolean getReadingProcessor(int translate, List<IPropertyProcessor<T>> processors, Map<Integer,Integer> map)
          Collect the property processors identified by annotation setted on the fields (@Column and @Embedded) of the class and its super class (if annoted with @RowBean).
 IRowProcessor<T> getRowProcessor()
          Build a RowProcessor from annotations setted on the class this processor deals with.
 CSVSettings getWritingCSVSettings()
          Returns CSVSettings for writing identified from the RowBean annotation of the class otherwise default writing CSV settings.
 ODSSettings getWritingODSSettings()
          Returns ODSSettings for writing identified from the RowBean annotation of the class otherwise default writing ODS settings.
private  boolean getWritingProcessor(Class<? super T> beanClass, Map<Integer,List<CellProcessor<T>>> map)
          Collects cell processors from column and embedded annotation setted on a class if annoted with RowBean annotation.
protected  boolean getWritingProcessor(Map<Integer,List<CellProcessor<T>>> map)
          Complete a map with the cell Processors identified on the annotated fields of the class (and superclass).
 boolean hasRowBeanAnnotation()
          Returns if T has RowBean annotation.
private  RowBeanProcessor.CSVPropertyType identifyPermittedProperty(Param param, RowBeanProcessor.CSVPropertyType[] permittedProperties)
          Identifies a param as an allowed CSVPropertyType.
private  RowBeanProcessor.ODSPropertyType identifyPermittedProperty(Param param, RowBeanProcessor.ODSPropertyType[] permittedProperties)
          Identifies a param as an allowed ODSPropertyType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final org.slf4j.Logger LOGGER
Class logger.


ODSReadingProperties

private RowBeanProcessor.ODSPropertyType[] ODSReadingProperties
ODSProperties allowed on Reading process.


ODSWritingProperties

private RowBeanProcessor.ODSPropertyType[] ODSWritingProperties
ODS Properties allowed on Writing process.


CSVReadingProperties

private RowBeanProcessor.CSVPropertyType[] CSVReadingProperties
CSV Properties allowed on Reading.


CSVWritingProperties

private RowBeanProcessor.CSVPropertyType[] CSVWritingProperties
CSV Properties allowed on Writing.


clazz

private Class<T> clazz
The class of the type.


columnProcessor

private ColumnProcessor<T> columnProcessor
Processor responsible for processing @Column annotations placed on the fields of the class.


embeddedProcessor

private EmbeddedProcessor<T> embeddedProcessor
Processor responsible for processing @Embedded annotations placed on the fields of the class.

Constructor Detail

RowBeanProcessor

public RowBeanProcessor(Class<T> clazz)
Constructor.

Parameters:
clazz - the T class.
Method Detail

hasRowBeanAnnotation

public boolean hasRowBeanAnnotation()
Returns if T has RowBean annotation.

Returns:
true if the T class has RowBean annotation.

getReadingODSSettings

public ODSSettings getReadingODSSettings()
                                  throws AnnotationProcessorException
Returns ODSSettings for reading identified from the RowBean annotation of the class otherwise default Reading ODS settings.

Returns:
the ODSSettings
Throws:
AnnotationProcessorException - if error occurs during annotation processing.

getWritingODSSettings

public ODSSettings getWritingODSSettings()
                                  throws AnnotationProcessorException
Returns ODSSettings for writing identified from the RowBean annotation of the class otherwise default writing ODS settings.

Returns:
the ODSSettings
Throws:
AnnotationProcessorException - if an error occurs during settings identification.

getReadingCSVSettings

public CSVSettings getReadingCSVSettings()
                                  throws AnnotationProcessorException
Returns CSVSettings for reading identified from the RowBean annotation of the class otherwise default Reading CSV settings.

Returns:
the CSVSettings
Throws:
AnnotationProcessorException - if an error occurs during settings identification.

getWritingCSVSettings

public CSVSettings getWritingCSVSettings()
                                  throws AnnotationProcessorException
Returns CSVSettings for writing identified from the RowBean annotation of the class otherwise default writing CSV settings.

Returns:
the CSVSettings
Throws:
AnnotationProcessorException - if an error occurs during settings identification.

getBeanProcessor

public IBeanProcessor<T> getBeanProcessor()
                                   throws AnnotationProcessorException
Build a BeanProcessor from annotations setted on the class this processor deals with.

Returns:
the beanProcessor
Throws:
AnnotationProcessorException - if error occurs during annotation processing.

getRowProcessor

public IRowProcessor<T> getRowProcessor()
                                 throws AnnotationProcessorException
Build a RowProcessor from annotations setted on the class this processor deals with.

Returns:
the RowProcessor
Throws:
AnnotationProcessorException - if error occurs during annotation processing.

getWritingProcessor

protected boolean getWritingProcessor(Map<Integer,List<CellProcessor<T>>> map)
Complete a map with the cell Processors identified on the annotated fields of the class (and superclass).

Parameters:
map - the map to complete with the CellProcessor built from column annotation setted on the class fields. the keys are the cell num target of the cellProcessor.
Returns:
true if no error occurs.

getReadingProcessor

protected boolean getReadingProcessor(int translate,
                                      List<IPropertyProcessor<T>> processors,
                                      Map<Integer,Integer> map)
Collect the property processors identified by annotation setted on the fields (@Column and @Embedded) of the class and its super class (if annoted with @RowBean).

Parameters:
translate - index from which begin the column numerotation
processors - the processor list to complete
map - the map to complete. this map shows for each cell num the count of the property processors setted on.
Returns:
true if no error occurs.

getWritingProcessor

private boolean getWritingProcessor(Class<? super T> beanClass,
                                    Map<Integer,List<CellProcessor<T>>> map)
Collects cell processors from column and embedded annotation setted on a class if annoted with RowBean annotation. Collects cell processors from super class if annoted with RowBean annotation.

Parameters:
beanClass - the bean class.
map - the map to complete with the CellProcessor built from column annotation setted on the field. the keys are the cell num target of the cellProcessor.
Returns:
true if no error occurs.

getReadingProcessor

private boolean getReadingProcessor(Class<? super T> beanClass,
                                    int translate,
                                    List<IPropertyProcessor<T>> processors,
                                    Map<Integer,Integer> map)
Find the property processors identified on a class if annoted with @RowBean and from its super class if annoted with @RowBean. The processor are read from the @Column and @Embedded annotation setted on its fields.

Parameters:
beanClass - the bean class.
translate - index from which begin the column numerotation
processors - the list to complete
map - the map to complete. this map shows for each cell num the count of the property processors setted on.
Returns:
true if no error occurs.

checkField

private boolean checkField(Field field,
                           Class<? super T> beanClass)
Check if a field hasn't both column annotation and Embedded annotation.

Parameters:
field - the field
beanClass - the class declaring the field.
Returns:
true if the field hasn't both column annotation and Embedded annotation.

identifyPermittedProperty

private RowBeanProcessor.ODSPropertyType identifyPermittedProperty(Param param,
                                                                   RowBeanProcessor.ODSPropertyType[] permittedProperties)
Identifies a param as an allowed ODSPropertyType.

Parameters:
param - the param.
permittedProperties - allowed ODSPropertyTypes.
Returns:
the ODSPropertyType or null if the param is not identify as a permitted properties.

getODSSettings

private ODSSettings getODSSettings(Param[] odsParams,
                                   RowBeanProcessor.ODSPropertyType[] properties,
                                   String type)
                            throws AnnotationProcessorException
Returns ODSSettings corresponding to ODS params of a process.

Parameters:
odsParams - the ODS Params
properties - the ODS Properties which are allowed for the process
type - String identifying the process
Returns:
the corresonding settings.
Throws:
AnnotationProcessorException - if errors occur

identifyPermittedProperty

private RowBeanProcessor.CSVPropertyType identifyPermittedProperty(Param param,
                                                                   RowBeanProcessor.CSVPropertyType[] permittedProperties)
Identifies a param as an allowed CSVPropertyType.

Parameters:
param - the param.
permittedProperties - allowed CSVPropertyTypes.
Returns:
the CSVPropertyType or null if the param is not identify as a permitted properties.

getCSVSettings

private CSVSettings getCSVSettings(Param[] csvParams,
                                   RowBeanProcessor.CSVPropertyType[] properties,
                                   String type)
                            throws AnnotationProcessorException
Products the CSVSettings corresponding to params of a process.

Parameters:
csvParams - the params to translate as CSVSettings
properties - the CSVProperties which are allowed for the specifig process
type - String identifying the process
Returns:
the CSVSettings corresponding to the param of the process
Throws:
AnnotationProcessorException - if errors occur.


Copyright © 2014. All Rights Reserved.