public class UserPool
extends java.lang.Object
implements java.io.Serializable
jpleal@fc.up.pt| Modifier and Type | Method and Description |
|---|---|
(package private) void |
addUser(java.lang.String nick,
java.lang.String password)
Add an user with given nick and password.
|
(package private) static void |
backup(UserPool pool)
Save given pool in file.
|
static java.io.File |
getBackupFile()
Get the current file used for backup.
|
(package private) static UserPool |
getInstance()
Single instance of this class.
|
(package private) User |
getUser(java.lang.String nick,
java.lang.String password)
Retrieve the user with given nick if it authenticates with given password.
|
(package private) void |
reset()
Resets UserPool's fields to enable unit testing
on the
Manager singleton. |
(package private) static UserPool |
restore()
Restore backup file and return saved pool.
|
static void |
setBackupFile(java.io.File backupFile)
Change the file used for backups.
|
static void |
setBackupFile(java.lang.String name)
Convenience method to set the backup file as a string
|
static UserPool getInstance() throws CardGameException
CardGameException - on error restoring backup file.public static java.io.File getBackupFile()
public static void setBackupFile(java.io.File backupFile)
backupFile - to save the serialization.public static void setBackupFile(java.lang.String name)
name - of backup file.static void backup(UserPool pool) throws CardGameException
pool - to save.CardGameException - if backup file is not writable
or I/O error occurs during writing.static UserPool restore() throws CardGameException
null if not availableCardGameException - if backup file is not readable
or I/O error occurs during readingUser getUser(java.lang.String nick, java.lang.String password) throws CardGameException
nick - of user.password - of user.CardGameException - nick or password are invalid.void addUser(java.lang.String nick,
java.lang.String password)
throws CardGameException
null value.nick - of user.password - of user.CardGameException - if any of the arguments is null.void reset()
Manager singleton.
This method must only be used during testing
and shoudn't be public.