net.sf.beep4j.internal.message
Class DefaultMessage

java.lang.Object
  extended by net.sf.beep4j.internal.message.DefaultMessage
All Implemented Interfaces:
Message

public class DefaultMessage
extends java.lang.Object
implements Message


Field Summary
 
Fields inherited from interface net.sf.beep4j.Message
BASE64_TRANSFER_ENCODING, BINARY_TRANSFER_ENCODING, CONTENT_TRANSFER_ENCODING, CONTENT_TYPE
 
Constructor Summary
DefaultMessage(MessageHeader header, java.nio.ByteBuffer content)
           
 
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.
 boolean equals(java.lang.Object obj)
           
protected  java.lang.String getCharsetName()
           
 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 charsetName)
          Gets a Reader to read the content of the message.
protected  java.lang.String getTransferEncoding()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMessage

public DefaultMessage(MessageHeader header,
                      java.nio.ByteBuffer content)
Method Detail

getContentType

public java.lang.String getContentType()
Description copied from interface: Message
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.

Specified by:
getContentType in interface Message
Returns:
the content type of the message

getCharsetName

protected java.lang.String getCharsetName()

getTransferEncoding

protected java.lang.String getTransferEncoding()

getHeaderNames

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

Specified by:
getHeaderNames in interface Message
Returns:
the list of header names

getHeader

public java.lang.String getHeader(java.lang.String name)
Description copied from interface: Message
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.

Specified by:
getHeader in interface Message
Parameters:
name - the name of the header
Returns:
the value of the header

getInputStream

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

Specified by:
getInputStream in interface Message
Returns:
the raw InputStream

getReader

public java.io.Reader getReader()
Description copied from interface: Message
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.

Specified by:
getReader in interface Message
Returns:
a fully configured Reader

getReader

public java.io.Reader getReader(java.lang.String charsetName)
Description copied from interface: Message
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.

Specified by:
getReader in interface Message
Parameters:
charsetName - the name of the charset
Returns:
the fully configured Reader

getContentBuffer

public java.nio.ByteBuffer getContentBuffer()
Description copied from interface: Message
Gets the content as a ByteBuffer.

Specified by:
getContentBuffer in interface Message
Returns:
the ByteBuffer of the content

asByteBuffer

public java.nio.ByteBuffer asByteBuffer()
Description copied from interface: Message
Writes the complete message (headers and content) into a ByteBuffer, which can then be used to send the message over the network.

Specified by:
asByteBuffer in interface Message
Returns:
the Message written into a ByteBuffer

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


Copyright © 2007 null. All Rights Reserved.