|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.ogsadai.examples.dataResourceAccessor.TemperatureDataResourceAccessor
Example temperature sensor data resource accessor.
The range of valid temperatures is read from a file range.txt
provided within the data service resource directory to which this accessor belongs. The file consists of a minimum value and a maximum value each on separate lines.
Data service resources using this accessor expose the minimum and maximum values through resource properties with names:
{https://ogsadai.org.uk/demoNamespace}minValue
{https://ogsadai.org.uk/demoNamespace}maxValue
Field Summary | |
private static java.lang.String |
COPYRIGHT_NOTICE Copyright statement |
private float |
maxValue Maximum temperature value |
private StaticProperty |
maxValueProp Maximum temperature value resource property |
private float |
minValue Minimum temperature value |
private StaticProperty |
minValueProp Minimum temperature value resource property |
private java.lang.String |
mResourceName Name of data service resource |
private java.util.Random |
rand Random number generator |
Constructor Summary | |
TemperatureDataResourceAccessor() Constructor. |
Method Summary | |
Property[] |
getProperties() Gets the resource properties associated with the data resource accessor. |
float |
getTemperature() Get the current temperature of the sensor. |
void |
restoreFromConfig(java.io.File directory) Configures the data resource accessor by reading any relevant configuration files in the given directory. |
void |
setResourceName(java.lang.String resourceName) Sets the name of the resource. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.String COPYRIGHT_NOTICE
private java.lang.String mResourceName
private float minValue
private float maxValue
private StaticProperty minValueProp
private StaticProperty maxValueProp
private java.util.Random rand
Constructor Detail |
public TemperatureDataResourceAccessor()
Method Detail |
public void setResourceName(java.lang.String resourceName)
DataResourceAccessor
setResourceName
in interface DataResourceAccessor
resourceName
- Name of the data service resource which will use this data resource accessor to mediate access to a data resource.public void restoreFromConfig(java.io.File directory) throws DataResourceAccessorConfigException, DataResourceAccessorMetaDataException, DataResourceAccessorSetupException, java.lang.IllegalArgumentException
PersistInFiles
If a data service resource is being constructed by reading from a configuration file this method will be called once immediately after the setName
method is called. The data resource accessor should read its configuration from the files in the given directory of the data service resource which uses it.
Data resource accessors are free to add, amend or delete files in the given directory at any time throughout their lifetime. The exception to this rule is the dataResourceClassConfig.xml
file which must be left unaltered since this specifies the data resource accessor class name.
restoreFromConfig
in interface PersistInFiles
directory
- Directory containing the data service resource configuration files. This includes the data resource accessor configuration files.java.lang.IllegalArgumentException
- if the directory
argument is null
or is not a directory.DataResourceAccessorSetupException
- if an error occurs when setting up the data resource accessor after having read the configuration files.DataResourceAccessorConfigException
- if an error occurs reading the configuration files.DataResourceAccessorMetaDataException
- if an error occurs when constructing data resource accessor meta data properties.public Property[] getProperties()
DataResourceAccessor
This method should be called once after the readConfig
method has been called but before any other methods are called.
getProperties
in interface DataResourceAccessor
public float getTemperature()
getTemperature
in interface TemperatureProvider
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |