net.sf.morph.transform.transformers
Class BaseCompositeTransformer

java.lang.Object
  extended by net.sf.morph.transform.transformers.BaseTransformer
      extended by net.sf.morph.transform.transformers.BaseCompositeTransformer
All Implemented Interfaces:
net.sf.composite.Component, net.sf.composite.Composite, net.sf.composite.SimpleComposite, net.sf.composite.StrictlyTypedComposite, DecoratedTransformer, ExplicitTransformer, Transformer
Direct Known Subclasses:
AssemblyCopierSupport, ChainedTransformer, CumulativeCopier, MultipleDestinationConverter, SimpleDelegatingTransformer

public abstract class BaseCompositeTransformer
extends BaseTransformer
implements Transformer, net.sf.composite.SimpleComposite, net.sf.composite.StrictlyTypedComposite

Since:
Dec 12, 2004
Author:
Matt Sgarlata

Field Summary
protected  java.lang.Object[] components
          Our component list
 
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
BaseCompositeTransformer()
           
 
Method Summary
 java.lang.Object[] getComponents()
          
 java.lang.Class getComponentType()
          Return the component type of this transformer.
 net.sf.composite.validate.ComponentValidator getComponentValidator()
          Return the ComponentValidator of this transformer.
protected  void initializeImpl()
          Gives subclasses a chance to perform any computations needed to initialize the transformer.
protected  boolean isNarrowingComponentArray()
          Learn whether we should automatically narrow the array type of components to that returned by getComponentType() after validating the components.
protected  boolean isWrappingRuntimeExceptions()
          Indicates whether runtime exceptions should be wrapped as TransformationExceptions.
 void setComponents(java.lang.Object[] components)
          
 void setComponentValidator(net.sf.composite.validate.ComponentValidator componentValidator)
          Set the ComponentValidator for this transformer.
protected  void setNestedTransformer(Transformer nestedTransformer)
          NodeCopier.setNestedTransformer(Transformer)
protected  void updateNestedTransformerComponents(Transformer incoming, Transformer outgoing)
          Propagate our nested transformer to any component NodeCopiers.
 
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, getDestinationClassesImpl, getInstantiatingReflector, getLocale, getLog, getNestedTransformer, getReflector, getReflector, getSourceClasses, getSourceClassesImpl, getTransformableCallCache, getTransformerName, initialize, isAutomaticallyHandlingNulls, isCachingIsTransformableCalls, isImpreciseTransformation, isImpreciseTransformationImpl, isInitialized, isPerformingLogging, isTransformable, isTransformableImpl, setCachingIsTransformableCalls, setDestinationClasses, setInitialized, setLog, 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
 

Field Detail

components

protected java.lang.Object[] components
Our component list

Constructor Detail

BaseCompositeTransformer

public BaseCompositeTransformer()
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()

getComponentType

public java.lang.Class getComponentType()
Return the component type of this transformer.

Specified by:
getComponentType in interface net.sf.composite.StrictlyTypedComposite
Returns:
Class

getComponents

public java.lang.Object[] getComponents()

Specified by:
getComponents in interface net.sf.composite.SimpleComposite
See Also:
SimpleComposite.getComponents()

setComponents

public void setComponents(java.lang.Object[] components)

Specified by:
setComponents in interface net.sf.composite.SimpleComposite
See Also:
SimpleComposite.setComponents(java.lang.Object[])

getComponentValidator

public net.sf.composite.validate.ComponentValidator getComponentValidator()
Return the ComponentValidator of this transformer.

Returns:
ComponentValidator

setComponentValidator

public void setComponentValidator(net.sf.composite.validate.ComponentValidator componentValidator)
Set the ComponentValidator for this transformer.

Parameters:
componentValidator - ComponentValidator

setNestedTransformer

protected void setNestedTransformer(Transformer nestedTransformer)
Description copied from class: BaseTransformer
NodeCopier.setNestedTransformer(Transformer)

Overrides:
setNestedTransformer in class BaseTransformer

updateNestedTransformerComponents

protected void updateNestedTransformerComponents(Transformer incoming,
                                                 Transformer outgoing)
Propagate our nested transformer to any component NodeCopiers.

Parameters:
incoming -
outgoing -

isWrappingRuntimeExceptions

protected boolean isWrappingRuntimeExceptions()
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
See Also:
BaseTransformer.isWrappingRuntimeExceptions()

isNarrowingComponentArray

protected boolean isNarrowingComponentArray()
Learn whether we should automatically narrow the array type of components to that returned by getComponentType() after validating the components.

Returns:
default true


Copyright © 2004-2008.