net.sf.morph.transform.transformers
Class TransformerDecorator

java.lang.Object
  extended by net.sf.morph.transform.transformers.BaseTransformer
      extended by net.sf.morph.transform.transformers.TransformerDecorator
All Implemented Interfaces:
net.sf.composite.Component, DecoratedTransformer, ExplicitTransformer, Transformer

public class TransformerDecorator
extends BaseTransformer
implements DecoratedTransformer

Decorates any Transformer so that it implements DecoratedTransformer. Example usage:

 Transformer myTransformer = new MyTransformer();
 DecoratedTransformer decoratedTransformer = new DecoratedTransformer(myTransformer);
 
 // now use decoratedTransformer instead of myTransformer
 if (decoratedTransformer.isTransformable(destinationType, sourceType)) {
     ...
 }
 

Since:
Dec 5, 2004
Author:
Matt Sgarlata

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
 
Constructor Summary
TransformerDecorator()
           
TransformerDecorator(Transformer transformer)
           
 
Method Summary
 java.lang.Class[] getDestinationClassesImpl()
          Transformer.getDestinationClasses() implementation template method.
 java.lang.Class[] getSourceClassesImpl()
          Transformer.getSourceClasses() implementation template method.
 Transformer getTransformer()
           
protected  boolean isWrappingRuntimeExceptions()
          Indicates whether runtime exceptions should be wrapped as TransformationExceptions.
 void setTransformer(Transformer transformer)
           
 
Methods inherited from class net.sf.morph.transform.transformers.BaseTransformer
clone, convert, convert, convertImpl, copy, copy, copyImpl, createDefaultReflector, createNewInstance, createNewInstanceImpl, createReusableSource, equals, equals, equalsUnidirectionalTest, getDestinationClasses, getInstantiatingReflector, getLocale, getLog, getNestedTransformer, getReflector, getReflector, getSourceClasses, getTransformableCallCache, getTransformerName, initialize, initializeImpl, isAutomaticallyHandlingNulls, isCachingIsTransformableCalls, isImpreciseTransformation, isImpreciseTransformationImpl, isInitialized, isPerformingLogging, isTransformable, isTransformableImpl, setCachingIsTransformableCalls, setDestinationClasses, setInitialized, setLog, setNestedTransformer, setReflector, setSourceClasses, 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.Transformer
getDestinationClasses, getSourceClasses
 
Methods inherited from interface net.sf.morph.transform.ExplicitTransformer
isTransformable
 

Constructor Detail

TransformerDecorator

public TransformerDecorator()

TransformerDecorator

public TransformerDecorator(Transformer transformer)
Method Detail

getSourceClassesImpl

public java.lang.Class[] getSourceClassesImpl()
Description copied from class: BaseTransformer
Transformer.getSourceClasses() implementation template method.

Specified by:
getSourceClassesImpl in class BaseTransformer
Returns:
Class[]

getDestinationClassesImpl

public java.lang.Class[] getDestinationClassesImpl()
Description copied from class: BaseTransformer
Transformer.getDestinationClasses() implementation template method.

Specified by:
getDestinationClassesImpl in class BaseTransformer
Returns:
Class[]

isWrappingRuntimeExceptions

protected boolean isWrappingRuntimeExceptions()
Description copied from class: BaseTransformer
Indicates whether runtime exceptions should be wrapped as TransformationExceptions. 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).

Overrides:
isWrappingRuntimeExceptions in class BaseTransformer
Returns:
true

getTransformer

public Transformer getTransformer()
Returns:
Returns the transformer.

setTransformer

public void setTransformer(Transformer transformer)
Parameters:
transformer - The transformer to set.


Copyright © 2004-2008.