org.mule.transformers
Class AbstractTransformer

java.lang.Object
  extended byorg.mule.transformers.AbstractTransformer
All Implemented Interfaces:
Cloneable, Initialisable, Serializable, UMOSimpleTransformer, UMOTransformer
Direct Known Subclasses:
AbstractCompressionTransformer, AbstractEncryptionTransformer, AbstractEventAwareTransformer, AbstractEventTransformer, AbstractJmsTransformer, AbstractXmlTransformer, Base64Decoder, Base64Encoder, ByteArrayToHexString, ByteArrayToSerializable, ByteArrayToString, ChatStringToString, CreditProfileXmlToCreditProfile, DQMessageToXml, EmailMessageToString, ErrorMessageToException, ErrorMessageToExceptionBean, ExceptionBeanToErrorMessage, FileToByteArray, HexStringToByteArray, HttpClientMethodResponseToObject, HttpRequestToString, HttpResponseToString, JXPathExtractor, LoanQuoteRequestToCreditProfileArgs, LoanQuoteRequestToCustomer, MapLookup, NameStringToChatString, NoActionTransformer, ObjectToFruitLover, ObjectToRemoteInvocationResultTransformer, ObjectToRemoteInvocationTransformer, ObjectToString, StringToByteArray, StringToNameString, UCDecoder, UCEncoder, UUDecoder, UUEncoder, XmlEntityDecoder, XmlEntityEncoder, XmlToDQMessage

public abstract class AbstractTransformer
extends Object
implements UMOTransformer

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

See Also:
Serialized Form

Field Summary
protected  UMOImmutableEndpoint endpoint
           
protected  Log logger
          logger used by this class
protected  String name
           
protected  UMOTransformer nextTransformer
          This is the following transformer in the chain of transformers.
protected  Class returnClass
           
protected  List sourceTypes
           
static 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  Object checkReturnClass(Object object)
           
 Object clone()
           
protected abstract  Object doTransform(Object src, String encoding)
           
protected  String generateTransformerName()
           
 UMOImmutableEndpoint getEndpoint()
           
 Class getFinalReturnClass()
          Will return the return type for the last transformer in the chain
 String getName()
           
 UMOTransformer getNextTransformer()
           
 Class getReturnClass()
           
 String getSourceType()
          Where multiple source types are listed, this method only returns the first one.
protected  Iterator getSourceTypeClassesIterator()
          Deprecated. simply iterate over sourceTypes directly
 void initialise()
          Template method were deriving classes can do any initialisation after the properties have been set on this transformer
 boolean isAcceptNull()
           
 boolean isIgnoreBadInput()
           
 boolean isSourceTypeSupported(Class aClass)
           
 boolean isSourceTypeSupported(Class aClass, boolean exactMatch)
           
protected  void registerSourceType(Class aClass)
           
 void setEndpoint(UMOImmutableEndpoint endpoint)
           
 void setIgnoreBadInput(boolean ignoreBadInput)
           
 void setName(String string)
           
 void setNextTransformer(UMOTransformer nextTransformer)
           
 void setReturnClass(Class newClass)
          Sets the expected return type for the transformed data.
 void setSourceType(String type)
          Convenience method to register source types using a bean property setter
 String toString()
           
 Object transform(Object src)
          Transforms the object.
protected  void unregisterSourceType(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 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 Class returnClass

name

protected String name

endpoint

protected UMOImmutableEndpoint endpoint

sourceTypes

protected List sourceTypes

nextTransformer

protected UMOTransformer nextTransformer
This is the following transformer in the chain of transformers.

Constructor Detail

AbstractTransformer

public AbstractTransformer()
default constructor required for discovery

Method Detail

checkReturnClass

protected Object checkReturnClass(Object object)
                           throws TransformerException
Throws:
TransformerException

registerSourceType

protected void registerSourceType(Class aClass)

unregisterSourceType

protected void unregisterSourceType(Class aClass)

getSourceTypeClassesIterator

protected Iterator getSourceTypeClassesIterator()
Deprecated. simply iterate over sourceTypes directly


getName

public String getName()
Specified by:
getName in interface UMOSimpleTransformer
Returns:
transformer name

setName

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

getReturnClass

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

setReturnClass

public void setReturnClass(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(Class aClass)
Specified by:
isSourceTypeSupported in interface UMOTransformer

isSourceTypeSupported

public boolean isSourceTypeSupported(Class aClass,
                                     boolean exactMatch)

transform

public final Object transform(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

protected abstract Object doTransform(Object src,
                                      String encoding)
                               throws TransformerException
Throws:
TransformerException

getNextTransformer

public UMOTransformer getNextTransformer()
Specified by:
getNextTransformer in interface UMOSimpleTransformer

setNextTransformer

public void setNextTransformer(UMOTransformer nextTransformer)
Specified by:
setNextTransformer in interface UMOSimpleTransformer

clone

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

getFinalReturnClass

public 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 String generateTransformerName()

setSourceType

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

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

getSourceType

public String getSourceType()
Where multiple source types are listed, this method only returns the first one. The full list of supported source types can also be obtained using getSourceTypesIterator()

Returns:
the first SourceType on the transformer or java.lang.Object if there is no source type set

isIgnoreBadInput

public boolean isIgnoreBadInput()

setIgnoreBadInput

public void setIgnoreBadInput(boolean ignoreBadInput)

toString

public String toString()

isAcceptNull

public boolean isAcceptNull()
Specified by:
isAcceptNull in interface UMOTransformer


Copyright © 2003-2006 MuleSource Inc.. All Rights Reserved.