Class DataFile

java.lang.Object
org.opensourcephysics.display.DataAdapter
org.opensourcephysics.display.DataFile
All Implemented Interfaces:
Data

public class DataFile extends DataAdapter
  • Field Details

    • delimiters

      protected static String[] delimiters
  • Constructor Details

    • DataFile

      public DataFile(File file)
      Creates a DataFile using data in the given file.
      Parameters:
      fileName -
  • Method Details

    • getDataList

      public List<Data> getDataList()
      Some objects (eg, a Group) do not contain data, but a list of Data objects that do. This method is used by Data displaying tools to create as many pages as needed.
      Specified by:
      getDataList in interface Data
      Overrides:
      getDataList in class DataAdapter
      Returns:
      a list of Data objects, or null if this object contains data
    • open

      public void open(File file)
      Opens an xml or data file specified by name.
      Parameters:
      fileName - the file name
    • parseData

      public double[][] parseData(String dataString, String fileName)
      Parses character-delimited data from a string. This attempts to extract the following information from the string: 1. A title to be used for the tab name 2. One or more columns of double data values 3. Column names for the data columns
      Parameters:
      dataString - the data string
      fileName - name of file containing the data string (may be null)
      Returns:
      DatasetManager with parsed data, or null if none found
    • readFirstLine

      protected String readFirstLine(Reader in)
    • parseStrings

      protected static String[] parseStrings(String text, String delimiter)
      Parses a String into tokens separated by a specified delimiter. A token may be "".
      Parameters:
      text - the text to parse
      delimiter - the delimiter
      Returns:
      an array of String tokens
    • parseStrings

      protected static String[][] parseStrings(String text, String rowDelimiter, String colDelimiter)
      Parses a String into tokens separated by specified row and column delimiters.
      Parameters:
      text - the text to parse
      rowDelimiter - the column delimiter
      colDelimiter - the column delimiter
      Returns:
      a 2D array of String tokens
    • parseDoubles

      protected static double[] parseDoubles(String[] strings)
      Parses a String array into doubles. Unparsable strings are set to Double.NaN.
      Parameters:
      strings - the String array to parse
      Returns:
      an array of doubles
    • parseDoubles

      protected static double[][] parseDoubles(String text, String rowDelimiter, String colDelimiter)
      Parses a String into doubles separated by specified row and column delimiters.
      Parameters:
      text - the text to parse
      rowDelimiter - the column delimiter
      colDelimiter - the column delimiter
      Returns:
      a 2D array of doubles
    • getRowArray

      protected static double[] getRowArray(int rowCount)
      Returns an array of row numbers.
      Parameters:
      rowCount - length of the array
      Returns:
      the array