formatter
Class Session

java.lang.Object
  extended by formatter.Session

public class Session
extends java.lang.Object

This is one chat. This is the representation of chat Notifications and Messages Which make up the time between when a chat window was opened and when one was closed. For some formats this is one file, for others it is not.

This class doubles as its own factory. It allows only one Session at a time. To create a new Session, call makeSession(String,String,Date). Once you're done, call closeSession() before trying to start another session. At any time, you can call getSession() to access the active Session.

I have decided to call the person that created the log, i.e. the person that saved this log "me" and the person that is talking with "me", "you". Therefore, getMySN() returns the name of the creator of this log, and getYourSN() returns the name of the person talking with "me" -- the other guy.


Method Summary
 void add(Event e)
          Appends the passed Event to the list containted in this Session.
 void append(java.lang.String msg)
          Appends the contents of the String object to the end of the last Message.
static void closeSession()
          Closes the current Session, allowing a new one to be made.
 Date getDate()
          Returns the Date this Session was made.
 java.lang.String getMySN()
          Returns the SN of the person that saved this log.
static Session getSession()
          Gets the most recently created Session.
 java.lang.String getYourSN()
          Returns the name of the SN talking with "me".
 java.util.Iterator<Event> iterator()
          Returns an Iterator of all the Events stored in this Session.
static Session makeSession(java.lang.String mySN, java.lang.String yourSN, Date date)
          Creates and sets active a new Session.
static boolean sessionIsActive()
          Determines if there is a Session already active.
 void setDate(Date date)
          Sets the date to a new value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makeSession

public static Session makeSession(java.lang.String mySN,
                                  java.lang.String yourSN,
                                  Date date)
Creates and sets active a new Session. This method is the only way to create a new Session object.

Parameters:
mySN - The name of the SN that is "me".
yourSN - The name of the SN that I'm speaking with.
date - The date this conversation took place.
Returns:
The newly created Session.

getSession

public static Session getSession()
Gets the most recently created Session.

Returns:
The most recently created Session.

closeSession

public static void closeSession()
Closes the current Session, allowing a new one to be made.


sessionIsActive

public static boolean sessionIsActive()
Determines if there is a Session already active.

Returns:
true if there is an already active Session false otherwise.

append

public void append(java.lang.String msg)
Appends the contents of the String object to the end of the last Message. Assumes the last Event passed to add(Event) was of type Message. If the last Event was not of type Message then an exception is thrown.

Throws:
java.lang.IllegalArgumentException - when the last Event object was not of type Message.

add

public void add(Event e)
Appends the passed Event to the list containted in this Session. It is assumed that these Events are passed chronologically.

Parameters:
e - The Event to add.

getMySN

public java.lang.String getMySN()
Returns the SN of the person that saved this log.

Returns:
The SN of the person that saved this log.

getYourSN

public java.lang.String getYourSN()
Returns the name of the SN talking with "me".

Returns:
The name of the SN talking with "me".

getDate

public Date getDate()
Returns the Date this Session was made.

Returns:
The Date this Session was made.

setDate

public void setDate(Date date)
Sets the date to a new value. This is needed when a conversation starts one day, but ends another. In this case it is desirable to list the conversation as having occured on the day the conversation ended, as opposed to the day it was begun.

Parameters:
date - The new Date to change to.
Throws:
java.lang.IllegalArgumentException - if the passed date occurs before the date already registered to the session.

iterator

public java.util.Iterator<Event> iterator()
Returns an Iterator of all the Events stored in this Session.

Returns:
The Events comprising this Session.