org.mule.transformers
Class AbstractTransformer

java.lang.Object
  extended byorg.mule.transformers.AbstractTransformer
All Implemented Interfaces:
java.lang.Cloneable, Initialisable, java.io.Serializable, UMOSimpleTransformer, UMOTransformer
Direct Known Subclasses:
AbstractCompressionTransformer, AbstractEncryptionTransformer, AbstractEventAwareTransformer, AbstractEventTransformer, AbstractJmsTransformer, AbstractXStreamTransformer, ByteArrayToSerialisable, ByteArrayToString, DefaultTransformer, DomDocumentToXml, EmailMessageToString, FileToByteArray, FileToString, GroovyTransformer, HttpClientMethodResponseToObject, ObjectToFileMessage, SerialisableToByteArray, StringToByteArray, XmlToDomDocument, XsltTransformer

public abstract class AbstractTransformer
extends java.lang.Object
implements UMOTransformer

AbstractTransformer Is a base class for all transformers. Transformations transform one object into another.

Version:
$Revision: 1.5 $
Author:
Ross Mason
See Also:
Serialized Form

Field Summary
protected  UMOImmutableEndpoint endpoint
           
protected  Log logger
          logger used by this class
protected  java.lang.String name
           
protected  java.lang.Class returnClass
           
protected  UMOTransformer transformer
           
static java.lang.String TRANSFORMER_DEFAULT
          The fully qualified class name of the fallback Transformer implementation class to use, if no other can be found.
 
Fields inherited from interface org.mule.umo.transformer.UMOSimpleTransformer
SERVICE_ID
 
Constructor Summary
AbstractTransformer()
          default constructor required for discovery
 
Method Summary
protected  java.lang.Object checkReturnClass(java.lang.Object object)
           
 java.lang.Object clone()
           
abstract  java.lang.Object doTransform(java.lang.Object src)
           
protected  java.lang.String generateTransformerName()
           
 UMOImmutableEndpoint getEndpoint()
           
 java.lang.Class getFinalReturnClass()
          Will return the return type for the last transformer in the chain
 java.lang.String getName()
           
 java.lang.Class getReturnClass()
           
protected  java.util.Iterator getSourceTypeClassesIterator()
           
 UMOTransformer getTransformer()
           
 void initialise()
          Template method were deriving classes can do any initialisation after the properties have been set on this transformer
 boolean isSourceTypeSupported(java.lang.Class aClass)
           
protected  void registerSourceType(java.lang.Class aClass)
           
 void setEndpoint(UMOImmutableEndpoint endpoint)
           
 void setName(java.lang.String string)
           
 void setReturnClass(java.lang.Class newClass)
          Sets the expected return type for the transformed data.
 void setSourceType(java.lang.String type)
          Convenience method to register source types using a bean property setter
 void setTransformer(UMOTransformer transformer)
           
 java.lang.String toString()
           
 java.lang.Object transform(java.lang.Object src)
          Transforms the object.
protected  void unregisterSourceType(java.lang.Class aClass)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TRANSFORMER_DEFAULT

public static final java.lang.String TRANSFORMER_DEFAULT
The fully qualified class name of the fallback Transformer implementation class to use, if no other can be found.

See Also:
Constant Field Values

logger

protected transient Log logger
logger used by this class


returnClass

protected java.lang.Class returnClass

name

protected java.lang.String name

endpoint

protected UMOImmutableEndpoint endpoint

transformer

protected UMOTransformer transformer
Constructor Detail

AbstractTransformer

public AbstractTransformer()
default constructor required for discovery

Method Detail

checkReturnClass

protected java.lang.Object checkReturnClass(java.lang.Object object)
                                     throws TransformerException
Throws:
TransformerException

registerSourceType

protected void registerSourceType(java.lang.Class aClass)

unregisterSourceType

protected void unregisterSourceType(java.lang.Class aClass)

getSourceTypeClassesIterator

protected java.util.Iterator getSourceTypeClassesIterator()

getName

public java.lang.String getName()
Specified by:
getName in interface UMOSimpleTransformer
Returns:

setName

public void setName(java.lang.String string)
Specified by:
setName in interface UMOSimpleTransformer
Parameters:
string -

getReturnClass

public java.lang.Class getReturnClass()
Specified by:
getReturnClass in interface UMOSimpleTransformer
Returns:
the exceptedreturn type

setReturnClass

public void setReturnClass(java.lang.Class newClass)
Description copied from interface: UMOSimpleTransformer
Sets the expected return type for the transformed data. If the transformed data is not of this class type a TransformerException will be thrown.

Specified by:
setReturnClass in interface UMOSimpleTransformer
Parameters:
newClass - the expected return type class

isSourceTypeSupported

public boolean isSourceTypeSupported(java.lang.Class aClass)
Specified by:
isSourceTypeSupported in interface UMOTransformer

transform

public final java.lang.Object transform(java.lang.Object src)
                                 throws TransformerException
Transforms the object.

Specified by:
transform in interface UMOSimpleTransformer
Parameters:
src - The source object to transform.
Returns:
The transformed object
Throws:
TransformerException - if a error occurs transforming the data or if the expected returnClass isn't the same as the transformed data

getEndpoint

public UMOImmutableEndpoint getEndpoint()
Specified by:
getEndpoint in interface UMOTransformer
Returns:
the endpoint associated with the transformer

setEndpoint

public void setEndpoint(UMOImmutableEndpoint endpoint)
Specified by:
setEndpoint in interface UMOTransformer
Parameters:
endpoint - sets the endpoint associated with the transfromer

doTransform

public abstract java.lang.Object doTransform(java.lang.Object src)
                                      throws TransformerException
Throws:
TransformerException

getTransformer

public UMOTransformer getTransformer()
Specified by:
getTransformer in interface UMOTransformer

setTransformer

public void setTransformer(UMOTransformer transformer)
Specified by:
setTransformer in interface UMOTransformer

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Specified by:
clone in interface UMOSimpleTransformer
Throws:
java.lang.CloneNotSupportedException

getFinalReturnClass

public java.lang.Class getFinalReturnClass()
Will return the return type for the last transformer in the chain

Returns:
the last transformers return type

initialise

public void initialise()
                throws InitialisationException
Template method were deriving classes can do any initialisation after the properties have been set on this transformer

Specified by:
initialise in interface Initialisable
Throws:
InitialisationException

generateTransformerName

protected java.lang.String generateTransformerName()

setSourceType

public void setSourceType(java.lang.String type)
                   throws java.lang.ClassNotFoundException
Convenience method to register source types using a bean property setter

Parameters:
type - the fully qualified class name
Throws:
java.lang.ClassNotFoundException - is thrown if the class is not on theclasspath

toString

public java.lang.String toString()


Copyright © 2003-2005 SymphonySoft Limited. All Rights Reserved.