stella.parameter
Class AbstractSwitch

java.lang.Object
  extended by util.PropertyContainer
      extended by stella.parameter.AbstractParameter
          extended by stella.parameter.AbstractTrigger
              extended by stella.parameter.SimpleTrigger
                  extended by stella.parameter.AbstractSwitch
All Implemented Interfaces:
Cloneable, Parameter, Switch, Trigger, ExitCleaning, Initializable, PropertyBearing, Reloadable
Direct Known Subclasses:
OneWireMultiSwitch, OneWireSwitch, RS485Switch

public abstract class AbstractSwitch
extends SimpleTrigger
implements Switch

An abstract implementation for a switch. All trigger methods are inherited from the simple switch class.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyContainer
PropertyContainer.URLResource
 
Field Summary
private  TimerTask forcedoff
          This timer task is used to switch off after a certain time-out.
 
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.PropertyContainer
KEY_LISTSEPARATOR, KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR, KEY_NOINITONCREATE, KEY_RESOURCEBUNDLES
 
Fields inherited from interface util.PropertyBearing
CONFIG, KEY_CLASS, KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
protected AbstractSwitch(Map prop)
          Constructs a new abstract switch.
 
Method Summary
protected abstract  boolean off()
          This method does the actual setting of the switch to off.
protected abstract  boolean on()
          This method does the actual setting of the switch to on.
 boolean turnOff()
          Turns the switch off.
 boolean turnOn(long timeout)
          Turns the switch on.
 
Methods inherited from class stella.parameter.SimpleTrigger
getLastToggleTime, getTrigger, init, rescanned, setTrigger
 
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.PropertyContainer
augment, augment, augment, clone, createFrom, createFrom, createFrom, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getLocalClassLoader, getLocalized, getLocalized, getLocalizedString, getLocalizedString, getProperties, getPropertiesToKey, getPropertiesToKey, getProperty, getResource, getResourceAsStream, getResourceFromKey, getResources, has, isNew, keyCreate, keyCreate, parseObject, reload, 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.Trigger
getElapsedToggleTime, getLastToggleTime, getTrigger, isTrue, setTrigger, toggleTrigger
 
Methods inherited from interface stella.Parameter
get, getFormatted, getName, getString, set
 
Methods inherited from interface util.PropertyBearing
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getLocalized, getProperties, getProperty, getResource, getResourceAsStream, getResources, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 
Methods inherited from interface util.Initializable
init
 
Methods inherited from interface util.Reloadable
reload
 

Field Detail

forcedoff

private TimerTask forcedoff
This timer task is used to switch off after a certain time-out.

Constructor Detail

AbstractSwitch

protected AbstractSwitch(Map prop)
Constructs a new abstract switch.

Method Detail

turnOn

public boolean turnOn(long timeout)
Turns the switch on. Diverts to the abstract method on() for actual switching. Does maximum time keeping.

Specified by:
turnOn in interface Switch
Parameters:
timeout - The maximum time the switch should be on (ms), zero for unlimited.
Returns:
True, if switch was successfully turned on.

turnOff

public boolean turnOff()
Turns the switch off. Diverts to the abstract method off() for actual switching. If a switch-off timer task was active, it is canceled.

Specified by:
turnOff in interface Switch
Returns:
True, if switch was successfully turned off.

on

protected abstract boolean on()
This method does the actual setting of the switch to on.

Returns:
True if successful.

off

protected abstract boolean off()
This method does the actual setting of the switch to off.

Returns:
True if successful.