|
Project JXTA | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Message defines the interface of messages sent or received to or from an endpoint and pipes. Applications are expected to use this interface in order to exchange messages.
A Message is an object that can be sent or received using the EndpointService API or the PipeService API. A message contains a set MessageElements.
MessageElement,
EndpointAddress,
EndpointService,
InputPipe,
OutputPipe,
PipeService| Method Summary | |
void |
addElement(MessageElement add)
Add a MessageElement into the message. |
java.lang.Object |
clone()
Deep copy of message. |
boolean |
equals(java.lang.Object o)
Check if two message are equals |
byte[] |
getBytes(java.lang.String qname)
get the named element from the message and return the element's byte array. |
EndpointAddress |
getDestinationAddress()
Get the desitnation address from the message. |
MessageElement |
getElement(java.lang.String name)
Retrieve a element by name from the message |
MessageElementEnumeration |
getElements()
Returns an enumeration of all of the elements contained in this message. |
StringEnumeration |
getNames()
Return a StringEnumeration for all the message element names in this message. |
java.util.Enumeration |
getNamespaces()
Return an Enumeration of all namespace names used in this message. |
long |
getRawSize()
Return the raw size of the message. |
EndpointAddress |
getSourceAddress()
Get the source address from the message. |
java.lang.String |
getString(java.lang.String elementName)
Get the element from the message as a string. |
boolean |
hasElement(java.lang.String nsname)
Chck for a message element with the given name. |
MessageElement |
newMessageElement(java.lang.String name,
MimeMediaType type,
byte[] b)
Create a new Element, but dont add it to the message. |
MessageElement |
newMessageElement(java.lang.String name,
MimeMediaType type,
byte[] b,
int offset,
int len)
Create a new Element, but dont add it to the message. |
MessageElement |
newMessageElement(java.lang.String name,
MimeMediaType type,
java.io.InputStream in)
Create a new MessageElement, but dont add it to the message. |
MessageElement |
newMessageElement(java.lang.String name,
MimeMediaType type,
java.io.InputStream in,
int len)
Create a new Element, but dont add it to the message. |
boolean |
removeElement(MessageElement remove)
Remove an element from a message. |
MessageElement |
removeElement(java.lang.String name)
Remove an element from a message by its name. |
void |
setBytes(java.lang.String name,
byte[] bytes)
Create or replace a MessageElement using the given namespace and name. |
void |
setBytes(java.lang.String name,
byte[] bytes,
int offset,
int len)
Create or replace an element and add it to the message. |
void |
setDestinationAddress(EndpointAddress dstAddress)
Set the destination address on to the message. |
void |
setSourceAddress(EndpointAddress srcAddress)
Set the source address on to the message. |
void |
setString(java.lang.String elementName,
java.lang.String s)
Set the string on to the message. |
| Method Detail |
public MessageElement newMessageElement(java.lang.String name,
MimeMediaType type,
java.io.InputStream in)
throws java.io.IOException
name - Name of the Element. May be the empty string ("") if
the Element is not named.type - Type of the Element. null is equivalent to specifying
the type "Application/Octet-stream"in - the stream containing the body of the Element. The stream
will be closed by the Element.NullPointerException - if name or InputStream are null.
public MessageElement newMessageElement(java.lang.String name,
MimeMediaType type,
java.io.InputStream in,
int len)
throws java.io.IOException
name - Name of the Element. May be the empty string ("") if
the Element is not named.type - Type of the Element. null is equivalent to specifying
the type "Application/Octet-stream"in - the stream containing the body of the Element. If the
stream does not support the "mark" operation then a copy of the
stream contents is made immediately. The stream will NOT be
closed by the Element.len - The size of the Element will be limited to len bytes
from the stream. If you are using the stream interface and know
the size of the stream, specifying it here improves performance
and space effciency a lot.NullPointerException - if name or InputStream are null.
public MessageElement newMessageElement(java.lang.String name,
MimeMediaType type,
byte[] b,
int offset,
int len)
name - Name of the Element. May be the empty string ("") if
the Element is not named.type - Type of the Element. null is equivalent to specifying
the type "Application/Octet-stream"b - A byte array containing the contents of this element.offset - all bytes before this location in b
will be ignored.NullPointerException - if name or b are null.IndexOutOfBoundsException - if offset is negative or greater
than or equal to the length of b
public MessageElement newMessageElement(java.lang.String name,
MimeMediaType type,
byte[] b)
name - Name of the Element. May be null if
the Element is not named.type - Type of the Element. null is equivalent to specifying
the type "Application/Octet-stream"b - A byte array containing the contents of this element.offset - all bytes before this location in b
will be ignored.NullPointerException - if name or b are null.IndexOutOfBoundsException - if offset is negative or greater
than or equal to the length of bpublic long getRawSize()
public void addElement(MessageElement add)
add - the Element to add to the message.public boolean hasElement(java.lang.String nsname)
nsname - name of the message element to search for.public MessageElement getElement(java.lang.String name)
nsname - name of the message element to search for.public MessageElementEnumeration getElements()
The Enumeration returned is not synchronized with the message. If you modify the state of the Message, the enumeration will not reflect your changes.
Same as getElementsInLifoOrder().
public StringEnumeration getNames()
public boolean removeElement(MessageElement remove)
remove - the Element to remove from the message.public MessageElement removeElement(java.lang.String name)
name - name of the Element to remove from the message.
public void setBytes(java.lang.String name,
byte[] bytes)
public void setBytes(java.lang.String name,
byte[] bytes,
int offset,
int len)
name - Name of the new element.bytes - byte array which defines the value of the element.offset - Start location in byte array.len - Length of byte array segment startin at offset.public byte[] getBytes(java.lang.String qname)
Note that the element is not removed from the message post: offset == 0. len == bytes.length.
qname - name of the element to get.public java.util.Enumeration getNamespaces()
public java.lang.Object clone()
clone in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - is a Message object to compare with.
public EndpointAddress getSourceAddress()
Convenience method.
public EndpointAddress getDestinationAddress()
Convenience method.
public void setSourceAddress(EndpointAddress srcAddress)
Convenience method.
srcAddress - EndpointAddress of the source of the message.public void setDestinationAddress(EndpointAddress dstAddress)
Convenience method.
dstAddress - EndpointAddress of the destination of the message.
public void setString(java.lang.String elementName,
java.lang.String s)
Convenience method.
elementName - name of the element that will contain the Strings - content of the Message Element.public java.lang.String getString(java.lang.String elementName)
Convenience method.
|
Project JXTA | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||