PaP
Class UserProfileBase

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

public class UserProfileBase
extends java.lang.Object

A UserProfileBase contains a hashtable where UserProfiles of all the users belonging to a Director is added. The class contains methods for adding, retrieving, updating and removing UserProfiles from the base. It also has a method that returns a list of all the UserProfiles 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 userprofiles are put.
 
Constructor Summary
UserProfileBase()
          Creates a new UserProfileBase.
 
Method Summary
 void addUserProfile(UserProfile up)
          Adds the specified UserProfile to the UserProfileBase.
 java.util.ArrayList getAllUserProfiles()
          Returns an ArrayList with all the UserProfile-objects in the UserProfileBase added to it.
 UserProfile getUserProfile(java.lang.String username)
          Returns the UserProfile with the specified username.
 Item listUserProfiles()
          Returns all the UserProfiles in the UserProfileBase in the form of an Item.
 void removeUserProfile(java.lang.String username)
          Removes the UserProfile with the specified username from the UserProfileBase.
 void setUserLoggedIn(java.lang.String username, boolean loggedIn)
          Sets the userLoggedIn property of the UserProfile of the user with the specified username to the specified boolean value.
 void updateUserProfile(UserProfile up)
          Updates the UserProfile with the specified UserProfile's username by removing the current UserProfile and adding itself to the base with the same username.
 boolean userProfileExists(java.lang.String username)
          Searches through the UserProfileBase to determine if there exists a UserProfile with a username equal to the specified 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 userprofiles are put.
Constructor Detail

UserProfileBase

public UserProfileBase()
Creates a new UserProfileBase.
Method Detail

addUserProfile

public void addUserProfile(UserProfile up)
Adds the specified UserProfile to the UserProfileBase. If the userprofile is null or if a UserProfile with the same username already exists in the UserProfileBase, nothing is done.
Parameters:
up - The UserProfile to be added.

getAllUserProfiles

public java.util.ArrayList getAllUserProfiles()
Returns an ArrayList with all the UserProfile-objects in the UserProfileBase added to it.
Returns:
All the UserProfiles in the UserProfileBase.

getUserProfile

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

listUserProfiles

public Item listUserProfiles()
Returns all the UserProfiles in the UserProfileBase in the form of an Item. The Item contains an array of Items that each contains the fields and values of one of the userprofiles in the base.
Returns:
All the UserProfiles in the base in the form of an Item.

setUserLoggedIn

public void setUserLoggedIn(java.lang.String username,
                            boolean loggedIn)
Sets the userLoggedIn property of the UserProfile of the user with the specified username to the specified boolean value.
Parameters:
username - The username of the user who either logged in or out.
loggedIn - The new value of the loggedIn property.

removeUserProfile

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

updateUserProfile

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

userProfileExists

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