Plotting
Class PlotFileReader

java.lang.Object
  extended by Plotting.PlotFileReader

public class PlotFileReader
extends java.lang.Object

File reader class for plot files.

This class contains static functions for parsing plot data files.

The methods of his class parse the files and return an object containing the parsed data. The class of the returned object depends on the plot type: for two-D graphs and histograms, it is PlotData

Since:
1.0
See Also:
PlotData

Field Summary
static java.lang.String mErrorDescription
           
 
Constructor Summary
PlotFileReader()
           
 
Method Summary
static int ParseFloats(java.lang.String line, java.lang.Float[] arr, int maxFloats)
           
static int ParseSeparatorFloats(java.lang.String line, java.lang.Float[] arr, int beginIndex, int maxFloats, java.lang.String separator)
           
static PlotData<java.lang.Float> Read2DPlotDataFile(java.lang.String fileName)
          Parses a two dimensional plot file and returns PlotData.
static PlotData<java.lang.Float> ReadFinanceFile(java.lang.String fileName)
          Parse a finance data file saved from Yahoo finance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mErrorDescription

public static java.lang.String mErrorDescription
Constructor Detail

PlotFileReader

public PlotFileReader()
Method Detail

ParseFloats

public static int ParseFloats(java.lang.String line,
                              java.lang.Float[] arr,
                              int maxFloats)
                       throws java.lang.NumberFormatException,
                              java.io.IOException
Throws:
java.lang.NumberFormatException
java.io.IOException

ParseSeparatorFloats

public static int ParseSeparatorFloats(java.lang.String line,
                                       java.lang.Float[] arr,
                                       int beginIndex,
                                       int maxFloats,
                                       java.lang.String separator)
                                throws java.lang.NumberFormatException,
                                       java.io.IOException
Throws:
java.lang.NumberFormatException
java.io.IOException

Read2DPlotDataFile

public static PlotData<java.lang.Float> Read2DPlotDataFile(java.lang.String fileName)

Parses a two dimensional plot file and returns PlotData. File format is:

  1. Every line contains two floating point numbers, first X and second Y coordinate.
  2. Every point defines a new point on the plot, joined to the previous point.
  3. To break a plot, use break on a line.
Eg: 0 0 1 1 Defines a two point plot.

Parameters:
fileName - Name of file to be read.
Returns:
PlotData

ReadFinanceFile

public static PlotData<java.lang.Float> ReadFinanceFile(java.lang.String fileName)
Parse a finance data file saved from Yahoo finance. The file looks like: Date,Open,High,Low,Close,Volume,Adj Close 2008-08-26,11383.56,11483.62,11284.47,11412.87,3587570000,11412.87

Parameters:
fileName - Name of the file
Returns:
PlotData if file read operation was successful. All errors are recorded in mErrorDescription