org.mule.transformer
Class AbstractMessageTransformer

java.lang.Object
  extended by org.mule.transformer.AbstractTransformer
      extended by org.mule.transformer.AbstractMessageTransformer
All Implemented Interfaces:
AnnotatedObject, MuleContextAware, Disposable, Initialisable, NameableObject, NamedObject, MessageProcessor, MessageTransformer, Transformer, EndpointAware
Direct Known Subclasses:
AbstractAddVariablePropertyTransformer, AbstractExpressionTransformer, AbstractJmsTransformer, AbstractJsonTransformer, AbstractMessageAwareTransformer, AbstractRemoveVariablePropertyTransformer, AbstractXmlTransformer, AbstractXStreamTransformer, AddAttachmentTransformer, AnnotatedTransformerProxy, AutoTransformer, CopyAttachmentsTransformer, CopyPropertiesTransformer, FormTransformer, HttpRequestBodyToParamMap, HttpRequestToBook, HttpRequestToParameter, HttpRequestToParameterMap, MessagePropertiesTransformer, MuleMessageToByteArray, MuleMessageToHttpResponse, ObjectToHttpClientMethodRequest, ObjectToXmppPacket, OrderToEmailTransformer, ParseTemplateTransformer, RemoveAttachmentTransformer, RestRequestToCustomerRequest, ScriptTransformer, ServletTransformer, SetPayloadTransformer, 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
 
Fields inherited from interface org.mule.api.AnnotatedObject
PROPERTY_NAME
 
Constructor Summary
AbstractMessageTransformer()
           
 
Method Summary
protected  Object checkReturnClass(Object object, MuleEvent event)
          Check if the return class is supported by this transformer
 Object doTransform(Object src, 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
 Object transform(Object src, MuleEvent event)
          Thransforms the supplied data and returns the result
 Object transform(Object src, String enc)
          Transform the message with no event specified.
 Object transform(Object src, String enc, MuleEvent event)
          Thransforms the supplied data and returns the result
abstract  Object transformMessage(MuleMessage message, String outputEncoding)
          Transform the message
 
Methods inherited from class org.mule.transformer.AbstractTransformer
dispose, generateTransformerName, getAnnotation, getAnnotations, getEncoding, getEncoding, getEndpoint, getMimeType, getName, getReturnClass, getReturnDataType, getSourceDataTypes, getSourceTypes, initialise, isAcceptNull, isAllowNullReturn, isConsumed, isIgnoreBadInput, isSourceDataTypeSupported, isSourceTypeSupported, isSourceTypeSupported, process, registerSourceType, registerSourceType, setAllowNullReturn, setAnnotations, 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.NameableObject
setName
 
Methods inherited from interface org.mule.api.NamedObject
getName
 
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 Object doTransform(Object src,
                                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 Object transform(Object src,
                              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 Object transform(Object src,
                        MuleEvent event)
                 throws TransformerMessagingException
Description copied from interface: MessageTransformer
Thransforms the supplied data and returns the result

Specified by:
transform in interface MessageTransformer
Parameters:
src - the data to transform
event - the event currently being processed
Returns:
the transformed data
Throws:
TransformerMessagingException - if a error occurs transforming the data or if the expected returnClass isn't the same as the transformed data

transform

public final Object transform(Object src,
                              String enc,
                              MuleEvent event)
                       throws TransformerMessagingException
Description copied from interface: MessageTransformer
Thransforms the supplied data and returns the result

Specified by:
transform in interface MessageTransformer
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
event - the event currently being processed
Returns:
the transformed data
Throws:
TransformerMessagingException - if a error occurs transforming the data or if the expected returnClass isn't the same as the transformed data

checkReturnClass

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

Throws:
TransformerMessagingException

transformMessage

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

Throws:
TransformerException


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