This release provides four methods for clients to query services. In all cases clients contact services by invoking the desired method in the class PrimitiveServiceStub. (Note that the class PrimitiveService contains many wildcard values that are useful in manual query creation.)
This is the simplest method of contacting a service, and can be used when all you need to do is retrieve an attribute without the need to specify any constraints on it. For these methods, you simply specify the name of the attribute you want to retrieve, the name of the key attribute, and the value of the key. (The key attribute used is usually the same as the service's own key attribute, but can potentially be any attribute that the service supports selection by.)
Example: SimpleCityTempClient
Queries the CityTemp service for the temperature in a particular city.
For these methods, you must provide each parameter to the basic query call. This may require constructing ArrayLists and expression trees for various parameters. The advantage of this work is that you gain complete control over the query including the ability to specify attribute requirements.
Example: CityTempClient
Queries the CityTemp service for the temperature in a particular city.
Example: CityTempClient2
Queries the CityTemp service for the temperature in a range of cities.
This is similar to specifying each element. However, the Query object provides a convenient method for packaging all elements of a query in one place. This is useful if the elements of a query need to be used in multiple places in code.
Example: CityTempClient3
Queries the CityTemp service for the temperature in a particular city.
Currently, PrimitiveServiceStub does not directly accept SQL-like strings. Instead, you must use a QParser class to parse an SQL-like string and create a Query object. This object is then used as if you created it by hand.
QParser currently does not support attribute requirements or timelimits, but these can be added to the Query object created.
Example: GenericyQuery
The Generic Query Example uses the query parser "QParser" to provide users the ability to execute arbitrary SQL-like queries. It may be used to query either the City service or the CityTemp service. Note that while the City service accepts arbitrary "where" expressions, the CityTemp service only accepts key equality expressions (e.g. where name="Canton").
Currently, posted queries and triggers can only be created manually. So, you must either specify all parameters, or create a PostedQuery, CondTrigger, or ModTrigger object that contains all the appropriate settings.
The results of a query execution (or trigger execution) are sent back in a QueryResult object. This object contains a list of attribute sets that matched the query (these can be viewed as "rows"). Each attribute set contains a list of attributes which are either static attributes or dynamic attributes depending on how the service has been implemented. (Both static and dynamic can occur in a single attribute set.)
Static attributes simply have a name and a value while dynamic attributes have a name, a value, and may optionally have a confidence, an accuracy range, an update time, and a sample interval time.