edu.washington.NVisF.dataIO
Class BinaryDataFileReader

java.lang.Object
  |
  +--edu.washington.NVisF.dataIO.DataReader
        |
        +--edu.washington.NVisF.dataIO.BinaryDataFileReader
Direct Known Subclasses:
SandPileReader, SSFileReader, TipsyFileReader

public abstract class BinaryDataFileReader
extends DataReader

BinaryDataFileReader extends DataReader to support readers of binary data files, providing simple implementations of the connection and meta-info methods. A subclass only needs to provide one initConnection() method (which usually reads the data from file into memory, and must create the TypeInfo object) and the data access methods.


Constructor Summary
BinaryDataFileReader()
           
 
Method Summary
 void closeConnection()
          does whatever work is needed to close the connection
abstract  int getCount(java.lang.String predicate)
          returns the number of objects that satisfy the given predicate.
abstract  float[] getScalar(java.lang.String predicate, java.lang.String dataField)
          returns an array of floats containing the specified scalar field element for all data objects that satisfy the given predicate.
 TypeInfo getTypeInfo()
          retrieves a description of the data available from this source as a TypeInfo object.
abstract  float[][] getVector(java.lang.String predicate, java.lang.String dataField)
          returns an array of arrays containing the specified vector field element for all data objects that satisfy the given predicate.
abstract  void initConnection(java.io.InputStream in)
           
 void initConnection(java.lang.String source)
          initiates a connection to the data source represented by the given String.
 void initConnection(java.net.URL source)
          initiates a connection to the data source represented by the given URL.
 boolean isConnectionOpen()
          tests whether an active connection exists
abstract  void loadData(java.lang.String predicate, java.lang.String[] dataFields)
          instructs this DataReader to gather and store the requested data for later access.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryDataFileReader

public BinaryDataFileReader()
Method Detail

isConnectionOpen

public boolean isConnectionOpen()
Description copied from class: DataReader
tests whether an active connection exists
Overrides:
isConnectionOpen in class DataReader
Following copied from class: edu.washington.NVisF.dataIO.DataReader
Returns:
true if a connection is active; false otherwise

initConnection

public void initConnection(java.lang.String source)
                    throws OpenConnectionException,
                           SourceNotFoundException,
                           DataIOException
Description copied from class: DataReader
initiates a connection to the data source represented by the given String.
Overrides:
initConnection in class DataReader
Following copied from class: edu.washington.NVisF.dataIO.DataReader
Parameters:
source - a string specifying the location of the data source
Throws:
OpenConnectionException - if a connection is already established
SourceNotFoundException - if the specified resource could not be found
DataIOException - if the attempt to open the connection fails

initConnection

public void initConnection(java.net.URL source)
                    throws OpenConnectionException,
                           SourceNotFoundException,
                           DataIOException
Description copied from class: DataReader
initiates a connection to the data source represented by the given URL.
Overrides:
initConnection in class DataReader
Following copied from class: edu.washington.NVisF.dataIO.DataReader
Parameters:
source - a URL specifying the location of the data source
Throws:
OpenConnectionException - if a connection is already established
SourceNotFoundException - if the specified resource could not be found
DataIOException - if the attempt to open the connection fails

initConnection

public abstract void initConnection(java.io.InputStream in)
                             throws DataIOException

closeConnection

public void closeConnection()
                     throws NoConnectionException,
                            DataIOException
Description copied from class: DataReader
does whatever work is needed to close the connection
Overrides:
closeConnection in class DataReader
Following copied from class: edu.washington.NVisF.dataIO.DataReader
Throws:
NoConnectionException - if there is no active connection
DataIOException - if the attempt to close the connection fails

getTypeInfo

public TypeInfo getTypeInfo()
                     throws NoConnectionException
Description copied from class: DataReader
retrieves a description of the data available from this source as a TypeInfo object.
Overrides:
getTypeInfo in class DataReader
Following copied from class: edu.washington.NVisF.dataIO.DataReader
Returns:
a TypeInfo object containing meta-data information
Throws:
NoConnectionException - if there is no ative connection
See Also:
TypeInfo

getCount

public abstract int getCount(java.lang.String predicate)
                      throws java.text.ParseException,
                             NoConnectionException,
                             DataIOException
Description copied from class: DataReader
returns the number of objects that satisfy the given predicate. Note that in the current version, the only predicates supported are simply the name of a data object.
Overrides:
getCount in class DataReader
Following copied from class: edu.washington.NVisF.dataIO.DataReader
Parameters:
predicate - a string in the query language that identifies the desired objects
Returns:
int the number of objects
Throws:
java.text.ParseException - if the predicate cannot be parsed
NoConnectionException - if there is no active connection
DataIOException - if an unexpected error occurs

loadData

public abstract void loadData(java.lang.String predicate,
                              java.lang.String[] dataFields)
                       throws java.text.ParseException,
                              NoConnectionException,
                              DataIOException
Description copied from class: DataReader
instructs this DataReader to gather and store the requested data for later access. The first argument identifies what objects to get data for, and the second identifies what fields to retrieve. If the second argument is null, then all fields are retrieved. Using this method may significantly speed up later calls to getData for this predicate. Note that in the current version, the only predicates supported are simply the name of a data object. This method is not guaranteed to be implemented by all subclasses. The default implementation is to do nothing.
Overrides:
loadData in class DataReader
Following copied from class: edu.washington.NVisF.dataIO.DataReader
Parameters:
predicate - a string in the query language that identifies the desired objects
fields - an array of strings giving the names of the desired fields
Throws:
java.text.ParseException - if the predicate cannot be parsed
NoConnectionException - if there is no active connection
DataIOException - if an unexpected error occurs
See Also:
DataReader.getScalar(java.lang.String, java.lang.String), DataReader.getVector(java.lang.String, java.lang.String)

getScalar

public abstract float[] getScalar(java.lang.String predicate,
                                  java.lang.String dataField)
                           throws java.text.ParseException,
                                  NoConnectionException,
                                  DataIOException
Description copied from class: DataReader
returns an array of floats containing the specified scalar field element for all data objects that satisfy the given predicate. The first argument is a string in the query language specifying the desired objects, while the second is a string giving the name of the field to return. Note that in the current version, the only predicates supported are simply the name of a data object, and data for all objects of that type are returned. This method is not guaranteed to be implemented by all subclasses. The default implementation throws a DataIOException identifying the non-implementing class. A null value is returned if the requested data object type does not exist, or if the requested data field is not defined as a scalar field element for that data object type.
Overrides:
getScalar in class DataReader
Following copied from class: edu.washington.NVisF.dataIO.DataReader
Parameters:
predicate - a string in the query language that identifies the desired objects
dataField - a string specifying the scalar field to be returned
Returns:
float[] containing the array of scalars, or null if no matches were found
Throws:
java.text.ParseException - if the predicate cannot be parsed
NoConnectionException - if there is no active connection
DataIOException - if an unexpected error occurs
See Also:
DataReader.loadData(java.lang.String, java.lang.String[])

getVector

public abstract float[][] getVector(java.lang.String predicate,
                                    java.lang.String dataField)
                             throws java.text.ParseException,
                                    NoConnectionException,
                                    DataIOException
Description copied from class: DataReader
returns an array of arrays containing the specified vector field element for all data objects that satisfy the given predicate. That is, the desired vector is represented as an array of floats (usually 3, for a 3-D system), and the return type is an array of these arrays with length N, where N is the number of matching data objects. The first argument is a string in the query language specifying the desired objects, while the second is a string giving the name of the field to return. Note that in the current version, the only predicates supported are simply the name of a data object, and data for all objects of that type are returned. This method is not guaranteed to be implemented by all subclasses. The default implementation throws a DataIOException identifying the non-implementing class. A null value is returned if the requested data object type does not exist, or if the requested data field is not defined as a vector field element for that data object type.
Overrides:
getVector in class DataReader
Following copied from class: edu.washington.NVisF.dataIO.DataReader
Parameters:
predicate - a string in the query language that identifies the desired objects
dataField - a string specifying the vector field to be returned
Returns:
float[][] containing the array of vectors, or null if no matches were found
Throws:
java.text.ParseException - if the predicate cannot be parsed
NoConnectionException - if there is no active connection
DataIOException - if an unexpected error occurs
See Also:
DataReader.loadData(java.lang.String, java.lang.String[])