FileDocCategorySizeDatePackage
Message.javaAPI DocAndroid 1.5 API4196Wed May 06 22:42:46 BST 2009com.android.im.engine

Message

public class Message extends Object implements android.os.Parcelable
Represents an instant message send between users.

Fields Summary
private String
mId
private Address
mFrom
private Address
mTo
private String
mBody
private Date
mDate
public static final Parcelable.Creator
CREATOR
Constructors Summary
public Message(String msg)

param
msg
throws
NullPointerException if msg is null.

        if (msg == null) {
            throw new NullPointerException("null msg");
        }
        mBody = msg;
    
public Message(android.os.Parcel source)

        mId = source.readString();
        mFrom = AddressParcelHelper.readFromParcel(source);
        mTo = AddressParcelHelper.readFromParcel(source);
        mBody = source.readString();
        long time = source.readLong();
        if(time != -1) {
            mDate = new Date(time);
        }
    
Methods Summary
public intdescribeContents()

        return 0;
    
public java.lang.StringgetBody()
Gets the body of this message.

return
the body of this message.

        return mBody;
    
public java.util.DategetDateTime()
Gets the date time associated with this message. If it's a message sent from this client, the date time is when the message is sent. If it's a message received from other users, the date time is either when the message was received or sent, depending on the underlying protocol.

return
the date time.

        if (mDate == null) {
            return null;
        }
        return new Date(mDate.getTime());
    
public AddressgetFrom()
Gets the address where the message is sent from.

return
the address where the message is sent from.

        return mFrom;
    
public java.lang.StringgetID()
Gets an identifier of this message. May be null if the underlying protocol doesn't support it.

return
the identifier of this message.

        return mId;
    
public AddressgetTo()
Gets the address where the message is sent to.

return
the address where the message is sent to.

        return mTo;
    
public voidsetBody(java.lang.String body)

        mBody = body;
    
public voidsetDateTime(java.util.Date dateTime)

        long time = dateTime.getTime();
        if (mDate == null) {
            mDate = new Date(time);
        } else {
            mDate.setTime(time);
        }
    
public voidsetFrom(Address from)

        mFrom = from;
    
public voidsetID(java.lang.String id)

        mId = id;
    
public voidsetTo(Address to)

        mTo = to;
    
public java.lang.StringtoString()

        return "From: " + mFrom.getScreenName() + " To: " + mTo.getScreenName()
                + " " + mBody;
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        dest.writeString(mId);
        AddressParcelHelper.writeToParcel(dest, mFrom);
        AddressParcelHelper.writeToParcel(dest, mTo);
        dest.writeString(mBody);
        dest.writeLong(mDate == null ? -1 : mDate.getTime());