|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IFoodDatasource
This interface defines the interaction the application will have with a static,
readonly data source. The methods on it are all the ways that the app might
ask for information on elements of the food system.
Note regaring Food
instances and this interface -- this interface and
all subclasses expect and should enforce (unless noted) that the Food
object passes as a parameter to a given instance have that same instance as its
dataSource
property.
Method Summary | |
---|---|
void |
close()
Close this connection. |
boolean |
containsFood(Food food)
Determine if this datasource contains the specified 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. |
java.util.List |
getFoodGroups()
Get a list of all food groups in this datasource. |
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 f,
NutrientTable nutrients)
Fill the provided NutrientTable with the nutrients associated with the
Food . |
java.util.List |
getSources()
Get a list of all sources in this datasource. |
void |
initialize()
Initialize the datasource to a working state. |
boolean |
isAvailable()
Determines if the datasource is operable and available. |
boolean |
isListable()
Implementors that can provide listing services should return true here, false otherwise. |
boolean |
isSearchable()
Implementors that can provide search services should return true here, false otherwise. |
Method Detail |
---|
java.util.List findFoods(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)java.util.List findFoods(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)java.util.List findAllFoods()
Food
objects consisting of every food in the datasource.
UnsupportedOperationException
- if the datasource does not
support listing. (if isListable()
is false)java.util.List getMeasuresFor(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.void getNutrientsFor(Food f, NutrientTable nutrients)
NutrientTable
with the nutrients associated with the
Food
.
f
- The food item to load fromnutrients
- the NutrientTable
to fill.java.util.List getSources()
List
of String
objects naming the sources
for this Datasource.java.util.List getFoodGroups()
List
of FoodGroup
objects naming the food
groups for this Datasource.boolean isSearchable()
true
if this Datasource supports search, false
otherwise.boolean isListable()
true
if this Datasource supports listing, false
otherwise.java.lang.String getName()
void close()
FoodDatasourceException getLastError()
Throwable
that an implementation of this interface
has thrown.boolean isAvailable()
true
if this datasource is functioning, false
otherwisevoid initialize()
isAvailable
must return
true
for this data source. If this source is already available, this
method will do nothing.
boolean containsFood(Food food)
Food
in this datasource, the Food's SourceUID
is equal
to that of the food on the command line.
food
- The food to test for
true
if there is a Food
in this datasource matching the
provided one.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |