public class DefaultMessageCollection extends DefaultMuleMessage implements MuleMessageCollection
MuleMessage type that manages a collection of MuleMessage Objects.
Typically this type of message is only used when users explicitly want to work with aggregated or re-sequenced
collections of messages.
Note that the DefaultMuleMessage.getPayload() for this message will return a List of payload objects for
each of the Mule messages stored in this collection.
Calling getPayload(Class) will attempt to transform all payloads and return a List.
The methods DefaultMuleMessage.getPayloadAsString() and getPayloadAsBytes() are unsupported, instead users should
call getPayload(Class) and pass in the return type byte[].class or String.class.ThreadSafeAccess.AccessControlREAD, WRITE| Constructor and Description |
|---|
DefaultMessageCollection() |
DefaultMessageCollection(DefaultMessageCollection msg)
Performs a shallow copy
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMessage(MuleMessage message) |
void |
addMessage(MuleMessage message,
int index) |
void |
addMessages(List messages) |
void |
addMessages(MuleEvent[] events) |
void |
addMessages(MuleMessage[] messages) |
MuleMessage |
getMessage(int index) |
protected List |
getMessageList() |
MuleMessage[] |
getMessagesAsArray() |
Object |
getPayload(Class outputType)
Applies the
getPayload(Class) call to every message in the collection and returns a
List of results. |
byte[] |
getPayloadAsBytes()
Converts the message implementation into a byte array representation
|
String |
getPayloadAsString(String encoding)
Converts the message implementation into a String representation
|
protected List |
getPayloadList() |
Object[] |
getPayloadsAsArray() |
ThreadSafeAccess |
newThreadCopy()
We need to overload this if we find we want to make this class available to users, but the copy will be expensive;
|
void |
removedMessage(MuleMessage message) |
int |
size() |
addAttachment, addProperties, addProperties, applyAllTransformers, applyTransformers, applyTransformers, assertAccess, clearProperties, getAdapter, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationId, getCorrelationSequence, getDoubleProperty, getEncoding, getExceptionPayload, getIntProperty, getLongProperty, getOrginalPayload, getOriginalAdapter, getPayload, getPayload, getPayloadAsString, getProperty, getProperty, getPropertyNames, getReplyTo, getStringProperty, getUniqueId, isPayloadConsumed, release, removeAttachment, removeProperty, resetAccessControl, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setLongProperty, setPayload, setProperty, setProperty, setReplyTo, setStringProperty, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitapplyTransformers, applyTransformers, getAdapter, getOrginalPayload, getOriginalAdapter, getPayloadAsString, setPayloadaddAttachment, addProperties, addProperties, clearProperties, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationId, getCorrelationSequence, getDoubleProperty, getEncoding, getExceptionPayload, getIntProperty, getLongProperty, getPayload, getProperty, getProperty, getPropertyNames, getReplyTo, getStringProperty, getUniqueId, release, removeAttachment, removeProperty, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setLongProperty, setProperty, setProperty, setReplyTo, setStringPropertypublic DefaultMessageCollection()
public DefaultMessageCollection(DefaultMessageCollection msg)
msg - public void addMessage(MuleMessage message)
addMessage in interface MuleMessageCollectionpublic MuleMessage[] getMessagesAsArray()
getMessagesAsArray in interface MuleMessageCollectionpublic Object[] getPayloadsAsArray()
getPayloadsAsArray in interface MuleMessageCollectionpublic void removedMessage(MuleMessage message)
removedMessage in interface MuleMessageCollectionpublic void addMessage(MuleMessage message, int index)
addMessage in interface MuleMessageCollectionpublic void addMessages(MuleEvent[] events)
addMessages in interface MuleMessageCollectionpublic void addMessages(List messages)
addMessages in interface MuleMessageCollectionpublic void addMessages(MuleMessage[] messages)
addMessages in interface MuleMessageCollectionpublic MuleMessage getMessage(int index)
getMessage in interface MuleMessageCollectionprotected List getMessageList()
protected List getPayloadList()
public Object getPayload(Class outputType) throws TransformerException
getPayload(Class) call to every message in the collection and returns a
List of results.
Will attempt to obtain the payload of this message with the desired Class type. This will
try and resolve a trnsformr 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 compatabilitygetPayload in interface MuleMessagegetPayload in class DefaultMuleMessageoutputType - the desired return typeTransformerException - if a transformer cannot be found or there is an error during transformation of the
payloadpublic int size()
size in interface MuleMessageCollectionpublic byte[] getPayloadAsBytes()
throws Exception
getPayloadAsBytes in interface MuleMessagegetPayloadAsBytes in class DefaultMuleMessageException - Implemetation may throw an endpoint specific exceptionpublic String getPayloadAsString(String encoding) throws Exception
getPayloadAsString in interface MuleMessagegetPayloadAsString in class DefaultMuleMessageencoding - The encoding to use when transforming the message (if
necessary). The parameter is used when converting from a byte arrayException - Implementation may throw an endpoint specific exceptionpublic ThreadSafeAccess newThreadCopy()
newThreadCopy in interface ThreadSafeAccessnewThreadCopy in class DefaultMuleMessageCopyright © 2003-2012 MuleSource, Inc.. All Rights Reserved.