org.mule.api.transformer
Interface Transformer

All Superinterfaces:
BaseTransformer, Initialisable, MuleContextAware, NamedObject
All Known Implementing Classes:
AbstractCompressionTransformer, AbstractDiscoverableTransformer, AbstractEncryptionTransformer, AbstractEventTransformer, AbstractExpressionTransformer, AbstractJmsTransformer, AbstractJsonTransformer, AbstractMessageAwareTransformer, AbstractTransformer, AbstractXmlTransformer, AbstractXStreamTransformer, AddBookResponse, AutoTransformer, Base64Decoder, Base64Encoder, BeanBuilderTransformer, BeanToMap, ByteArrayToHexString, ByteArrayToMuleMessage, ByteArrayToObject, ByteArrayToSerializable, ChatStringToString, CreditProfileXmlToCreditProfile, DecryptionTransformer, DomDocumentToXml, EmailMessageToString, EncryptionTransformer, ErrorMessageToException, ErrorMessageToExceptionBean, EventObjectTransformer, ExceptionBeanToErrorMessage, ExceptionToString, ExpressionTransformer, FileToByteArray, FileToString, GetBeanProperty, GZipCompressTransformer, GZipUncompressTransformer, HexStringToByteArray, HttpClientMethodResponseToObject, HttpRequestBodyToParamMap, HttpRequestToBook, HttpRequestToByteArray, HttpRequestToInputStream, HttpRequestToNameString, HttpRequestToParameter, HttpRequestToParameterMap, HttpRequestToSoapRequest, HttpResponseToString, IPToSender, JMSMessageToObject, JsonToObject, JXPathExtractor, LoanQuoteRequestToCreditProfileArgs, MapLookup, MapToBean, MessagePropertiesTransformer, MimeMessageToRfc822ByteArray, MuleMessageToByteArray, MuleMessageToHttpResponse, NameStringToChatString, NoActionTransformer, ObjectArrayToString, ObjectToByteArray, ObjectToHttpClientMethodRequest, ObjectToInputStream, ObjectToJMSMessage, ObjectToJson, ObjectToMimeMessage, ObjectToOutputHandler, ObjectToRemoteInvocationResultTransformer, ObjectToRemoteInvocationTransformer, ObjectToString, ObjectToXml, ObjectToXmppPacket, OrderToEmailTransformer, RestRequestToCustomerRequest, Rfc822ByteArraytoMimeMessage, ScriptTransformer, SerializableToByteArray, ServletRequestToOutputHandler, SetLendersAsRecipients, SimpleMathTransformer, StdinToNameString, StringAppendTestTransformer, StringAppendTransformer, StringToEmailMessage, StringToNameString, StringToNumber, StringToObjectArray, TransformerChain, TransformerTemplate, ValidateResponse, XmlEntityDecoder, XmlEntityEncoder, XmlPrettyPrinter, XmlToDomDocument, XmlToObject, XmlToOutputHandler, XmlToXMLStreamReader, XmppPacketToObject, XPathExtractor, XQueryTransformer, XsltTransformer

public interface Transformer
extends BaseTransformer, MuleContextAware

Transformer can be chained together to covert message payloads from one object type to another.


Field Summary
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Method Summary
 Class getReturnClass()
          Specifies the Java type of the result after this transformer has been executed.
 List<Class> getSourceTypes()
          Returns an unmodifiable list of Source types registered on this transformer
 boolean isAcceptNull()
          Does this transformer allow null input?
 boolean isIgnoreBadInput()
          By default, Mule will throw an exception if a transformer is invoked with a source object that is not compatible with the transformer.
 boolean isSourceTypeSupported(Class aClass)
          Determines if a particular source class can be handled by this transformer
 void setReturnClass(Class theClass)
          Sets the expected return type for the transformed data.
 Object transform(Object src)
          Thransforms the supplied data and returns the result
 Object transform(Object src, String encoding)
          Thransforms the supplied data and returns the result
 
Methods inherited from interface org.mule.api.transformer.BaseTransformer
getEndpoint, setEndpoint
 
Methods inherited from interface org.mule.api.lifecycle.Initialisable
initialise
 
Methods inherited from interface org.mule.api.NamedObject
getName, setName
 
Methods inherited from interface org.mule.api.context.MuleContextAware
setMuleContext
 

Method Detail

isSourceTypeSupported

boolean isSourceTypeSupported(Class aClass)
Determines if a particular source class can be handled by this transformer

Parameters:
aClass - The class to check for compatability
Returns:
true if the transformer supports this type of class or false otherwise

getSourceTypes

List<Class> getSourceTypes()
Returns an unmodifiable list of Source types registered on this transformer

Returns:
an unmodifiable list of Source types registered on this transformer

isAcceptNull

boolean isAcceptNull()
Does this transformer allow null input?

Returns:
true if this transformer can accept null input

isIgnoreBadInput

boolean isIgnoreBadInput()
By default, Mule will throw an exception if a transformer is invoked with a source object that is not compatible with the transformer. Since transformers are often chained, it is useful to be able to ignore a transformer in the chain and move to the next one.

Returns:
true if the transformer can be ignorred if the currnet source type is not supported, false if an exception should be throw due to an incompatible source type being passed in.

transform

Object transform(Object src)
                 throws TransformerException
Thransforms the supplied data and returns the result

Parameters:
src - the data to transform
Returns:
the transformed data
Throws:
TransformerException - if a error occurs transforming the data or if the expected returnClass isn't the same as the transformed data

transform

Object transform(Object src,
                 String encoding)
                 throws TransformerException
Thransforms the supplied data and returns the result

Parameters:
src - the data to transform
encoding - the encoding to use by this transformer. many transformations will not need encoding unless dealing with text so you only need to use this method if yo wish to customize the encoding
Returns:
the transformed data
Throws:
TransformerException - if a error occurs transforming the data or if the expected returnClass isn't the same as the transformed data

setReturnClass

void setReturnClass(Class theClass)
Sets the expected return type for the transformed data. If the transformed data is not of this class type a TransformerException will be thrown.

Parameters:
theClass - the expected return type class

getReturnClass

Class getReturnClass()
Specifies the Java type of the result after this transformer has been executed. Mule will use this to validate the return type but also allow users to perform automatic transformations based on the source type of the object to transform and this return type.

Returns:
the excepted return type from this transformer


Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.