net.sf.morph.transform.converters
Class ConstantConverter
java.lang.Object
net.sf.morph.transform.transformers.BaseTransformer
net.sf.morph.transform.converters.ConstantConverter
- All Implemented Interfaces:
- net.sf.composite.Component, Converter, DecoratedConverter, DecoratedTransformer, ExplicitTransformer, Transformer
public class ConstantConverter
- extends BaseTransformer
- implements DecoratedConverter
Converter that always returns a certain destination object.
- Since:
- Morph 1.1
- Author:
- mbenson
Methods inherited from class net.sf.morph.transform.transformers.BaseTransformer |
clone, convert, convert, copy, copy, copyImpl, createDefaultReflector, createNewInstance, createNewInstanceImpl, createReusableSource, equals, equals, equalsUnidirectionalTest, getDestinationClasses, getInstantiatingReflector, getLocale, getLog, getNestedTransformer, getReflector, getReflector, getSourceClasses, getTransformableCallCache, getTransformerName, initialize, initializeImpl, isCachingIsTransformableCalls, isImpreciseTransformation, isImpreciseTransformationImpl, isInitialized, isPerformingLogging, isTransformable, isTransformableImpl, isWrappingRuntimeExceptions, 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 |
ConstantConverter
public ConstantConverter()
- Create a new
ConstantConverter
.
ConstantConverter
public ConstantConverter(java.lang.Object result)
- Create a new ConstantConverter.
- Parameters:
result
- the Object result to set.
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()
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()
convertImpl
protected java.lang.Object convertImpl(java.lang.Class destinationClass,
java.lang.Object source,
java.util.Locale locale)
throws java.lang.Exception
- The implementation of the
convert
method, which may omit
the invalid argument checks already performed by this base class. By
default, this method creates a new instance of the destinationClass and
copies information from the source to the destination. This
implementation should be fine as-is for Copiers, but Converters will need
to implement this method since they will not be implementing the copy
method.
- Overrides:
convertImpl
in class BaseTransformer
locale
- the locale in which the conversion should take place. for
converters that are not locale-aware, the local argument can
simply be ignored
- Throws:
java.lang.Exception
- See Also:
BaseTransformer.convertImpl(java.lang.Class, java.lang.Object, java.util.Locale)
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
null
s 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 - See Also:
BaseTransformer.isAutomaticallyHandlingNulls()
getResult
public java.lang.Object getResult()
- Get the result.
- Returns:
- Object.
setResult
public void setResult(java.lang.Object result)
- Set the result.
- Parameters:
result
- the Object result to set.
Copyright © 2004-2008.