Project JXTA

net.jxta.impl.endpoint
Class OutgoingMessageTag

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

public class OutgoingMessageTag
extends java.lang.Object
implements MessageTag

An OutgoingMessageTag encapsulates the name a chunk of data that has to be sent with a Message. This class also implements the InputStream API so it can directely be used by the message layer to produce the bytes to be sent. This implementation assumes that the Message layer and/or the Transport layer does either synchronously send the message or is responsible to copy the data into an private buffer, letting the caller re-use the stream if needed. Doing that allows in the best case situation to avoid an extra copy of the user data, which can be very expensive, both for performance and memory utilization.


Inner Class Summary
 class OutgoingMessageTag.OutMsgTagWireInputStream
          This portion is the implementation of the InputStream API.
 
Constructor Summary
OutgoingMessageTag()
          Default constructor
OutgoingMessageTag(java.lang.String thisTag)
          Constructor.
 
Method Summary
 java.io.InputStream getInputStream()
          returns an InputStream to the data of the tag.
 java.lang.String getTag()
          Get the String representation of the tag.
 java.io.InputStream getWireFormatInputStream()
           
 void setInputStream(java.io.InputStream thisStream)
          Set the user InputStream.
 void setTag(java.lang.String thisTag)
          set this MessageTag with the tag.
 void share()
          This this tag shareable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutgoingMessageTag

public OutgoingMessageTag()
Default constructor

OutgoingMessageTag

public OutgoingMessageTag(java.lang.String thisTag)
Constructor. Build a message tag from its symbolic name.
Parameters:
thisTag - contains the symbolic name of this MessageTag.
Method Detail

setTag

public void setTag(java.lang.String thisTag)
            throws java.io.IOException
set this MessageTag with the tag. If the tag is invalid, IOException is thrown.
Specified by:
setTag in interface MessageTag
Parameters:
tag - String containing of the tag

getTag

public java.lang.String getTag()
Get the String representation of the tag.
Specified by:
getTag in interface MessageTag
Returns:
the String representation of the tag.

setInputStream

public void setInputStream(java.io.InputStream thisStream)
                    throws java.io.IOException
Set the user InputStream. This implementation of the MessageTag makes the assumption that the message will be either sent asynchronously or copied by the Endpoint and transport layer, so there is no need to worry here about sharing the stream with the user.
Specified by:
setInputStream in interface MessageTag
Parameters:
thisStream - InputStream provided by the caller.

share

public void share()
This this tag shareable. This implies buffering the data
Specified by:
share in interface MessageTag

getInputStream

public java.io.InputStream getInputStream()
returns an InputStream to the data of the tag.
Specified by:
getInputStream in interface MessageTag
Returns:
returns an InputStream to the data of the tag.

getWireFormatInputStream

public java.io.InputStream getWireFormatInputStream()
Specified by:
getWireFormatInputStream in interface MessageTag

Project JXTA