net.sf.beanlib.hibernate3
Class Hibernate3DtoCopier

java.lang.Object
  extended by net.sf.beanlib.hibernate3.Hibernate3DtoCopier

public class Hibernate3DtoCopier
extends Object

Convenient class for converting application specific Hibernate 3 persistence object to DTO.

Author:
Joe D. Velopar

Nested Class Summary
static class Hibernate3DtoCopier.Factory
          Factory for Hibernate3DtoCopier.
 
Field Summary
private  String applicationPackagePrefix
           
 
Constructor Summary
private Hibernate3DtoCopier()
          Must be constructed only via the factory.
 
Method Summary
private
<E> E
copy(Class<E> targetEntityType, Object from, Class[] entityBeanClassArray)
           
private
<E> E
copy(Class<E> targetEntityType, Object from, Class[] entityBeanClassArray, CollectionPropertyName[] collectionPropertyNameArray)
           
private  Object copy(Object from, Class[] entityBeanClassArray)
          Copy with a Application specific BeanPopulatable excluding all member Set properties.
protected  Hibernate3BeanReplicator createHibernateBeanReplicator()
           
<E> List<E>
hibernate2dto(Class<E> targetEntityType, Collection hibernateBeans, Class[] interestedEntityTypes, CollectionPropertyName[] collectionPropertyNameArray)
          Returns a list of DTO's by cloning portion of the object graph of the given collection of Hibernate beans.
<E,T> E
hibernate2dto(Class<E> targetEntityType, T entityBean)
           
<E,T> E
hibernate2dto(Class<E> targetEntityType, T entityBean, Class[] interestedEntityTypes, CollectionPropertyName[] collectionPropertyNames)
           
 List hibernate2dto(Collection hibernateBeans)
          Returns a list of DTO's by cloning portion of the object graph of the given collection of Hibernate beans.
<T> T
hibernate2dto(T entityBean)
          Returns a DTO by cloning portion of the object graph of the given Hibernate bean.
<T> T
hibernate2dto(T entityBean, Class[] interestedEntityTypes, CollectionPropertyName[] collectionPropertyNames)
          Returns a DTO by cloning portion of the object graph of the given Hibernate bean.
 List hibernate2dtoFully(Collection hibernateBeans)
          Returns a list of DTO's by deep cloning the given collection of Hibernate beans.
<T> T
hibernate2dtoFully(T entityBean)
          Returns a DTO by deep cloning the given Hibernate bean.
protected  Hibernate3DtoCopier init(String applicationPackagePrefix, Class applicationSampleClass)
          Used to specify the application package prefix, with a sample application class for verification purposes.
 boolean isApplicationClass(Class c)
          Returns true iff c is a application class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

applicationPackagePrefix

private String applicationPackagePrefix
Constructor Detail

Hibernate3DtoCopier

private Hibernate3DtoCopier()
Must be constructed only via the factory.

Method Detail

createHibernateBeanReplicator

protected Hibernate3BeanReplicator createHibernateBeanReplicator()

init

protected Hibernate3DtoCopier init(String applicationPackagePrefix,
                                   Class applicationSampleClass)
Used to specify the application package prefix, with a sample application class for verification purposes.


hibernate2dtoFully

public <T> T hibernate2dtoFully(T entityBean)
Returns a DTO by deep cloning the given Hibernate bean.


hibernate2dtoFully

public List hibernate2dtoFully(Collection hibernateBeans)
Returns a list of DTO's by deep cloning the given collection of Hibernate beans.


hibernate2dto

public <T> T hibernate2dto(T entityBean)
Returns a DTO by cloning portion of the object graph of the given Hibernate bean.

Parameters:
entityBean - given Hibernate Bean

hibernate2dto

public <E,T> E hibernate2dto(Class<E> targetEntityType,
                             T entityBean)

hibernate2dto

public <T> T hibernate2dto(T entityBean,
                           Class[] interestedEntityTypes,
                           CollectionPropertyName[] collectionPropertyNames)
Returns a DTO by cloning portion of the object graph of the given Hibernate bean.

Parameters:
entityBean - given Hibernate Bean
collectionPropertyNames - set properties to be included in the object graph

hibernate2dto

public <E,T> E hibernate2dto(Class<E> targetEntityType,
                             T entityBean,
                             Class[] interestedEntityTypes,
                             CollectionPropertyName[] collectionPropertyNames)

hibernate2dto

public List hibernate2dto(Collection hibernateBeans)
Returns a list of DTO's by cloning portion of the object graph of the given collection of Hibernate beans.

Parameters:
hibernateBeans - given collection of Hibernate Beans.

hibernate2dto

public <E> List<E> hibernate2dto(Class<E> targetEntityType,
                                 Collection hibernateBeans,
                                 Class[] interestedEntityTypes,
                                 CollectionPropertyName[] collectionPropertyNameArray)
Returns a list of DTO's by cloning portion of the object graph of the given collection of Hibernate beans.

Parameters:
hibernateBeans - given collection of Hibernate Beans.

copy

private Object copy(Object from,
                    Class[] entityBeanClassArray)
Copy with a Application specific BeanPopulatable excluding all member Set properties.


copy

private <E> E copy(Class<E> targetEntityType,
                   Object from,
                   Class[] entityBeanClassArray)

copy

private <E> E copy(Class<E> targetEntityType,
                   Object from,
                   Class[] entityBeanClassArray,
                   CollectionPropertyName[] collectionPropertyNameArray)

isApplicationClass

public boolean isApplicationClass(Class c)
Returns true iff c is a application class.