net.sf.morph.transform.converters
Class BaseToPrettyTextConverter

java.lang.Object
  extended by net.sf.morph.transform.transformers.BaseTransformer
      extended by net.sf.morph.transform.transformers.BaseReflectorTransformer
          extended by net.sf.morph.transform.converters.BaseToPrettyTextConverter
All Implemented Interfaces:
net.sf.composite.Component, Converter, DecoratedConverter, DecoratedTransformer, ExplicitTransformer, ImpreciseTransformer, Transformer
Direct Known Subclasses:
BeanToPrettyTextConverter, ContainerToPrettyTextConverter, ObjectToPrettyTextConverter

public abstract class BaseToPrettyTextConverter
extends BaseReflectorTransformer
implements DecoratedConverter, ImpreciseTransformer

Base class for converts that convert objects to a pretty programmer-friendly representation using information retrieved using a reflector.

Since:
Feb 15, 2005
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
 
Fields inherited from interface net.sf.morph.transform.Transformer
TRANSFORMATION_TYPE_CONVERT, TRANSFORMATION_TYPE_COPY
 
Constructor Summary
BaseToPrettyTextConverter()
           
 
Method Summary
protected  java.lang.Class[] getDestinationClassesImpl()
          Transformer.getDestinationClasses() implementation template method.
protected  java.lang.Class getIntermediateClass()
          Get the intermediate class passed to the text converter.
 java.lang.String getPrefix()
          Get the prefix.
 java.lang.String getSeparator()
          Get the separator.
 java.lang.String getSuffix()
          Get the suffix.
 Converter getTextConverter()
          Get the text converter used by this BaseToPrettyTextConverter.
 Converter getToTextConverter()
          Get the "to text" converter used by this BaseToPrettyTextConverter.
protected  boolean isImpreciseTransformationImpl(java.lang.Class destinationClass, java.lang.Class sourceClass)
          Implementation of isImpreciseTransformation
protected  boolean isPerformingLogging()
          Indicates if calls to the main transformation methods (convert, copy) will cause a log message to be recorded
 boolean isShowNullValues()
          Learn whether this BaseToPrettyTextConverter is configured to show null values.
protected  boolean isWrappingRuntimeExceptions()
          Indicates whether runtime exceptions should be wrapped as TransformationExceptions.
 void setPrefix(java.lang.String prefix)
          Set the prefix.
 void setSeparator(java.lang.String separator)
          Set the separator.
 void setShowNullValues(boolean showNullValues)
          Set whether this BaseToPrettyTextConverter should show null values.
 void setSuffix(java.lang.String suffix)
          Set the suffix.
 void setTextConverter(Converter textConverter)
          Set the text converter used by this BaseToPrettyTextConverter.
 void setToTextConverter(Converter objectToTextConverter)
          Set the "to text" converter used by this BaseToPrettyTextConverter.
 
Methods inherited from class net.sf.morph.transform.transformers.BaseReflectorTransformer
getBeanReflector, getContainerReflector, getGrowableContainerReflector, getIndexedContainerReflector, getMutableIndexedContainerReflector, getSourceClassesImpl, hasReflector
 
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, isInitialized, 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.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.ImpreciseTransformer
isImpreciseTransformation
 

Constructor Detail

BaseToPrettyTextConverter

public BaseToPrettyTextConverter()
Method Detail

getDestinationClassesImpl

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

Overrides:
getDestinationClassesImpl in class BaseReflectorTransformer
Returns:
Class[]
Throws:
java.lang.Exception

isPerformingLogging

protected boolean isPerformingLogging()
Indicates if calls to the main transformation methods (convert, copy) will cause a log message to be recorded

Overrides:
isPerformingLogging in class BaseTransformer
Returns:
boolean

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

getSeparator

public java.lang.String getSeparator()
Get the separator.

Returns:
String

setSeparator

public void setSeparator(java.lang.String separator)
Set the separator.

Parameters:
separator -

getPrefix

public java.lang.String getPrefix()
Get the prefix.

Returns:
String

setPrefix

public void setPrefix(java.lang.String prefix)
Set the prefix.

Parameters:
prefix -

getSuffix

public java.lang.String getSuffix()
Get the suffix.

Returns:
String

setSuffix

public void setSuffix(java.lang.String suffix)
Set the suffix.

Parameters:
suffix -

getTextConverter

public Converter getTextConverter()
Get the text converter used by this BaseToPrettyTextConverter.

Returns:
Converter

setTextConverter

public void setTextConverter(Converter textConverter)
Set the text converter used by this BaseToPrettyTextConverter.

Parameters:
textConverter -

getToTextConverter

public Converter getToTextConverter()
Get the "to text" converter used by this BaseToPrettyTextConverter.

Returns:
Converter

setToTextConverter

public void setToTextConverter(Converter objectToTextConverter)
Set the "to text" converter used by this BaseToPrettyTextConverter.

Parameters:
objectToTextConverter -

isShowNullValues

public boolean isShowNullValues()
Learn whether this BaseToPrettyTextConverter is configured to show null values.

Returns:
boolean

setShowNullValues

public void setShowNullValues(boolean showNullValues)
Set whether this BaseToPrettyTextConverter should show null values. Default false.

Parameters:
showNullValues -

isImpreciseTransformationImpl

protected boolean isImpreciseTransformationImpl(java.lang.Class destinationClass,
                                                java.lang.Class sourceClass)
Implementation of isImpreciseTransformation

Overrides:
isImpreciseTransformationImpl in class BaseTransformer
Returns:
boolean

getIntermediateClass

protected java.lang.Class getIntermediateClass()
Get the intermediate class passed to the text converter.

Returns:


Copyright © 2004-2008.