org.apache.camel
Interface Message

All Known Implementing Classes:
DefaultMessage, FileMessage, JMXMessage, MessageSupport

public interface Message

Implements the Message pattern and represents an inbound or outbound message as part of an Exchange

Version:
$Revision: 642753 $

Method Summary
 Message copy()
          Creates a copy of this message so that it can be used and possibly modified further in another exchange
 void copyFrom(Message message)
          Copies the contents of the other message into this message
 Object getBody()
          Returns the body of the message as a POJO
<T> T
getBody(Class<T> type)
          Returns the body as the specified type
 Exchange getExchange()
          Returns the exchange this message is related to
 Object getHeader(String name)
          Accesses a specific header
<T> T
getHeader(String name, Class<T> type)
          Returns a header associated with this message by name and specifying the type required
 Map<String,Object> getHeaders()
          Returns all of the headers associated with the message
 String getMessageId()
          Returns the id of the message
 Object removeHeader(String name)
          Removes the named header from this message
 void setBody(Object body)
          Sets the body of the message
<T> void
setBody(Object body, Class<T> type)
          Sets the body of the message as a specific type
 void setHeader(String name, Object value)
          Sets a header on the message
 void setHeaders(Map<String,Object> headers)
          Set all the headers associated with this message
 void setMessageId(String messageId)
          Sets the id of the message
 

Method Detail

getMessageId

String getMessageId()
Returns the id of the message

Returns:
the id of the message

setMessageId

void setMessageId(String messageId)
Sets the id of the message

Parameters:
messageId -

getExchange

Exchange getExchange()
Returns the exchange this message is related to


getHeader

Object getHeader(String name)
Accesses a specific header

Parameters:
name - name of header
Returns:
object header associated with the name

getHeader

<T> T getHeader(String name,
                Class<T> type)
Returns a header associated with this message by name and specifying the type required

Parameters:
name - the name of the header
type - the type of the header
Returns:
the value of the given header or null if there is no property for the given name or it cannot be converted to the given type

setHeader

void setHeader(String name,
               Object value)
Sets a header on the message

Parameters:
name - of the header
value - to associate with the name

removeHeader

Object removeHeader(String name)
Removes the named header from this message

Parameters:
name -
Returns:
the old value of the header

getHeaders

Map<String,Object> getHeaders()
Returns all of the headers associated with the message

Returns:
all the headers in a Map

setHeaders

void setHeaders(Map<String,Object> headers)
Set all the headers associated with this message

Parameters:
headers -

getBody

Object getBody()
Returns the body of the message as a POJO

Returns:
the body of the message

getBody

<T> T getBody(Class<T> type)
Returns the body as the specified type

Parameters:
type - the type that the body
Returns:
the body of the message as the specified type

setBody

void setBody(Object body)
Sets the body of the message


setBody

<T> void setBody(Object body,
                 Class<T> type)
Sets the body of the message as a specific type


copy

Message copy()
Creates a copy of this message so that it can be used and possibly modified further in another exchange

Returns:
a new message instance copied from this message

copyFrom

void copyFrom(Message message)
Copies the contents of the other message into this message



Copyright © 2008 Apache Software Foundation. All Rights Reserved.