net.sf.morph.transform.converters
Class ContainerToPrettyTextConverter
java.lang.Object
net.sf.morph.transform.transformers.BaseTransformer
net.sf.morph.transform.transformers.BaseReflectorTransformer
net.sf.morph.transform.converters.BaseToPrettyTextConverter
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
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.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 |
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
ContainerToPrettyTextConverter
public ContainerToPrettyTextConverter()
- Create a new ContainerToPrettyTextConverter.
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.