|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ca.spaz.cron.datasource.AbstractFoodDataSource
public abstract class AbstractFoodDataSource
This is a partial implementation of the IFoodDatasource
interface, providing checking for proper sources for Food
parameters and basic naming. Protected abstract implementation methods
are provided for all public methods that this class handles.
Constructor Summary | |
---|---|
protected |
AbstractFoodDataSource(java.lang.String name)
Construct a new instance of this class, with the name supplied. |
Method Summary | |
---|---|
protected void |
diffSource(Food food)
Gatekeeper method to ensure that the Food object is from
a different Datasource. |
protected abstract java.util.List |
doFindAllFoods()
Retrieve a list of all foods in this datasource. |
protected abstract java.util.List |
doFindFoods(java.lang.String[] keys)
Retrieve a List of all foods in this particular Datasource. |
protected abstract 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 abstract java.util.List |
doGetMeasuresFor(Food food)
Return a List of Measure objects for the provided food. |
protected abstract void |
doGetNutrientsFor(Food food,
NutrientTable nutrients)
Fill the provided NutrientTable with the nutrients associated with the
Food . |
java.util.List |
findAllFoods()
Retrieve a list of all foods in this datasource. |
java.util.List |
findFoods(java.lang.String[] keys)
Retrieve a List of all foods in this particular Datasource. |
java.util.List |
findFoods(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. |
FoodDatasourceException |
getLastError()
Provides access to the last exception thrown by the underlying representation. |
java.util.List |
getMeasuresFor(Food food)
Return a List of Measure objects for the provided food. |
java.lang.String |
getName()
Retrieve the name of this datasource for use in UI components. |
void |
getNutrientsFor(Food food,
NutrientTable nutrients)
Fill the provided NutrientTable with the nutrients associated with the
Food . |
protected void |
notNull(java.lang.Object testedObject)
Gatekeeper method to ensure that an object is not null. |
protected void |
registerError(java.lang.Throwable t)
Set the last error message to the supplied Throwable. |
protected void |
sameSource(Food food)
Gatekeeper method to ensure that the Food object is from
this Datasource. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ca.spaz.cron.datasource.IFoodDatasource |
---|
close, containsFood, getFoodGroups, getSources, initialize, isAvailable, isListable, isSearchable |
Constructor Detail |
---|
protected AbstractFoodDataSource(java.lang.String name)
name
- the name of this datasource.Method Detail |
---|
protected void diffSource(Food food)
Food
object is from
a different Datasource.
food
- a food object to test.
java.lang.IllegalArgumentException
- if the food object is from this datasource.protected void notNull(java.lang.Object testedObject)
testedObject
- protected abstract java.util.List doFindAllFoods()
Food
objects consisting of every food in the datasource.
UnsupportedOperationException
- if the datasource does not
support listing. (if isListable()
is false)protected abstract java.util.List doFindFoods(java.lang.String[] keys)
List
of all foods in this particular Datasource.
keys
- the keys to search on. This searches with an AND relation.
Food
objects matching the criteria.
UnsupportedOperationException
- if the datasource does not
support searching. (if isSearchable()
is false)protected abstract java.util.List doFindFoods(java.lang.String[] keys, java.lang.String foodGroup, java.lang.String source)
List
of all foods in this particular Datasource having
the given food group and source.
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.
Food
objects matching the criteria.
UnsupportedOperationException
- if the datasource does not
support searching. (if isSearchable()
is false)protected abstract java.util.List doGetMeasuresFor(Food food)
List
of Measure
objects for the provided food.
food
- a Food
object to find the measures for
List
that is guaranteed to contain only Measure
objects.protected abstract void doGetNutrientsFor(Food food, NutrientTable nutrients)
NutrientTable
with the nutrients associated with the
Food
.
food
- The food item to load fromnutrients
- the NutrientTable
to fill.public final java.util.List findAllFoods()
IFoodDatasource
findAllFoods
in interface IFoodDatasource
Food
objects consisting of every food in the datasource.public final java.util.List findFoods(java.lang.String[] keys)
IFoodDatasource
List
of all foods in this particular Datasource.
findFoods
in interface IFoodDatasource
keys
- the keys to search on. This searches with an AND relation.
Food
objects matching the criteria.public final java.util.List findFoods(java.lang.String[] keys, java.lang.String foodGroup, java.lang.String source)
IFoodDatasource
List
of all foods in this particular Datasource having
the given food group and source.
findFoods
in interface IFoodDatasource
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.
Food
objects matching the criteria.public final java.util.List getMeasuresFor(Food food)
IFoodDatasource
List
of Measure
objects for the provided food.
getMeasuresFor
in interface IFoodDatasource
food
- a Food
object to find the measures for
List
that is guaranteed to contain only Measure
objects.public java.lang.String getName()
IFoodDatasource
getName
in interface IFoodDatasource
public final void getNutrientsFor(Food food, NutrientTable nutrients)
IFoodDatasource
NutrientTable
with the nutrients associated with the
Food
.
getNutrientsFor
in interface IFoodDatasource
food
- The food item to load fromnutrients
- the NutrientTable
to fill.protected void sameSource(Food food)
Food
object is from
this Datasource.
food
- a food object to test.
java.lang.IllegalArgumentException
- if the food object is from another datasource.public final java.lang.String toString()
toString
in class java.lang.Object
public FoodDatasourceException getLastError()
IFoodDatasource
getLastError
in interface IFoodDatasource
Throwable
that an implementation of this interface
has thrown.protected void registerError(java.lang.Throwable t)
t
- the exception that just happened.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |