ischool.info340.teamE
Class User

java.lang.Object
  extended by ischool.info340.teamE.User

public class User
extends java.lang.Object

Represents a user in the storage medium


Constructor Summary
User(int id, java.lang.String username, java.lang.String password, java.lang.String name, java.lang.String interests, java.util.Date dateOfBirth, UserManager manager)
          Creates a new user
User(java.lang.String username, java.lang.String password, java.lang.String name, java.lang.String interests, java.util.Date dateOfBirth, UserManager manager)
          Creates a new user and inserts it into the storage medium
 
Method Summary
 boolean exists()
           
 java.util.Date getDateOfBirth()
           
 java.util.Collection getFavoritePlaces()
           
 int getId()
           
 java.lang.String getInterest()
           
 java.lang.String getName()
           
 java.lang.String getPassword()
           
 java.lang.String getUsername()
           
 boolean remove()
          Removes this user from the storage medium and marks it as unusable so future use of this user will generate exceptions.
 boolean restore()
          Inserts this previously removed user back into the storage medium and marks it as usable again.
 boolean update(java.lang.String username, java.lang.String password, java.lang.String name, java.lang.String interests, java.util.Date dateOfBirth)
          Updates this user and its representation in the storage medium to have a new set of properties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

User

public User(int id,
            java.lang.String username,
            java.lang.String password,
            java.lang.String name,
            java.lang.String interests,
            java.util.Date dateOfBirth,
            UserManager manager)
Creates a new user

Parameters:
id - The unique identifier in the storage medium for this user
username - The login name for this user
password - The password for this user
name - The real name for this user
interests - A string containing a list of the user's interests
dateOfBirth - The date this user was born
manager - The storage medium which this user exists in
Throws:
java.lang.IllegalArgumentException - If user, password, interests dateOfBirth, or manager is null or id < 0

User

public User(java.lang.String username,
            java.lang.String password,
            java.lang.String name,
            java.lang.String interests,
            java.util.Date dateOfBirth,
            UserManager manager)
Creates a new user and inserts it into the storage medium

Parameters:
username - The login name for this user
password - The password for this user
name - The real name for this user
interests - A string containing a list of the user's interests
dateOfBirth - The date this user was born
manager - The storage medium which this user exists in
Throws:
java.lang.IllegalArgumentException - If user, password, interests dateOfBirth, or manager is null or id < 0
Method Detail

getUsername

public java.lang.String getUsername()

getPassword

public java.lang.String getPassword()

getName

public java.lang.String getName()

getInterest

public java.lang.String getInterest()

getDateOfBirth

public java.util.Date getDateOfBirth()

getId

public int getId()

exists

public boolean exists()
Returns:
true if this user exists in the storage medium and thus can be edited.

getFavoritePlaces

public java.util.Collection getFavoritePlaces()
Returns:
a collection Place objects representing this this users favorite places.

update

public boolean update(java.lang.String username,
                      java.lang.String password,
                      java.lang.String name,
                      java.lang.String interests,
                      java.util.Date dateOfBirth)
Updates this user and its representation in the storage medium to have a new set of properties

Parameters:
username - The new login name for this user
password - The new password for this user
name - The new real name for this user
interests - A string containing a list of the user's interests
dateOfBirth - The new date this user was born
Returns:
True if the update is successful or false if there was an error

remove

public boolean remove()
Removes this user from the storage medium and marks it as unusable so future use of this user will generate exceptions.

Returns:
True if this operation is successful or false if there is an error

restore

public boolean restore()
Inserts this previously removed user back into the storage medium and marks it as usable again.

Returns:
True if this operation is successful or false if there is an error
Throws:
java.lang.IllegalStateException - if this user has not yet been deleted