net.agmodel.physical
Class DataSetImpl

java.lang.Object
  |
  +--net.agmodel.physical.DataSetImpl
All Implemented Interfaces:
DataSet, Serializable, ServerResult
Direct Known Subclasses:
StationDataSetImpl

public class DataSetImpl
extends Object
implements DataSet, Serializable

A serializable implementation of DataSet which uses a HashMap to store Sequences.

See Also:
Serialized Form

Field Summary
protected  Interval interval
           
protected  Duration resolution
           
protected  Map sequences
           
 
Constructor Summary
DataSetImpl(Interval interval, Duration resolution)
           
 
Method Summary
 void addSequence(Object key, Sequence sequenceToAdd)
           
 String dumpDuration(DateFormat df, String delimiter, String rowTerminator, String timeHeader, String noData)
          Returns a string representation of the entire data set
 Interval getInterval()
          Gets the interval covered by the data set
 int getNumberOfRows()
          Gets the number of rows of data based on the data set's duration and resolution
 int getNumberOfSequences()
          Gets the number of data sequences
 Duration getResolution()
          Gets the resolution of the station data set
 Sequence getSequence(Object key)
          Gets the data, if it exists, for a particular weather element.
protected  Sequence[] getSequenceArray()
          Returns the sequences as a list (used in dumpDuration) May be overridden by descendant classes to order the output of dumpDuration.
 String toString()
          Returns a basic string representation of data set (without the actual data).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sequences

protected Map sequences

interval

protected Interval interval

resolution

protected Duration resolution
Constructor Detail

DataSetImpl

public DataSetImpl(Interval interval,
                   Duration resolution)
Method Detail

addSequence

public void addSequence(Object key,
                        Sequence sequenceToAdd)

getSequence

public Sequence getSequence(Object key)
Gets the data, if it exists, for a particular weather element.

Specified by:
getSequence in interface DataSet
Parameters:
key - an identifier for the required sequence.
Returns:
a concrete implementation of Sequence, or null if not data exists for that element.

toString

public String toString()
Returns a basic string representation of data set (without the actual data). See dumpDuration(java.text.DateFormat, java.lang.String, java.lang.String, java.lang.String, java.lang.String) for data output.

Overrides:
toString in class Object
Returns:
a string containing the station details

getInterval

public Interval getInterval()
Description copied from interface: DataSet
Gets the interval covered by the data set

Specified by:
getInterval in interface DataSet
Returns:
the interval

getResolution

public Duration getResolution()
Gets the resolution of the station data set

Specified by:
getResolution in interface DataSet
Returns:
the resolution (eg hourly or daily)

getNumberOfRows

public int getNumberOfRows()
Gets the number of rows of data based on the data set's duration and resolution

Specified by:
getNumberOfRows in interface DataSet
Returns:
the number of rows

getNumberOfSequences

public int getNumberOfSequences()
Gets the number of data sequences

Specified by:
getNumberOfSequences in interface DataSet
Returns:
the number of sequences

getSequenceArray

protected Sequence[] getSequenceArray()
Returns the sequences as a list (used in dumpDuration) May be overridden by descendant classes to order the output of dumpDuration.

Returns:
an array of sequences

dumpDuration

public String dumpDuration(DateFormat df,
                           String delimiter,
                           String rowTerminator,
                           String timeHeader,
                           String noData)
Description copied from interface: DataSet
Returns a string representation of the entire data set

Specified by:
dumpDuration in interface DataSet
Parameters:
df - a DateFormat to use for the dates and times
delimiter - the delimiter to put between the data items
rowTerminator - the string to use at the end of each row
timeHeader - a string to head the date/time column
noData - a string to show when there is no data
Returns:
a table of data, with colunn headings, and the first column being a date/time.