org.mule.transformer
Class AbstractMessageTransformer

java.lang.Object
  extended by org.mule.transformer.AbstractTransformer
      extended by org.mule.transformer.AbstractMessageTransformer
All Implemented Interfaces:
MuleContextAware, MuleContextNotificationListener<MuleContextNotification>, ServerNotificationListener<MuleContextNotification>, Disposable, Initialisable, NamedObject, MessageProcessor, MessageTransformer, Transformer, EndpointAware
Direct Known Subclasses:
AbstractExpressionTransformer, AbstractJmsTransformer, AbstractJsonTransformer, AbstractMessageAwareTransformer, AbstractXmlTransformer, AbstractXStreamTransformer, AnnotatedTransformerProxy, AutoTransformer, HttpRequestBodyToParamMap, HttpRequestToBook, HttpRequestToParameter, HttpRequestToParameterMap, MessagePropertiesTransformer, MuleMessageToByteArray, MuleMessageToHttpResponse, ObjectToHttpClientMethodRequest, ObjectToXmppPacket, RestRequestToCustomerRequest, ScriptTransformer, StringToEmailMessage, TransformerChain, TransformerTemplate, XmppPacketToObject

public abstract class AbstractMessageTransformer
extends AbstractTransformer
implements MessageTransformer

AbstractMessageTransformer is a transformer that has a reference to the current message. This message can be used to obtain properties associated with the current message which are useful to the transform. Note that when part of a transform chain, the MuleMessage payload reflects the pre-transform message state, unless there is no current event for this thread, then the message will be a new DefaultMuleMessage with the src as its payload. Transformers should always work on the src object not the message payload.

See Also:
MuleMessage, DefaultMuleMessage

Field Summary
 
Fields inherited from class org.mule.transformer.AbstractTransformer
encoding, endpoint, logger, mimeType, MULE_MESSAGE_DATA_TYPE, muleContext, name, returnType, sourceTypes
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
AbstractMessageTransformer()
           
 
Method Summary
protected  java.lang.Object checkReturnClass(java.lang.Object object, MuleEvent event)
          Check if the return class is supported by this transformer
 java.lang.Object doTransform(java.lang.Object src, java.lang.String enc)
          Perform a non-message aware transform.
 boolean isSourceDataTypeSupported(DataType<?> dataType, boolean exactMatch)
          Determines whether that data type passed in is supported by this transformer
 java.lang.Object transform(java.lang.Object src, MuleEvent event)
          transform the specified message
 java.lang.Object transform(java.lang.Object src, java.lang.String enc)
          Transform the message with no event specified.
 java.lang.Object transform(java.lang.Object src, java.lang.String enc, MuleEvent event)
          transform the specified message
abstract  java.lang.Object transformMessage(MuleMessage message, java.lang.String outputEncoding)
          Transform the message
 
Methods inherited from class org.mule.transformer.AbstractTransformer
checkReturnClass, dispose, generateTransformerName, getEncoding, getEncoding, getEndpoint, getMimeType, getName, getReturnClass, getReturnDataType, getSourceDataTypes, getSourceTypes, initialise, isAcceptNull, isAllowNullReturn, isConsumed, isIgnoreBadInput, isSourceDataTypeSupported, isSourceTypeSupported, isSourceTypeSupported, onNotification, process, registerSourceType, registerSourceType, setAllowNullReturn, setEncoding, setEndpoint, setIgnoreBadInput, setMimeType, setMuleContext, setName, setReturnClass, setReturnDataType, toString, transform, unregisterSourceType, unregisterSourceType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mule.api.transformer.Transformer
getEncoding, getEndpoint, getMimeType, getReturnClass, getReturnDataType, getSourceDataTypes, getSourceTypes, isAcceptNull, isIgnoreBadInput, isSourceDataTypeSupported, isSourceTypeSupported, setReturnClass, setReturnDataType, transform
 
Methods inherited from interface org.mule.api.processor.MessageProcessor
process
 
Methods inherited from interface org.mule.api.lifecycle.Initialisable
initialise
 
Methods inherited from interface org.mule.api.lifecycle.Disposable
dispose
 
Methods inherited from interface org.mule.api.NamedObject
getName, setName
 
Methods inherited from interface org.mule.api.context.MuleContextAware
setMuleContext
 
Methods inherited from interface org.mule.endpoint.EndpointAware
setEndpoint
 

Constructor Detail

AbstractMessageTransformer

public AbstractMessageTransformer()
Method Detail

isSourceDataTypeSupported

public boolean isSourceDataTypeSupported(DataType<?> dataType,
                                         boolean exactMatch)
Description copied from class: AbstractTransformer
Determines whether that data type passed in is supported by this transformer

Overrides:
isSourceDataTypeSupported in class AbstractTransformer
Parameters:
dataType - the type to check against
exactMatch - if set to true, this method will look for an exact match to the data type, if false it will look for a compatible data type.
Returns:
whether the data type is supported

doTransform

public final java.lang.Object doTransform(java.lang.Object src,
                                          java.lang.String enc)
                                   throws TransformerException
Perform a non-message aware transform. This should never be called

Specified by:
doTransform in class AbstractTransformer
Throws:
TransformerException

transform

public final java.lang.Object transform(java.lang.Object src,
                                        java.lang.String enc)
                                 throws TransformerException
Transform the message with no event specified.

Specified by:
transform in interface Transformer
Overrides:
transform in class AbstractTransformer
Parameters:
src - the data to transform
enc - 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

transform

public java.lang.Object transform(java.lang.Object src,
                                  MuleEvent event)
                           throws TransformerMessagingException
transform the specified message

Specified by:
transform in interface MessageTransformer
Parameters:
src - the data to transform
event - the event currently being processed
Returns:
Throws:
TransformerMessagingException

transform

public final java.lang.Object transform(java.lang.Object src,
                                        java.lang.String enc,
                                        MuleEvent event)
                                 throws TransformerMessagingException
transform the specified message

Specified by:
transform in interface MessageTransformer
Parameters:
src - the data to transform
enc -
event - the event currently being processed
Returns:
Throws:
TransformerMessagingException

checkReturnClass

protected java.lang.Object checkReturnClass(java.lang.Object object,
                                            MuleEvent event)
                                     throws TransformerMessagingException
Check if the return class is supported by this transformer

Parameters:
object -
event -
Returns:
Throws:
TransformerMessagingException

transformMessage

public abstract java.lang.Object transformMessage(MuleMessage message,
                                                  java.lang.String outputEncoding)
                                           throws TransformerException
Transform the message

Parameters:
message -
outputEncoding -
Returns:
Throws:
TransformerMessagingException
TransformerException


Copyright © 2003-2010 MuleSoft, Inc.. All Rights Reserved.