net.sf.morph.util
Class TransformerUtils

java.lang.Object
  extended by net.sf.morph.util.TransformerUtils

public abstract class TransformerUtils
extends java.lang.Object

Utility functions for implementing and using Transformers.

Since:
Nov 26, 2004
Author:
Matt Sgarlata

Constructor Summary
TransformerUtils()
           
 
Method Summary
static java.lang.Class[] getDestinationClasses(Transformer transformer, java.lang.Class sourceType)
          Get the set of destination classes available from the specified Transformer for the specified source type.
static java.lang.Class[] getDestinationClassIntersection(Transformer[] transformers)
          Get the set of destination classes common to all specified Transformers.
static java.lang.Class getMappedDestinationType(java.util.Map typeMapping, java.lang.Class requestedType)
          Get the mapped destination type from the specified typemap.
static java.lang.Class[] getSourceClasses(Transformer transformer, java.lang.Class destinationType)
          Get the set of source classes available from the specified Transformer for the specified destination type.
static java.lang.Class[] getSourceClassIntersection(Transformer[] transformers)
          Get the set of source classes common to all specified Transformers.
static boolean isImplicitlyTransformable(Transformer transformer, java.lang.Class destinationClass, java.lang.Class sourceClass)
          Learn whether sourceClass is transformable to destinationClass by transformer considering only source and destination types.
static boolean isImpreciseTransformation(Transformer transformer, java.lang.Class destinationClass, java.lang.Class sourceClass)
          Learn whether transformer's transformation of sourceClass to destinationClass might yield an imprecise result.
static boolean isTransformable(Transformer transformer, java.lang.Class destinationClass, java.lang.Class sourceClass)
          Learn whether sourceClass is transformable to destinationClass by transformer by implicit or explicit rules.
static java.lang.Object transform(Transformer transformer, java.lang.Class destinationType, java.lang.Object destination, java.lang.Object source, java.util.Locale locale, java.lang.Integer preferredTransformationType)
          Performs a transformation of one object graph into another object graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformerUtils

public TransformerUtils()
Method Detail

isImplicitlyTransformable

public static boolean isImplicitlyTransformable(Transformer transformer,
                                                java.lang.Class destinationClass,
                                                java.lang.Class sourceClass)
Learn whether sourceClass is transformable to destinationClass by transformer considering only source and destination types.

Parameters:
transformer -
destinationClass -
sourceClass -
Returns:
boolean

isTransformable

public static boolean isTransformable(Transformer transformer,
                                      java.lang.Class destinationClass,
                                      java.lang.Class sourceClass)
Learn whether sourceClass is transformable to destinationClass by transformer by implicit or explicit rules.

Parameters:
transformer -
destinationClass -
sourceClass -
Returns:
boolean
See Also:
isImplicitlyTransformable(Transformer, Class, Class), ExplicitTransformer

isImpreciseTransformation

public static boolean isImpreciseTransformation(Transformer transformer,
                                                java.lang.Class destinationClass,
                                                java.lang.Class sourceClass)
Learn whether transformer's transformation of sourceClass to destinationClass might yield an imprecise result.

Parameters:
transformer -
destinationClass -
sourceClass -
Returns:
boolean
Since:
Morph 1.1
See Also:
ImpreciseTransformer

transform

public static java.lang.Object transform(Transformer transformer,
                                         java.lang.Class destinationType,
                                         java.lang.Object destination,
                                         java.lang.Object source,
                                         java.util.Locale locale,
                                         java.lang.Integer preferredTransformationType)
                                  throws TransformationException
Performs a transformation of one object graph into another object graph.

Parameters:
destinationType - the type of the root node of the destination object graph
the - optional root node of the destination object graph. If this parameter is specified, it will be possible to copy information to an existing object graph rather than requiring a new object graph be created
source - the root node of the source object graph
locale - the locale in which any needed transformations should take place
preferredTransformationType - the preferred type of transformation to be performed
Returns:
the transformed object graph
Throws:
TransformationException - if the graph could not be transformed for some reason
See Also:
Transformer.TRANSFORMATION_TYPE_CONVERT, Transformer.TRANSFORMATION_TYPE_COPY

getMappedDestinationType

public static java.lang.Class getMappedDestinationType(java.util.Map typeMapping,
                                                       java.lang.Class requestedType)
Get the mapped destination type from the specified typemap.

Parameters:
typeMapping - Map
requestedType - Class
Returns:
Class

getSourceClasses

public static java.lang.Class[] getSourceClasses(Transformer transformer,
                                                 java.lang.Class destinationType)
Get the set of source classes available from the specified Transformer for the specified destination type.

Parameters:
transformer -
destinationType -
Returns:
Class[]

getDestinationClasses

public static java.lang.Class[] getDestinationClasses(Transformer transformer,
                                                      java.lang.Class sourceType)
Get the set of destination classes available from the specified Transformer for the specified source type.

Parameters:
transformer -
sourceType -
Returns:
Class[]
Since:
Morph 1.1

getSourceClassIntersection

public static java.lang.Class[] getSourceClassIntersection(Transformer[] transformers)
Get the set of source classes common to all specified Transformers.

Parameters:
transformers -
Returns:
Class[]

getDestinationClassIntersection

public static java.lang.Class[] getDestinationClassIntersection(Transformer[] transformers)
Get the set of destination classes common to all specified Transformers.

Parameters:
transformers -
Returns:
Class[]


Copyright © 2004-2008.