com.jstatcom.io
Class TSGaussFMTHandler
- java.lang.Object
-
- com.jstatcom.io.TSGaussFMTHandler
-
- All Implemented Interfaces:
- DataHandler
public final class TSGaussFMTHandler extends java.lang.Object implements DataHandler
Class for importing files from Gauss.fmtfiles. There are 4 supported formats, see the Gauss reference manual for a specification of the binary formats:- Small Matrix v89
- Extended Matrix v89
- Matrix v92
- Universal Matrix v96
Version v96 is also supported for exporting data via a static method.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidexportData(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.voidexportTS(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.JSCDatagetData(ImportTypes type)Gets the imported data according to an instance ofTSImportTypes.static TSGaussFMTHandlergetInstance()Gets the singleton instance of this handler.static java.lang.String[]getNamesArray(java.io.File fName, int cols, java.lang.String namesFromDialog)Helper method to get an array of valid variable names.booleanimportData(java.io.File file)Initiates parsing of .fmt Gauss matrix file.voidsetTestMode(boolean noDialog)Sets this handler in test mode.
-
-
-
Method Detail
-
getInstance
public static TSGaussFMTHandler getInstance()
Gets the singleton instance of this handler.- Returns:
- instance
-
getNamesArray
public static java.lang.String[] getNamesArray(java.io.File fName, int cols, java.lang.String namesFromDialog)Helper method to get an array of valid variable names.- Parameters:
fName- filename of the file to be read incols- number of columns with numerical datanamesFromDialog- string with space separated names, typically from a dialog, for example"a b c d"- Returns:
- a cols x 1 string array with valid names that are either
assembled from
fNameand an index or fromnamesFromDialog
-
importData
public boolean importData(java.io.File file)
Initiates parsing of .fmt Gauss matrix file.- Specified by:
importDatain interfaceDataHandler- Parameters:
file- the file to read in- Returns:
trueof import was ok,falseif cancelled or erroneous- Throws:
java.lang.IllegalArgumentException-if (file == null || !file.isFile())java.lang.RuntimeException- when file reading fails
-
getData
public JSCData getData(ImportTypes type)
Gets the imported data according to an instance ofTSImportTypes.- Specified by:
getDatain interfaceDataHandler- Parameters:
type- the elementtype of a time series dataset- Returns:
- the data stored as
JSCData - Throws:
java.lang.IllegalArgumentException-if (type == null)java.lang.IllegalStateException- if nothing was imported before
-
exportTS
public void exportTS(java.io.File file, TS[] ts, java.lang.String description)Description copied from interface:DataHandlerExports 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.
- Specified by:
exportTSin interfaceDataHandler- Parameters:
file- the file to store the time series tots- array of time series to exportdescription- an optional dataset description that handler implementations might use
-
exportData
public void exportData(java.io.File file, JSCData data, java.lang.String description)Description copied from interface:DataHandlerExports data to a file in the format that the respective implementation of this interface handles. This method should throw an exception if the type ofdatais not suppported.Implementations of this method should throw unchecked exceptions in case of errors, which should be dealt with by the calling objects.
- Specified by:
exportDatain interfaceDataHandler- Parameters:
file- the file to store the data todata- the data object to store, must be supporteddescription- an optional description that handler implementations might use
-
setTestMode
public void setTestMode(boolean noDialog)
Sets this handler in test mode. No user dialog is shown, default values are used instead. This is helpful for running automated unit tests.- Parameters:
noDialog-
-
-
DMelt 3.0 © DataMelt by jWork.ORG