edu.harvard.deas.hyperenc.gui
Class GuiMessage

java.lang.Object
  extended by edu.harvard.deas.hyperenc.gui.GuiMessage
All Implemented Interfaces:
Serializable

public class GuiMessage
extends Object
implements Serializable

A message with some extra fields for user interaction purposes. For example, a GuiMessage may have different states, as e-mails do in an e-mail client (read versus unread, and so on).

GuiMessages are immutable.

See Also:
Serialized Form

Constructor Summary
GuiMessage(HyperMessage m, ReadStatus read)
          Construct a new GuiMessage around the given HyperMessage.
 
Method Summary
 boolean equals(Object o)
          Compares this GuiMessage to the specified object.
 String getContent()
          Get the content of this GuiMessage.
 Date getDate()
          Get the date of this GuiMessage.
 HyperMessage getHyperMessage()
          Get the HyperMessage underlying this GuiMessage.
 int getID()
          Get the unique ID of this GuiMessage.
 Contact getRecipient()
          Get the recipient of this GuiMessage.
 Contact getSender()
          Get the sender of this GuiMessage.
 String getSubject()
          Get the subject of this GuiMessage.
 int hashCode()
          Returns the hashCode() of the contained HyperMessage.
 boolean isEncrypted()
          Whether this message is encrypted.
 ReadStatus isRead()
          Whether this message has been read or not.
static GuiMessage markRead(GuiMessage gm)
          Returns a message whose fields are the same as those of gm, except the message is marked as read.
static GuiMessage markUnread(GuiMessage gm)
          Returns a message whose fields are the same as those of gm, except the message is marked as unread.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GuiMessage

public GuiMessage(HyperMessage m,
                  ReadStatus read)
Construct a new GuiMessage around the given HyperMessage.

Method Detail

getHyperMessage

public HyperMessage getHyperMessage()
Get the HyperMessage underlying this GuiMessage.

Returns:
the HyperMessage underlying this GuiMessage

getID

public int getID()
Get the unique ID of this GuiMessage. This is identical to the ID of the underlying HyperMessage.

Returns:
the ID of this message

getSubject

public String getSubject()
Get the subject of this GuiMessage. This is identical to the subject of the underlying HyperMessage.

Returns:
the subject of this message

getDate

public Date getDate()
Get the date of this GuiMessage. This is identical to the date of the underlying HyperMessage.

Returns:
the date of this message

getSender

public Contact getSender()
Get the sender of this GuiMessage. This is identical to the sender of the underlying HyperMessage.

Returns:
the sender of this message

getRecipient

public Contact getRecipient()
Get the recipient of this GuiMessage. This is identical to the recipient of the underlying HyperMessage.

Returns:
the recipient of this message

getContent

public String getContent()
Get the content of this GuiMessage. This is identical to the content of the underlying HyperMessage.

Returns:
the content of this message

isRead

public ReadStatus isRead()
Whether this message has been read or not. Used to indicate whether or not the message has been previously viewed by the user.

Returns:
the read status of this message

markRead

public static GuiMessage markRead(GuiMessage gm)
Returns a message whose fields are the same as those of gm, except the message is marked as read. After this method returns, isRead() returns ReadStatus.READ.

If gm is already marked as read, it is unspecified whether the returned GuiMessage is the same object as gm.

Parameters:
gm - a message
Returns:
a GuiMessage identical to gm except that it is marked as read

markUnread

public static GuiMessage markUnread(GuiMessage gm)
Returns a message whose fields are the same as those of gm, except the message is marked as unread. After this method returns, isRead() returns ReadStatus.UNREAD.

If gm is already marked as unread, it is unspecified whether the returned GuiMessage is the same object as gm.

Parameters:
gm - a message
Returns:
a GuiMessage identical to gm except that it is marked as unread

isEncrypted

public boolean isEncrypted()
Whether this message is encrypted.

Returns:
true if the message content is encrypted, false if not

equals

public boolean equals(Object o)
Compares this GuiMessage to the specified object. The result is true if and only if the argument is not null and is a GuiMessage object whose HyperMessage is equal to this GuiMessage's HyperMessage. (The ReadStatus field of GuiMessage is ignored in the equality comparison.)

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns the hashCode() of the contained HyperMessage.

Overrides:
hashCode in class Object