|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.esb.message.Payload
public class Payload
A message payload.
A message can have a number of payloads. Every message has a primary message payload, as well as 0 or more attachment payloads. A payload can be any java Object, or an array of bytes. The content can be accessed through thegetContent()
method and set through the setContent(Object)
and setContent(byte[], String)
methods.
A payload definition also contains a set of MIME headers, which can be managed
through the getMimeHeaders()
method. Examples of such MIME headers
are "Content-Type
",
"Content-ID
" and "Content-Location
".
If the content is a byte array, the "Content-Type
" MIME header
must be set, otherwise an exception is likely to occur during serialization of the
message. This of course will depend on the wire format (XML stream, Java Object stream etc).
This class is modeled directly on AttachmentPart
as defined in the SAAJ API.
Field Summary | |
---|---|
static String |
CONTENT_ID
|
static String |
CONTENT_LOCATION
|
static String |
CONTENT_TYPE
|
Constructor Summary | |
---|---|
Payload()
Contruct an empty payload instance. |
|
Payload(byte[] content,
String contentType)
Construct a binary content payload. |
|
Payload(Object content)
Construct a Java Object content payload. |
Method Summary | |
---|---|
Object |
getContent()
Get the message payload. |
String |
getContentType()
Get the Content-Type MIME header. |
Properties |
getMimeHeaders()
Get the MIME headers. |
void |
setContent(byte[] content,
String contentType)
Set a binary payload. |
void |
setContent(Object content)
Set a Java Object content payload. |
void |
setContentType(String contentType)
Set the Content-Type MIME header. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static String CONTENT_TYPE
public static String CONTENT_ID
public static String CONTENT_LOCATION
Constructor Detail |
---|
public Payload()
setContent(Object)
or setContent(byte[], String)
methods.
public Payload(Object content)
IllegalArgumentException
will occur if the supplied content instance is a byte[]. In this case,
you should use the Payload(byte[], String)
constructor.
content
- The Java payload.public Payload(byte[] content, String contentType)
content
- The binary payload.contentType
- The binary payload content type.Method Detail |
---|
public Properties getMimeHeaders()
public Object getContent()
getMimeHeaders()
method.
public void setContent(Object content)
IllegalArgumentException
will occur if the supplied content instance is a byte[]. In this case,
you should use the setContent(byte[], String)
method.
content
- The content payload.public void setContent(byte[] content, String contentType)
content
- The binary payload.contentType
- The payload content type.public String getContentType()
getMimeHeaders
.getProperty(CONTENT_TYPE
);
public void setContentType(String contentType)
getMimeHeaders
.setProperty(CONTENT_TYPE
, "text/plain");
contentType
- The content type.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |