ca.spaz.cron.user.impl
Class CRONUser

java.lang.Object
  extended by ca.spaz.cron.user.impl.CRONUser
All Implemented Interfaces:
User

public class CRONUser
extends java.lang.Object
implements User

A CRONOMETER-specific, property-based User implementation.

Author:
Chris Rose

Nested Class Summary
static class CRONUser.UserPropertyValidator
          A simple validator for user properties.
 
Method Summary
 void addUserChangeListener(UserChangeListener l)
          Add a listener for user change events.
 void addUserMetrics(java.util.Date date, UserMetrics metrics)
          Add a new set of metrics for a particular date.
 void addUserMetrics(UserMetrics metrics)
          Add a new set of metrics for the current time.
 boolean firstRun()
           
 java.lang.Integer getAge()
          Get the user's age
 java.util.Date getBirthDate()
          Get the user's birthdate
 java.lang.Double getHeightInCM()
          Get the user's height in cm
 java.lang.String getName()
          Get the name of the user.
 Target getTarget(NutrientInfo nutrient)
          Get the target value for a particular nutrient.
static User getUser()
           
 java.util.List getUserMetrics()
          Get a List of all user metrics.
 java.util.List getUserMetrics(java.util.Date date)
          Get a List of all user metrics for a given day.
 java.lang.String getUserPreference(java.lang.String prefName)
          This gets a user preference by name.
 boolean isFemale()
          Get the gender of the user.
 boolean isMale()
          Get the gender of the user.
protected  void notifyListeners()
           
 void removeUserChangeListener(UserChangeListener l)
          Remove a listener for user change events.
 void removeUserMetrics(UserMetrics metrics)
          Remove a set of user metrics from the database.
 void setBirthDate(java.util.Date date)
          Set the user's birthdate
 void setFirstRun(boolean val)
           
 void setGender(boolean male)
          Set the gender of the user
 void setHeightInCM(java.lang.Double height)
          Set the user's height in cm
 void setName(java.lang.String name)
          Set the name of the user
 void setTarget(NutrientInfo nutrient, Target target)
          Set a target value for a particular NutrientInfo.
 void setUserPreference(java.lang.String prefName, java.lang.String value)
          Sets the value of a user preference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getUser

public static final User getUser()

getName

public java.lang.String getName()
Description copied from interface: User
Get the name of the user.

Specified by:
getName in interface User
Returns:
The user's name.

setName

public void setName(java.lang.String name)
Description copied from interface: User
Set the name of the user

Specified by:
setName in interface User

getBirthDate

public java.util.Date getBirthDate()
Description copied from interface: User
Get the user's birthdate

Specified by:
getBirthDate in interface User
Returns:
the user's birthdate.

setBirthDate

public void setBirthDate(java.util.Date date)
Description copied from interface: User
Set the user's birthdate

Specified by:
setBirthDate in interface User

getAge

public java.lang.Integer getAge()
Description copied from interface: User
Get the user's age

Specified by:
getAge in interface User
Returns:
the user's age

getHeightInCM

public java.lang.Double getHeightInCM()
Description copied from interface: User
Get the user's height in cm

Specified by:
getHeightInCM in interface User
Returns:
the user's height in cm

setHeightInCM

public void setHeightInCM(java.lang.Double height)
Description copied from interface: User
Set the user's height in cm

Specified by:
setHeightInCM in interface User

getUserPreference

public java.lang.String getUserPreference(java.lang.String prefName)
Description copied from interface: User
This gets a user preference by name.

Specified by:
getUserPreference in interface User
Parameters:
prefName - the ID of the preference.
Returns:
the value of the user's preference.

setUserPreference

public void setUserPreference(java.lang.String prefName,
                              java.lang.String value)
Description copied from interface: User
Sets the value of a user preference. This value is subject to validation by the validators configured in CRONConfiguration. In the case where the value is not legal, this method will silently fail.

Specified by:
setUserPreference in interface User
Parameters:
prefName - Tne ID of the preference.
value - The new value for the preference.

getUserMetrics

public java.util.List getUserMetrics()
Description copied from interface: User
Get a List of all user metrics. These are the values that the user is tracking.

Specified by:
getUserMetrics in interface User
Returns:
a List containing UserMetrics objects for each date the user has a metric for.

getUserMetrics

public java.util.List getUserMetrics(java.util.Date date)
Description copied from interface: User
Get a List of all user metrics for a given day. The day in the Date provided will be used to select them.

Specified by:
getUserMetrics in interface User
Parameters:
date - The date to search for metrics from.
Returns:
the User's metrics for the provided date.

addUserMetrics

public void addUserMetrics(java.util.Date date,
                           UserMetrics metrics)
Description copied from interface: User
Add a new set of metrics for a particular date.

Specified by:
addUserMetrics in interface User

addUserMetrics

public void addUserMetrics(UserMetrics metrics)
Description copied from interface: User
Add a new set of metrics for the current time.

Specified by:
addUserMetrics in interface User

removeUserMetrics

public void removeUserMetrics(UserMetrics metrics)
Description copied from interface: User
Remove a set of user metrics from the database.

Specified by:
removeUserMetrics in interface User

setTarget

public void setTarget(NutrientInfo nutrient,
                      Target target)
Description copied from interface: User
Set a target value for a particular NutrientInfo.

Specified by:
setTarget in interface User

getTarget

public Target getTarget(NutrientInfo nutrient)
Description copied from interface: User
Get the target value for a particular nutrient.

Specified by:
getTarget in interface User
Returns:
the nutrient's current Target

addUserChangeListener

public final void addUserChangeListener(UserChangeListener l)
Description copied from interface: User
Add a listener for user change events.

Specified by:
addUserChangeListener in interface User
Parameters:
l - the listener.

notifyListeners

protected final void notifyListeners()

removeUserChangeListener

public final void removeUserChangeListener(UserChangeListener l)
Description copied from interface: User
Remove a listener for user change events.

Specified by:
removeUserChangeListener in interface User
Parameters:
l - the listener.

isMale

public boolean isMale()
Description copied from interface: User
Get the gender of the user.

Specified by:
isMale in interface User
Returns:
the gender of the user.

isFemale

public boolean isFemale()
Description copied from interface: User
Get the gender of the user.

Specified by:
isFemale in interface User
Returns:
the gender of the user.

setGender

public void setGender(boolean male)
Description copied from interface: User
Set the gender of the user

Specified by:
setGender in interface User
Parameters:
male - true if the user is male, false otherwise.

firstRun

public boolean firstRun()

setFirstRun

public void setFirstRun(boolean val)


Copyright © 2005 Spaz. All Rights Reserved.