Package jahuwaldt.js.datareader
Class TREETOPSDataReader
- java.lang.Object
-
- jahuwaldt.js.datareader.TREETOPSDataReader
-
- All Implemented Interfaces:
DataReader
,java.lang.Comparable<DataReader>
public class TREETOPSDataReader extends java.lang.Object implements DataReader
This class reads data from a NASA TREETOPS/CLVTOPS *.dat and matching *.crf file and returns a list of DataSet data structures containing the simulation data.Modified by: Joseph A. Huwaldt
- Version:
- November 23, 2019
- Author:
- Joseph A. Huwaldt, Date: March 17, 2017
-
-
Constructor Summary
Constructors Constructor Description TREETOPSDataReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
canReadData(java.lang.String pathName, java.io.BufferedInputStream input)
Method that determines if this reader can read data from the specified input stream.boolean
canWriteData()
Returns false.int
compareTo(DataReader o)
Compares this object with the specified object for order based on thetoString().compareTo(o.toString())
method.java.lang.String
getExtension()
Returns the preferred file extension (not including the ".") for files of this DataReader's type.java.util.List<DataSet>
read(java.lang.String pathName, java.io.InputStream input)
Method that reads in CLVTOPS formatted simulation data from the specified input stream and returns that data as a list ofDataSet
objects.java.util.List<DataSet>
selectDataForSaving(java.awt.Frame parent, java.util.List<DataSet> data)
This class can not write to the CLVTOPS format file(s), so this method always throws an exception.void
setDefaultSetName(java.lang.CharSequence name)
Sets the default set name to use.java.lang.String
toString()
Returns a string representation of the object.void
write(java.io.OutputStream output, java.util.List<DataSet> data)
Method that writes out the data stored in the specifiedDataSet
object to the specified output stream in CLVTOPS format.
-
-
-
Field Detail
-
EXTENSION
public static final java.lang.String EXTENSION
-
-
Constructor Detail
-
TREETOPSDataReader
public TREETOPSDataReader()
-
-
Method Detail
-
toString
public java.lang.String toString()
Returns a string representation of the object. This will return a brief description of the format read by this reader.- Overrides:
toString
in classjava.lang.Object
-
getExtension
public java.lang.String getExtension()
Returns the preferred file extension (not including the ".") for files of this DataReader's type.- Specified by:
getExtension
in interfaceDataReader
- Returns:
- The preferred file extension for this file's type.
-
compareTo
public int compareTo(DataReader o)
Compares this object with the specified object for order based on thetoString().compareTo(o.toString())
method. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Specified by:
compareTo
in interfacejava.lang.Comparable<DataReader>
-
canReadData
public int canReadData(java.lang.String pathName, java.io.BufferedInputStream input) throws java.io.IOException
Method that determines if this reader can read data from the specified input stream.- Specified by:
canReadData
in interfaceDataReader
- Parameters:
pathName
- The path to the file to be read.input
- An input stream containing the data to be read. Any methods that read from this stream must first set a mark and then reset back to that mark before the method returns (even if it returns with an exception).- Returns:
- DataReader.NO if the file is not recognized at all or DataReader.MAYBE if the file has an appropriate extension.
- Throws:
java.io.IOException
- If the input stream could not be read from.
-
canWriteData
public boolean canWriteData()
Returns false. This class can not write data to a CLVTOPS formatted file stream.- Specified by:
canWriteData
in interfaceDataReader
- Returns:
- Always returns false.
-
read
public java.util.List<DataSet> read(java.lang.String pathName, java.io.InputStream input) throws java.io.IOException
Method that reads in CLVTOPS formatted simulation data from the specified input stream and returns that data as a list ofDataSet
objects.- Specified by:
read
in interfaceDataReader
- Parameters:
pathName
- The path to the file to be read. In addition to the *.dat file that this should point to, there must be a *.crf file with the same prefix in the same directory that will also be read in.input
- An input stream containing the space delimited array data file (*.dat).- Returns:
- A list of DataSet objects that contains the data read in from the specified stream (will contain a single data set which will contain a single case with ArrayParam objects for each column).
- Throws:
java.io.IOException
- If there is a problem reading the specified stream.
-
setDefaultSetName
public void setDefaultSetName(java.lang.CharSequence name)
Sets the default set name to use.- Specified by:
setDefaultSetName
in interfaceDataReader
- Parameters:
name
- The name to use as the default set name.
-
selectDataForSaving
public java.util.List<DataSet> selectDataForSaving(java.awt.Frame parent, java.util.List<DataSet> data)
This class can not write to the CLVTOPS format file(s), so this method always throws an exception.- Specified by:
selectDataForSaving
in interfaceDataReader
- Parameters:
parent
-data
-- Returns:
-
write
public void write(java.io.OutputStream output, java.util.List<DataSet> data) throws java.io.IOException
Method that writes out the data stored in the specifiedDataSet
object to the specified output stream in CLVTOPS format. This method will throw an exception as writing to this format is not supported.- Specified by:
write
in interfaceDataReader
- Parameters:
output
- The output stream to which the data is to be written.data
- A list ofDataSet
objects containing data to be written out.- Throws:
java.io.IOException
- If there is a problem writing to the specified stream.
-
-