public class Table
extends java.util.LinkedHashMap<java.lang.String,double[]>
All data in the Table is stored as double.
However, if a time stamp column was found in the original File,
a long[] of time stamps may be retrieved.
Additionally, if a time stamp column is present, the sampling rate of the
data can be requested.
Note the difference between put and add.
put will behave exactly as described in the
Map interface.
add will add a column name-data pair to this Table.
| Constructor and Description |
|---|
Table(java.io.File theSource,
java.lang.String[] theColumnNames,
double[][] theData,
long[] theTimeStamps)
Constructs a
Table with its source set by theSource,
columns as given by theColumnNames, data as given by theData, and
time stamps as given by theTimeStamps. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(java.lang.String[] theColumnNames,
double[][] theColumnData)
Adds columns to the Table.
|
int |
getNrRows()
Returns the number of rows, or records, in this Table.
|
float |
getSamplingRate()
Returns the sampling rate (in Hz.) of the data in the Table.
|
java.lang.String |
getSource()
Return the full path of the original
File that was used
to create the Table. |
long[] |
getTimeStamps()
Returns the
long[] containing the time stamps. |
boolean |
hasTimeStamps()
Returns
true if this Table has a time stamp column, and
false otherwise. |
double[] |
put(java.lang.String theKey,
double[] theData)
Overridden put() avoids strange misalignments that will occur if
external classes call put directly.
|
boolean |
rename(java.lang.String theOldKey,
java.lang.String theNewKey)
Renames a column.
|
void |
setSamplingRate(float theRate)
Sets the sampling rate (in Hz.) of the data in the Table.
|
public Table(java.io.File theSource,
java.lang.String[] theColumnNames,
double[][] theData,
long[] theTimeStamps)
Table with its source set by theSource,
columns as given by theColumnNames, data as given by theData, and
time stamps as given by theTimeStamps.
The parameters theSource and theTimeStamps are both optional, and may
be null.
See add for restrictions on
theColumnNames and theData.
theSource - The File the Table is constructed from.theColumnNames - The names of the columns to add.theData - The data for each column to add.theTimeStamps - The time stamp for the records of the data.FileLoader,
add(String[], double[][])public int getNrRows()
public boolean hasTimeStamps()
true if this Table has a time stamp column, and
false otherwise.
The Table has a time stamp column if one of the columns in the
File handed to the file loader that
created the Table contained data that was successfully parsed as a
date format.
true iff this Table has a time stamp
column, false otherwise.FileLoaderpublic long[] getTimeStamps()
long[] containing the time stamps.
If hasTimeStamps() evaluates to
false, null is returned.
long[] containing the time stamps.hasTimeStamps()public float getSamplingRate()
The sampling rate it guessed based on the data.
If it is incorrect, it can be set by calling
setSamplingRate(float).
If hasTimeStamps() evaluates to
false, 1.0f is returned.
hasTimeStamps(),
setSamplingRate(float)public void setSamplingRate(float theRate)
If hasTimeStamps() evaluates to
false, this method has no real use.
hasTimeStamps()public java.lang.String getSource()
File that was used
to create the Table.String if there was an error resolving it.public void add(java.lang.String[] theColumnNames,
double[][] theColumnData)
For this method to succeed, the number of column names must be equal to the number of data columns. Additionally, all data columns must contain the same number of elements.
Columns will be added to the Table by taking the i-th name from theColumnNames, and the corresponding i-th data array from theColumnData.
theColumnNames - The column names.theColumnData - The column data.public double[] put(java.lang.String theKey,
double[] theData)
Table if the value is not
of the correct length.
Note that it is impossible to update the Value for a
Key, by calling put(Key, newValue).put in interface java.util.Map<java.lang.String,double[]>put in class java.util.HashMap<java.lang.String,double[]>theKey - The key.theData - The value, or data, associated with the key.null if it is of
incorrect length.public boolean rename(java.lang.String theOldKey,
java.lang.String theNewKey)
This is done by replacing the column with the Key
theOldKey, with a column with the Key theNewKey.
If the Table does not contain a Key theOldKey, this
method returns false.
theOldKey - The old key.theNewKey - The new key.true iff the renaming operation was
successful, false otherwise.