net.sf.morph.transform.converters
Class ObjectToPrettyTextConverter

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
              extended by net.sf.morph.transform.converters.ObjectToPrettyTextConverter
All Implemented Interfaces:
net.sf.composite.Component, Converter, DecoratedConverter, DecoratedTransformer, ExplicitTransformer, ImpreciseTransformer, Transformer

public class ObjectToPrettyTextConverter
extends BaseToPrettyTextConverter

.

Creates a String representation of an object that is useful for debugging. This class is threadsafe and will not enter an infinite loop, even if displaying the information in a cyclic graph of objects.

Since:
Feb 15, 2005
Author:
Matt Sgarlata

Field Summary
static int DEFAULT_LEVELS
          Default levels
static java.lang.Class[] DEFAULT_TYPES_USING_TO_STRING
          Default types using toString()
 
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
ObjectToPrettyTextConverter()
          Create a new ObjectToPrettyTextConverter.
 
Method Summary
protected  java.lang.Object convertImpl(java.lang.Class destinationClass, java.lang.Object source, java.util.Locale locale)
          The implementation of the convert method, which may omit the invalid argument checks already performed by this base class.
 Converter getBeanToPrettyTextConverter()
          Get the converter used to convert beans to pretty text.
 Converter getContainerToPrettyTextConverter()
          Get the converter used to convert containers to pretty text.
 int getLevels()
          Get the levels
protected  java.lang.Class[] getSourceClassesImpl()
          Transformer.getSourceClasses() implementation template method.
 java.lang.Class[] getTypesUsingToString()
          Get the types using toString().
protected  java.util.Set getTypesUsingToStringInternal()
          Get the types using toString().
 void setBeanToPrettyTextConverter(Converter beanToTextConverter)
          Set the converter used to convert beans to pretty text.
 void setContainerToPrettyTextConverter(Converter containerToTextConverter)
          Set the converter used to convert containers to pretty text.
 void setLevels(int levels)
          Set the levels.
 void setTypesUsingToString(java.lang.Class[] typesUsingToString)
          Set the types using toString().
 
Methods inherited from class net.sf.morph.transform.converters.BaseToPrettyTextConverter
getDestinationClassesImpl, getIntermediateClass, getPrefix, getSeparator, getSuffix, getTextConverter, getToTextConverter, isImpreciseTransformationImpl, isPerformingLogging, isShowNullValues, isWrappingRuntimeExceptions, setPrefix, setSeparator, setShowNullValues, setSuffix, setTextConverter, setToTextConverter
 
Methods inherited from class net.sf.morph.transform.transformers.BaseReflectorTransformer
getBeanReflector, getContainerReflector, getGrowableContainerReflector, getIndexedContainerReflector, getMutableIndexedContainerReflector, hasReflector
 
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, 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
 

Field Detail

DEFAULT_TYPES_USING_TO_STRING

public static final java.lang.Class[] DEFAULT_TYPES_USING_TO_STRING
Default types using toString()


DEFAULT_LEVELS

public static final int DEFAULT_LEVELS
Default levels

See Also:
Constant Field Values
Constructor Detail

ObjectToPrettyTextConverter

public ObjectToPrettyTextConverter()
Create a new ObjectToPrettyTextConverter.

Method Detail

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

getSourceClassesImpl

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

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

getLevels

public int getLevels()
Get the levels

Returns:
int

setLevels

public void setLevels(int levels)
Set the levels.

Parameters:
levels -

getBeanToPrettyTextConverter

public Converter getBeanToPrettyTextConverter()
Get the converter used to convert beans to pretty text.

Returns:
Converter

setBeanToPrettyTextConverter

public void setBeanToPrettyTextConverter(Converter beanToTextConverter)
Set the converter used to convert beans to pretty text.

Parameters:
beanToTextConverter -

getContainerToPrettyTextConverter

public Converter getContainerToPrettyTextConverter()
Get the converter used to convert containers to pretty text.

Returns:
Converter

setContainerToPrettyTextConverter

public void setContainerToPrettyTextConverter(Converter containerToTextConverter)
Set the converter used to convert containers to pretty text.

Parameters:
containerToTextConverter -

getTypesUsingToStringInternal

protected java.util.Set getTypesUsingToStringInternal()
Get the types using toString().

Returns:
Set

getTypesUsingToString

public java.lang.Class[] getTypesUsingToString()
Get the types using toString().

Returns:
Class[]

setTypesUsingToString

public void setTypesUsingToString(java.lang.Class[] typesUsingToString)
Set the types using toString().

Parameters:
typesUsingToString -


Copyright © 2004-2008.