PaP
Class Session

java.lang.Object
  |
  +--PaP.Session
All Implemented Interfaces:
java.io.Serializable

public class Session
extends java.lang.Object
implements java.io.Serializable

The Session class contains the information about the Session for a user. A Session has a username that identifies who the Session belongs to as well as information about a set of actor instances that the user has plugged in. Each actor instance contains the name of a play and the version of the play that the Role the actor instance is playing belongs to. It also contains the name of the actor instance, an ArrayList of all the RoleSessions of the actor instance as well as a string defining the state of the actor instance.
The Session class contains methods for getting and setting the username, methods for adding, finding, getting and removing actor instances, as well as a method for getting the number of actor instances.

Version:
1.0 - 12.05.02
Author:
Lars Erik Liljebäck
See Also:
Serialized Form

Field Summary
private  java.util.ArrayList actorInstances
          ArrayList containing all the.
private  UserProfile profile
          The UserProfile of the user that this session belongs to.
private  java.lang.String username
          The username of the user that this session belongs to.
 
Constructor Summary
Session()
          Creates a new Session.
 
Method Summary
 void addActorInstance(java.util.ArrayList instance)
          Adds the specifed ArrayList to the main ArrayList.
private  int findActorInstance(java.lang.String play, java.lang.String version, java.lang.String actorname)
          Searches through the main ArrayLists for an ArrayList with the same play, version and actorname as the specified play, version and actorname.
 java.util.ArrayList getActorInstance(int index)
          Returns the ArrayList containing information about the actor instance at the specified index.
 java.util.ArrayList getActorInstance(java.lang.String play, java.lang.String version, java.lang.String actorname)
          Searches through the main ArrayList for an ArrayList with the same play, version and actorname as the specified play, version and actorname.
 int getActorInstanceCount()
          Returns the number of actor instances added to this Session.
 java.lang.String getUsername()
          Returns the username of the user that this Session belongs to.
 UserProfile getUserProfile()
          Return the UserProfile of the user that this Session belongs to.
 Item listActorInstances()
          Returns the information about all the actor instances in the main ArrayList in the form of an Item.
 void removeActorInstance(java.lang.String play, java.lang.String version, java.lang.String actorname)
          Searches through the main ArrayLists for an ArrayList with the same play, version and actorname as the specified play, version and actorname.
 void removeAll()
          Removes all the actorinstances from this Session-object.
 void setUsername(java.lang.String name)
          Sets the username of the user that this Session belongs to.
 void setUserProfile(UserProfile newProfile)
          Sets the UserProfile of the user that this Session belongs to.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

username

private java.lang.String username
The username of the user that this session belongs to.

profile

private UserProfile profile
The UserProfile of the user that this session belongs to.

actorInstances

private java.util.ArrayList actorInstances
ArrayList containing all the.
Constructor Detail

Session

public Session()
Creates a new Session.
Method Detail

addActorInstance

public void addActorInstance(java.util.ArrayList instance)
Adds the specifed ArrayList to the main ArrayList. It contains information about an actorinstance. The ArrayList should contain Play, Version, the Role the actor is playing, name of the actor, ArrayList with zero or more strings specifying the RoleSessions of the actor and a string with the state of the actor.
Parameters:
instance - ArrayList with information about an actor instance.

getActorInstance

public java.util.ArrayList getActorInstance(int index)
Returns the ArrayList containing information about the actor instance at the specified index.
Parameters:
index - The index specifying the actor instance to be returned.
Returns:
If the index is invalid it returns null, else it returns the ArrayList at the specified index in the main ArrayList.

getActorInstance

public java.util.ArrayList getActorInstance(java.lang.String play,
                                            java.lang.String version,
                                            java.lang.String actorname)
Searches through the main ArrayList for an ArrayList with the same play, version and actorname as the specified play, version and actorname. If a matching actor instance is found, the ArrayList is returned. If it is not found it returns null.
Parameters:
play - The name of the play that the Role the actor instance is playing belongs to.
version - The version of the play.
actorname - The name of the actor instance.
Returns:
The ArrayList containing information about the actor instance or null if it is not found.

getActorInstanceCount

public int getActorInstanceCount()
Returns the number of actor instances added to this Session.
Returns:
The size of the main ArrayList.

getUsername

public java.lang.String getUsername()
Returns the username of the user that this Session belongs to.
Returns:
The username.

getUserProfile

public UserProfile getUserProfile()
Return the UserProfile of the user that this Session belongs to.
Returns:
The UserProfile.

listActorInstances

public Item listActorInstances()
Returns the information about all the actor instances in the main ArrayList in the form of an Item. The Item contains an array of Items that each contains the fields and values of one of the actor instances.
Returns:
The information about all the actor instances in the form of an Item.

removeActorInstance

public void removeActorInstance(java.lang.String play,
                                java.lang.String version,
                                java.lang.String actorname)
Searches through the main ArrayLists for an ArrayList with the same play, version and actorname as the specified play, version and actorname. If a matching actor instance is found the ArrayList is removed from the main ArrayList. If it is not found, nothing is done.
Parameters:
play - The name of the play that the Role the actor instance is playing belongs to.
version - The version of the play.
actorname - The name of the actor instance.
Returns:
The index of the ArrayList containing information about the actor instance or -1 if it is not found.

removeAll

public void removeAll()
Removes all the actorinstances from this Session-object.

setUsername

public void setUsername(java.lang.String name)
Sets the username of the user that this Session belongs to.
Parameters:
name - The new username.

setUserProfile

public void setUserProfile(UserProfile newProfile)
Sets the UserProfile of the user that this Session belongs to.
Parameters:
newProfile - The new UserProfile.

findActorInstance

private int findActorInstance(java.lang.String play,
                              java.lang.String version,
                              java.lang.String actorname)
Searches through the main ArrayLists for an ArrayList with the same play, version and actorname as the specified play, version and actorname. If a matching actor instance is found the index of the ArrayList is returned. of the play is returned. If the application is not found it returns -1.
Parameters:
play - The name of the play that the Role the actor instance is playing belongs to.
version - The version of the play.
actorname - The name of the actor instance.
Returns:
The index of the ArrayList containing information about the actor instance or -1 if it is not found.