|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jstatcom.io.TSASCIIHandler
public final class TSASCIIHandler
Import handler for ASCII data files that either contain only the data points or are in the DAT format. It is designed as a singleton.
An example DAT file looks like:
<1960 Q1>
invest income cons
180 451 415
179 465 421
185 485 434
In line 1 the first number is number of variables, then the date of the first
observation and the periodicity.
Line 2 contains the variable names. The remaining lines are the ordered
observations. Any Description is added as a comment and must be included in / *
... * /.
Method Summary | |
---|---|
void |
exportData(java.io.File file,
JSCData data,
java.lang.String description)
Exports data to a file in ASCII format. |
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 an instance of TSImportTypes . |
static TSASCIIHandler |
getInstance()
Gets the singleton instance of this handler. |
boolean |
importData(java.io.File dataFile)
Initiates parsing of data file. |
void |
setTestMode(boolean noDialog)
Sets this handler in test mode. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static TSASCIIHandler getInstance()
public boolean importData(java.io.File dataFile)
importData
in interface DataHandler
dataFile
- the file to read in
true
of import was ok, false
if
canceled or erroneous
java.lang.IllegalArgumentException
- if (dataFile == null || !dataFile.isFile())
public JSCData getData(ImportTypes type)
TSImportTypes
.
getData
in interface DataHandler
type
- the elementtype of a time series dataset
JSCData
java.lang.IllegalArgumentException
- if (type == null)
java.lang.IllegalStateException
- if nothing was imported beforepublic void exportTS(java.io.File file, TS[] ts, java.lang.String description)
DataHandler
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.
exportTS
in interface DataHandler
file
- the file to store the time series tots
- array of time series to exportdescription
- an optional dataset description that handler implementations
might usepublic void exportData(java.io.File file, JSCData data, java.lang.String description)
display
method on the data
parameter.
Usage Note:
To store NARRAY
data with its full precision, make sure to
call data.setFormatString("%-s ")
before. Otherwise the
default formatter is used, which only stores 4 digits. Nothing happens if
data
is empty.
exportData
in interface DataHandler
file
- the file to store the data todata
- the data object to store, all JSCData
types are
supporteddescription
- an optional description that handler implementations might
use, can be null
java.lang.IllegalArgumentException
- if file
or data
is
null
java.lang.RuntimeException
- if file writing failspublic void setTestMode(boolean noDialog)
noDialog
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |