net.sf.beep4j
Interface Message

All Known Implementing Classes:
DefaultMessage

public interface Message

Interface exposing all necessary methods a Message must have.

Author:
Simon Raess

Field Summary
static java.lang.String BASE64_TRANSFER_ENCODING
          Value for base64 transfer encoding.
static java.lang.String BINARY_TRANSFER_ENCODING
          Value for binary transfer encoding.
static java.lang.String CONTENT_TRANSFER_ENCODING
          Canonical name of the Content-Transfer-Encoding header.
static java.lang.String CONTENT_TYPE
          Canonical name of the Content-Type header.
 
Method Summary
 java.nio.ByteBuffer asByteBuffer()
          Writes the complete message (headers and content) into a ByteBuffer, which can then be used to send the message over the network.
 java.nio.ByteBuffer getContentBuffer()
          Gets the content as a ByteBuffer.
 java.lang.String getContentType()
          Gets the content type of the message.
 java.lang.String getHeader(java.lang.String name)
          Gets the value of the header with the given name.
 java.util.Iterator<java.lang.String> getHeaderNames()
          Gets the list of all defined header names.
 java.io.InputStream getInputStream()
          Gets an InputStream to read the content of the message.
 java.io.Reader getReader()
          Gets a Reader to read the content of the message.
 java.io.Reader getReader(java.lang.String charset)
          Gets a Reader to read the content of the message.
 

Field Detail

CONTENT_TYPE

static final java.lang.String CONTENT_TYPE
Canonical name of the Content-Type header.

See Also:
Constant Field Values

CONTENT_TRANSFER_ENCODING

static final java.lang.String CONTENT_TRANSFER_ENCODING
Canonical name of the Content-Transfer-Encoding header.

See Also:
Constant Field Values

BINARY_TRANSFER_ENCODING

static final java.lang.String BINARY_TRANSFER_ENCODING
Value for binary transfer encoding.

See Also:
Constant Field Values

BASE64_TRANSFER_ENCODING

static final java.lang.String BASE64_TRANSFER_ENCODING
Value for base64 transfer encoding.

See Also:
Constant Field Values
Method Detail

getContentType

java.lang.String getContentType()
Gets the content type of the message. The format of the content type is defined in RFC 2045. The returned value does not contain parameters.

Returns:
the content type of the message

getHeaderNames

java.util.Iterator<java.lang.String> getHeaderNames()
Gets the list of all defined header names. The content type header is not returned from this method.

Returns:
the list of header names

getHeader

java.lang.String getHeader(java.lang.String name)
Gets the value of the header with the given name. If no such header exists, null is returned. The content type header is not returned from this method.

Parameters:
name - the name of the header
Returns:
the value of the header

getInputStream

java.io.InputStream getInputStream()
Gets an InputStream to read the content of the message. Use this method if you receive binary messages. Otherwise we recommend using the getReader() method, which returns a fully configured Reader.

Returns:
the raw InputStream

getReader

java.io.Reader getReader()
Gets a Reader to read the content of the message. Use this method to process textual messages. The reader is fully configured, e.g. the correct charset is used to decode the binary content.

Returns:
a fully configured Reader

getReader

java.io.Reader getReader(java.lang.String charset)
Gets a Reader to read the content of the message. Use this method if the charset has not been specified as part of the content-type and there is no default charset for the content type.

Parameters:
charset - the name of the charset
Returns:
the fully configured Reader

getContentBuffer

java.nio.ByteBuffer getContentBuffer()
Gets the content as a ByteBuffer.

Returns:
the ByteBuffer of the content

asByteBuffer

java.nio.ByteBuffer asByteBuffer()
Writes the complete message (headers and content) into a ByteBuffer, which can then be used to send the message over the network.

Returns:
the Message written into a ByteBuffer


Copyright © 2007 null. All Rights Reserved.