org.mule.api
Interface MuleMessage

All Superinterfaces:
MessageAdapter, Serializable
All Known Subinterfaces:
MuleMessageCollection
All Known Implementing Classes:
DefaultMessageCollection, DefaultMuleMessage

public interface MuleMessage
extends MessageAdapter

MuleMessage represents a message payload. The Message comprises of the payload itself and properties associated with the payload.


Method Summary
 void applyTransformers(List transformers)
          Will apply a list of transformers to the payload of the message.
 void applyTransformers(List transformers, Class outputType)
          Will apply a list of transformers to the payload of the message.
 MessageAdapter getAdapter()
          Returns the currently edited Message adapter for this message.
 Object getOrginalPayload()
          Returns the original payload used to create this message.
 MessageAdapter getOriginalAdapter()
          Returns the original payload used to create this message.
 Object getPayload(Class outputType)
          Will attempt to obtain the payload of this message with the desired Class type.
 byte[] getPayloadAsBytes()
          Converts the message implementation into a byte array representation
 String getPayloadAsString()
          Converts the message implementation into a String representation.
 String getPayloadAsString(String encoding)
          Converts the message implementation into a String representation
 void setPayload(Object payload)
          Update the message payload.
 
Methods inherited from interface org.mule.api.transport.MessageAdapter
addAttachment, addProperties, addProperties, clearProperties, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationId, getCorrelationSequence, getDoubleProperty, getEncoding, getExceptionPayload, getIntProperty, getLongProperty, getPayload, getProperty, getProperty, getProperty, getPropertyNames, getPropertyNames, getReplyTo, getStringProperty, getUniqueId, release, removeAttachment, removeProperty, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setLongProperty, setProperty, setProperty, setReplyTo, setStringProperty
 

Method Detail

getAdapter

MessageAdapter getAdapter()
Returns the currently edited Message adapter for this message. If no edits have been made this methd will return the same as getOriginalAdapter()

Returns:

getOriginalAdapter

MessageAdapter getOriginalAdapter()
Returns the original payload used to create this message. The payload of the message can change if applyTransformers(java.util.List) or applyTransformers(java.util.List, Class) is called.

Returns:
the original payload used to create this message

applyTransformers

void applyTransformers(List transformers)
                       throws TransformerException
Will apply a list of transformers to the payload of the message. This *Will* change the payload of the message. This method provides the only way to alter the paylaod of this message without recreating a copy of the message

Parameters:
transformers - the transformers to apply to the message payload
Throws:
TransformerException - if a transformation error occurs or one or more of the transformers passed in a are incompatible with the message payload

applyTransformers

void applyTransformers(List transformers,
                       Class outputType)
                       throws TransformerException
Will apply a list of transformers to the payload of the message. This *Will* change the payload of the message. This method provides the only way to alter the paylaod of this message without recreating a copy of the message

Parameters:
transformers - the transformers to apply to the message payload
outputType - the required output type for this transformation. by adding this parameter some additional transformations will occur on the message payload to ensure that the final payload is of the specified type. If no transformers can be found in the registry that can transform from the return type of the transformation list to the outputType and exception will be thrown
Throws:
TransformerException - if a transformation error occurs or one or more of the transformers passed in a are incompatible with the message payload

setPayload

void setPayload(Object payload)
Update the message payload. This is typically only called if the payload was originally an InputStream. In which case, if the InputStream is consumed, it needs to be replaced for future access.

Parameters:
payload - the object to assign as the message payload

getPayload

Object getPayload(Class outputType)
                  throws TransformerException
Will attempt to obtain the payload of this message with the desired Class type. This will try and resolve a transformer that can do this transformation. If a transformer cannot be found an exception is thrown. Any transfromers added to the reqgistry will be checked for compatability

Parameters:
outputType - the desired return type
Returns:
The converted payload of this message. Note that this method will not alter the payload of this message *unless* the payload is an inputstream in which case the stream will be read and the payload will become the fully read stream.
Throws:
TransformerException - if a transformer cannot be found or there is an error during transformation of the payload

getPayloadAsString

String getPayloadAsString(String encoding)
                          throws Exception
Converts the message implementation into a String representation

Parameters:
encoding - The encoding to use when transforming the message (if necessary). The parameter is used when converting from a byte array
Returns:
String representation of the message payload
Throws:
Exception - Implementation may throw an endpoint specific exception

getPayloadAsString

String getPayloadAsString()
                          throws Exception
Converts the message implementation into a String representation. If encoding is required it will use the encoding set on the message

Returns:
String representation of the message payload
Throws:
Exception - Implementation may throw an endpoint specific exception

getPayloadAsBytes

byte[] getPayloadAsBytes()
                         throws Exception
Converts the message implementation into a byte array representation

Returns:
byte array of the message
Throws:
Exception - Implemetation may throw an endpoint specific exception

getOrginalPayload

Object getOrginalPayload()
Returns the original payload used to create this message. The payload of the message can change if applyTransformers(java.util.List) or applyTransformers(java.util.List, Class) is called.

Returns:
the original payload used to create this message


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