net.sourceforge.pavlov.user
Class User

java.lang.Object
  extended by net.sourceforge.pavlov.user.User

public final class User
extends Object

Describe class User here.


Constructor Summary
User()
          Creates an empty user named "Unnamed" with password "empty."
User(String name, String password)
          Creates a user with the given name and password.
 
Method Summary
 void addBook(BookData b)
          Adds the bookdata to this user.
static void addQuizData(ChapterData who, QuizData qdd)
          Adds data for a quiz to this user.
 boolean checkPassword(String pass)
          Returns true if pass is the user's password.
 void deleteQuestionID(String bkName, String cpName, String qn)
          Deprecated. implement reverse validation in this class, then privatize this method
 boolean equals(Object o)
          Returns true if 1) both are null, or 2) name and password are the same.
protected  String getBaseFileName()
          Describe getBaseFileName method here.
 BookData getBookData(String bkName)
          Gets data describing the users global history with the named book.
 ChapterData getChapterData(ChapterReference ref)
          Describe getChapterData method here.
 ChapterData getChapterData(String bkName, String cpName)
          Deprecated. use getChapterData(ChapterReference) instead.
 String getName()
          Returns this user's name.
 int getNumberOfQuestions(String bkName, String cpName)
          Number of questions in this book.
 QuestionData getQuestionData(String bkName, String cpName, String qid)
          Describe getQuestionData method here.
 String getQuestionId(String bkName, String cpName)
          Returns a question from the given book & chapter using the current strategy.
static QuizCollectionData getStatistics(ChapterData who)
          Returns descriptive statistics about this user's past quizzes.
 UserFile getUserFile()
          Gets the userfile to save this user to.
static Question getValidQuestion(ChapterData chapDat, AbstractChapter chapt)
          Reverse-validation: if a user.QuestionData exists for a nonexistant library.question, unceremoniously remove the user.QuestionData.
 void save()
          Saves this file to file userFile.
 void save(File directory)
          Saves this file to the given directory.
 void setName(String n)
          Sets this user's name.
 void setPassword(String n)
          Sets this user's password.
 void setUserFile(UserFile f)
          Sets the userfile for saving/loading this user.
 void toXML(Writer writer)
          Sends a representation of this user in XML form to the given writer.
 void validate(AbstractLibrary l)
          Ensures the user has QuestionData for all the questions in this book, creating QuestionData as necessary.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

User

public User(String name,
            String password)
Creates a user with the given name and password.

Parameters:
name - a String value
password - a String value

User

public User()
Creates an empty user named "Unnamed" with password "empty."

Method Detail

checkPassword

public boolean checkPassword(String pass)
Returns true if pass is the user's password.

Parameters:
pass - a String value
Returns:
a boolean value

equals

public boolean equals(Object o)
Returns true if 1) both are null, or 2) name and password are the same.

Overrides:
equals in class Object
Parameters:
o - an Object value
Returns:
a boolean value

getBookData

public BookData getBookData(String bkName)
Gets data describing the users global history with the named book.

Parameters:
bkName - a String value
Returns:
a BookData value

validate

public void validate(AbstractLibrary l)
Ensures the user has QuestionData for all the questions in this book, creating QuestionData as necessary.

Parameters:
l - an AbstractLibrary value

getQuestionData

@Deprecated
public QuestionData getQuestionData(String bkName,
                                               String cpName,
                                               String qid)
Describe getQuestionData method here.

Parameters:
bkName - a String value
cpName - a String value
qid - a String value
Returns:
a QuestionData value

getNumberOfQuestions

@Deprecated
public int getNumberOfQuestions(String bkName,
                                           String cpName)
Number of questions in this book.

Parameters:
bkName - a String value
cpName - a String value
Returns:
an int value

deleteQuestionID

@Deprecated
public void deleteQuestionID(String bkName,
                                        String cpName,
                                        String qn)
Deprecated. implement reverse validation in this class, then privatize this method

if this is needed by an outside class, make it through an intermediate method in this class

Parameters:
bkName - a String value
cpName - a String value
qn - a String value

getValidQuestion

public static Question getValidQuestion(ChapterData chapDat,
                                        AbstractChapter chapt)
Reverse-validation: if a user.QuestionData exists for a nonexistant library.question, unceremoniously remove the user.QuestionData.

Parameters:
chapDat - a ChapterData value
chapt - an AbstractChapter value
Returns:
a Question value
See Also:
Chapter, ChapterData

getQuestionId

public String getQuestionId(String bkName,
                            String cpName)
Returns a question from the given book & chapter using the current strategy.

Parameters:
bkName - a String value
cpName - a String value
Returns:
a String value
See Also:
ChapterData.getQuestion()

setName

public void setName(String n)
Sets this user's name.

Parameters:
n - a String value

getName

public String getName()
Returns this user's name.

Returns:
a String value

setPassword

public void setPassword(String n)
Sets this user's password. Notice that getPassword isn't implemented.

Parameters:
n - a String value

addBook

public void addBook(BookData b)
Adds the bookdata to this user.

Parameters:
b - a BookData value

toXML

public void toXML(Writer writer)
           throws IOException
Sends a representation of this user in XML form to the given writer.

Parameters:
writer - a java.io.Writer value
Throws:
IOException - if an error occurs

getUserFile

public UserFile getUserFile()
Gets the userfile to save this user to.

Returns:
an UserFile value

setUserFile

public void setUserFile(UserFile f)
Sets the userfile for saving/loading this user.

Parameters:
f - an UserFile value

save

public void save()
          throws FileNotFoundException,
                 IOException
Saves this file to file userFile.

Throws:
FileNotFoundException - if an error occurs
IOException - if an error occurs

save

public void save(File directory)
          throws IOException
Saves this file to the given directory.

Parameters:
directory - a File value
Throws:
IOException - if an error occurs

getBaseFileName

protected String getBaseFileName()
Describe getBaseFileName method here.

Returns:
a String value

getChapterData

@Deprecated
public ChapterData getChapterData(String bkName,
                                             String cpName)
Deprecated. use getChapterData(ChapterReference) instead.

Describe getChapterData method here.

Parameters:
bkName - a String value
cpName - a String value
Returns:
a ChapterData value

getChapterData

public ChapterData getChapterData(ChapterReference ref)
Describe getChapterData method here.

Parameters:
ref - a ChapterReference value
Returns:
a ChapterData value

addQuizData

public static void addQuizData(ChapterData who,
                               QuizData qdd)
Adds data for a quiz to this user.

Parameters:
who - a ChapterData value
qdd - a QuizData value

getStatistics

public static QuizCollectionData getStatistics(ChapterData who)
Returns descriptive statistics about this user's past quizzes.

Parameters:
who - a ChapterData value
Returns:
a QuizCollectionData value