stella.parameter
Class ShelfStatistic

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.AbstractValue
                      extended by stella.parameter.ShelfStatistic
All Implemented Interfaces:
Cloneable, Parameter, Value, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying
Direct Known Subclasses:
SensorShelf, ShelfStatistic.Average, ShelfStatistic.Maximum, ShelfStatistic.Minimum, ShelfStatistic.Test

public abstract class ShelfStatistic
extends AbstractValue

This class hooks on to a shelf to generate minima/maxima or averages. The intended use is to hook this parameter to a DataCaster that is permanently generating data. Retrieving the value is either minima, maxima or average. It is similar to a SensorStatistic, but provides not that much of an overhead.


Nested Class Summary
static class ShelfStatistic.Average
          Useable class returning the average.
static class ShelfStatistic.Maximum
          Useable class returning the average.
static class ShelfStatistic.Minimum
          Useable class returning the average.
static class ShelfStatistic.Test
          Test class.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  double average
          The current average.
private static boolean DEFNOMINMAX
          The default choice for ignoring minima maxima calculation.
private static int DEFSHELFSIZE
          The length of the average cycle.
private static int DEFTHRESHOLD
          The minimum length of the shelf to return valid values.
static String KEY_NOMINMAX
          If this boolean is set, minima/maxima are not updated.
static String KEY_SHELFSIZE
          The length of the average cycle.
static String KEY_THRESHOLD
          The minimum length of the shelf to return valid values.
private  double maxima
          The current maxima.
private  double minima
          The current minima.
private  Shelf numbers
          A list of numbers gathered from the data source.
 
Fields inherited from class stella.parameter.AbstractParameter
KEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWN
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
protected ShelfStatistic(Map prop)
          Constructs a new shelf-based statistics sensor.
 
Method Summary
 void clear()
          Clears the shelf data on request.
protected  Number getAverage()
          From all accumulated numbers, get the average.
protected  Number getMaximum()
          From all accumulated numbers, get the maximum.
protected  Number getMinimum()
          From all accumulated numbers, get the maximum.
 boolean isValid()
          A statistiv parameter is valid, if its numbers collected exceeds the validity threshold.
private  void scanMinMax()
          If we removed the minima or the maxima from our shelf, and this value is no longer present in the data shelf, we have to scan the entire shelf for the new minima and maxima.
 Number setValue(Number add)
          Adds a number to the shelf statistic.
 
Methods inherited from class stella.parameter.AbstractValue
get, set
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, exit, getFormatted, getFormatted, getName, getPreserveFile, getString, getString, init, register, rescanned, setName, toString
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, setObject, setProperties, setProperty, stringProperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface stella.Value
getValue
 
Methods inherited from interface stella.Parameter
getFormatted, getName, getString
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 
Methods inherited from interface util.Initializable
init
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_SHELFSIZE

public static final String KEY_SHELFSIZE
The length of the average cycle. Counts not time, but events.

See Also:
Constant Field Values

KEY_THRESHOLD

public static final String KEY_THRESHOLD
The minimum length of the shelf to return valid values.

See Also:
Constant Field Values

KEY_NOMINMAX

public static final String KEY_NOMINMAX
If this boolean is set, minima/maxima are not updated.

See Also:
Constant Field Values

DEFSHELFSIZE

private static final int DEFSHELFSIZE
The length of the average cycle. Counts not time, but events.

See Also:
Constant Field Values

DEFTHRESHOLD

private static final int DEFTHRESHOLD
The minimum length of the shelf to return valid values.

See Also:
Constant Field Values

DEFNOMINMAX

private static final boolean DEFNOMINMAX
The default choice for ignoring minima maxima calculation.

See Also:
Constant Field Values

numbers

private Shelf numbers
A list of numbers gathered from the data source.


minima

private double minima
The current minima.


maxima

private double maxima
The current maxima.


average

private double average
The current average.

Constructor Detail

ShelfStatistic

protected ShelfStatistic(Map prop)
Constructs a new shelf-based statistics sensor.

Method Detail

clear

public void clear()
Clears the shelf data on request.


setValue

public Number setValue(Number add)
Adds a number to the shelf statistic. This is the receiving end of this parameter to add new measurements. The number returned is the recently removed shelf object.


getAverage

protected Number getAverage()
From all accumulated numbers, get the average.


getMaximum

protected Number getMaximum()
From all accumulated numbers, get the maximum.


getMinimum

protected Number getMinimum()
From all accumulated numbers, get the maximum.


isValid

public boolean isValid()
A statistiv parameter is valid, if its numbers collected exceeds the validity threshold.


scanMinMax

private void scanMinMax()
If we removed the minima or the maxima from our shelf, and this value is no longer present in the data shelf, we have to scan the entire shelf for the new minima and maxima. This is the only time-consuming part in the sensor, but its handable.