ABLE 2.0.0 07/02/2003 10:25:01

com.ibm.able.beans
Class AbleDataSet

java.lang.Object
  |
  +--com.ibm.able.beans.AbleDataSet
All Implemented Interfaces:
AbleImportData, java.io.Serializable

public class AbleDataSet
extends java.lang.Object
implements AbleImportData, java.io.Serializable

This class describes and reads a text file. It uses an external data set called a definition file *.dfn which describes the field name, type (continuous/discrete/categorical), and usage (input/output/ignore). It reads a block of records specified by bufferSize into a textData vector where each element consists of an array of String objects.

See Also:
Serialized Form

Field Summary
protected  boolean allNumericData
          A boolean indicating whether all fields in the data source are continuous.
protected  int bufferSize
          An integer specifying the number of records to read from the database table and insert into the textData Vector.
protected  java.lang.String delimiter
          The delimiter is the character from the DelimiterChars Vector used to separate fields for this text file.
protected  java.util.Vector fieldList
          A Vector of AbleField elements in order of definition; ie, Vector index equals column number.
protected  java.lang.String fileName
          The path and file name to the definition and data files to be read.
protected  java.io.BufferedReader in
          The BufferedReader used to read the file.
static int MAX_BUFFER_SIZE
          The maximum number of records which may be read.
protected  long numRecords
          A long calculated to be the number of records in the database table.
protected  boolean ready
          A boolean indicating whether the file is ready for processing.
protected  java.util.Vector textData
          A Vector of String arrays containing records from the file.
 
Constructor Summary
AbleDataSet(java.lang.String fileName)
          Construct an AbleDataSet object for a given file.
 
Method Summary
 void close()
          Close the BufferedReader on the data file (if open).
static java.lang.String Copyright()
          Determine the copyright of this class.
protected  AbleField createAbleField(AbleFieldDefinition definition)
          Construct a corresponding AbleField from an AbleFieldDefinition.
 void displayVariables()
          Display the fieldList and its values.
 int getBufferSize()
          Return the number of records to place in the textData Vector each time a record block is read with readNextRecordBlock.
 java.lang.String getDelimiter()
           
 java.util.Vector getFieldList()
          Return a Vector of AbleField objects where each object describes a data column.
 int getNumFieldsPerRec()
          Return the number of fields in each record.
 long getNumRecords()
          Return the number of records in this database table.
 java.util.Vector getTextData()
          Returns a Vector of String[] objects representing all loaded text data.
 boolean isAllNumericData()
          Returns true if all fields are "continuous", false if any are "discrete" or "categorical" (i.e.
 boolean isReady()
          Return a boolean indicating whether or not the file is ready for processing.
 void loadDataFile()
          Load the entire data file from a text file into a vector of String arrays.
 void open()
          Open the data set definition named fileName.
 void readNextRecordBlock()
          Read the next n records from a file into a vector of String arrays.
 void reopen()
          Reopen (recreate) the BufferedReader on the text file.
 void setBufferSize(int size)
          Set the number of records to place in the textData Vector each time a record block is read with readNextRecordBlock.
 void setDelimiter(java.lang.String delimiter)
           
 void setFieldList(java.util.Vector fieldList)
          Set a Vector of AbleField objects where each object describes a data column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_BUFFER_SIZE

public static final int MAX_BUFFER_SIZE
The maximum number of records which may be read.

fileName

protected java.lang.String fileName
The path and file name to the definition and data files to be read.

in

protected transient java.io.BufferedReader in
The BufferedReader used to read the file.

allNumericData

protected boolean allNumericData
A boolean indicating whether all fields in the data source are continuous.

textData

protected java.util.Vector textData
A Vector of String arrays containing records from the file. The Vector contains all records if bufferSize is 0.

fieldList

protected java.util.Vector fieldList
A Vector of AbleField elements in order of definition; ie, Vector index equals column number.

bufferSize

protected int bufferSize
An integer specifying the number of records to read from the database table and insert into the textData Vector. A value of 0 means all records are to be read.

numRecords

protected long numRecords
A long calculated to be the number of records in the database table.

delimiter

protected java.lang.String delimiter
The delimiter is the character from the DelimiterChars Vector used to separate fields for this text file. Default is blank white space (" ").

ready

protected boolean ready
A boolean indicating whether the file is ready for processing.
Constructor Detail

AbleDataSet

public AbleDataSet(java.lang.String fileName)
Construct an AbleDataSet object for a given file.
Parameters:
fileName - A String containing the path and name for the definition and data file to read.
Method Detail

isReady

public boolean isReady()
Return a boolean indicating whether or not the file is ready for processing.
Specified by:
isReady in interface AbleImportData

displayVariables

public void displayVariables()
Display the fieldList and its values.

createAbleField

protected AbleField createAbleField(AbleFieldDefinition definition)
                             throws AbleException
Construct a corresponding AbleField from an AbleFieldDefinition. Categorical, continuous, and discrete are supported.
Parameters:
definition - An AbleFieldDefinition.
Returns:
A corresponding AbleField object.
Throws:
An - exception if the AbleFieldDefinition provided is unsupported.

getNumFieldsPerRec

public int getNumFieldsPerRec()
Return the number of fields in each record.
Specified by:
getNumFieldsPerRec in interface AbleImportData

open

public void open()
          throws AbleException
Open the data set definition named fileName. Create a BufferedReader over the specified text file, read the *.dfn file and create the fieldList if needed for this data set. Read each record in the data file, and populate the textData Vector with as many records as specified by the bufferSize.
Specified by:
open in interface AbleImportData

reopen

public void reopen()
            throws AbleException
Reopen (recreate) the BufferedReader on the text file. This should only be called directly when the file has changed. It does not reload the data definition.

close

public void close()
Close the BufferedReader on the data file (if open).
Specified by:
close in interface AbleImportData

loadDataFile

public void loadDataFile()
                  throws AbleException
Load the entire data file from a text file into a vector of String arrays. Assumes the data file definition (variables) has already been loaded.

readNextRecordBlock

public void readNextRecordBlock()
                         throws AbleException
Read the next n records from a file into a vector of String arrays. Assumes that the fieldList and textData Vectors have already been created, and the file opened. When the last record in the file is found, wrap back to the first record and continue populating elements of the textData Vector until its size reaches the bufferSize.
Specified by:
readNextRecordBlock in interface AbleImportData

getTextData

public java.util.Vector getTextData()
Returns a Vector of String[] objects representing all loaded text data. Note: This represents the original data as read from the file.
Specified by:
getTextData in interface AbleImportData

isAllNumericData

public boolean isAllNumericData()
Returns true if all fields are "continuous", false if any are "discrete" or "categorical" (i.e. symbols).
Specified by:
isAllNumericData in interface AbleImportData

setBufferSize

public void setBufferSize(int size)
Set the number of records to place in the textData Vector each time a record block is read with readNextRecordBlock.
Specified by:
setBufferSize in interface AbleImportData

getBufferSize

public int getBufferSize()
Return the number of records to place in the textData Vector each time a record block is read with readNextRecordBlock.
Specified by:
getBufferSize in interface AbleImportData

getFieldList

public java.util.Vector getFieldList()
Return a Vector of AbleField objects where each object describes a data column.
Specified by:
getFieldList in interface AbleImportData

setFieldList

public void setFieldList(java.util.Vector fieldList)
Set a Vector of AbleField objects where each object describes a data column.
Specified by:
setFieldList in interface AbleImportData

getNumRecords

public long getNumRecords()
Return the number of records in this database table.
Specified by:
getNumRecords in interface AbleImportData

getDelimiter

public java.lang.String getDelimiter()

setDelimiter

public void setDelimiter(java.lang.String delimiter)

Copyright

public static java.lang.String Copyright()
Determine the copyright of this class.
Returns:
A String containing this class's copyright statement.

ABLE 2.0.0 07/02/2003 10:25:01

(C) Copyright IBM Corporation 1999, 2003