Project JXTA

net.jxta.impl.endpoint.msgframing
Class MessagePackageHeader

java.lang.Object
  extended bynet.jxta.impl.endpoint.msgframing.MessagePackageHeader

public class MessagePackageHeader
extends Object

Header Package for Messages. Analagous to HTTP Headers.


Nested Class Summary
static class MessagePackageHeader.Header
          Used for storing headers.
 
Field Summary
(package private)  List headers
           
 
Constructor Summary
MessagePackageHeader()
          Creates a new instance of MessagePackage.
MessagePackageHeader(InputStream in)
          Creates a new instance of MessagePackage.
 
Method Summary
 void addHeader(String name, byte[] value)
          Add a header.
 long getContentLengthHeader()
          Convenience Method for Content Length header
 MimeMediaType getContentTypeHeader()
          Convenience Method for Content Type header
 Iterator getHeader(String name)
          Gets all of the headers matching the specified name
 Iterator getHeaders()
          Gets all of the headers
 void replaceHeader(String name, byte[] value)
          Replace a header.
 void sendToStream(OutputStream out)
          Write the headers to a stream
 void setContentLengthHeader(long length)
          Convenience Method for Content Length header
 void setContentTypeHeader(MimeMediaType type)
          Convenience Method for Content Type header
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

headers

List headers
Constructor Detail

MessagePackageHeader

public MessagePackageHeader()
Creates a new instance of MessagePackage. Used for outgoing messages.


MessagePackageHeader

public MessagePackageHeader(InputStream in)
                     throws IOException
Creates a new instance of MessagePackage. Used for incoming messages.

Parameters:
in - the stream from which the headers will be read.
Method Detail

addHeader

public void addHeader(String name,
                      byte[] value)
Add a header.

Parameters:
name - the header name
value - the value for the header

replaceHeader

public void replaceHeader(String name,
                          byte[] value)
Replace a header. Replaces all existing headers with the same name

Parameters:
name - the header name
value - the value for the header

getHeaders

public Iterator getHeaders()
Gets all of the headers


getHeader

public Iterator getHeader(String name)
Gets all of the headers matching the specified name

Parameters:
name - the name of the header we are seeking.

sendToStream

public void sendToStream(OutputStream out)
                  throws IOException
Write the headers to a stream

Parameters:
out - the stream to send the headers to.
Throws:
IOException

setContentLengthHeader

public void setContentLengthHeader(long length)
Convenience Method for Content Length header

Parameters:
length - length of the message.

getContentLengthHeader

public long getContentLengthHeader()
Convenience Method for Content Length header

Returns:
length from the header.

setContentTypeHeader

public void setContentTypeHeader(MimeMediaType type)
Convenience Method for Content Type header

Parameters:
type - type of the message.

getContentTypeHeader

public MimeMediaType getContentTypeHeader()
Convenience Method for Content Type header

Returns:
type from the header.

JXTA J2SE