FileDocCategorySizeDatePackage
ShortMessage.javaAPI DocWireless Messaging API2063Mon Nov 10 21:05:12 GMT 2003wmafw

ShortMessage.java

/*
 *  ShortMessage.java
 *
 *  Author: C. Enrique Ortiz, October 2003
 *
 *  Companion source code to "Advanced Messaging Coding with JSR 120".
 *
 *  Based on original work by C. Enrique Ortiz.
 *
 *  COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2003.
 *  The software is the copyrighted work of Sony Ericsson Mobile Communications AB.
 *  The use of the software is subject to the terms of the end-user license
 *  agreement which accompanies or is included with the software. The software is
 *  provided "as is" and Sony Ericsson specifically disclaim any warranty or
 *  condition whatsoever regarding merchantability or fitness for a specific
 *  purpose, title or non-infringement. No warranty of any kind is made in
 *  relation to the condition, suitability, availability, accuracy, reliability,
 *  merchantability and/or non-infringement of the software provided herein.
 */

package wmafw;

import java.util.Calendar;
import java.util.Date;

/**
 * Represents a short message, text and binary.
 */
public class ShortMessage {

    protected String id;
    protected String from;
    protected String text;
    protected byte[] data;

    /**
     * Constructor. Creates an Email Message.
     * @param from is the message sender.
     * @param text is the text message.
     * @param data is the binary message.
     */
    public ShortMessage(String from, String text, byte[] data) {
        this.from = from;
        this.text = text;
        this.data = data;
        //  Calculate unique ID
        Calendar cal = Calendar.getInstance();
        Date date = cal.getTime();
        id = from+date.getTime();
    }

    /**
     * Returns the text part of this message, if one.
     * @return the text message.
     */
    public String getMessageText() {
        return text;
    }

    /**
     * Returns the binary part of this message, if one.
     * @return the binary message.
     */
    public byte[] getMessageData() {
        return data;
    }
}