org.mbari.io
Class FlatFileReader

java.lang.Object
  extended byorg.mbari.io.FlatFileReader
Direct Known Subclasses:
OasisFileReader

public class FlatFileReader
extends java.lang.Object

Constructors initialize memory only, to actually read the data file call the readFile method. This is done because some data files are very large ( ~100MB) and reading them may take awhile. This allows a programmer to specify when the big performance hit occurs.

FlatFileReader is meant for files with equal numbers of values on each line. Lines that do not have the same number of values are ignored. It currently assumes that the most commonly occuring number of values on a line is the correct number of values.

Lines with the first charater of '#' or '%' are assumed to be comments

Author:
brian

Field Summary
protected  double[][] data
          Description of the Field
protected  java.io.File file
          Description of the Field
 
Constructor Summary
FlatFileReader(java.io.File f)
          Create a FlatFileReader and intialize memory.
FlatFileReader(java.io.File f, int n)
          Create a FlatFileReader and intialize memory.
FlatFileReader(java.lang.String s)
          Create a FlatFileReader and intialize memory.
FlatFileReader(java.lang.String s, int n)
          Create a FlatFileReader and intialize memory.
 
Method Summary
 int countColumns()
          Method to get the number of columns in the data array
 int countRows()
          Method to get the number of rows in the data array
 double[] getColumn(int column)
          Return a specific column of data.
 double[][] getData()
          Accesor method to access the data in the flat file
 double getData(int row, int column)
          Accesor method to access a single data point in the flat file
 java.lang.String getFilename()
          Accesor method to get the filename of read by the FlatFileReader
protected  void ID()
          Method declaration
static void main(java.lang.String[] args)
          Method declaration
 void readFile()
          This method does the actual reading of the data file.
 void setData(int row, int column, double n)
          This method is used to replace a single value in the array of data read from a flat file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

protected java.io.File file
Description of the Field


data

protected double[][] data
Description of the Field

Constructor Detail

FlatFileReader

public FlatFileReader(java.lang.String s)
               throws java.io.IOException
Create a FlatFileReader and intialize memory.

Parameters:
s - Name of file to read
Throws:
java.io.IOException - Description of the Exception

FlatFileReader

public FlatFileReader(java.io.File f)
               throws java.io.IOException
Create a FlatFileReader and intialize memory.

Parameters:
f - File object representing the file to be read
Throws:
java.io.IOException - Description of the Exception

FlatFileReader

public FlatFileReader(java.lang.String s,
                      int n)
               throws java.io.IOException
Create a FlatFileReader and intialize memory.

Parameters:
s - Name of file to read
n - Number of columns of data each line should have
Throws:
java.io.IOException - Description of the Exception

FlatFileReader

public FlatFileReader(java.io.File f,
                      int n)
               throws java.io.IOException
Create a FlatFileReader and intialize memory.

Parameters:
f - File object representing the file to be read
n - Number of columns of data each line should have
Throws:
java.io.IOException - Description of the Exception
Method Detail

readFile

public void readFile()
              throws java.io.IOException
This method does the actual reading of the data file. It tokenizes the line by using white spaces

Throws:
java.io.IOException

setData

public void setData(int row,
                    int column,
                    double n)
This method is used to replace a single value in the array of data read from a flat file. The array is accessed as data[row][column]

Parameters:
row - Row of desired value
column - Column of desired value
n - The value to be set at data[row][column]

getData

public double[][] getData()
Accesor method to access the data in the flat file

Returns:
data A double array of the data contained in the flat file

getData

public double getData(int row,
                      int column)
Accesor method to access a single data point in the flat file

Parameters:
column - Column of data array
row - Description of the Parameter
Returns:
d A single double value from data[row][column]

getFilename

public java.lang.String getFilename()
Accesor method to get the filename of read by the FlatFileReader

Returns:
filename The name of the file used to construct a FlatFileReader instance.

getColumn

public double[] getColumn(int column)
Return a specific column of data.

Parameters:
column - The column of data to fetch.
Returns:
The column of data specified by c

countRows

public int countRows()
Method to get the number of rows in the data array

Returns:
The number of rows of data read.

countColumns

public int countColumns()
Method to get the number of columns in the data array

Returns:
The number of columns of data read.

ID

protected void ID()
Method declaration

See Also:

main

public static void main(java.lang.String[] args)
Method declaration

Parameters:
args -
See Also: