JXTA

net.jxta.impl.endpoint
Class WireFormatMessageBinary

java.lang.Object
  extended by net.jxta.impl.endpoint.WireFormatMessageBinary
All Implemented Interfaces:
Document, DocumentByteBufferIO, DocumentStreamIO, WireFormatMessage

public class WireFormatMessageBinary
extends Object
implements WireFormatMessage

A Wire Format Message which encodes the message into MIME Type "application/x-jxta-msg".

This implementation does nothing with encodings.

This implementation does not use any MIME parameters attached to the requesting mime type.

See Also:
WireFormatMessageFactory, JXTA Protocols Specification : Binary Message Format

Nested Class Summary
(package private) static class WireFormatMessageBinary.binaryElementProxy
          Proxy for a message element.
(package private) static class WireFormatMessageBinary.binaryMessageProxy
          Internal representation for a binary format wire message.
(package private) static class WireFormatMessageBinary.Instantiator
          Our instantiator.
 
Field Summary
protected static byte HAS_ENCODING
           
protected static byte HAS_SIGNATURE
           
protected static byte HAS_TYPE
           
static WireFormatMessageFactory.Instantiator INSTANTIATOR
          Our instantiator for the factory.
protected static int MESSAGE_VERSION
           
 
Constructor Summary
WireFormatMessageBinary(Message msg, MimeMediaType type, MimeMediaType[] preferedContentEncodings)
          Creates a new instance of WireFormatMessageBinary.
 
Method Summary
 boolean equals(Object obj)
          
 ByteBuffer[] getByteBuffers()
          Returns the Document as a sequence of ByteBuffers
 long getByteLength()
          Returns the size of the serialized and encoded form of the message in bytes.
 MimeMediaType getContentEncoding()
          Returns the encoding used for this content.
 String getFileExtension()
          Returns the file extension type used by this Document.
 MimeMediaType getMimeType()
          Returns the MIME Media type of this Document per IETF RFC 2046 MIME : Media Types.
 InputStream getStream()
          Returns the stream of bytes which represents the content of this Document.
 int hashCode()
          
 void sendToStream(OutputStream sendTo)
          Send the contents of this Document to the specified stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HAS_TYPE

protected static final byte HAS_TYPE
See Also:
Constant Field Values

HAS_ENCODING

protected static final byte HAS_ENCODING
See Also:
Constant Field Values

HAS_SIGNATURE

protected static final byte HAS_SIGNATURE
See Also:
Constant Field Values

MESSAGE_VERSION

protected static final int MESSAGE_VERSION
See Also:
Constant Field Values

INSTANTIATOR

public static final WireFormatMessageFactory.Instantiator INSTANTIATOR
Our instantiator for the factory.

Constructor Detail

WireFormatMessageBinary

WireFormatMessageBinary(Message msg,
                        MimeMediaType type,
                        MimeMediaType[] preferedContentEncodings)
                  throws IOException
Creates a new instance of WireFormatMessageBinary. Called only by the Instantiator.

Parameters:
msg - the message being serialized
type - the mime mediatype being requested.
preferedContentEncodings - The ranked content encodings preferred by the recipient.
Throws:
IOException - if an io error occurs
Method Detail

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

getFileExtension

public String getFileExtension()
Returns the file extension type used by this Document. This value is usually chosen based upon the MIME Media Type.

Specified by:
getFileExtension in interface Document
Returns:
An appropriate file extension for this Document.

getMimeType

public MimeMediaType getMimeType()
Returns the MIME Media type of this Document per IETF RFC 2046 MIME : Media Types.

JXTA does not currently support the 'Multipart' or 'Message' media types.

Specified by:
getMimeType in interface Document
Returns:
The MIME Media Type for this Document.

getStream

public InputStream getStream()
                      throws IOException
Returns the stream of bytes which represents the content of this Document.

Specified by:
getStream in interface DocumentStreamIO
Returns:
An InputStream containing the bytes of this Document.
Throws:
IOException - For errors while writing the Document.

getByteBuffers

public ByteBuffer[] getByteBuffers()
Returns the Document as a sequence of ByteBuffers

Specified by:
getByteBuffers in interface DocumentByteBufferIO

sendToStream

public void sendToStream(OutputStream sendTo)
                  throws IOException
Send the contents of this Document to the specified stream.

Specified by:
sendToStream in interface DocumentStreamIO
Parameters:
sendTo - The OutputStream to which the Document will be written.
Throws:
IOException - For errors while writing the Document.

getByteLength

public long getByteLength()
Returns the size of the serialized and encoded form of the message in bytes.

Specified by:
getByteLength in interface WireFormatMessage
Returns:
The size of the serialized and encoded message in bytes.

getContentEncoding

public MimeMediaType getContentEncoding()
Returns the encoding used for this content. May be null for unencoded (raw) content.

Specified by:
getContentEncoding in interface WireFormatMessage
Returns:
The encoding used for this message.

JXSE