net.sf.morph.transform.converters
Class ContainerToPrettyTextConverter

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.ContainerToPrettyTextConverter
All Implemented Interfaces:
net.sf.composite.Component, Converter, DecoratedConverter, DecoratedTransformer, ExplicitTransformer, ImpreciseTransformer, Transformer

public class ContainerToPrettyTextConverter
extends BaseToPrettyTextConverter

Converts a container to a textual representation (String or StringBuffer only). The string representation is comprised of a prefix, a textual representation of the array contents, and a suffix. The textual representation of the array contents is in turn made up of the string representation of each of the elements in the array separated by a separator character. Conversions to characters will only succeed if the result of the conversion is a single character in length.

For example, if the prefix is {, the suffix is }, the separator is , and the contents of the array are the Integers 1,2 and 3, the array will be converted to the text {1,2,3}.

Since:
Dec 25, 2004
Author:
Matt Sgarlata

Field Summary
static java.lang.String DEFAULT_PREFIX
          Default prefix
static java.lang.String DEFAULT_SEPARATOR
          Default separator
static java.lang.String DEFAULT_SUFFIX
          Default suffix
 
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
ContainerToPrettyTextConverter()
          Create a new ContainerToPrettyTextConverter.
 
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.
protected  java.lang.Class[] getSourceClassesImpl()
          Transformer.getSourceClasses() implementation template method.
 
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_PREFIX

public static final java.lang.String DEFAULT_PREFIX
Default prefix

See Also:
Constant Field Values

DEFAULT_SUFFIX

public static final java.lang.String DEFAULT_SUFFIX
Default suffix

See Also:
Constant Field Values

DEFAULT_SEPARATOR

public static final java.lang.String DEFAULT_SEPARATOR
Default separator

See Also:
Constant Field Values
Constructor Detail

ContainerToPrettyTextConverter

public ContainerToPrettyTextConverter()
Create a new ContainerToPrettyTextConverter.

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


Copyright © 2004-2008.