Project JXTA

net.jxta.impl.endpoint
Class MessageImpl

java.lang.Object
  |
  +--net.jxta.impl.endpoint.MessageImpl

public class MessageImpl
extends java.lang.Object
implements net.jxta.endpoint.Message

A MessageImpl contains data and protocol specific information that are exchanged between peer protocols. A MessageImpl consists of a queue of data chunks that are assiciated with a MessageImplTag. A MessageImpl is also associated to the TransportAddress of the sender and the receiver of the message. Note that several different chunks of data associated to the same tag can be pushed. In that case, several pops will be needed to retrieve all the chunks.


Constructor Summary
MessageImpl()
          Constructor for outgoing message.
MessageImpl(byte[] src)
           
MessageImpl(byte[] src, int offset)
           
MessageImpl(byte[] src, int offset, int len)
          Constructor for incoming messages
 
Method Summary
 net.jxta.endpoint.Message dup()
          Duplicate the message.
 net.jxta.endpoint.EndpointAddress getDestAddress()
           
 java.io.InputStream getInputStream()
          Return an InputStream on the entire message.
 java.util.Enumeration getNames()
          Returns an Enumeration containing all the MessageTag names in the message.
 int getSize(java.lang.String atag)
          Get the size of a particular tag's data in the message.
 net.jxta.endpoint.EndpointAddress getSrcAddress()
           
 java.util.Vector getTags()
           
 java.io.InputStream pop(java.lang.String search)
          Pop an InputStream associated with a symbolic name
 void push(java.lang.String name, java.io.InputStream inputStream)
          Push an a new InputStream onto the message associated with a symbolic name.
 void setDestAddress(net.jxta.endpoint.EndpointAddress addr)
          The following public API is not intended to the application but only to the endpoint implementation.
 void setSrcAddress(net.jxta.endpoint.EndpointAddress addr)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageImpl

public MessageImpl()
Constructor for outgoing message. Note that an outgoing message is always valid.

MessageImpl

public MessageImpl(byte[] src)

MessageImpl

public MessageImpl(byte[] src,
                   int offset)

MessageImpl

public MessageImpl(byte[] src,
                   int offset,
                   int len)
Constructor for incoming messages
Method Detail

push

public void push(java.lang.String name,
                 java.io.InputStream inputStream)
          throws java.io.IOException
Push an a new InputStream onto the message associated with a symbolic name.
Specified by:
push in interface net.jxta.endpoint.Message
Parameters:
name - is the symbolic name associated with the InputStream
inputStream - is the new InputStream to push onto the message
Throws:
java.io.IOException - when the inputStream is not available.

pop

public java.io.InputStream pop(java.lang.String search)
                        throws java.io.IOException
Pop an InputStream associated with a symbolic name
Specified by:
pop in interface net.jxta.endpoint.Message
Parameters:
name - is the symbolic name associated with the InputStream to get.
Returns:
InputStream returns an InputStream associated with name.
Throws:
java.io.IOException - when the InputStream is not available.

getSize

public int getSize(java.lang.String atag)
Get the size of a particular tag's data in the message.
Specified by:
getSize in interface net.jxta.endpoint.Message
Parameters:
atag - the name of the tag whose size to get
Returns:
the size of the data in the message for the specified tag

getNames

public java.util.Enumeration getNames()
Returns an Enumeration containing all the MessageTag names in the message.
Specified by:
getNames in interface net.jxta.endpoint.Message
Returns:
Enumeration of MessageTag objects.

dup

public net.jxta.endpoint.Message dup()
Duplicate the message.
Specified by:
dup in interface net.jxta.endpoint.Message

getInputStream

public java.io.InputStream getInputStream()
Return an InputStream on the entire message. The bytes returned by the InputStream are formatted in the standard JXTA Endpoint message format. This method is used to get the bytes to be sent (outgoing messages).

setDestAddress

public void setDestAddress(net.jxta.endpoint.EndpointAddress addr)
The following public API is not intended to the application but only to the endpoint implementation. Maybe in the future, we will provide this API to the applications if there is a need for it.

setSrcAddress

public void setSrcAddress(net.jxta.endpoint.EndpointAddress addr)

getDestAddress

public net.jxta.endpoint.EndpointAddress getDestAddress()

getSrcAddress

public net.jxta.endpoint.EndpointAddress getSrcAddress()

getTags

public java.util.Vector getTags()

Project JXTA