com.ferri.core.vo.commons.converters
Class AbstractConverter<DTO extends BaseDTO,VO extends BaseVO>

java.lang.Object
  extended by com.ferri.core.vo.commons.converters.AbstractConverter<DTO,VO>
All Implemented Interfaces:
Initializable
Direct Known Subclasses:
AdministradorConverter, ClientConverter, ConstantsConverter, ContracteConverter, EstatConverter, FacturaConverter, GestoriaConverter, IntervencioConverter, PressupostConverter, TipusClientConverter, TipusPeriodeConverter

public abstract class AbstractConverter<DTO extends BaseDTO,VO extends BaseVO>
extends Object
implements Initializable

Author:
dferri

Field Summary
private  BeansConverter beansConverter
           
private  Class<DTO> classTypeDTO
           
private  Class<VO> classTypeVO
           
protected  Class<? extends AbstractConverter> clazz
          The Class instance of this DispatchAction class.
private static String CONVERT_DTO_2_VO
           
private  org.apache.log4j.Logger logger
           
private  HashMap<String,Method> methods
          The set of Method objects we have introspected for this class, keyed by method name.
 
Constructor Summary
AbstractConverter()
           
 
Method Summary
 Collection<VO> convertCollectionDTO2VO(Collection<BaseDTO> colDTO)
           
 Collection<VO> convertCollectionDTO2VO(Collection<BaseDTO> colDTO, String methodName)
           
 Collection<DTO> convertCollectionVO2DTO(Collection<BaseVO> colVO)
           
 Collection<DTO> convertCollectionVO2DTO(Collection<BaseVO> colVO, String methodName)
           
abstract  VO convertDTO2VO(DTO dto)
          Convert instance DTO to instance VO
abstract  DTO convertVO2DTO(VO vo)
          Convert instance VO to instance DTO
 void deregisterInConverters(Map<Class<?>,AbstractConverter<? extends BaseDTO,? extends BaseVO>> converters)
           
private  AbstractBase executeMethod(AbstractBase abstractBase, String baseMethodName, String methodName)
           
 BeansConverter getBeansConverter()
           
 Class<DTO> getClassTypeDTO()
           
 Class<VO> getClassTypeVO()
           
protected  org.apache.log4j.Logger getLogger()
           
protected  Method getMethod(String name, Class<?> arg)
          Introspect the current class to identify a method of the specified name that accepts the same parameter types as the execute method does.
private  String getMethodPattern(String prefix, String methodName)
           
 void initialize()
          Execute the first operations to complete the instanciation.
private  void initiateObjectsType()
          Initialize casters objects
(package private)  VO internalWarpDTO2VO(BaseDTO baseDTO)
           
(package private)  VO internalWarpDTO2VO(BaseDTO baseDTO, String methodName)
           
(package private)  DTO internalWarpVO2DTO(BaseVO baseVO)
           
(package private)  DTO internalWarpVO2DTO(BaseVO baseVO, String methodName)
           
 void registerInConverters(Map<Class<?>,AbstractConverter<? extends BaseDTO,? extends BaseVO>> converters)
           
 void setBeansConverter(BeansConverter beansConverter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONVERT_DTO_2_VO

private static final String CONVERT_DTO_2_VO
See Also:
Constant Field Values

logger

private org.apache.log4j.Logger logger

clazz

protected Class<? extends AbstractConverter> clazz
The Class instance of this DispatchAction class.


methods

private HashMap<String,Method> methods
The set of Method objects we have introspected for this class, keyed by method name. This collection is populated as different methods are called, so that introspection needs to occur only once per method name.


beansConverter

private BeansConverter beansConverter

classTypeDTO

private Class<DTO extends BaseDTO> classTypeDTO

classTypeVO

private Class<VO extends BaseVO> classTypeVO
Constructor Detail

AbstractConverter

public AbstractConverter()
Method Detail

convertDTO2VO

public abstract VO convertDTO2VO(DTO dto)
Convert instance DTO to instance VO

Parameters:
dto - DTO
Returns:
VO

convertVO2DTO

public abstract DTO convertVO2DTO(VO vo)
Convert instance VO to instance DTO

Parameters:
vo - VO
Returns:
DTO

getClassTypeDTO

public final Class<DTO> getClassTypeDTO()

getClassTypeVO

public final Class<VO> getClassTypeVO()

internalWarpDTO2VO

VO internalWarpDTO2VO(BaseDTO baseDTO)

internalWarpDTO2VO

VO internalWarpDTO2VO(BaseDTO baseDTO,
                      String methodName)
                               throws InvocationTargetException,
                                      NoSuchMethodException,
                                      IllegalAccessException
Throws:
InvocationTargetException
NoSuchMethodException
IllegalAccessException

internalWarpVO2DTO

DTO internalWarpVO2DTO(BaseVO baseVO)

internalWarpVO2DTO

DTO internalWarpVO2DTO(BaseVO baseVO,
                       String methodName)
                                 throws InvocationTargetException,
                                        NoSuchMethodException,
                                        IllegalAccessException
Throws:
InvocationTargetException
NoSuchMethodException
IllegalAccessException

convertCollectionDTO2VO

public Collection<VO> convertCollectionDTO2VO(Collection<BaseDTO> colDTO)

convertCollectionDTO2VO

public Collection<VO> convertCollectionDTO2VO(Collection<BaseDTO> colDTO,
                                              String methodName)
                                                      throws InvocationTargetException,
                                                             NoSuchMethodException,
                                                             IllegalAccessException
Throws:
InvocationTargetException
NoSuchMethodException
IllegalAccessException

convertCollectionVO2DTO

public Collection<DTO> convertCollectionVO2DTO(Collection<BaseVO> colVO)

convertCollectionVO2DTO

public Collection<DTO> convertCollectionVO2DTO(Collection<BaseVO> colVO,
                                               String methodName)
                                                        throws InvocationTargetException,
                                                               NoSuchMethodException,
                                                               IllegalAccessException
Throws:
InvocationTargetException
NoSuchMethodException
IllegalAccessException

registerInConverters

public void registerInConverters(Map<Class<?>,AbstractConverter<? extends BaseDTO,? extends BaseVO>> converters)

deregisterInConverters

public void deregisterInConverters(Map<Class<?>,AbstractConverter<? extends BaseDTO,? extends BaseVO>> converters)

executeMethod

private AbstractBase executeMethod(AbstractBase abstractBase,
                                   String baseMethodName,
                                   String methodName)
                            throws InvocationTargetException,
                                   NoSuchMethodException,
                                   IllegalAccessException
Parameters:
abstractBase -
baseMethodName -
methodName -
Returns:
Throws:
InvocationTargetException
NoSuchMethodException
IllegalAccessException

initialize

public void initialize()
                throws GenericClassNotFound,
                       GenericTypeNotFound
Description copied from interface: Initializable
Execute the first operations to complete the instanciation.

Specified by:
initialize in interface Initializable
Throws:
GenericClassNotFound - if the given class dont have the expected parent class
GenericTypeNotFound - if the given type is not found
See Also:
Initializable.initialize()

initiateObjectsType

private void initiateObjectsType()
                          throws GenericClassNotFound,
                                 GenericTypeNotFound
Initialize casters objects

Throws:
GenericClassNotFound - if the given class dont have the expected parent class
GenericTypeNotFound - if the given type is not found

getMethod

protected Method getMethod(String name,
                           Class<?> arg)
                    throws NoSuchMethodException
Introspect the current class to identify a method of the specified name that accepts the same parameter types as the execute method does.

Parameters:
name - Name of the method to be introspected
arg -
Returns:
The method with the specified name.
Throws:
NoSuchMethodException - if no such method can be found

getMethodPattern

private String getMethodPattern(String prefix,
                                String methodName)

getBeansConverter

public BeansConverter getBeansConverter()
Returns:
the beansConverter

setBeansConverter

public void setBeansConverter(BeansConverter beansConverter)
Parameters:
beansConverter - the beansConverter to set

getLogger

protected org.apache.log4j.Logger getLogger()
Returns:
the logger