stella.parameter
Class CountDownTrigger

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.CountDownTrigger
All Implemented Interfaces:
Cloneable, Parameter, StatePreserving, ParameterDepending, Trigger, ExitCleaning, Initializable, LocalizedSupplying, Preserving, PropertySupplying, Reloadable, ResourceSupplying

public class CountDownTrigger
extends SimpleTrigger
implements StatePreserving, ParameterDepending

A trigger that has a nominal state, set by initboolean. If toggled (or set) to the non-init case, it re-attains the original state at least after the KEY_TOGGLETIME has passed. If this time is zero, it acts as a normal trigger. If a time parameter is registered to this trigger, it is used (allows for acceleration), otherwise the system time is used.


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 static String DEFTIME
          The default name of the time to use.
private static long DEFTOGGLETIME
          Per default we act as a simple trigger, with no reset.
static String KEY_TIME
          The name of the time parameter.
static String KEY_TOGGLETIME
          The time until we toggle to the original state.
private  long lasttrue
          The last time this trigger became not-init.
private  Time time
          The time parameter.
 
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
CountDownTrigger(Map<String,String> prop)
          Constructs a new counting trigger.
 
Method Summary
private  long getCurrentTime()
          If an individual time parameter was set in this trigger, we use its value, otherwise system time.
 Boolean getTrigger()
          Gets the trigger value.
 boolean preserve()
          Preserves the overall true time of the trigger.
 void registerParameter(Parameter p)
          If parameter is a time and has the correct name, we use it, otherwise system time.
 boolean restore()
          Initializes the trigger.
 void setToggleTime(long nutog)
          Allows direct setting of the toggle time, i.e.
 Boolean setTrigger(Boolean newval)
          Sets the trigger.
 
Methods inherited from class stella.parameter.SimpleTrigger
getLastToggleTime, 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, 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, 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 util.ExitCleaning
exit
 
Methods inherited from interface util.Reloadable
reload
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_TOGGLETIME

public static final String KEY_TOGGLETIME
The time until we toggle to the original state.

See Also:
Constant Field Values

KEY_TIME

public static final String KEY_TIME
The name of the time parameter.

See Also:
Constant Field Values

DEFINITBOOLEAN

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

See Also:
Constant Field Values

DEFTOGGLETIME

private static final long DEFTOGGLETIME
Per default we act as a simple trigger, with no reset.

See Also:
Constant Field Values

DEFTIME

private static final String DEFTIME
The default name of the time to use.

See Also:
Constant Field Values

lasttrue

private long lasttrue
The last time this trigger became not-init.


time

private Time time
The time parameter.

Constructor Detail

CountDownTrigger

public CountDownTrigger(Map<String,String> prop)
Constructs a new counting trigger. It is initialized to the #KEY_INIT value.

Method Detail

registerParameter

public void registerParameter(Parameter p)
If parameter is a time and has the correct name, we use it, otherwise system time.

Specified by:
registerParameter in interface ParameterDepending

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

setToggleTime

public void setToggleTime(long nutog)
Allows direct setting of the toggle time, i.e. the revert time when the trigger re-attains its original value.


getTrigger

public Boolean getTrigger()
Gets the trigger value. If the value is not the initial one, we check for the time it was last set to this value. If this is too long ago, we toogle back to the initial value.

Specified by:
getTrigger in interface Trigger
Overrides:
getTrigger in class SimpleTrigger

setTrigger

public Boolean setTrigger(Boolean newval)
Sets the trigger. If we set to a value that is not the initial boolean value, we also mark the time this trigger was set. Only within KEY_TOGGLETIME we may return this non-init value. If the trigger is set repeatedly to the non-init value, only the last setting is considered for the time out, i.e. the count down restarts.

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

getCurrentTime

private long getCurrentTime()
If an individual time parameter was set in this trigger, we use its value, otherwise system time.