Class 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
    • 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 the toString().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 of DataSet 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 specified DataSet object to the specified output stream in CLVTOPS format.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • EXTENSION

        public static final java.lang.String EXTENSION
    • 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 class java.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 interface DataReader
        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 the toString().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 interface java.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 interface DataReader
        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 interface DataReader
        Returns:
        Always returns false.
      • read

        public java.util.List<DataSetread​(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 of DataSet objects.
        Specified by:
        read in interface DataReader
        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 interface DataReader
        Parameters:
        name - The name to use as the default set name.
      • selectDataForSaving

        public java.util.List<DataSetselectDataForSaving​(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 interface DataReader
        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 specified DataSet 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 interface DataReader
        Parameters:
        output - The output stream to which the data is to be written.
        data - A list of DataSet objects containing data to be written out.
        Throws:
        java.io.IOException - If there is a problem writing to the specified stream.