uchicago.src.sim.analysis
Class ObjectDataRecorder

java.lang.Object
  extended by uchicago.src.sim.analysis.ObjectDataRecorder

public class ObjectDataRecorder
extends java.lang.Object

Records Objects to files as Strings. ObjectDataRecorder will record Objects together with an optional String comment. Typically, this comment will be the tick count, but need not be.

In non-batch mode, a file header will be written that includes all the model's properties and the values of these properties. These values will be the value at the time the first call to write is made, allowing the user to manipulate the parameters after setting up but prior to running the model. Consequently, your initial model parameters should only be changeable via the user or through a parameter file. If not, the file header may be inaccurate. The actual data will be written as a block where the block includes the optional comment as a header, followed by the String representation of the Object itself.

In batch mode, any constant model parameters will be written in the file header. The data block will include the value of any dynamic parameters, the run number, as well as the optional comment (again, typically the tick count), together with the String representation of the Object to be recorded.

Version:
$Revision: 1.7 $ $Date: 2004/11/03 19:51:00 $
Author:
Nick Collier

Nested Class Summary
protected  class ObjectDataRecorder.ObjectStringPair
           
 
Field Summary
protected  java.util.Vector data
           
protected  DataFileHeader dfHeader
           
protected  java.lang.String lineSep
           
protected  DataFileWriter writer
           
 
Constructor Summary
ObjectDataRecorder(java.lang.String fileName, SimModel model)
          Creates a new ObjectDataRecorder.
ObjectDataRecorder(java.lang.String fileName, java.lang.String modelHeader)
          Creates a new ObjectDataRecorder.
 
Method Summary
 void record(java.lang.Object o)
          Records the specified object.
 void record(java.lang.Object o, java.lang.String comment)
          Records the specified Object together with the comment.
 void write()
          Writes all the recorded data (ie Objects) to the file specified in the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected java.util.Vector data

dfHeader

protected DataFileHeader dfHeader

lineSep

protected java.lang.String lineSep

writer

protected DataFileWriter writer
Constructor Detail

ObjectDataRecorder

public ObjectDataRecorder(java.lang.String fileName,
                          SimModel model)
Creates a new ObjectDataRecorder.

Parameters:
fileName - the name of the file to record objects to.
model - the model associated with this ObjectDataRecorder

ObjectDataRecorder

public ObjectDataRecorder(java.lang.String fileName,
                          java.lang.String modelHeader)
Creates a new ObjectDataRecorder.

Parameters:
fileName - the name of the file to record objects to.
modelHeader - user provided header
Method Detail

record

public void record(java.lang.Object o,
                   java.lang.String comment)
Records the specified Object together with the comment. The String returned by Object.toString() is what is actuall recorded.

Parameters:
o - the object to record
comment - a comment about the object

record

public void record(java.lang.Object o)
Records the specified object. The String returned by Object.toString() is what is actuall recorded.

Parameters:
o - the object to record

write

public void write()
Writes all the recorded data (ie Objects) to the file specified in the constructor. See the general class description for the specifics of the file format. The Objects are recorded via their toString() method.