next up previous contents
Next: DTWDataPlotter module detail Up: GUI detailed design Previous: DTWData module detail   Contents

DTWFileIO module detail

Private data and data structures

java.io.BufferedReader DataSetReader

A FileReader object used for reading the data set.

Implementation of methods
openDataSet

  1. Create a new FileReader object and initialize it with Filename received as a parameter
  2. Initialize DataSetReader with the FileReader object.
  3. Catch any IOExceptions, and throw an DTWFileIOException. Output the IOException to System.err.
  4. Get the number of records in file by calling DataSetReader.readLine() and adding to a counter until EOF.
  5. Return the total number of records (lines).

loadRecord

  1. Reset DataSetReader by calling DataSetReader.reset().
  2. Go to line num in DataSetReader by calling DataSetReader.readLine() $n-1$ times.
  3. Read next line by DataSetReader.readLine() and store the return value in a String object.
  4. Parse float values from the String and store the values in a float array.
  5. Return the float array containing the record.
  6. In case of an error, raise a DTWFileIOException with descriptive Message. Output the IOException to System.err.

closeDataSet

  1. Close data set file by DataSetReader.close().
  2. Raise a DTWFileIOException in case an error occurs. Output the IOException to System.err.

loadTemplates

  1. Create a new BufferedReader(FileReader(Filename)).
  2. Create a new Vector.
  3. Repeat until EOF:
  4. Create a DTWDataVector array of size newVector.size().
  5. Copy newVector items to the DTWDataVector array.
  6. Call DataObject.addTemplates( newDataVector );
  7. Raise an DTWFileIOException in case of an error. Output the IOException to System.err.

saveTemplates

  1. Create a new BufferedWriter(FileWriter(Filename)).
  2. Get templates in an DTWDataVector array by DataObject.getTemplates() method.
  3. Repeat the following actions for newDTWDataVector.length() times.
  4. Raise an DTWFileIOException in case of an error. Output the IOException to System.err.

loadObservation

  1. Create a new BufferedReader(FileReader(Filename)).
  2. Create a new DTWDataVector object.
  3. Read a line from BufferedReader object and store it as DTWDataVector.name.
  4. Read a line from BufferedReader.
  5. Parse the line to a float array and copy it to DTWDataVector.values.
  6. DataObject.setObservation( newDTWDataVector ).
  7. Raise an DTWFileIOException in case of an error. Output the IOException to System.err.

saveObservation

  1. Create a new BufferedWriter(FileWriter(Filename)).
  2. Write DataObject.getObservationName() to the file.
  3. Write DataObject.getObservation() to the file as a series of float numbers converted to strings separated with spaces.
  4. Raise an DTWFileIOException in case of an error. Output the IOException to System.err.

saveLog

  1. Create a new BufferedWriter(FileWriter(Filename)).
  2. Get date and time using system functions and write them to the file using BufferedWriter.write() method.
  3. Get algorithm parameters from the DataObject class using getDTWEnv method. Save the return value to file with BufferedWriter.write() method.
  4. Get observation name by DataObject.getObservationName(). Save the return value to the file.
  5. Get DTW algorithm run results from DataObject.getResults() method.
  6. Repeat the following actions for DataObject.Templates.length() times.
  7. Raise an DTWFileIOException in case of an error. Output the IOException to System.err.


next up previous contents
Next: DTWDataPlotter module detail Up: GUI detailed design Previous: DTWData module detail   Contents
2002-03-19