ca.spaz.cron.database
Interface Food

All Known Subinterfaces:
SQLFood
All Known Implementing Classes:
NutritionDataFood

public interface Food

This interface defines a Food object in CRON-O-Meter.

Author:
Chris Rose

Method Summary
 AminoAcids getAminoAcids()
          Retrieve the Amino Acids list for this Food.
 double getCalories()
          Deprecated. This method should apply only to Servings.
 IFoodDatasource getDataSource()
           
 java.lang.String getDescription()
          Get a textual description of the food.
 FoodGroup getFoodGroup()
          Get the FoodGroup associated with this food
 Lipids getLipids()
          Retrieve the Lipids list for this Food.
 MacroNutrients getMacroNutrients()
          Retrieve the MacroNutrients list for this Food.
 java.util.List getMeasures()
          Retrieve a List of Measures for this Food.
 Minerals getMinerals()
          Retrieve the Minerals list for this Food.
 int getNumTimesConsumed()
          Get the number of times this food was consumed.
 double getNutrientAmount(NutrientInfo ni)
          Get the amount of a nutrient provided by this Food.
 java.lang.String getSource()
          Get the identifying 'source' of this food.
 java.lang.String getSourceUID()
          Retrieve a key for this food uniquely identifying both its datasource and its own unique ID in the DS.
 Vitamins getVitamins()
          Retrieve the Vitamins list for this Food.
 void setDescription(java.lang.String text)
          Update this Food's description.
 void setFoodGroup(FoodGroup foodGroup)
          Set the FoodGroup associated with this food.
 void setMeasures(java.util.List measures)
          Replace the list of Measures for this food.
 void setModified()
          Call this method to set the food as modified.
 void setNutrientAmount(NutrientInfo ni, double val)
          Set the amount of a nutrient provided by this Food.
 void setSource(java.lang.String source)
          Set the identifying 'source' of this Food.
 void setSourceUID(java.lang.String uid)
          Directly set the sourceUID of a food to that of another one.
 

Method Detail

getFoodGroup

FoodGroup getFoodGroup()
Get the FoodGroup associated with this food

Returns:
a FoodGroup instance associated with this food.

setFoodGroup

void setFoodGroup(FoodGroup foodGroup)
Set the FoodGroup associated with this food. The Food implementation must be associated with a writeable datasource. If the FoodGroup is not already in this Food's datasource, it will be added.

Parameters:
foodGroup - A FoodGroup instance.

getDescription

java.lang.String getDescription()
Get a textual description of the food.

Returns:
this Food's description.

setDescription

void setDescription(java.lang.String text)
Update this Food's description. The Food implementation must be associated with a writeable datasource.

Parameters:
text - The new description.

getMeasures

java.util.List getMeasures()
Retrieve a List of Measures for this Food.

Returns:
all Measures associated with this Food.

setMeasures

void setMeasures(java.util.List measures)
Replace the list of Measures for this food. The Food implementation must be associated with a writeable datasource.

Parameters:
measures - A list of Measure objects that will completely replace the ones currently in existence for this Food.

getCalories

double getCalories()
Deprecated. This method should apply only to Servings.

A convenience method to retrieve the number of calories this Food provides.

Returns:
The number of calories provided in one gram of this food.

getMacroNutrients

MacroNutrients getMacroNutrients()
Retrieve the MacroNutrients list for this Food.

Returns:
the MacroNutrients.

getMinerals

Minerals getMinerals()
Retrieve the Minerals list for this Food.

Returns:
the Minerals.

getVitamins

Vitamins getVitamins()
Retrieve the Vitamins list for this Food.

Returns:
the Vitamins.

getAminoAcids

AminoAcids getAminoAcids()
Retrieve the Amino Acids list for this Food.

Returns:
the Amino Acids.

getLipids

Lipids getLipids()
Retrieve the Lipids list for this Food.

Returns:
the Lipids.

getNutrientAmount

double getNutrientAmount(NutrientInfo ni)
Get the amount of a nutrient provided by this Food.

Parameters:
ni - the NutrientInfo to look up.
Returns:
the amount of the requested nutrient per unit.

setNutrientAmount

void setNutrientAmount(NutrientInfo ni,
                       double val)
Set the amount of a nutrient provided by this Food. The Food implementation must be associated with a writeable datasource.

Parameters:
ni - the Nutrient to modify.
val - the amount of the Nutrient per unit.

getNumTimesConsumed

int getNumTimesConsumed()
Get the number of times this food was consumed.

Returns:
the number of times this food was consumed.
To Do:
Determine if this Food can be associated with other instances of the same between datasources.

getSource

java.lang.String getSource()
Get the identifying 'source' of this food. This is distinct from the physical datasource, and is instead intended to allow multiple sources of food to coexist in a single food DB.

Returns:
the source of this Food.

setSource

void setSource(java.lang.String source)
Set the identifying 'source' of this Food. The Food implementation must be associated with a writeable datasource.

Parameters:
source -

getDataSource

IFoodDatasource getDataSource()
Returns:
Returns the dataSource.

getSourceUID

java.lang.String getSourceUID()
Retrieve a key for this food uniquely identifying both its datasource and its own unique ID in the DS. The general contract of this method is that if f1.getSourceUID().equals(f2.getSourceUID()) then f1 and f2 both come from the same DS, and refer to the same item in that DS.

Returns:
A UID for this food.

setModified

void setModified()
Call this method to set the food as modified. This will clear any stored sourceUID in the food, and cause it to report its sourceUID() as if it were newly created in the datasource. This method is NOT reversible.


setSourceUID

void setSourceUID(java.lang.String uid)
Directly set the sourceUID of a food to that of another one.

Parameters:
uid - The Food whose sourceUID will be used.


Copyright © 2005 Spaz. All Rights Reserved.