stella.parameter
Class CountingTrigger

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.AbstractTrigger
                      extended by stella.parameter.SimpleTrigger
                          extended by stella.parameter.CountingTrigger
All Implemented Interfaces:
Cloneable, Parameter, StatePreserving, Trigger, ExitCleaning, Initializable, LocalizedSupplying, Preserving, PropertySupplying, Reloadable, ResourceSupplying

public class CountingTrigger
extends SimpleTrigger
implements StatePreserving

A trigger that counts the time whenever it is true. A call to getTrueTime() returns the elapsed time this trigger was true. A call to #getTotalTime returns the total life-time of this trigger.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static boolean DEFINITBOOLEAN
          The default initial state of this trigger.
private  long lasttrue
          The last time this trigger became true.
private  long overall
          The accumulated true-time.
 
Fields inherited from class stella.parameter.SimpleTrigger
KEY_INITBOOLEAN
 
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
CountingTrigger(Map prop)
          Constructs a new counting trigger.
 
Method Summary
 String getFormatted()
          Returns the formatted value of this parameter.
 long getTrueTime()
          Returns the total time this trigger was true.
 boolean preserve()
          Preserves the overall true time of the trigger.
 boolean restore()
          Initializes the trigger.
 Boolean setTrigger(Boolean newval)
          Sets the trigger.
 
Methods inherited from class stella.parameter.SimpleTrigger
getLastToggleTime, getTrigger, init, rescanned
 
Methods inherited from class stella.parameter.AbstractTrigger
get, getElapsedToggleTime, isTrue, set, toggleTrigger
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, exit, getFormatted, getName, getPreserveFile, getString, getString, register, 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, 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 util.ExitCleaning
exit
 
Methods inherited from interface util.Reloadable
reload
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

DEFINITBOOLEAN

private static final boolean DEFINITBOOLEAN
The default initial state of this trigger.

See Also:
Constant Field Values

lasttrue

private long lasttrue
The last time this trigger became true.


overall

private long overall
The accumulated true-time.

Constructor Detail

CountingTrigger

public CountingTrigger(Map prop)
Constructs a new counting trigger. It is initialized to the #KEY_INIT value.

Method Detail

restore

public boolean restore()
Initializes the trigger. When the super method is called, the initial state of this trigger is set. Accordingly, we start counting if we are true.

Specified by:
restore in interface Preserving
Returns:
False, if restoring the value was not possible.

preserve

public boolean preserve()
Preserves the overall true time of the trigger.

Specified by:
preserve in interface Preserving
Returns:
false, if preserving the current state was not possible

setTrigger

public Boolean setTrigger(Boolean newval)
Sets the trigger. Only settings that toggle the trigger are considered. Note that this trigger is never invalid.

Specified by:
setTrigger in interface Trigger
Overrides:
setTrigger in class SimpleTrigger
Returns:
The old value of the trigger.

getTrueTime

public long getTrueTime()
Returns the total time this trigger was true. Only counts during its life-time.


getFormatted

public String getFormatted()
Returns the formatted value of this parameter. Returns the true time round to seconds as an integer string.

Specified by:
getFormatted in interface Parameter
Overrides:
getFormatted in class AbstractParameter