ca.spaz.cron.datasource.www
Class NutritionDataFood

java.lang.Object
  extended by ca.spaz.cron.datasource.www.NutritionDataFood
All Implemented Interfaces:
Food

public class NutritionDataFood
extends java.lang.Object
implements Food

A Food implementation for NutritionDataDatasource

Author:
Chris Rose

Constructor Summary
NutritionDataFood(NutritionDataDatasource source, com.meterware.httpunit.WebResponse response)
           
 
Method Summary
 AminoAcids getAminoAcids()
          Retrieve the Amino Acids list for this Food.
 double getCalories()
          A convenience method to retrieve the number of calories this Food provides.
 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 string)
          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.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NutritionDataFood

public NutritionDataFood(NutritionDataDatasource source,
                         com.meterware.httpunit.WebResponse response)
Method Detail

getFoodGroup

public FoodGroup getFoodGroup()
Description copied from interface: Food
Get the FoodGroup associated with this food

Specified by:
getFoodGroup in interface Food
Returns:
a FoodGroup instance associated with this food.

getSource

public java.lang.String getSource()
Description copied from interface: Food
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.

Specified by:
getSource in interface Food
Returns:
the source of this Food.

getMeasures

public java.util.List getMeasures()
Description copied from interface: Food
Retrieve a List of Measures for this Food.

Specified by:
getMeasures in interface Food
Returns:
all Measures associated with this Food.

setMeasures

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

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

getCalories

public double getCalories()
Description copied from interface: Food
A convenience method to retrieve the number of calories this Food provides.

Specified by:
getCalories in interface Food
Returns:
The number of calories provided in one gram of this food.

getMacroNutrients

public MacroNutrients getMacroNutrients()
Description copied from interface: Food
Retrieve the MacroNutrients list for this Food.

Specified by:
getMacroNutrients in interface Food
Returns:
the MacroNutrients.

getDescription

public java.lang.String getDescription()
Description copied from interface: Food
Get a textual description of the food.

Specified by:
getDescription in interface Food
Returns:
this Food's description.

getMinerals

public Minerals getMinerals()
Description copied from interface: Food
Retrieve the Minerals list for this Food.

Specified by:
getMinerals in interface Food
Returns:
the Minerals.

getVitamins

public Vitamins getVitamins()
Description copied from interface: Food
Retrieve the Vitamins list for this Food.

Specified by:
getVitamins in interface Food
Returns:
the Vitamins.

getAminoAcids

public AminoAcids getAminoAcids()
Description copied from interface: Food
Retrieve the Amino Acids list for this Food.

Specified by:
getAminoAcids in interface Food
Returns:
the Amino Acids.

getLipids

public Lipids getLipids()
Description copied from interface: Food
Retrieve the Lipids list for this Food.

Specified by:
getLipids in interface Food
Returns:
the Lipids.

getNutrientAmount

public double getNutrientAmount(NutrientInfo ni)
Description copied from interface: Food
Get the amount of a nutrient provided by this Food.

Specified by:
getNutrientAmount in interface Food
Parameters:
ni - the NutrientInfo to look up.
Returns:
the amount of the requested nutrient per unit.

setNutrientAmount

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

Specified by:
setNutrientAmount in interface Food
Parameters:
ni - the Nutrient to modify.
val - the amount of the Nutrient per unit.

setDescription

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

Specified by:
setDescription in interface Food
Parameters:
text - The new description.

setFoodGroup

public void setFoodGroup(FoodGroup foodGroup)
Description copied from interface: Food
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.

Specified by:
setFoodGroup in interface Food
Parameters:
foodGroup - A FoodGroup instance.

getNumTimesConsumed

public int getNumTimesConsumed()
Description copied from interface: Food
Get the number of times this food was consumed.

Specified by:
getNumTimesConsumed in interface Food
Returns:
the number of times this food was consumed.

setSource

public void setSource(java.lang.String string)
Description copied from interface: Food
Set the identifying 'source' of this Food. The Food implementation must be associated with a writeable datasource.

Specified by:
setSource in interface Food

getDataSource

public IFoodDatasource getDataSource()
Specified by:
getDataSource in interface Food
Returns:
Returns the dataSource.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSourceUID

public java.lang.String getSourceUID()
Description copied from interface: Food
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.

Specified by:
getSourceUID in interface Food
Returns:
A UID for this food.

setModified

public void setModified()
Description copied from interface: Food
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.

Specified by:
setModified in interface Food

setSourceUID

public void setSourceUID(java.lang.String uid)
Description copied from interface: Food
Directly set the sourceUID of a food to that of another one.

Specified by:
setSourceUID in interface Food
Parameters:
uid - The Food whose sourceUID will be used.


Copyright © 2005 Spaz. All Rights Reserved.