GridSim 5.0 beta

gridsim.util
Class SimReport

Object
  extended by SimReport

public class SimReport
extends Object

Records any information that is needed by a GridSim entity. It is the responsibility of each entity to record data.
NOTE: before the simulation ends, call finalWrite() to finalize writing the data into a file and close it. Forgotten to call this method will result in not writing into a file at all.

Given the file name, this class will record information in CSV (Comma delimited) format (*.csv) with the first column usually represents the simulation time. The format of the next columns afterward is the responsibility of the coder.

Since:
GridSim Toolkit 3.1
Author:
Anthony Sulistio
Invariant:
$none

Field Summary
static int INDENT_COMMA
          A comma-delimited text file, i.e.
static int INDENT_SPACE
          A space-delimited text file, i.e.
static int INDENT_TAB
          A tab-delimited text file, i.e.
 
Constructor Summary
SimReport(String name)
          Creates a new report file.
SimReport(String name, int indent)
          Creates a new report file.
 
Method Summary
 void finalWrite()
          Finalize the recording by writing all the previously given information into a file.
 void write(double num, String desc)
          Write the given data into the file.
 void write(int num, String desc)
          Write the given data into the file.
 void write(long num, String desc)
          Write the given data into the file.
 void write(String data)
          Write the given data into the file.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDENT_SPACE

public static final int INDENT_SPACE
A space-delimited text file, i.e. each column is separated by a space

See Also:
Constant Field Values

INDENT_COMMA

public static final int INDENT_COMMA
A comma-delimited text file, i.e. each column is separated by a comma

See Also:
Constant Field Values

INDENT_TAB

public static final int INDENT_TAB
A tab-delimited text file, i.e. each column is separated by a tab

See Also:
Constant Field Values
Constructor Detail

SimReport

public SimReport(String name)
          throws ParameterException
Creates a new report file. This constructor will automatically append the file extension to the given parameter. Use finalWrite() before exiting to write the data into a file and close it. Forgotten to call this method will result in not writing into a file at all.
NOTE: By default, each column inside this file is separated by a comma.
WARNING: existing file with the same name will be overwritten.

Parameters:
name - file/entity name
Throws:
ParameterException - This happens when name is invalid or null.
Pre Condition:
name != null
Post Condition:
$none

SimReport

public SimReport(String name,
                 int indent)
          throws ParameterException
Creates a new report file. This constructor will automatically append the file extension to the given parameter. Use finalWrite() before exiting to write the data into a file and close it. Forgotten to call this method will result in not writing into a file at all.
WARNING: existing file with the same name will be overwritten.

Parameters:
name - file/entity name
indent - type of indentation (either a space, a comma or a tab)
Throws:
ParameterException - This happens when name is invalid or null.
Pre Condition:
name != null
Post Condition:
$none
Method Detail

write

public void write(int num,
                  String desc)
Write the given data into the file.
For each row, the format would be: simulation time, num, desc. The simulation time is automatically handle inside this method.

Parameters:
num - integer number
desc - the description of this number
Pre Condition:
$none
Post Condition:
$none

write

public void write(double num,
                  String desc)
Write the given data into the file.
For each row, the format would be: simulation time, num, desc. The simulation time is automatically handle inside this method.

Parameters:
num - decimal number
desc - the description of this number
Pre Condition:
$none
Post Condition:
$none

write

public void write(long num,
                  String desc)
Write the given data into the file.
For each row, the format would be: simulation time, num, desc. The simulation time is automatically handle inside this method.

Parameters:
num - long number
desc - the description of this number
Pre Condition:
$none
Post Condition:
$none

write

public void write(String data)
Write the given data into the file.
For each row, the format would be: simulation time, desc. The simulation time is automatically handle inside this method.

Parameters:
data - data to be recorded
Pre Condition:
$none
Post Condition:
$none

finalWrite

public void finalWrite()
Finalize the recording by writing all the previously given information into a file.
Forgotten to call this method will result in not writing into a file at all.

Pre Condition:
$none
Post Condition:
$none

GridSim 5.0 beta

The University of Melbourne, Australia, 2009