Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.service.protocol
Class AbstractMessage

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AbstractMessage
All Implemented Interfaces:
Message
Direct Known Subclasses:
MessageDictImpl, MessageGibberishImpl, MessageIcqImpl, MessageIrcImpl, MessageJabberImpl, MessageMsnImpl, MessageRssImpl, MessageSipImpl, MessageSSHImpl, MessageYahooImpl, MessageZeroconfImpl, MockMessage

public abstract class AbstractMessage
extends Object
implements Message

Represents a default implementation of Message in order to make it easier for implementers to provide complete solutions while focusing on implementation-specific details.

Author:
Lubomir Marinov

Constructor Summary
protected AbstractMessage(String content, String contentType, String encoding, String subject)
           
protected AbstractMessage(String content, String contentType, String encoding, String subject, String messageUID)
           
 
Method Summary
protected  String createMessageUID()
           
 String getContent()
          Returns the content of this message if representable in text form or null if this message does not contain text data.
 String getContentType()
          Returns the MIME type for the message content.
 String getEncoding()
          Returns the MIME content encoding of this message.
 String getMessageUID()
          Returns a unique identifier of this message.
 byte[] getRawData()
          Get the raw/binary content of an instant message.
 int getSize()
          Returns the size of the content stored in this message.
 String getSubject()
          Returns the subject of this message or null if the message contains no subject.
protected  void setContent(String content)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMessage

protected AbstractMessage(String content,
                          String contentType,
                          String encoding,
                          String subject)

AbstractMessage

protected AbstractMessage(String content,
                          String contentType,
                          String encoding,
                          String subject,
                          String messageUID)
Method Detail

createMessageUID

protected String createMessageUID()

getContent

public final String getContent()
Returns the content of this message if representable in text form or null if this message does not contain text data.

The implementation is final because it caches the raw data of the content.

Specified by:
getContent in interface Message
Returns:
a String containing the content of this message or null if the message does not contain data representable in text form.

getContentType

public String getContentType()
Description copied from interface: Message
Returns the MIME type for the message content.

Specified by:
getContentType in interface Message
Returns:
a String containing the mime type of the message contant.

getEncoding

public final String getEncoding()
Returns the MIME content encoding of this message.

The implementation is final because of the presumption it can set the encoding.

Specified by:
getEncoding in interface Message
Returns:
a String indicating the MIME encoding of this message.

getMessageUID

public String getMessageUID()
Description copied from interface: Message
Returns a unique identifier of this message.

Specified by:
getMessageUID in interface Message
Returns:
a String that uniquely represents this message in the scope of this protocol.

getRawData

public byte[] getRawData()
Description copied from interface: Message
Get the raw/binary content of an instant message.

Specified by:
getRawData in interface Message
Returns:
a byte[] array containing message bytes.

getSize

public int getSize()
Description copied from interface: Message
Returns the size of the content stored in this message.

Specified by:
getSize in interface Message
Returns:
an int indicating the number of bytes that this message contains.

getSubject

public String getSubject()
Description copied from interface: Message
Returns the subject of this message or null if the message contains no subject.

Specified by:
getSubject in interface Message
Returns:
the subject of this message or null if the message contains no subject.

setContent

protected void setContent(String content)

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.