|
||||||||||
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.transform.copiers.PropertyExpressionMappingCopier
public class PropertyExpressionMappingCopier
Maps property expressions between objects using a Morph Language. The map you specify should have String keys, and in its simplest form, will have String values as well. However, the values in the mapping may be containers of Strings as well, allowing you to map > 1 destination for a given source property.
Field Summary |
---|
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 |
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 | |
---|---|
PropertyExpressionMappingCopier()
Create a new PropertyExpressionMappingCopier. |
|
PropertyExpressionMappingCopier(java.util.Map mapping)
Create a new PropertyExpressionMappingCopier. |
Method Summary | |
---|---|
protected void |
copyImpl(java.lang.Object destination,
java.lang.Object source,
java.util.Locale locale,
java.lang.Integer preferredTransformationType)
Implementation of the copy method. |
protected void |
copyProperty(java.lang.String sourceProperty,
java.lang.Object source,
java.lang.String destinationProperty,
java.lang.Object destination,
java.util.Locale locale,
java.lang.Integer preferredTransformationType)
Copy source.sourceProperty to dest.destProperty . |
java.lang.Object |
createReusableSource(java.lang.Class destinationClass,
java.lang.Object source)
NodeCopier.createReusableSource(Class, Object) |
protected java.lang.Class[] |
getDestinationClassesImpl()
Transformer.getDestinationClasses() implementation template method. |
Language |
getLanguage()
Get the language of this PropertyExpressionMappingCopier. |
java.util.Map |
getMapping()
Get the mapping of this PropertyExpressionMappingCopier. |
Transformer |
getNestedTransformer()
NodeCopier.getNestedTransformer() |
protected java.lang.Class[] |
getSourceClassesImpl()
Transformer.getSourceClasses() implementation template method. |
protected void |
initializeImpl()
Gives subclasses a chance to perform any computations needed to initialize the transformer. |
protected boolean |
isWrappingRuntimeExceptions()
Indicates whether runtime exceptions should be wrapped as TransformationException s. |
void |
setDestinationClasses(java.lang.Class[] destinationClasses)
Configures the destinationClasses property of this
transformer. |
void |
setLanguage(Language language)
Set the language of this PropertyExpressionMappingCopier. |
void |
setMapping(java.util.Map mapping)
Set the mapping of this PropertyExpressionMappingCopier. |
void |
setNestedTransformer(Transformer nestedTransformer)
NodeCopier.setNestedTransformer(Transformer) |
void |
setSourceClasses(java.lang.Class[] sourceClasses)
Configures the sourceClasses property of this transformer. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.morph.transform.DecoratedConverter |
---|
convert, equals, equals |
Methods inherited from interface net.sf.morph.transform.Converter |
---|
convert |
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 |
Methods inherited from interface net.sf.morph.transform.DecoratedCopier |
---|
copy |
Methods inherited from interface net.sf.morph.transform.Copier |
---|
copy |
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 |
Methods inherited from interface net.sf.morph.transform.NodeCopier |
---|
createNewInstance |
Methods inherited from interface net.sf.morph.transform.Copier |
---|
copy |
Methods inherited from interface net.sf.morph.transform.Transformer |
---|
getDestinationClasses, getSourceClasses |
Constructor Detail |
---|
public PropertyExpressionMappingCopier()
public PropertyExpressionMappingCopier(java.util.Map mapping)
mapping
- property mappingMethod Detail |
---|
public Language getLanguage()
public void setLanguage(Language language)
language
- the language to setprotected void initializeImpl() throws java.lang.Exception
initializeImpl
in class BaseTransformer
java.lang.Exception
protected void copyImpl(java.lang.Object destination, java.lang.Object source, java.util.Locale locale, java.lang.Integer preferredTransformationType) throws java.lang.Exception
copyImpl
in class BaseTransformer
java.lang.Exception
protected void copyProperty(java.lang.String sourceProperty, java.lang.Object source, java.lang.String destinationProperty, java.lang.Object destination, java.util.Locale locale, java.lang.Integer preferredTransformationType) throws java.lang.Exception
source.sourceProperty
to dest.destProperty
.
sourceProperty
- source
- destinationProperty
- destination
- locale
- preferredTransformationType
-
java.lang.Exception
protected java.lang.Class[] getDestinationClassesImpl() throws java.lang.Exception
Transformer.getDestinationClasses()
implementation template method.
getDestinationClassesImpl
in class BaseTransformer
java.lang.Exception
protected java.lang.Class[] getSourceClassesImpl() throws java.lang.Exception
Transformer.getSourceClasses()
implementation template method.
getSourceClassesImpl
in class BaseTransformer
java.lang.Exception
public java.util.Map getMapping()
public void setMapping(java.util.Map mapping)
mapping
- the mapping to setpublic void setSourceClasses(java.lang.Class[] sourceClasses)
sourceClasses
property of this transformer.
Note that this method should be called before the transformer is used.
Otherwise, if another thread is in the middle of transforming an object
graph and this method is called, the behavior of the transformer can
change partway through the transformation.
setSourceClasses
in class BaseTransformer
sourceClasses
- the new sourceClasses
for this transformerpublic void setDestinationClasses(java.lang.Class[] destinationClasses)
destinationClasses
property of this
transformer. Note that this method should be called before the
transformer is used. Otherwise, if another thread is in the middle of
transforming an object graph and this method is called, the behavior of
the transformer can change partway through the transformation.
setDestinationClasses
in class BaseTransformer
destinationClasses
- the new destinationClasses
for this transformerpublic java.lang.Object createReusableSource(java.lang.Class destinationClass, java.lang.Object source)
NodeCopier.createReusableSource(Class, Object)
createReusableSource
in interface NodeCopier
createReusableSource
in class BaseTransformer
destinationClass
- the destination class to which this source object will be
transformedsource
- a source object that will undergo a transformation by this
copier
public void setNestedTransformer(Transformer nestedTransformer)
NodeCopier.setNestedTransformer(Transformer)
setNestedTransformer
in interface NodeCopier
setNestedTransformer
in class BaseTransformer
nestedTransformer
- the transformer used to perform nested transformationspublic Transformer getNestedTransformer()
NodeCopier.getNestedTransformer()
getNestedTransformer
in interface NodeCopier
getNestedTransformer
in class BaseTransformer
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
BaseTransformer.isWrappingRuntimeExceptions()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |