|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ILocalFoodDatasource
This interface defines a datasource whose contents may be changed by
interested classes. All of the standard issues apply (especially the
Food needing to be associated with this datasource)
| Method Summary | |
|---|---|
Food |
addFood(Food food)
Add a Food to this datasource. |
void |
addFoodDatasourceListener(IFoodDatasourceListener listener)
Add a new IFoodDatasourceListener to this implementation. |
void |
addFoodGroup(FoodGroup foodGroup)
Add a new FoodGroup to the data source. |
boolean |
addMeasure(Food food,
Measure measure)
Each food in the Datasource has available a list of Measures that
describe portions or servings. |
Food |
addServing(Serving serving)
This method consumes the food in a serving. |
boolean |
changeMeasure(Food food,
java.util.List measures)
|
boolean |
changeServingAmount(Serving newServing)
Changes the amount of a food consumed to the amount in the serving provided. |
Food |
createNewFood()
Create a new Food object associated with this datasource. |
java.util.List |
getConsumedOn(java.util.Date date)
Retrieve a list of all Servings consumed on a particular date. |
int |
getTimesConsumed(Food food)
Retrieve the total number of times that this food has been consumed. |
int |
getTimesConsumed(Food food,
java.util.Date startDate,
java.util.Date endDate)
Retrieve the number of times the specified Food was consumed
between the provided dates. |
boolean |
removeFood(Food food)
Remove a Food from the datasource. |
void |
removeFoodDatasourceListener(IFoodDatasourceListener listener)
Remove an IFoodDatasourceListener from the list of observers of this class. |
boolean |
removeMeasure(Food food,
Measure measure)
Remove a particular form of Measure from the list of those available for
a particular Food. |
boolean |
removeServing(Serving serving)
Remove the Food in a particular serving from the user's consumed
list. |
boolean |
saveFood(Food food)
Alter the information of some Food object in the backing representation of the datasource. |
| Methods inherited from interface ca.spaz.cron.datasource.IFoodDatasource |
|---|
close, containsFood, findAllFoods, findFoods, findFoods, getFoodGroups, getLastError, getMeasuresFor, getName, getNutrientsFor, getSources, initialize, isAvailable, isListable, isSearchable |
| Method Detail |
|---|
Food addServing(Serving serving)
Food object have
this as its datasource, since in this case if the Food
object has a different datasource, it will either A) be added to this
one, and then consumed, or B) if it is already present in this datasource
it will simply be added from this datasource.
serving - a Serving to add to the user's consumed list.
Food object that represents the Food
that is associated with this datasource. If the food was already associated
with this datasource, the same object will be returned. null
will be returned if some error occurred.void addFoodGroup(FoodGroup foodGroup)
foodGroup - the new food group to add to the data source.boolean changeServingAmount(Serving newServing)
Food retrieved by calling
getFood() on newServing. If the food is not already
in the database as being consumed, it will be added. The food must already
be in the user datasource, however.
newServing - a Serving object whose Food's serving
quantity on the proper date will be altered.
true if the serving was altered, false if some
error occurred.boolean removeServing(Serving serving)
Food in a particular serving from the user's consumed
list. Operates regardless of quantity.
serving - the serving to un-consume.
true if the action succeeded, false if there
was some error.
boolean addMeasure(Food food,
Measure measure)
Measures that
describe portions or servings. This method will add a valid Measure
to a Food object stored in this datasource.
food - The Food object to which the new measure applies.measure - The new Measure.
true if successful, false if some error occurred.
boolean changeMeasure(Food food,
java.util.List measures)
food - measures -
true if successful, false if some error occurred.
boolean removeMeasure(Food food,
Measure measure)
Measure from the list of those available for
a particular Food.
food - measure -
true if successful, false if some error occurred.int getTimesConsumed(Food food)
food - the Food to check.
-1 on error.
int getTimesConsumed(Food food,
java.util.Date startDate,
java.util.Date endDate)
Food was consumed
between the provided dates.
food - the Food to check.startDate - the starting date.endDate - the ending date.
-1
on error.java.util.List getConsumedOn(java.util.Date date)
Servings consumed on a particular date.
date - the Date to retrieve the foods for.
List consisting only of Serving objects,
or null if some error occurred. If no servings were consumed
on the specified date, an empty list will be returned.Food addFood(Food food)
Food to this datasource.
This method is an exception to the local datasource rule -- the Food
provided to this method must not be attached to this datasource.
food - A Food object that comes from another datasource.
Food object whose information is the same as the parameter,
but that exists only in this datasource, with all nutrient information still
represtented. null will be returned if some error occurred.Food createNewFood()
Food object associated with this datasource.
Food instance.boolean saveFood(Food food)
Food implementation specific to the datasource has a concept of
unique identifiers, a true alteration will occur. However, if the Food
object does not have this feature, for example in a flat-file database or something
like it, the implementor should check for name similarity, and if that does not
match, simply add the new food to the database.
food - a Food object to be changed.
true if successful, false if some error occurred.boolean removeFood(Food food)
Food from the datasource.
food - the Food to remove.
true if successful, false if some error occurred.void addFoodDatasourceListener(IFoodDatasourceListener listener)
IFoodDatasourceListener to this implementation. The listener
will be notified on any successful change to the underlying datasource.
listener - the new IFoodDatasourceListener.void removeFoodDatasourceListener(IFoodDatasourceListener listener)
IFoodDatasourceListener from the list of observers of this class.
listener - the IFoodDatasourceListener.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||