|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.morph.transform.transformers.BaseTransformer net.sf.morph.integration.commons.beanutils.BeanUtilsConverter
public class BeanUtilsConverter
A converter which delegates to Commons BeanUtils.
Field Summary | |
---|---|
static java.lang.Class[] |
ALL_OBJECTS
Source-destination classes. |
Fields inherited from class net.sf.morph.transform.transformers.BaseTransformer |
---|
destinationClasses, log, sourceClasses |
Fields inherited from interface net.sf.morph.transform.Transformer |
---|
TRANSFORMATION_TYPE_CONVERT, TRANSFORMATION_TYPE_COPY |
Fields inherited from interface net.sf.morph.transform.Transformer |
---|
TRANSFORMATION_TYPE_CONVERT, TRANSFORMATION_TYPE_COPY |
Fields inherited from interface net.sf.morph.transform.Transformer |
---|
TRANSFORMATION_TYPE_CONVERT, TRANSFORMATION_TYPE_COPY |
Constructor Summary | |
---|---|
BeanUtilsConverter()
|
Method Summary | |
---|---|
protected java.lang.Object |
convertImpl(java.lang.Class destinationClass,
java.lang.Object source,
java.util.Locale locale)
The implementation of the convert method, which may omit
the invalid argument checks already performed by this base class. |
org.apache.commons.beanutils.ConvertUtilsBean |
getConvertUtilsBean()
Returns the ConvertUtilsBean set with the setConvertUtilsBean method, or the default ConvertUtilsBean instance that is used by the static methods in ConvertUtils. |
java.lang.Class[] |
getDestinationClassesImpl()
Transformer.getDestinationClasses() implementation template method. |
java.lang.Class[] |
getSourceClassesImpl()
Transformer.getSourceClasses() implementation template method. |
protected boolean |
isNaivelyConvertible(java.lang.Class destinationClass,
java.lang.Class sourceClass)
Learn whether the given source-destination combination is "naively" convertible. |
protected boolean |
isTransformableImpl(java.lang.Class destinationType,
java.lang.Class sourceType)
Default implementation for Transformer#isTransformable(Class, Class) that assumes that each
source type can be converted into each destination type. |
protected boolean |
isWrappingRuntimeExceptions()
Indicates whether runtime exceptions should be wrapped as TransformationException s. |
void |
setConvertUtilsBean(org.apache.commons.beanutils.ConvertUtilsBean convertUtilsBean)
Set the ConvertUtilsBean to use. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.morph.transform.Transformer |
---|
getDestinationClasses, getSourceClasses |
Methods inherited from interface net.sf.morph.transform.DecoratedConverter |
---|
convert, equals, equals |
Methods inherited from interface net.sf.morph.transform.Transformer |
---|
getDestinationClasses, getSourceClasses |
Methods inherited from interface net.sf.morph.transform.Transformer |
---|
getDestinationClasses, getSourceClasses |
Methods inherited from interface net.sf.morph.transform.ExplicitTransformer |
---|
isTransformable |
Field Detail |
---|
public static final java.lang.Class[] ALL_OBJECTS
Constructor Detail |
---|
public BeanUtilsConverter()
Method Detail |
---|
protected boolean isTransformableImpl(java.lang.Class destinationType, java.lang.Class sourceType)
Transformer#isTransformable(Class, Class)
that assumes that each
source type can be converted into each destination type.
isTransformableImpl
in class BaseTransformer
destinationType
- the destination type to testsourceType
- the source type to test
protected java.lang.Object convertImpl(java.lang.Class destinationClass, java.lang.Object source, java.util.Locale locale) throws TransformationException
convert
method, which may omit
the invalid argument checks already performed by this base class. By
default, this method creates a new instance of the destinationClass and
copies information from the source to the destination. This
implementation should be fine as-is for Copiers, but Converters will need
to implement this method since they will not be implementing the copy
method.
convertImpl
in class BaseTransformer
locale
- the locale in which the conversion should take place. for
converters that are not locale-aware, the local argument can
simply be ignored
TransformationException
public org.apache.commons.beanutils.ConvertUtilsBean getConvertUtilsBean()
public void setConvertUtilsBean(org.apache.commons.beanutils.ConvertUtilsBean convertUtilsBean)
convertUtilsBean
- protected boolean isNaivelyConvertible(java.lang.Class destinationClass, java.lang.Class sourceClass)
destinationClass
- sourceClass
-
protected boolean isWrappingRuntimeExceptions()
TransformationException
s. By default, this method returns
true
.
Simple transformers in Morph that operate on JDK types like Numbers and
Strings will usually set this value to true
so that they
throw TransformationExceptions if problems occur. More complex
transformers that operate on graphs of objects are encouraged to set this
value to false
so that runtime exceptions are not wrapped.
This way, problems accessing data will be expressed by the native API of
a user's domain objects and avoid the need to catch Morph-specific
exceptions (assuming the use of runtime exceptions in said domain
objects).
isWrappingRuntimeExceptions
in class BaseTransformer
true
public java.lang.Class[] getSourceClassesImpl()
Transformer.getSourceClasses()
implementation template method.
getSourceClassesImpl
in class BaseTransformer
public java.lang.Class[] getDestinationClassesImpl()
Transformer.getDestinationClasses()
implementation template method.
getDestinationClassesImpl
in class BaseTransformer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |