|
||||||||||
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.transformers.BaseReflectorTransformer net.sf.morph.transform.copiers.BasePropertyNameCopier
public abstract class BasePropertyNameCopier
Base class for copiers that copy information from one bean to another based on the property names in the source and destination objects.
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 | |
---|---|
BasePropertyNameCopier()
Create a new BasePropertyNameCopier. |
|
BasePropertyNameCopier(boolean errorOnMissingProperty)
Create a new BasePropertyNameCopier. |
Method Summary | |
---|---|
protected Transformer |
chooseTransformer(java.lang.String sourceProperty,
java.lang.Object source,
java.lang.String destinationProperty,
java.lang.Object destination,
java.util.Locale locale,
java.lang.Integer preferredTransformationType)
Choose the appropriate property transformer. |
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)
Perform the specified property copy. |
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. |
Transformer |
getNestedTransformer()
NodeCopier.getNestedTransformer() |
protected java.lang.Integer |
getPreferredTransformationType(java.lang.Object source,
java.lang.String sourceProperty,
java.lang.Object sourceValue,
java.lang.Object destination,
java.lang.String destinationProperty,
java.lang.Object destinationValue,
java.util.Locale locale,
java.lang.Integer preferredTransformationType)
Extension point for subclasses to override preferredTransformationType. |
java.util.Map |
getPropertyTransformers()
Get the Map of Transformers to use instead of nestedTransformer . |
protected java.lang.Class[] |
getSourceClassesImpl()
Transformer.getSourceClasses() implementation template method. |
boolean |
isErrorOnMissingProperty()
Return true if errors should should be thrown when a
property is missing. |
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 |
setErrorOnMissingProperty(boolean isStrict)
Set the value of the errorOnMissingProperty flag. |
void |
setNestedTransformer(Transformer transformer)
NodeCopier.setNestedTransformer(Transformer) |
void |
setPropertyTransformers(java.util.Map propertyTransformers)
Set the Map of Transformers to use instead of nestedTransformer . |
void |
setSourceClasses(java.lang.Class[] sourceClasses)
Configures the sourceClasses property of this transformer. |
Methods inherited from class net.sf.morph.transform.transformers.BaseReflectorTransformer |
---|
getBeanReflector, getContainerReflector, getGrowableContainerReflector, getIndexedContainerReflector, getMutableIndexedContainerReflector, hasReflector |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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.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.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 BasePropertyNameCopier()
public BasePropertyNameCopier(boolean errorOnMissingProperty)
errorOnMissingProperty
- Method Detail |
---|
public 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 boolean isErrorOnMissingProperty()
true
if errors should should be thrown when a
property is missing.
true
if errors should be thrown when a property is
missing or false
, otherwise.public void setErrorOnMissingProperty(boolean isStrict)
errorOnMissingProperty
- The value of errorOnMissingProperty to set.protected Transformer chooseTransformer(java.lang.String sourceProperty, java.lang.Object source, java.lang.String destinationProperty, java.lang.Object destination, java.util.Locale locale, java.lang.Integer preferredTransformationType)
sourceProperty
- source
- destinationProperty
- destination
- locale
- preferredTransformationType
-
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)
sourceProperty
- source
- destinationProperty
- destination
- locale
- preferredTransformationType
- protected java.lang.Integer getPreferredTransformationType(java.lang.Object source, java.lang.String sourceProperty, java.lang.Object sourceValue, java.lang.Object destination, java.lang.String destinationProperty, java.lang.Object destinationValue, java.util.Locale locale, java.lang.Integer preferredTransformationType)
source
- sourceProperty
- sourceValue
- destination
- destinationProperty
- destinationValue
- locale
- preferredTransformationType
-
Transformer
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 Transformer getNestedTransformer()
NodeCopier.getNestedTransformer()
getNestedTransformer
in interface NodeCopier
getNestedTransformer
in class BaseTransformer
public void setNestedTransformer(Transformer transformer)
NodeCopier.setNestedTransformer(Transformer)
setNestedTransformer
in interface NodeCopier
setNestedTransformer
in class BaseTransformer
transformer
- the transformer used to perform nested transformationspublic java.util.Map getPropertyTransformers()
nestedTransformer
.
public void setPropertyTransformers(java.util.Map propertyTransformers)
nestedTransformer
.
propertyTransformers
- protected java.lang.Class[] getSourceClassesImpl() throws java.lang.Exception
Transformer.getSourceClasses()
implementation template method.
getSourceClassesImpl
in class BaseReflectorTransformer
java.lang.Exception
public 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 transformerprotected java.lang.Class[] getDestinationClassesImpl() throws java.lang.Exception
Transformer.getDestinationClasses()
implementation template method.
getDestinationClassesImpl
in class BaseReflectorTransformer
java.lang.Exception
public 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 transformer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |