stella.parameter
Class StatisticValue

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.StatisticValue
All Implemented Interfaces:
Cloneable, ErrorDependingParameter, Parameter, Value, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying
Direct Known Subclasses:
SensorStatistic, StatisticValue.Average, StatisticValue.Maximum, StatisticValue.Median, StatisticValue.Minimum

public abstract class StatisticValue
extends AbstractValue
implements ErrorDependingParameter

A value that is reset at receiving a certain error-event, cumulates numbers with its set method and returns statistical values on get queris. Note that this class is abstract, concrete subclasses may use one of the getAverage(), getMinimum(), etc. methods to retrieve a single value.


Nested Class Summary
static class StatisticValue.Average
          Useable class returning the average.
static class StatisticValue.Maximum
          Useable class returning the average.
static class StatisticValue.Median
          Useable class returning the median.
static class StatisticValue.Minimum
          Useable class returning the average.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static int DEFTHRESHOLD
          The minimum length of the shelf to return valid values.
static String KEY_ERROR
          The class name of the error that serves as a reset-trigger.
static String KEY_THRESHOLD
          The minimum length of the shelf to return valid values.
private  List numbers
          A list of numbers gathered from the last reset.
private  Statistic stat
          The statisitcs object used to calculate values.
 
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 stella.ErrorDependingParameter
NAMING_EXTENSION
 
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 StatisticValue(Map prop)
          Constructs a new snapshot parameter.
 
Method Summary
private static Statistic createStatistic(List nums)
          Converts my number list into a ready-to-use statistics object.
protected  Number getAverage()
          From all accumulated numbers, get the average.
 Object getForError(ErrorEvent err)
          Checks if the error received is of the type specified in the KEY_ERROR property.
protected  Number getMaximum()
          From all accumulated numbers, get the maximum.
protected  Number getMedian()
          From all accumulated numbers, get the median.
protected  Number getMinimum()
          From all accumulated numbers, get the maximum.
protected  Number getSigma()
          From all accumulated numbers, get the standard eviation.
 boolean isValid()
          Returns true if we have at least KEY_THRESHOLD values in our list.
 void registerError(ErrorEvent err)
          Registers the error.
 Number setValue(Number accu)
          Accumulates a number to the statistics.
 
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.Parameter
get, getFormatted, getName, getString, set
 
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 stella.Value
getValue
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_ERROR

public static final String KEY_ERROR
The class name of the error that serves as a reset-trigger.

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

DEFTHRESHOLD

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

See Also:
Constant Field Values

numbers

private List numbers
A list of numbers gathered from the last reset.


stat

private transient Statistic stat
The statisitcs object used to calculate values.

Constructor Detail

StatisticValue

protected StatisticValue(Map prop)
Constructs a new snapshot parameter.

Method Detail

getForError

public Object getForError(ErrorEvent err)
Checks if the error received is of the type specified in the KEY_ERROR property. If so, the current value is returned via the Value.getValue() method.

Specified by:
getForError in interface ErrorDependingParameter

registerError

public void registerError(ErrorEvent err)
Registers the error. If the error is recognized, i.e. it matches the name in the KEY_ERROR property, the statistics is reset.

Specified by:
registerError in interface ErrorDependingParameter

setValue

public Number setValue(Number accu)
Accumulates a number to the statistics. Returns the number added at the last call to this method or null. Internally, this method clears any left-over statistics.

Specified by:
setValue in interface Value

getAverage

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


getMedian

protected Number getMedian()
From all accumulated numbers, get the median. Might be a time-consuming operation.


getMaximum

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


getMinimum

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


getSigma

protected Number getSigma()
From all accumulated numbers, get the standard eviation.


isValid

public boolean isValid()
Returns true if we have at least KEY_THRESHOLD values in our list.


createStatistic

private static final Statistic createStatistic(List nums)
Converts my number list into a ready-to-use statistics object.