stella.parameter
Class ElapsedTime

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.ElapsedTime
All Implemented Interfaces:
Cloneable, Parameter, ParameterDepending, Value, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, Reloadable, ResourceSupplying

public class ElapsedTime
extends AbstractValue
implements ParameterDepending, Reloadable

An elapsed time is a value linked to a trigger. If queried, it returns the triggers last toggle time, negative if the trigger itself is false, positive Long if the trigger is true. It is intended for making trigger times available as values, think of querying the time a lamp was turned on.

To properly work, the underlying trigger must be registered to this value, thus the class implements the ParameterDepending interface. The KEY_ELAPSED property must piont to the trigger of the given name.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
static String KEY_ELAPSED
          The trigger that is observed in this value.
private  Trigger monitor
          The trigger whose elapsed toggel tiem is monitored by this number.
 
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
ElapsedTime(Map prop)
          Constructs a new elapsed time parameter.
 
Method Summary
 Number getValue()
          If we have a trigger registered to this value, we return the triggers elapsed toggle time.
 void registerParameter(Parameter observe)
          Registers the trigger named KEY_ELAPSED to this value.
 double rescanned(String key, String old, String newval)
          As any parameter depending instance we fail if the parameter we depend on is now a different one.
 Number setValue(Number val)
          Setting this value is only possible via setting its underlying trigger.
 
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, 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 util.Reloadable
reload
 
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_ELAPSED

public static final String KEY_ELAPSED
The trigger that is observed in this value.

See Also:
Constant Field Values

monitor

private Trigger monitor
The trigger whose elapsed toggel tiem is monitored by this number.

Constructor Detail

ElapsedTime

public ElapsedTime(Map prop)
Constructs a new elapsed time parameter. The properties handed over must specify the name of this value and the name of the trigger that is observed.

Method Detail

rescanned

public double rescanned(String key,
                        String old,
                        String newval)
As any parameter depending instance we fail if the parameter we depend on is now a different one.

Specified by:
rescanned in interface Reloadable
Overrides:
rescanned in class AbstractParameter

registerParameter

public void registerParameter(Parameter observe)
Registers the trigger named KEY_ELAPSED to this value.

Specified by:
registerParameter in interface ParameterDepending
See Also:
getValue

getValue

public Number getValue()
If we have a trigger registered to this value, we return the triggers elapsed toggle time. The sign of this value is determined by the value of the trigger: If the trigger is true, we return a positive value, otherwise a negative one. If no trigger was linked to this value, null is returned.

Specified by:
getValue in interface Value

setValue

public Number setValue(Number val)
                throws UnsupportedOperationException
Setting this value is only possible via setting its underlying trigger.

Specified by:
setValue in interface Value
Throws:
UnsupportedOperationException