com.jstatcom.io
Interface DataHandler

All Known Implementing Classes:
TSASCIIHandler, TSExcelHandler, TSGaussDATHandler, TSGaussFMTHandler, TSMatlabHandler

public interface DataHandler

Interface to be implemented by classes that initiate parsing of data files and the creation of datasets. It can be used to import all kinds of datasets, because it does not rely on a distinct dataset class. It only uses the convention that elements of the dataset are stored as JSCData objects and that there exist ImportTypes defining the structure of a dataset.

The implementations of DataHandler should check whether a created dataset is in a consistent state when it can be accessed via getData.

Author:
Markus Kraetzig

Method Summary
 void exportData(java.io.File file, JSCData data, java.lang.String description)
          Exports data to a file in the format that the respective implementation of this interface handles.
 void exportTS(java.io.File file, TS[] ts, java.lang.String description)
          Exports time series to a file in the format that the respective implementation of this interface handles.
 JSCData getData(ImportTypes type)
          Gets the imported data according to the respective type, which defines the kind of information to retrieve from the imported dataset.
 boolean importData(java.io.File file)
          Parses file and collects the data as JSCData objects in a SymbolTable.
 

Method Detail

importData

boolean importData(java.io.File file)
Parses file and collects the data as JSCData objects in a SymbolTable. In case of an error this method should throw an exception. The return parameter should only indicate that the import operation was cancelled.

Parameters:
file - the file containing the data
Returns:
true of import was ok, false if cancelled

getData

JSCData getData(ImportTypes type)
Gets the imported data according to the respective type, which defines the kind of information to retrieve from the imported dataset.

Parameters:
type - defines the element of the dataset to get, for example the start date
Returns:
the data stored as JSCData

exportTS

void exportTS(java.io.File file,
              TS[] ts,
              java.lang.String description)
Exports time series to a file in the format that the respective implementation of this interface handles.

Implementation Note:
Not every handler implementation uses all information contained in a time series. For example, some handlers might not store the variable names, the date, and the description, because this may not be supported by the respective format.

Implementations of this method should throw unchecked exceptions in case of errors, which should be dealt with by the calling objects.

Parameters:
file - the file to store the time series to
ts - array of time series to export
description - an optional dataset description that handler implementations might use

exportData

void exportData(java.io.File file,
                JSCData data,
                java.lang.String description)
Exports data to a file in the format that the respective implementation of this interface handles. This method should throw an exception if the type of data is not suppported.

Implementations of this method should throw unchecked exceptions in case of errors, which should be dealt with by the calling objects.

Parameters:
file - the file to store the data to
data - the data object to store, must be supported
description - an optional description that handler implementations might use