PaP
Class SessionBase

java.lang.Object
  |
  +--PaP.SessionBase

public class SessionBase
extends java.lang.Object

A SessionBase contains a hashtable where Sessions for the users belonging to a Director is added. The class contains methods for adding, retrieving updating and removing Sessions from the base. It also has a method that returns a list of all the Sessions in the base in the form of an Item.

Version:
1.0 - 12.05.02
Author:
Lars Erik Liljebäck

Field Summary
private  java.util.Hashtable ht
          A hashtable where all the Sessions are put.
 
Constructor Summary
SessionBase()
          Creates a new SessionBase.
 
Method Summary
 void addSession(Session session)
          Adds the specified Session to the SessionBase.
 java.util.ArrayList getAllSessions()
          Returns an ArrayList with all the Session-objects in the SessionBase added to it.
 Session getSession(java.lang.String username)
          Returns the Session with the specified username.
 Item listSessions()
          Returns all the Sessions in the SessionBase in the form of an Item.
 void removeSession(java.lang.String username)
          Removes the Session with the specified username from the SessionBase.
 boolean sessionExists(java.lang.String username)
          Searches through the SessionBase to determine if there exists a Session with a username equal to the specified username.
 void updateSession(Session session)
          Updates the Session with the specified Session's username by removing the current Session and adding itself to the base with the same username.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

ht

private java.util.Hashtable ht
A hashtable where all the Sessions are put.
Constructor Detail

SessionBase

public SessionBase()
Creates a new SessionBase.
Method Detail

addSession

public void addSession(Session session)
Adds the specified Session to the SessionBase. If the session is null or if a Session with the same username already exists in the SessionBase, nothing is done.
Parameters:
session - The Session to be added.

getSession

public Session getSession(java.lang.String username)
Returns the Session with the specified username. If the username is null or if the Session does not exist in the SessionBase it returns null.
Parameters:
username - The username of the Session to be returned.
Returns:
Returns the Session if found in the base, else returns null.

getAllSessions

public java.util.ArrayList getAllSessions()
Returns an ArrayList with all the Session-objects in the SessionBase added to it.
Returns:
All the Session-objects in the SessionBase.

listSessions

public Item listSessions()
Returns all the Sessions in the SessionBase in the form of an Item. The Item contains an array of Items that each contains the fields and values of one of the Sessions in the base.
Returns:
All the Sessions in the base in the form of an Item.

removeSession

public void removeSession(java.lang.String username)
Removes the Session with the specified username from the SessionBase. If the Session is not found, nothing is removed.
Parameters:
username - The username specifying the Session to be removed.

sessionExists

public boolean sessionExists(java.lang.String username)
Searches through the SessionBase to determine if there exists a Session with a username equal to the specified username.
Parameters:
username - The username of the Session to search for.
Returns:
Returns true if the Session already exists, false otherwise.

updateSession

public void updateSession(Session session)
Updates the Session with the specified Session's username by removing the current Session and adding itself to the base with the same username.
Parameters:
session - The Session to be added to update an existing Session.