jenes.utils
Class CSVLogger

java.lang.Object
  extended by jenes.utils.AbstractLogger
      extended by jenes.utils.CSVLogger

public class CSVLogger
extends AbstractLogger

This class defines a StatisticsLogger based on CSV (comma separated values) file. The logger has a schema, made of the fields the user means to record. If the schema is not specified, the logger use the set of keys making a record as schema. The default separator is tab, but a different separator can be specified at instantiation time. The default logfile is named log.csv and placed into the working directory. The logger can record or not the first line with the header made of the field names.

Since:
1.3
Version:
1.3
Author:
Luigi Troiano

Field Summary
 
Fields inherited from class jenes.utils.AbstractLogger
closed, record, schema
 
Constructor Summary
CSVLogger(java.lang.String[] schema)
          Creates a logger with the specified schema, and log.csv as default filename, tab as default separator.
CSVLogger(java.lang.String[] schema, java.lang.String filename)
          Creates a logger with the specified schema and filename, tab as default separator.
CSVLogger(java.lang.String[] schema, java.lang.String filename, java.lang.String separator)
          Creates a logger with the specified schema, filename and separator.
CSVLogger(java.lang.String[] schema, java.lang.String filename, java.lang.String separator, boolean header)
          Creates a logger with the specified schema, filename and separator.
 
Method Summary
protected  void doClose()
          Closes the logger.
protected  void doSave()
          Saves cached records on media
 java.io.PrintWriter getOut()
          Return the output stream used for logging.
protected  void store()
          Stores the current record.
 
Methods inherited from class jenes.utils.AbstractLogger
close, finalize, get, getFields, getSchema, isRecordComplete, log, put, save
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVLogger

public CSVLogger(java.lang.String[] schema)
          throws java.io.FileNotFoundException
Creates a logger with the specified schema, and log.csv as default filename, tab as default separator. The header is placed on the first line.

Parameters:
schema - - the array making the schema of records
Throws:
java.io.FileNotFoundException

CSVLogger

public CSVLogger(java.lang.String[] schema,
                 java.lang.String filename)
          throws java.io.FileNotFoundException
Creates a logger with the specified schema and filename, tab as default separator. The header is placed on the first line.

Parameters:
schema - - the array making the schema of records
filename - - the output filename
Throws:
java.io.FileNotFoundException

CSVLogger

public CSVLogger(java.lang.String[] schema,
                 java.lang.String filename,
                 java.lang.String separator)
          throws java.io.FileNotFoundException
Creates a logger with the specified schema, filename and separator. The header is placed on the first line.

Parameters:
schema - - the array making the schema of records
filename - - the output filename
separator - - the values separator
Throws:
java.io.FileNotFoundException

CSVLogger

public CSVLogger(java.lang.String[] schema,
                 java.lang.String filename,
                 java.lang.String separator,
                 boolean header)
          throws java.io.FileNotFoundException
Creates a logger with the specified schema, filename and separator. The header is placed on the first line if required.

Parameters:
schema - - the array making the schema of records
filename - - the output filename
separator - - the values separator
header - - the header is included if true, otherwise not.
Throws:
java.io.FileNotFoundException
Method Detail

getOut

public java.io.PrintWriter getOut()
Return the output stream used for logging.

Returns:
the log writer

store

protected void store()
Description copied from class: AbstractLogger
Stores the current record.

Specified by:
store in class AbstractLogger

doSave

protected void doSave()
Description copied from class: AbstractLogger
Saves cached records on media

Specified by:
doSave in class AbstractLogger

doClose

protected void doClose()
Description copied from class: AbstractLogger
Closes the logger. Any further log is not allowed.

Specified by:
doClose in class AbstractLogger