JXTA

net.jxta.document
Class BinaryDocument

java.lang.Object
  extended by net.jxta.document.BinaryDocument
All Implemented Interfaces:
Document, DocumentStreamIO

public class BinaryDocument
extends Object
implements Document

This class is an implementation of the Document interface. It is perhaps the simplest implementation of the Document interface possible.


Constructor Summary
BinaryDocument(byte[] someBytes)
          Creates new BinaryDocument from a byte array.
BinaryDocument(byte[] someBytes, MimeMediaType type)
          Creates new BinaryDocument from a byte array.
 
Method Summary
 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.
static MimeMediaType[] getSupportedMimeTypes()
          Returns the MIME Media types supported by this this Document per IETF RFC 2046 MIME : Media Types.
 void sendToStream(OutputStream stream)
          Send the contents of this Document to the specified stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryDocument

public BinaryDocument(byte[] someBytes)
Creates new BinaryDocument from a byte array. The data in the array is not copied. If you intend to modify the array after creating a document then you should pass a copy of the data instead.

Parameters:
someBytes - Contains a byte array which will serve as our data.

BinaryDocument

public BinaryDocument(byte[] someBytes,
                      MimeMediaType type)
Creates new BinaryDocument from a byte array. The data in the array is not copied. If you intend to modify the array after creating a document then you should pass a copy of the data instead.

Parameters:
someBytes - Contains a byte array which will serve as our data.
type - The MIME media type for this document.
Method Detail

getSupportedMimeTypes

public static MimeMediaType[] getSupportedMimeTypes()
Returns the MIME Media types supported by this this Document per IETF RFC 2046 MIME : Media Types.

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

Returns:
An array of MimeMediaType objects containing the MIME Media Type 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.

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.

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.

sendToStream

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

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

JXSE