[sip-comm-cvs] CVS update: /sip-communicator/src/net/java/sip/communicator/impl/protocol/sip/MessageSipImpl.java

emcho at dev.java.net emcho at dev.java.net
Wed May 16 16:51:13 CEST 2007


User: emcho   
Date: 2007-05-16 14:51:13+0000
Log:
 Adding Ben's implementation of instant messaging for SIP (by Benoit Pradelle)
 
 added an implementation of the Message interface for SIP

File Changes:

Directory: /sip-communicator/src/net/java/sip/communicator/impl/protocol/sip/
=============================================================================

File [added]: MessageSipImpl.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/protocol/sip/MessageSipImpl.java?rev=1.1&content-type=text/vnd.viewcvs-markup
Added lines: 145
----------------
/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.impl.protocol.sip;

import net.java.sip.communicator.service.protocol.*;

/**
 * A simple implementation of the <tt>Message</tt> interface for SIP/SIMPLE.
 *
 * @author Benoit Pradelle
 */
public class MessageSipImpl
    implements Message
{
    /**
     * The content of this message.
     */
    private String textContent = null;

    /**
     * The content type of text. Right now only text/plain is supported.
     */
    private String contentType = null;

    /**
     * The encoding under which the contennt of this message is encoded.
     */
    private String contentEncoding = null;

    /**
     * An String uniquely identifying this Message.
     */
    private String messageUID = null;

    /**
     * The subject of the message if any (may remain null).
     */
    private String subject = null;

    /**
     * Creates an instance of this Message with the specified parameters.
     *
     * @param content the text content of the message.
     * @param contentType a MIME string indicating the content type of the
     * <tt>content</tt> String.
     * @param contentEncoding a MIME String indicating the content encoding of
     * the <tt>content</tt> String.
     * @param subject the subject of the message or null for empty.
     */
    public MessageSipImpl(String content,
                          String contentType,
                          String contentEncoding,
                          String subject)
    {
        this.textContent = content;
        this.contentType = contentType;
        this.contentEncoding = contentEncoding;
        this.subject = subject;

        //generate the uid
        this.messageUID = String.valueOf( System.currentTimeMillis())
                          + String.valueOf(hashCode());

    }

    /**
     * Returns the content of this message if representable in text form or
     * null if this message does not contain text data.
     *
     * @return a String containing the content of this message or null if
     *   the message does not contain data representable in text form.
     */
    public String getContent()
    {
        return this.textContent;
    }

    /**
     * Returns the MIME type for the message content.
     *
     * @return a String containing the mime type of the message contant.
     */
    public String getContentType()
    {
        return this.contentType;
    }

    /**
     * Returns the MIME content encoding of this message.
     *
     * @return a String indicating the MIME encoding of this message.
     */
    public String getEncoding()
    {
        return this.contentEncoding;
    }

    /**
     * Returns a unique identifier of this message.
     *
     * @return a String that uniquely represents this message in the scope
     *   of this protocol.
     */
    public String getMessageUID()
    {
        return this.messageUID;
    }

    /**
     * Get the raw/binary content of an instant message.
     *
     * @return a byte[] array containing message bytes.
     */
    public byte[] getRawData()
    {
        return getContent().getBytes();
    }

    /**
     * Returns the size of the content stored in this message.
     *
     * @return an int indicating the number of bytes that this message
     *   contains.
     */
    public int getSize()
    {
        return getContent().length();
    }

    /**
     * Returns the subject of this message or null if the message contains no
     * subject.
     *
     * @return the subject of this message or null if the message contains
     *   no subject.
     */
    public String getSubject()
    {
        return this.subject;
    }
}




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: cvs-help at sip-communicator.dev.java.net





More information about the commits mailing list