bcds.phison.sim
Class StatsExporterBase

java.lang.Object
  extended by bcds.phison.sim.StatsExporterBase
All Implemented Interfaces:
StatsExporter, WithEnvParams
Direct Known Subclasses:
SxSeriesToGnuPlot, SxStdoutBasic

public abstract class StatsExporterBase
extends java.lang.Object
implements StatsExporter, WithEnvParams

Provides default functionality and data for classes implementing the StatsExporter interface.

Author:
Juan Segovia S.

Constructor Summary
StatsExporterBase()
           
 
Method Summary
 Environ getEnviron()
          Returns the environment object that was received through setup or created there (if the parameters was null).
 java.lang.Object[] getEnvParams()
          Returns an empty array.
 java.lang.String getName()
          Returns this instance's unqualified class name.
static java.lang.String sanitizeFilename(java.lang.String fname, java.lang.String replacement)
          Returns a string consisting of "valid" characters only.
 void setup(SimStatsCollector stats, Environ env)
          Saves the parameters stats and env, and calls env.adaptTypes.
 SimStatsCollector stats()
          Returns the statistics collector object received in setup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bcds.phison.sim.StatsExporter
run
 

Constructor Detail

StatsExporterBase

public StatsExporterBase()
Method Detail

setup

public void setup(SimStatsCollector stats,
                  Environ env)
Saves the parameters stats and env, and calls env.adaptTypes. If env is null, a new instance is first created.

Specified by:
setup in interface StatsExporter

getName

public java.lang.String getName()
Returns this instance's unqualified class name.

Specified by:
getName in interface WithEnvParams

getEnvParams

public java.lang.Object[] getEnvParams()
Returns an empty array.

Specified by:
getEnvParams in interface WithEnvParams

getEnviron

public Environ getEnviron()
Returns the environment object that was received through setup or created there (if the parameters was null).

Specified by:
getEnviron in interface WithEnvParams

stats

public SimStatsCollector stats()
Returns the statistics collector object received in setup. This method exists so that the interface is reminiscent of a processing module.


sanitizeFilename

public static java.lang.String sanitizeFilename(java.lang.String fname,
                                                java.lang.String replacement)
Returns a string consisting of "valid" characters only. Valid characters are (English) alphabet letters, digits, hyphen and underscore. Characters in fname not in this set are replaced with the string replacement.

Beware that the replacement char/string may contain elements that are "invalid" by the validity definition in this function; that situation is left unchecked.

This function is typically used to transform the id or name of a statistics collector into a filename. Hence the restriction on the character set.