org.activemath.webapp.user
Class BookState

java.lang.Object
  extended by org.activemath.webapp.user.BookState

public class BookState
extends Object

This class represents the state of a book for a given user. It stores the last page the user has been working on, the book id, the number of times the user has accessed the book, the date of the first and last time the book was opened.


Constructor Summary
BookState()
           
BookState(String bookId)
          Constructs a BookState for the book with the given ID
 
Method Summary
 void access()
          increases the number of accesses by one.
 String getBookId()
          gets the id of the book this BookState is for
 BookStat getBookStat()
           
 int getCurrentPage()
          returns the current Page number
 long getFirstTimeOpened()
          returns the Date when the correspondig book was first opened.
 long getLastAccess()
          gets the Date the user last accessed the book.
 int getMastery()
          Average mastery for this book.
 Integer getMasteryInt()
           
 int getNumberOfAccesses()
          gets the number of the times the book has been accessed.
 String getUserId()
           
 void setBookStat(BookStat bookStat)
           
 void setCurrentPage(int currentPage)
          Sets the current Page number
 void setMastery(int mastery)
           
 void setMasteryInt(Integer mastery)
          For Hibernate: frickle with Integer to allow "null" in column.
 void setUserId(String userId)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BookState

public BookState()

BookState

public BookState(String bookId)
Constructs a BookState for the book with the given ID

Parameters:
id - The id of the book to create this BookState for.
Method Detail

toString

public String toString()
Overrides:
toString in class Object

access

public void access()
increases the number of accesses by one.


setCurrentPage

public void setCurrentPage(int currentPage)
Sets the current Page number

Parameters:
currentPage - the new page to set as current page.

getCurrentPage

public int getCurrentPage()
returns the current Page number

Returns:
the number of the page the user currently is on.

getLastAccess

public long getLastAccess()
gets the Date the user last accessed the book.

Returns:
a Date object initialized with lastAccess.getTime()

getBookId

public String getBookId()
gets the id of the book this BookState is for

Returns:
The id of the Book this BookState is for.

getFirstTimeOpened

public long getFirstTimeOpened()
returns the Date when the correspondig book was first opened.

Returns:
A Date Object initialized with firstTimeOpened.getTime().

getNumberOfAccesses

public int getNumberOfAccesses()
gets the number of the times the book has been accessed.

Returns:
the number of the times the book has been accessed.

getMastery

public int getMastery()
Average mastery for this book. Maintained by ViewBook controller.


setMastery

public void setMastery(int mastery)

setMasteryInt

public void setMasteryInt(Integer mastery)
For Hibernate: frickle with Integer to allow "null" in column. This is because I messed up when adding this column to the mapping, and there are databases out there with null in this column.


getMasteryInt

public Integer getMasteryInt()

getUserId

public String getUserId()

setUserId

public void setUserId(String userId)

getBookStat

public BookStat getBookStat()

setBookStat

public void setBookStat(BookStat bookStat)