org.hd.d.pg2k.svrCore.vars
Class SimpleVarStats

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.vars.SimpleVarStats
Direct Known Subclasses:
SimpleNumberStats

public class SimpleVarStats
extends java.lang.Object

Generic stats on a variable. More specific instances may be useful in many cases, but this will do for simple cases, and just shows a mapping from participating system to value without interpretting those values.


Field Summary
protected  SimpleVariableValue filteredVar
          The TYPE_NUMBER variable we were constructed from after filtering; never null.
private  InstanceID thisSys
          This system ID, or null if none selected.
 
Constructor Summary
SimpleVarStats(SimpleVariableValue originalVar, long oldestAllowed, InstanceID sysID)
          Construct a new instance, filtering variable globalMap members by age.
 
Method Summary
 SimpleVariableValue getFilteredVar()
          Get the variable stripped of old globalMap entries.
 java.lang.Object getMainValue()
          Get "main" value; may be null.
 int getNonNullValueCount()
          Get count of globalMap entries with non-null values.
 int getSystemCount()
          Get count of participating systems (ie globalMap entries); 0 for local variable or no globalMap.
 java.lang.String toString()
          Returns HTML- and human- friendly summary of stats.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

thisSys

private final InstanceID thisSys
This system ID, or null if none selected.


filteredVar

protected final SimpleVariableValue filteredVar
The TYPE_NUMBER variable we were constructed from after filtering; never null.

Constructor Detail

SimpleVarStats

public SimpleVarStats(SimpleVariableValue originalVar,
                      long oldestAllowed,
                      InstanceID sysID)
Construct a new instance, filtering variable globalMap members by age.

Parameters:
originalVar - the variable to compute; must be non-null but getValue() is permitted to return null so that we can handle TYPE_NONE values for example
oldestAllowed - any globalMap entry than this will be ignored, which allows only up-to-date information to be included
sysID - identifies this system so we can select the local value of a global variable if available; can be null
Method Detail

getFilteredVar

public SimpleVariableValue getFilteredVar()
Get the variable stripped of old globalMap entries.


getMainValue

public java.lang.Object getMainValue()
Get "main" value; may be null. For a local value it is simply the result of getValue().

For a global, if a system ID is supplied and has an entry in the globalMap, its value is used, else the normal getValue() is used as for a local.


getSystemCount

public int getSystemCount()
Get count of participating systems (ie globalMap entries); 0 for local variable or no globalMap. A local value will never have globalMap entries; a global value will not if all the entries were too old to use.


getNonNullValueCount

public int getNonNullValueCount()
Get count of globalMap entries with non-null values. This can never be greater than the result of getSystemCount() and never negative.


toString

public java.lang.String toString()
Returns HTML- and human- friendly summary of stats. This does not include the variable name.

If the count is zero, just returns a formatted version of the value.

Note that this simply relies on the toString() method of the value type, and shows a direct map of all the values, so may not work well for large numbers of systems or unfriendly values.

It may be best to override this for many/most variable types.

Overrides:
toString in class java.lang.Object

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.