jenes.utils
Class AbstractLogger

java.lang.Object
  extended by jenes.utils.AbstractLogger
Direct Known Subclasses:
CSVLogger, XLSLogger

public abstract class AbstractLogger
extends java.lang.Object

This class provides basic support and interface for logging on different media. A log is made of records. Each record is an associative table of properties.

Since:
1.3
Version:
1.3
Author:
Luigi Troiano

Field Summary
protected  boolean closed
           
protected  java.util.Map<java.lang.String,java.lang.Object> record
          The table of value to store.
protected  java.util.List<java.lang.String> schema
          The statistics schema
 
Constructor Summary
AbstractLogger(java.lang.String[] schema)
          Creates a new logger providing a schema
 
Method Summary
 void close()
          Saves cached records on media and closes the logger.
protected abstract  void doClose()
          Closes the logger.
protected abstract  void doSave()
          Saves cached records on media
protected  void finalize()
           
 java.lang.Object get(java.lang.String key)
          Retrieves a statistics from the current record.
 java.util.Iterator<java.lang.String> getFields()
          Returns the list of schema fields
 java.lang.String[] getSchema()
          Returns the logging schema
 boolean isRecordComplete()
          Returns true if the record is complete
 void log()
          Logs a current record by storing it and making the record empty.
 void put(java.lang.String key, java.lang.Object value)
          Puts a value into the current record.
 void save()
          Saves cached records on media.
protected abstract  void store()
          Stores the current record.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schema

protected java.util.List<java.lang.String> schema
The statistics schema


record

protected java.util.Map<java.lang.String,java.lang.Object> record
The table of value to store. It is the current record to fill.


closed

protected boolean closed
Constructor Detail

AbstractLogger

public AbstractLogger(java.lang.String[] schema)
Creates a new logger providing a schema

Parameters:
schema - - the logging schema
Method Detail

getSchema

public java.lang.String[] getSchema()
Returns the logging schema


getFields

public java.util.Iterator<java.lang.String> getFields()
Returns the list of schema fields


put

public final void put(java.lang.String key,
                      java.lang.Object value)
Puts a value into the current record.

Parameters:
key - - the statistics name
value - - the statistics value

get

public final java.lang.Object get(java.lang.String key)
Retrieves a statistics from the current record.

Parameters:
key - - the statistics name
Returns:
the statistics value

isRecordComplete

public boolean isRecordComplete()
Returns true if the record is complete

Returns:
true if the record is complete

log

public final void log()
Logs a current record by storing it and making the record empty. This is the method to invoke to store the current recorrd.


save

public void save()
Saves cached records on media. If the logger is closed this operation is not allowed.


close

public void close()
Saves cached records on media and closes the logger. If the logger is closed this operation is not allowed.


store

protected abstract void store()
Stores the current record.


doSave

protected abstract void doSave()
Saves cached records on media


doClose

protected abstract void doClose()
Closes the logger. Any further log is not allowed.


finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object