net.agmodel.physical
Class GeneralSequenceImpl

java.lang.Object
  |
  +--net.agmodel.physical.GeneralSequenceImpl
All Implemented Interfaces:
Cloneable, CompoundSequence, Sequence, Serializable
Direct Known Subclasses:
GeneralMetSequenceImpl

public abstract class GeneralSequenceImpl
extends Object
implements CompoundSequence, Serializable, Cloneable

A general mechanism for implementing sequences. Descendent objects implement storage of sequences in various ways.

See Also:
Serialized Form

Field Summary
protected  Interval dateRange
           
protected  Duration maximumTemporalInterpolation
           
protected  SummaryHistory summaryHistory
           
 
Constructor Summary
GeneralSequenceImpl(Interval dateRange, SummaryHistory composition)
          Creates a general sequence implementation.
 
Method Summary
 void cancelTemporalInterpolation()
          Cancels any temporal interpolation in subsequent calls to getXXXX
 Object clone()
           
 String dumpSequence(DateFormat df, String delimiter, String rowTerminator)
          Gets a printable version of the sequence contents.
 float[][] getAllCoverage()
          Indicates which array elements returned by getAllData() are missing.
 double[][] getAllData()
          Creates a two-dimensional array containing the data.
abstract  String getContentsAsString(Date time, String delimiter)
          Returns the measurement associated with a particular time as a string.
abstract  float[] getCoverage(int index)
          Indicates which array elements returned by getData(int) are missing.
 Duration getCurrentResolution()
          Returns the current resolution of data in the sequence (eg daily);
abstract  double[] getData(int index)
          Creates a one-dimensional array containing one subcomponent of the data.
 Interval getDateRange()
          Returns the date range for which data can be stored in the sequence
 Duration getMaximumTemporalInterpolation()
          Returns the longest data gap over which values can be temporally interpolated
abstract  int getNumberOfSubComponents()
          Get the number of sub-components in the sequence.
 Duration getResolution()
          Returns the current resolution of data in the sequence (eg daily);
abstract  String getSequenceHeading(String delimiter)
          Returns a localized top level description of the kind of data stored in the sequence.
abstract  String getSubHeading(int index)
          Gets a brief description of the data stored in a Sequence subcomponent in the language of the default locale.
 String getSubHeading(String delimiter)
          Gets a localized subheading, assumed to be in the context of an overall column heading.
 SummaryHistory getSummaryHistory()
          Returns the summary history for the data stored in the sequence
 SummaryKind getSummaryKind()
          Returns the current summarykind of data in the sequence (eg averaged);
 boolean getTemporalInterpolation()
          Indicates whether temporal interpolation is enabled
abstract  String getUnitsHeading(int index)
          Gets a string representation of the measurement units of the column.
 String getUnitsHeading(String delimiter)
          Gets a string representation of the measurement units of the column.
abstract  void setSequenceHeading(String aHeading)
          Sets the brief top level description of the kind of data stored in the sequence in the language of the default locale.
abstract  void setSubHeading(int index, String aHeading)
          Sets the brief description of the kind of data stored in the sequence in the language of the default locale.
 void setTemporalInterpolation(Duration maximumTemporalInterpolation)
          Sets the longest data gap over which values can be temporally interpolated.
abstract  void setUnitsHeading(int index, String aHeading)
          Sets a string representation of the measurement units of the column.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.agmodel.physical.Sequence
getColumnHeading, getName, setColumnHeading, setName
 

Field Detail

summaryHistory

protected SummaryHistory summaryHistory

dateRange

protected Interval dateRange

maximumTemporalInterpolation

protected Duration maximumTemporalInterpolation
Constructor Detail

GeneralSequenceImpl

public GeneralSequenceImpl(Interval dateRange,
                           SummaryHistory composition)
Creates a general sequence implementation.

Parameters:
dateRange - the interval for which readings can be stored
composition - a record of how raw data has been summarised to make the sequence.
Method Detail

getDateRange

public Interval getDateRange()
Returns the date range for which data can be stored in the sequence

Specified by:
getDateRange in interface Sequence
Returns:
the date range

getCurrentResolution

public Duration getCurrentResolution()
Description copied from interface: Sequence
Returns the current resolution of data in the sequence (eg daily);

Specified by:
getCurrentResolution in interface Sequence

getResolution

public Duration getResolution()
Description copied from interface: Sequence
Returns the current resolution of data in the sequence (eg daily);

Specified by:
getResolution in interface Sequence

getSummaryKind

public SummaryKind getSummaryKind()
Description copied from interface: Sequence
Returns the current summarykind of data in the sequence (eg averaged);

Specified by:
getSummaryKind in interface Sequence

setTemporalInterpolation

public void setTemporalInterpolation(Duration maximumTemporalInterpolation)
Sets the longest data gap over which values can be temporally interpolated.

Specified by:
setTemporalInterpolation in interface CompoundSequence

cancelTemporalInterpolation

public void cancelTemporalInterpolation()
Cancels any temporal interpolation in subsequent calls to getXXXX

Specified by:
cancelTemporalInterpolation in interface CompoundSequence

getTemporalInterpolation

public boolean getTemporalInterpolation()
Indicates whether temporal interpolation is enabled

Specified by:
getTemporalInterpolation in interface CompoundSequence
Returns:
true if data can be temporally interpolated, false otherwise
See Also:
getMaximumTemporalInterpolation()

getMaximumTemporalInterpolation

public Duration getMaximumTemporalInterpolation()
Returns the longest data gap over which values can be temporally interpolated

Specified by:
getMaximumTemporalInterpolation in interface CompoundSequence
Returns:
the duration over which data can be interpolated, or null if interpolation is disabled
See Also:
getTemporalInterpolation()

getSequenceHeading

public abstract 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

setSequenceHeading

public abstract void setSequenceHeading(String aHeading)
Description copied from interface: CompoundSequence
Sets the brief top level description of the kind of data stored in the sequence in the language of the default locale. This value can be used as a column heading if the sequence is listed.

Specified by:
setSequenceHeading in interface CompoundSequence
Parameters:
aHeading - the new heading
See Also:
Sequence.getNumberOfSubComponents(), Sequence.getSequenceHeading(String)

getNumberOfSubComponents

public abstract 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)

getSubHeading

public abstract String getSubHeading(int index)
Description copied from interface: CompoundSequence
Gets a brief description of the data stored in a Sequence subcomponent in the language of the default locale. This value can be used as a column sub heading if the sequence is listed. It is assumed to be in the context of an overall column heading.

Specified by:
getSubHeading in interface CompoundSequence
See Also:
Sequence.getNumberOfSubComponents(), Sequence.getSequenceHeading(String)

setSubHeading

public abstract void setSubHeading(int index,
                                   String aHeading)
Description copied from interface: CompoundSequence
Sets the brief description of the kind of data stored in the sequence in the language of the default locale. This value can be used as a column sub heading if the sequence is listed. It is assumed to be in the context of an overall column heading.

Specified by:
setSubHeading in interface CompoundSequence
Parameters:
aHeading - the new heading
index - the zero-based index of the heading
See Also:
Sequence.getNumberOfSubComponents(), Sequence.getSequenceHeading(String)

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)

getUnitsHeading

public abstract String getUnitsHeading(int index)
Description copied from interface: CompoundSequence
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 CompoundSequence
See Also:
Sequence.getNumberOfSubComponents(), Sequence.getSequenceHeading(String), CompoundSequence.getSubHeading(int)

setUnitsHeading

public abstract void setUnitsHeading(int index,
                                     String aHeading)
Description copied from interface: CompoundSequence
Sets 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:
setUnitsHeading in interface CompoundSequence
Parameters:
index - the zero-based index of the heading
aHeading - the new heading
See Also:
Sequence.getNumberOfSubComponents(), CompoundSequence.setSequenceHeading(String), CompoundSequence.setSubHeading(int,String)

getContentsAsString

public abstract String getContentsAsString(Date time,
                                           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:
time - 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.

getSummaryHistory

public SummaryHistory getSummaryHistory()
Returns the summary history for the data stored in the sequence

Returns:
the composition

getAllData

public double[][] getAllData()
Description copied from interface: CompoundSequence
Creates a two-dimensional array containing the data. The subcomponent is represented by the first index (row), and time by the second index (column). This is because Java handles 2D arrays as arrays of arrays - it is about 4 x faster to create several large arrays rather than many small ones. Use CompoundSequence.getAllCoverage() to test for missing values (at present these are returned as Double.NaN but don't rely on this).
Note that the first element of the array corresponds to getStart() and is therefore empty in most cases.
eg. To print all the data:
 double[][] theData=getAllData();
 int components=getNumberOfSubComponents();
 for (int timeIndex=1;timeIndex

Specified by:
getAllData in interface CompoundSequence
Returns:
the data within the sequence, with each row representing one interval of time.

getData

public abstract double[] getData(int index)
Description copied from interface: CompoundSequence
Creates a one-dimensional array containing one subcomponent of the data. Use CompoundSequence.getCoverage(int) to test for missing values (at present these are returned as Double.NaN but don't rely on this).
Note that the first element of the array corresponds to getStart() and is therefore empty in most cases.

Specified by:
getData in interface CompoundSequence
Parameters:
index - the zero-based index of the subcomponent
Returns:
the subcomponent as a timeseries array.
See Also:
Sequence.getNumberOfSubComponents()

getAllCoverage

public float[][] getAllCoverage()
Description copied from interface: CompoundSequence
Indicates which array elements returned by CompoundSequence.getAllData() are missing. Coverage values are in the range JigsawQuantity.DEVOID to JigsawQuantity.COMPLETE.
Note that the first element of the array corresponds to getStart() and is therefore empty in most cases.

Specified by:
getAllCoverage in interface CompoundSequence
Returns:
an array with the same layout as that returned by getAllData()

getCoverage

public abstract float[] getCoverage(int index)
Description copied from interface: CompoundSequence
Indicates which array elements returned by CompoundSequence.getData(int) are missing. Coverage values are in the range JigsawQuantity.DEVOID to JigsawQuantity.COMPLETE.
Note that the first element of the array corresponds to getStart() and is therefore empty in most cases.

Specified by:
getCoverage in interface CompoundSequence
Parameters:
index - the zero-based index of the subcomponent
Returns:
a array of the same length as that returned by getData()

clone

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