bcds.tools.stat
Class CollectorBase

java.lang.Object
  extended by bcds.tools.stat.CollectorBase
All Implemented Interfaces:
Collector
Direct Known Subclasses:
Series, SimpleAvg

public abstract class CollectorBase
extends java.lang.Object
implements Collector

Provides default implementation for classes implementing the Collector interface, as well as utility functions.

Author:
Juan Segovia S.

Constructor Summary
CollectorBase()
           
 
Method Summary
 boolean equals(java.lang.Object b)
          Twco Collectors are equal if their type and name match.
 java.lang.String getDescription()
          Returns this collector's description.
 java.lang.String getName()
          Returns this collector's name.
 int hashCode()
          Returns this object's hash code.
 java.lang.String report()
          Returns this collector's name followed by the a list of desciption=value for the results.
static java.lang.String report(java.util.Collection<? extends Collector> collectors)
          Returns a string, one line per collector, resulting from calling the report method on each object in the given collection.
static java.lang.String report(java.lang.String collector_label, java.util.Collection<? extends Collector> collectors)
          Formats the results of a series of collectors belonging to the same class, one line per collector, and as many columns as results are provided by the class.
 void setup(java.lang.String name, java.lang.String desc)
          Resets this collector (the observation counter is set to 0).
 java.lang.String toString()
          Returns this collector's name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface bcds.tools.stat.Collector
collect, getResults, getResultsLabels
 

Constructor Detail

CollectorBase

public CollectorBase()
Method Detail

setup

public void setup(java.lang.String name,
                  java.lang.String desc)
Resets this collector (the observation counter is set to 0).

Specified by:
setup in interface Collector

getName

public java.lang.String getName()
Returns this collector's name.

Specified by:
getName in interface Collector

getDescription

public java.lang.String getDescription()
Returns this collector's description.

Specified by:
getDescription in interface Collector

report

public java.lang.String report()
Returns this collector's name followed by the a list of desciption=value for the results. In this class, the only result is the number of observations ("count"). In a hypothetical class of four "results", this method would return something like:
    Number of xyz average=1.3134 stddev=0.6 min=0.3 max=4.12 count=240 
 

Specified by:
report in interface Collector

toString

public java.lang.String toString()
Returns this collector's name.

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Returns this object's hash code. More specifically, the hash code of its name is returned.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object b)
Twco Collectors are equal if their type and name match.

Overrides:
equals in class java.lang.Object

report

public static java.lang.String report(java.lang.String collector_label,
                                      java.util.Collection<? extends Collector> collectors)
Formats the results of a series of collectors belonging to the same class, one line per collector, and as many columns as results are provided by the class.

Example:

 Variable  |average|min  |max
 ----------|-------|-----|-----
 Some var a|3.1234 |0.312|6.738
 Some var b|nnn    |yyy  |www
 Some var c|nnn    |yyyy |ww
 ...
 
The format is tabular (values are vertically aligned with spaces, left-justified).

The parameter collector_label may be null, in which case the word "Variable" is used as label.

Collectors appear in the order in which they are returned by the collections' iterator.

If the result cannot be tabulated, indicated by the fact that Collector.getResultsLabels() return a zero-length array, this method returns an empty string.

Throws:
java.lang.IllegalArgumentException - if the objects in collectors are not all of exactly the same class, or if the results cannot be tabulated, indicated by the fact that Collector.getResultsLabels() return a zero-length array.

report

public static java.lang.String report(java.util.Collection<? extends Collector> collectors)
Returns a string, one line per collector, resulting from calling the report method on each object in the given collection. Objects need not belong to the same class. The output is not "tabular".