net.agmodel.physical
Class SynchronousStoreImpl

java.lang.Object
  extended bynet.agmodel.physical.StoreImpl
      extended bynet.agmodel.physical.SynchronousStoreImpl
All Implemented Interfaces:
Cloneable, Sequence, Serializable, Store

public class SynchronousStoreImpl
extends StoreImpl
implements Cloneable

An implementation of Store which uses an array to store data and their derivation Most suitable for regularly spaced data which continually fluctuate, such as hourly temperatures

Author:
Matthew Laurenson
See Also:
Serialized Form

Constructor Summary
SynchronousStoreImpl(Interval dateRange, SummaryHistory history, String name)
           
 
Method Summary
 Object clone()
           
 String dumpSequence(DateFormat df, String delimiter, String rowTerminator)
          Gets a printable version of the sequence contents.
Data is formatted with a line for each time interval.
The first field in the line is the date and time, formatted using the DateFormat passed as a parameter.
The data for that time interval follows, separated by the default delimiter, with a new line character at the end of the row.
 JigsawQuantity getAverage(Interval interval)
          Returns the average value of the time series over the interval.
 int getCapacity()
          Returns the number of possible data values in the store.
 String getContentsAsString(Date date, String delimiter)
          Returns the measurement associated with a particular time as a string.
 float[] getCoverage()
          Creates an array representing the coverage of the data returned by getData().
 double[] getData()
          Creates an array containing the data from the store.
 JigsawQuantity getInstant(Date time)
          Returns the instantaneous value of the time series at a particular point in time.
 JigsawQuantity getMaximum(Interval interval)
          Returns the maximum value of the time series over the interval.
 JigsawQuantity getMinimum(Interval interval)
          Returns the minimum value of the time series over the interval.
 int getNumberOfSubComponents()
          Get the number of sub-components in the sequence.
 double getNumberOfValues()
          Returns the number of data values in the store
 String getSequenceHeading(String delimiter)
          Returns a localized top level description of the kind of data stored in the sequence.
 String getSubHeading(String delimiter)
          Gets a localized subheading, assumed to be in the context of an overall column heading.
 JigsawQuantity getTotal(Interval interval)
          Returns the total value of the sequence over the interval.
 String getUnitsHeading(String delimiter)
          Gets a string representation of the measurement units of the column.
 void putInstantValue(Date time, double value)
          Records the instantaneous value of the time series at a particular time
 void putValueOverInterval(Interval interval, double value)
          Records the value of the timeseries over some subinterval.
 void putValueOverInterval(Interval interval, JigsawQuantity value)
          Records the value of the timeseries over some subinterval, its coverage, and the extent to which it was interpolated.
 String toString()
           
 
Methods inherited from class net.agmodel.physical.StoreImpl
averageStore, averageStore, extendStore, extendStore, getColumnHeading, getCurrentResolution, getDateRange, getName, getResolution, getSummaryHistory, getSummaryKind, maximumStore, maximumStore, minimumStore, minimumStore, sampleStore, sampleStore, setColumnHeading, setName, totalStore, totalStore
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SynchronousStoreImpl

public SynchronousStoreImpl(Interval dateRange,
                            SummaryHistory history,
                            String name)
Method Detail

getNumberOfValues

public double getNumberOfValues()
Description copied from interface: Store
Returns the number of data values in the store

Specified by:
getNumberOfValues in interface Store
Returns:
the number of data values stored. If the data is summarised, this may be fractional

getCapacity

public int getCapacity()
Returns the number of possible data values in the store.


getInstant

public JigsawQuantity getInstant(Date time)
Description copied from interface: Store
Returns the instantaneous value of the time series at a particular point in time. If interpolation is requested, the value may be spatially and/or temporally interpolated from other data.

Specified by:
getInstant in interface Store
Specified by:
getInstant in class StoreImpl

getTotal

public JigsawQuantity getTotal(Interval interval)
Description copied from interface: Store
Returns the total value of the sequence over the interval. Weighted contributions from sequence values at either end of the interval are included based on the extent to which they "fall into" the interval. Point measurements are interpreted as if they represented an interval ending at the sample time. If data is missing, the total returned is just the total of the available data; the returned value not scaled up in any way. This ensures that, for example, rainfall for the current day is not overestimated.

Specified by:
getTotal in interface Store
Specified by:
getTotal in class StoreImpl

getAverage

public JigsawQuantity getAverage(Interval interval)
Description copied from interface: Store
Returns the average value of the time series over the interval. Sequence values at either end of the interval are included by weighting their values according to the proportion of their duration that lies in the period of interest.

Specified by:
getAverage in interface Store
Specified by:
getAverage in class StoreImpl

getMaximum

public JigsawQuantity getMaximum(Interval interval)
Description copied from interface: Store
Returns the maximum value of the time series over the interval. Sequence values at either end of the interval are included in the comparison if more than 50% of their duration lies within the interval of interest. If exactly 50% of their duration lies within the interval, then the first measurement is omitted and the last measurement is included

Specified by:
getMaximum in interface Store
Specified by:
getMaximum in class StoreImpl

getMinimum

public JigsawQuantity getMinimum(Interval interval)
Description copied from interface: Store
Returns the minimum value of the time series over the interval. Sequence values at either end of the interval are included in the comparison if more than 50% of their duration lies within the interval of interest. If exactly 50% of their duration lies within the interval, then the first measurement is omitted and the last measurement is included

Specified by:
getMinimum in interface Store
Specified by:
getMinimum in class StoreImpl

putInstantValue

public void putInstantValue(Date time,
                            double value)
Description copied from interface: Store
Records the instantaneous value of the time series at a particular time

Specified by:
putInstantValue in interface Store
Specified by:
putInstantValue in class StoreImpl

putValueOverInterval

public void putValueOverInterval(Interval interval,
                                 double value)
Description copied from interface: Store
Records the value of the timeseries over some subinterval. It is assumed that the subinterval coverage is complete (ie there is no missing data in the subinterval) and that no interpolation took place.
If the store contains totalled data, and interval>currentResolution, then the data will be evenly distributed between the "cells" of the store.

Specified by:
putValueOverInterval in interface Store
Specified by:
putValueOverInterval in class StoreImpl

putValueOverInterval

public void putValueOverInterval(Interval interval,
                                 JigsawQuantity value)
Description copied from interface: Store
Records the value of the timeseries over some subinterval, its coverage, and the extent to which it was interpolated. If the store contains totalled data, and interval>currentResolution, then the data will be evenly distributed between the "cells" of the store.

Specified by:
putValueOverInterval in interface Store
Specified by:
putValueOverInterval in class StoreImpl

getSequenceHeading

public String getSequenceHeading(String delimiter)
Description copied from interface: Sequence
Returns a localized top level description of the kind of data stored in the sequence. This value can be used as a column heading if the sequence is listed. If there is more than one component in the heading, this value is right-padded with additional delimiters - one for each component.

Specified by:
getSequenceHeading in interface Sequence
Parameters:
delimiter - the delimiter to use if padding is required for multiple columns

getSubHeading

public String getSubHeading(String delimiter)
Description copied from interface: Sequence
Gets a localized subheading, assumed to be in the context of an overall column heading.

Specified by:
getSubHeading in interface Sequence
Parameters:
delimiter - the delimiter to use between columns if there are multiple columns
See Also:
Sequence.getNumberOfSubComponents(), Sequence.getSequenceHeading(String)

getUnitsHeading

public String getUnitsHeading(String delimiter)
Description copied from interface: Sequence
Gets a string representation of the measurement units of the column. This value is typically used as part of the column heading when the sequence is listed. It is assumed to be in the context of an overall column heading.

Specified by:
getUnitsHeading in interface Sequence
Parameters:
delimiter - the delimiter to use between columns if there are multiple columns
See Also:
Sequence.getNumberOfSubComponents(), Sequence.getSequenceHeading(String), Sequence.getSubHeading(String)

getNumberOfSubComponents

public int getNumberOfSubComponents()
Description copied from interface: Sequence
Get the number of sub-components in the sequence. This indicates how many "columns" the sequence output will occupy.

Specified by:
getNumberOfSubComponents in interface Sequence
Returns:
the number of sub-components
See Also:
Sequence.getSequenceHeading(String)

getContentsAsString

public String getContentsAsString(Date date,
                                  String delimiter)
Description copied from interface: Sequence
Returns the measurement associated with a particular time as a string. Used by dumpSequence.

Specified by:
getContentsAsString in interface Sequence
Parameters:
date - the time of interest.
delimiter - a string to use between values if required.

dumpSequence

public String dumpSequence(DateFormat df,
                           String delimiter,
                           String rowTerminator)
Description copied from interface: Sequence
Gets a printable version of the sequence contents.
Data is formatted with a line for each time interval.
The first field in the line is the date and time, formatted using the DateFormat passed as a parameter.
The data for that time interval follows, separated by the default delimiter, with a new line character at the end of the row.

Specified by:
dumpSequence in interface Sequence
Parameters:
df - the format to use for the date and time
delimiter - the separator to use between the date and the data
rowTerminator - the String used at the end of each row
Returns:
a string containing all the sequences data with formatted times.

getData

public double[] getData()
Description copied from interface: Store
Creates an array containing the data from the store. You should use Store.getCoverage() to test for the coverage. (Missing values are returned as Double.NaN at present, but this might change.)
Note that the first element of the array corresponds to getStart() and is therefore empty in most cases.

Specified by:
getData in interface Store
Specified by:
getData in class StoreImpl

getCoverage

public float[] getCoverage()
Description copied from interface: Store
Creates an array representing the coverage of the data returned by Store.getData().

Specified by:
getCoverage in interface Store
Specified by:
getCoverage in class StoreImpl

clone

public Object clone()
Specified by:
clone in interface Sequence
Overrides:
clone in class StoreImpl

toString

public String toString()


Copyright (C) NARC 2001 All Rights Reserved.