org.starhope.appius.messaging
Class MailMessage

java.lang.Object
  extended by org.starhope.appius.sql.SQLPeerDatum
      extended by org.starhope.appius.messaging.MailMessage
All Implemented Interfaces:
Serializable, Comparable<Object>, GameWorldMessage

public class MailMessage
extends SQLPeerDatum
implements GameWorldMessage

Author:
brpocock@star-hope.org, twheys@gmail.com
See Also:
Serialized Form

Nested Class Summary
static class MailMessage.MessageFlag
          Flags for messages
 
Field Summary
private  String attachmentURL
          URL of an attachment (XXX WHAT?)
private  String body
          body of the message
private static AbstractCensor censor
          The censoring object used to filter in-game mail messages
private  HashMap<Integer,MailMessage.MessageFlag> flags
          Flags set on this message, stored by key of the userID who created the flag and the value of the flag names.
private  int fromID
          sender user ID
private  String fromName
          sender name
private  int id
          message unique ID
private  int inReplyTo
          If this message is in reply to another, then this is the message ID of the parent message.
private  boolean isDeleted
          If true, the user (or a moderator) has deleted this message
private  boolean isWallPost
          If true, this message is a Wall Post on TootsBook.
private  Timestamp read
          WRITEME: document this field (brpocock@star-hope.org, Nov 19, 2009) read (MailMessage)
private  Timestamp sent
          WRITEME: document this field (brpocock@star-hope.org, Nov 19, 2009) sent (MailMessage)
private static long serialVersionUID
          Java serialisation version ID
private  String subject
          WRITEME: document this field (brpocock@star-hope.org, Nov 19, 2009) subject (MailMessage)
private  int toID
          WRITEME: document this field (brpocock@star-hope.org, Nov 19, 2009) toID (MailMessage)
private  String toName
          The name of the message's recipient.
 
Constructor Summary
MailMessage()
           
MailMessage(ResultSet row)
          Instantiate a mail message from a database row
 
Method Summary
 void addFlag(AbstractUser u, MailMessage.MessageFlag flag)
          Add a flag to this message.
 void addFlag(int fromUserID, MailMessage.MessageFlag flag)
          Add a flag to this message.
 void delete()
          Delete this message (making it invisible in the inbox or wall)
 void flush()
           
 String getAttachmentURL()
          WRITEME
 String getBody()
          WRITEME
 GameWorldMessage getByID(int idToGet)
           
protected  String getCacheUniqueID()
           
private  void getFlags()
           twheys@gmail.com Apr 6, 2010
 int getFromID()
           
 String getFromName()
           
 int getID()
          Returns the ID of this post.
 int getInReplyTo()
           
 Vector<GameWorldMessage> getMessagesFrom(PreparedStatement st)
          Fetch an ordered set of messages based upon a prepared statement
 Timestamp getRead()
           
 Timestamp getSent()
           
 String getSubject()
           
 int getToID()
           
 String getToName()
           
private  void insert()
           
 boolean isDeleted()
           
 boolean isWallPost()
           
 void markAsRead()
           
 boolean send()
           
protected  void set(ResultSet rs)
           
 void setAttachmentURL(String newAttachmentURL)
          WRITEME
 boolean setBody(String newBody)
           
 void setFrom(GeneralUser sender)
          Set the sender of this message
 void setFromID(int fromID1)
           
 void setInReplyTo(int parentMessageID)
           
 void setRead(Timestamp timeRead)
           
 void setSent(Timestamp sent1)
           
 void setSubject(String subject1)
           
 void setTo(GeneralUser recipient)
          Set the recipient of this message
 void setToID(int toID1)
          Set the recipient of this message
 void setWallPost(boolean wallPostQ)
          // * @param wallPostQ WRITEME
 org.json.JSONObject toJSON()
          This is the default SQLPeerDatum implementation of toJSON.
 org.json.JSONObject toJSON(boolean inMailbox)
          Get the public representation of this message in JSON form
 void undelete()
           Undeletes a mail message and places it in the Inbox.
 
Methods inherited from class org.starhope.appius.sql.SQLPeerDatum
changed, compareTo, findInCache, get, saveInCache, set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

censor

private static final AbstractCensor censor
The censoring object used to filter in-game mail messages


serialVersionUID

private static final long serialVersionUID
Java serialisation version ID

See Also:
Constant Field Values

attachmentURL

private String attachmentURL
URL of an attachment (XXX WHAT?)


body

private String body
body of the message


flags

private final HashMap<Integer,MailMessage.MessageFlag> flags
Flags set on this message, stored by key of the userID who created the flag and the value of the flag names. See MySQL table messageFlags.


fromID

private int fromID
sender user ID


fromName

private String fromName
sender name


id

private int id
message unique ID


inReplyTo

private int inReplyTo
If this message is in reply to another, then this is the message ID of the parent message.


isDeleted

private boolean isDeleted
If true, the user (or a moderator) has deleted this message


isWallPost

private boolean isWallPost
If true, this message is a Wall Post on TootsBook.


read

private Timestamp read
WRITEME: document this field (brpocock@star-hope.org, Nov 19, 2009) read (MailMessage)


sent

private Timestamp sent
WRITEME: document this field (brpocock@star-hope.org, Nov 19, 2009) sent (MailMessage)


subject

private String subject
WRITEME: document this field (brpocock@star-hope.org, Nov 19, 2009) subject (MailMessage)


toID

private int toID
WRITEME: document this field (brpocock@star-hope.org, Nov 19, 2009) toID (MailMessage)


toName

private String toName
The name of the message's recipient.

Constructor Detail

MailMessage

public MailMessage()

MailMessage

public MailMessage(ResultSet row)
            throws SQLException
Instantiate a mail message from a database row

Parameters:
row - the database row to be interpreted
Throws:
SQLException - if the dataset can't be interpreted
Method Detail

addFlag

public void addFlag(AbstractUser u,
                    MailMessage.MessageFlag flag)
Add a flag to this message.

Parameters:
u - The user adding the flag
flag - the flag to be added

addFlag

public void addFlag(int fromUserID,
                    MailMessage.MessageFlag flag)
Add a flag to this message.

Parameters:
fromUserID - The user ID for the user adding the flag
flag - the flag to be added

delete

public void delete()
Description copied from interface: GameWorldMessage
Delete this message (making it invisible in the inbox or wall)

Specified by:
delete in interface GameWorldMessage
See Also:
GameWorldMessage.delete()

flush

public void flush()
Specified by:
flush in interface GameWorldMessage
Specified by:
flush in class SQLPeerDatum
See Also:
GameWorldMessage.flush()

getAttachmentURL

public String getAttachmentURL()
WRITEME

Specified by:
getAttachmentURL in interface GameWorldMessage
Returns:
the attachmentURL

getBody

public String getBody()
WRITEME

Specified by:
getBody in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.getBody()

getByID

public GameWorldMessage getByID(int idToGet)
                         throws NotFoundException
Specified by:
getByID in interface GameWorldMessage
Parameters:
idToGet - WRITEME
Returns:
WRITEME
Throws:
NotFoundException - WRITEME

getCacheUniqueID

protected String getCacheUniqueID()
Specified by:
getCacheUniqueID in class SQLPeerDatum
Returns:
The local (Stringified) version of an unique ID; usually the database ID column
See Also:
SQLPeerDatum.getCacheUniqueID()

getFlags

private void getFlags()
 twheys@gmail.com Apr 6, 2010
 
TO getFlags WRITEME...


getFromID

public int getFromID()
Specified by:
getFromID in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.getFromID()

getFromName

public String getFromName()
Specified by:
getFromName in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.getFromName()

getID

public int getID()
Description copied from interface: GameWorldMessage
Returns the ID of this post.

Specified by:
getID in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.getID()

getInReplyTo

public int getInReplyTo()
Specified by:
getInReplyTo in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.getInReplyTo()

getMessagesFrom

public Vector<GameWorldMessage> getMessagesFrom(PreparedStatement st)
                                         throws SQLException
Fetch an ordered set of messages based upon a prepared statement

Specified by:
getMessagesFrom in interface GameWorldMessage
Parameters:
st - A prepared statement ready to be executed
Returns:
the set of messages returned by the given prepared statement
Throws:
SQLException - if there's a problem getting results

getRead

public Timestamp getRead()
Specified by:
getRead in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.getRead()

getSent

public Timestamp getSent()
Specified by:
getSent in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.getSent()

getSubject

public String getSubject()
Specified by:
getSubject in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.getSubject()

getToID

public int getToID()
Specified by:
getToID in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.getToID()

getToName

public String getToName()
Specified by:
getToName in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.getToName()

insert

private void insert()

isDeleted

public boolean isDeleted()
Specified by:
isDeleted in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.isDeleted()

isWallPost

public boolean isWallPost()
Specified by:
isWallPost in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.isWallPost()

markAsRead

public void markAsRead()
Specified by:
markAsRead in interface GameWorldMessage
See Also:
GameWorldMessage.markAsRead()

send

public boolean send()
Specified by:
send in interface GameWorldMessage
Returns:
WRITEME
See Also:
GameWorldMessage.send()

set

protected void set(ResultSet rs)
            throws SQLException
Specified by:
set in class SQLPeerDatum
Parameters:
rs - The result of an SQL query, with the cursor already pointed at the row describing this specific instance of the object.
Throws:
SQLException - if the database fails somehow
See Also:
SQLPeerDatum.set(java.sql.ResultSet)

setAttachmentURL

public void setAttachmentURL(String newAttachmentURL)
WRITEME

Specified by:
setAttachmentURL in interface GameWorldMessage
Parameters:
newAttachmentURL - the attachmentURL to set

setBody

public boolean setBody(String newBody)
Specified by:
setBody in interface GameWorldMessage
Parameters:
newBody - The new body content for the message
Returns:
If the body does not pass the filters, return false
See Also:
GameWorldMessage.setBody(java.lang.String)

setFrom

public void setFrom(GeneralUser sender)
Description copied from interface: GameWorldMessage
Set the sender of this message

Specified by:
setFrom in interface GameWorldMessage
Parameters:
sender - the sender (FROM: field) for the message
See Also:
GameWorldMessage.setFrom(GeneralUser)

setFromID

public void setFromID(int fromID1)
Specified by:
setFromID in interface GameWorldMessage
Parameters:
fromID1 - the sender's user ID
See Also:
GameWorldMessage.setFromID(int)

setInReplyTo

public void setInReplyTo(int parentMessageID)
Specified by:
setInReplyTo in interface GameWorldMessage
Parameters:
parentMessageID - the message ID of the parent message, to which this one is a reply
See Also:
GameWorldMessage.setInReplyTo(int)

setRead

public void setRead(Timestamp timeRead)
Specified by:
setRead in interface GameWorldMessage
Parameters:
timeRead - WRITEME
See Also:
GameWorldMessage.setRead(java.sql.Timestamp)

setSent

public void setSent(Timestamp sent1)
Specified by:
setSent in interface GameWorldMessage
Parameters:
sent1 - WRITEME
See Also:
GameWorldMessage.setSent(java.sql.Timestamp)

setSubject

public void setSubject(String subject1)
Specified by:
setSubject in interface GameWorldMessage
Parameters:
subject1 - The Subject of the message
See Also:
GameWorldMessage.setSubject(java.lang.String)

setTo

public void setTo(GeneralUser recipient)
Description copied from interface: GameWorldMessage
Set the recipient of this message

Specified by:
setTo in interface GameWorldMessage
Parameters:
recipient - WRITEME
See Also:
GameWorldMessage#setTo(org.starhope.appius.user.User)

setToID

public void setToID(int toID1)
Description copied from interface: GameWorldMessage
Set the recipient of this message

Specified by:
setToID in interface GameWorldMessage
Parameters:
toID1 - WRITEME
See Also:
GameWorldMessage.setToID(int)

setWallPost

public void setWallPost(boolean wallPostQ)
// * @param wallPostQ WRITEME

Specified by:
setWallPost in interface GameWorldMessage
Parameters:
wallPostQ - the isWallPost to set
See Also:
GameWorldMessage.setWallPost(boolean)

toJSON

public org.json.JSONObject toJSON()
Description copied from class: SQLPeerDatum
This is the default SQLPeerDatum implementation of toJSON. This uses Java reflection and “bean-type” methods to extract the contents of an object and create a JSON field.

Specified by:
toJSON in interface GameWorldMessage
Overrides:
toJSON in class SQLPeerDatum
Returns:
This object's data, serialized into JSON form.
See Also:
GameWorldMessage.toJSON()

toJSON

public org.json.JSONObject toJSON(boolean inMailbox)
Description copied from interface: GameWorldMessage
Get the public representation of this message in JSON form

Specified by:
toJSON in interface GameWorldMessage
Parameters:
inMailbox - WRITEME
Returns:
WRITEME
See Also:
GameWorldMessage.toJSON(boolean)

undelete

public void undelete()
Description copied from interface: GameWorldMessage

Undeletes a mail message and places it in the Inbox.

Note that this will not undelete a Wall message correctly, as it will go into the Inbox regardless.

Specified by:
undelete in interface GameWorldMessage
See Also:
GameWorldMessage.undelete()