net.sf.morph.transform.copiers
Class SetExpressionCopier

java.lang.Object
  extended by net.sf.morph.transform.transformers.BaseTransformer
      extended by net.sf.morph.transform.copiers.SetExpressionCopier
All Implemented Interfaces:
net.sf.composite.Component, Converter, Copier, DecoratedConverter, DecoratedCopier, DecoratedTransformer, ExplicitTransformer, Transformer

public class SetExpressionCopier
extends BaseTransformer
implements DecoratedCopier, DecoratedConverter

Uses a DecoratedLanguage to set the property denoted by an expression on the destination object.

Since:
Morph 1.1
Author:
mbenson

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
 
Constructor Summary
SetExpressionCopier()
          Create a new SetExpressionCopier.
SetExpressionCopier(java.lang.String expression)
          Create a new SetExpressionCopier.
 
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  java.lang.Class[] getDestinationClassesImpl()
          Transformer.getDestinationClasses() implementation template method.
 java.lang.String getExpression()
          Get the String expression.
 DecoratedLanguage getLanguage()
          Get the DecoratedLanguage language.
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 isAutomaticallyHandlingNulls()
          Indicates whether null values will automatically be converted to null by this base class before even calling the subclass's BaseTransformer.convertImpl(Class, Object, Locale) method.
 void setDestinationClasses(java.lang.Class[] destinationClasses)
          Configures the destinationClasses property of this transformer.
 void setExpression(java.lang.String expression)
          Set the String expression.
 void setLanguage(DecoratedLanguage language)
          Set the DecoratedLanguage language.
 void setSourceClasses(java.lang.Class[] sourceClasses)
          Configures the sourceClasses property of this transformer.
 
Methods inherited from class net.sf.morph.transform.transformers.BaseTransformer
clone, convert, convert, convertImpl, copy, copy, createDefaultReflector, createNewInstance, createNewInstanceImpl, createReusableSource, equals, equals, equalsUnidirectionalTest, getDestinationClasses, getInstantiatingReflector, getLocale, getLog, getNestedTransformer, getReflector, getReflector, getSourceClasses, getTransformableCallCache, getTransformerName, initialize, isCachingIsTransformableCalls, isImpreciseTransformation, isImpreciseTransformationImpl, isInitialized, isPerformingLogging, isTransformable, isTransformableImpl, isWrappingRuntimeExceptions, setCachingIsTransformableCalls, setInitialized, setLog, setNestedTransformer, setReflector, setTransformableCallCache, setTransformerName, toString
 
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
 

Constructor Detail

SetExpressionCopier

public SetExpressionCopier()
Create a new SetExpressionCopier.


SetExpressionCopier

public SetExpressionCopier(java.lang.String expression)
Create a new SetExpressionCopier.

Method Detail

initializeImpl

protected void initializeImpl()
                       throws java.lang.Exception
Gives subclasses a chance to perform any computations needed to initialize the transformer.

Overrides:
initializeImpl in class BaseTransformer
Throws:
java.lang.Exception
See Also:
BaseTransformer.initializeImpl()

copyImpl

protected void copyImpl(java.lang.Object destination,
                        java.lang.Object source,
                        java.util.Locale locale,
                        java.lang.Integer preferredTransformationType)
                 throws java.lang.Exception
Implementation of the copy method. By default, this method throws UnsupportedOperationException.

Overrides:
copyImpl in class BaseTransformer
Throws:
java.lang.Exception
See Also:
BaseTransformer.copyImpl(java.lang.Object, java.lang.Object, java.util.Locale, java.lang.Integer)

setDestinationClasses

public void setDestinationClasses(java.lang.Class[] destinationClasses)
Configures the 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.

Overrides:
setDestinationClasses in class BaseTransformer
Parameters:
destinationClasses - the new destinationClasses for this transformer
See Also:
BaseTransformer.setDestinationClasses(java.lang.Class[])

getDestinationClassesImpl

protected java.lang.Class[] getDestinationClassesImpl()
                                               throws java.lang.Exception
Transformer.getDestinationClasses() implementation template method.

Specified by:
getDestinationClassesImpl in class BaseTransformer
Returns:
Class[]
Throws:
java.lang.Exception
See Also:
BaseTransformer.getDestinationClassesImpl()

setSourceClasses

public void setSourceClasses(java.lang.Class[] sourceClasses)
Configures the 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.

Overrides:
setSourceClasses in class BaseTransformer
Parameters:
sourceClasses - the new sourceClasses for this transformer
See Also:
BaseTransformer.setSourceClasses(java.lang.Class[])

getSourceClassesImpl

protected java.lang.Class[] getSourceClassesImpl()
                                          throws java.lang.Exception
Transformer.getSourceClasses() implementation template method.

Specified by:
getSourceClassesImpl in class BaseTransformer
Returns:
Class[]
Throws:
java.lang.Exception
See Also:
BaseTransformer.getSourceClassesImpl()

getExpression

public java.lang.String getExpression()
Get the String expression.

Returns:
String

setExpression

public void setExpression(java.lang.String expression)
Set the String expression.

Parameters:
expression - String

getLanguage

public DecoratedLanguage getLanguage()
Get the DecoratedLanguage language.

Returns:
DecoratedLanguage

setLanguage

public void setLanguage(DecoratedLanguage language)
Set the DecoratedLanguage language.

Parameters:
language - DecoratedLanguage

isAutomaticallyHandlingNulls

protected boolean isAutomaticallyHandlingNulls()
Indicates whether null values will automatically be converted to null by this base class before even calling the subclass's BaseTransformer.convertImpl(Class, Object, Locale) method. Subclasses which depend on this behavior (which is all subclasses, by default) should include null as one of their source and destination classes so that the actual behavior of the transformer is consistent with the values that are returned by the BaseTransformer.isTransformable(Class, Class) method. The conversions will happen automatically even if the source and destination classes don't contain null, but for the sake of consistency the nulls should be included.

Overrides:
isAutomaticallyHandlingNulls in class BaseTransformer
Returns:
whether null values will automatically be converted to null by this base class before even calling the subclass's BaseTransformer.convertImpl(Class, Object, Locale) method


Copyright © 2004-2008.