ca.spaz.cron.datasource.www
Class NutritionDataDatasource

java.lang.Object
  extended by ca.spaz.cron.datasource.AbstractFoodDataSource
      extended by ca.spaz.cron.datasource.www.AbstractWWWDatasource
          extended by ca.spaz.cron.datasource.www.NutritionDataDatasource
All Implemented Interfaces:
IFoodDatasource

public class NutritionDataDatasource
extends AbstractWWWDatasource

A datasource that is tied to the website http://www.nutritiondata.com/

Author:
Chris Rose

Method Summary
 boolean containsFood(Food food)
          Determine if this datasource contains the specified food.
static NutritionDataDatasource createReadonlyFoodSource()
           
protected  void doClose()
           
protected  java.util.List doFindAllFoods()
          Retrieve a list of all foods in this datasource.
protected  java.util.List doFindFoods(java.lang.String[] keys)
          Retrieve a List of all foods in this particular Datasource.
protected  java.util.List doFindFoods(java.lang.String[] keys, java.lang.String foodGroup, java.lang.String source)
          Retrieve a List of all foods in this particular Datasource having the given food group and source.
protected  java.util.List doGetFoodGroups()
          Retrieve a list of food groups for this data source.
protected  java.util.List doGetMeasuresFor(Food food)
          Return a List of Measure objects for the provided food.
protected  void doGetNutrientsFor(Food food, NutrientTable nutrients)
          Fill the provided NutrientTable with the nutrients associated with the Food.
protected  java.util.List doGetSources()
          Retrieve a list of Sources available from this data source.
 boolean isAvailable()
          Determines if the datasource is operable and available.
static void main(java.lang.String[] args)
           
 
Methods inherited from class ca.spaz.cron.datasource.www.AbstractWWWDatasource
close, getFoodGroups, getFoodGroups, getSources, initialize, isListable, isSearchable, readURLAsString
 
Methods inherited from class ca.spaz.cron.datasource.AbstractFoodDataSource
diffSource, findAllFoods, findFoods, findFoods, getLastError, getMeasuresFor, getName, getNutrientsFor, notNull, registerError, sameSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

createReadonlyFoodSource

public static final NutritionDataDatasource createReadonlyFoodSource()

doFindAllFoods

protected java.util.List doFindAllFoods()
Description copied from class: AbstractFoodDataSource
Retrieve a list of all foods in this datasource.

Specified by:
doFindAllFoods in class AbstractWWWDatasource
Returns:
a List of Food objects consisting of every food in the datasource.

doGetSources

protected java.util.List doGetSources()
Description copied from class: AbstractWWWDatasource
Retrieve a list of Sources available from this data source.

Specified by:
doGetSources in class AbstractWWWDatasource
Returns:
a List of sources for this datasource.

doGetFoodGroups

protected java.util.List doGetFoodGroups()
Description copied from class: AbstractWWWDatasource
Retrieve a list of food groups for this data source.

Specified by:
doGetFoodGroups in class AbstractWWWDatasource
Returns:
a List of FoodGroup implementations containing all of the food groups in this data source.

doClose

protected void doClose()
Specified by:
doClose in class AbstractWWWDatasource

doFindFoods

protected java.util.List doFindFoods(java.lang.String[] keys)
Description copied from class: AbstractFoodDataSource
Retrieve a List of all foods in this particular Datasource.

Overrides:
doFindFoods in class AbstractWWWDatasource
Parameters:
keys - the keys to search on. This searches with an AND relation.
Returns:
a List of Food objects matching the criteria.

doFindFoods

protected java.util.List doFindFoods(java.lang.String[] keys,
                                     java.lang.String foodGroup,
                                     java.lang.String source)
Description copied from class: AbstractFoodDataSource
Retrieve a List of all foods in this particular Datasource having the given food group and source.

Overrides:
doFindFoods in class AbstractWWWDatasource
Parameters:
keys - the keys to search on. This searches with an AND relation.
foodGroup - the food group to search for. null to ignore.
source - the source of this food item. null to ignore.
Returns:
a List of Food objects matching the criteria.

doGetMeasuresFor

protected java.util.List doGetMeasuresFor(Food food)
Description copied from class: AbstractFoodDataSource
Return a List of Measure objects for the provided food.

Overrides:
doGetMeasuresFor in class AbstractWWWDatasource
Parameters:
food - a Food object to find the measures for
Returns:
a List that is guaranteed to contain only Measure objects.

doGetNutrientsFor

protected void doGetNutrientsFor(Food food,
                                 NutrientTable nutrients)
Description copied from class: AbstractFoodDataSource
Fill the provided NutrientTable with the nutrients associated with the Food.

Overrides:
doGetNutrientsFor in class AbstractWWWDatasource
Parameters:
food - The food item to load from
nutrients - the NutrientTable to fill.

isAvailable

public boolean isAvailable()
Description copied from interface: IFoodDatasource
Determines if the datasource is operable and available. This includes connections to physical datasources, proper setup of tables, or any other conditions that may prevent this from being a functional datasource.

Returns:
true if this datasource is functioning, false otherwise

main

public static void main(java.lang.String[] args)

containsFood

public boolean containsFood(Food food)
Description copied from interface: IFoodDatasource
Determine if this datasource contains the specified food. This method will return true if for any Food in this datasource, the Food's SourceUID is equal to that of the food on the command line.

Parameters:
food - The food to test for
Returns:
true if there is a Food in this datasource matching the provided one.


Copyright © 2005 Spaz. All Rights Reserved.