stella.parameter
Class WatchController

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.WatchController
All Implemented Interfaces:
Cloneable, Parameter, AfterRegistering, ParameterDepending, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying
Direct Known Subclasses:
Observing, TargetInstitution

public abstract class WatchController
extends AbstractParameter
implements ParameterDepending, AfterRegistering

A watch-controller is a super-class for instances that control a set of RollOverWatches. It is a parameter that registers additional parameters that are instances of RollOverWatch, if they are accepted with the KEY_ACCEPT. A roll-over watch is accepted, if it's flavour matches this controller's KEY_ACCEPT key. Note that all roll-over watches are reset initially at a date derived from the KEY_COARSE and the KEY_T0 properties in a way that the first roll-over date is that that minizes the integer n in

   f(t) = n*coarse+t0-t, 
   
with f(t)>0. E.g. if the KEY_COARSE points to 86400000 (ms) and KEY_T0 to 2000-01-01 12:00:00, then the first roll-over will occur on noon the next following day.


Nested Class Summary
protected  class WatchController.ResetTask
          A timer task that simply resets the roll-over watch passed to it as a constructor argument.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static long DEFCOARSE
          The default coarseness.
private static SimpleDateFormat DEFDATEFORMAT
          The default date format to use.
private static String DEFT0
          The default date.
static String KEY_ACCEPT
          A key defining the flavour of roll-over watches to accept.
static String KEY_COARSE
          A key defining the coarseness of the first roll-over.
static String KEY_DATEFORMAT
          The date format to use with KEY_T0.
static String KEY_T0
          An offset for the first roll-over.
private static Timer reset
          The timer to controll roll-overs of registered watches.
private  List watches
          The list of all roll-over watches controlled by this controller.
 
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
protected WatchController(Map prop)
          Constructs a new watch controller.
 
Method Summary
 void afterAll()
          Initializes this watch controllers.
protected  List getWatches()
          Returns all the roll-over watches served by this parameter.
 void registerParameter(Parameter iswatch)
          Registers an additional parameter.
protected  double rescanned(String key, String old, String newval)
          We throw an exception if the watches changed.
 
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 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.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_ACCEPT

public static final String KEY_ACCEPT
A key defining the flavour of roll-over watches to accept.

See Also:
Constant Field Values

KEY_COARSE

public static final String KEY_COARSE
A key defining the coarseness of the first roll-over.

See Also:
Constant Field Values

KEY_T0

public static final String KEY_T0
An offset for the first roll-over. See KEY_DATEFORMAT.

See Also:
Constant Field Values

KEY_DATEFORMAT

public static final String KEY_DATEFORMAT
The date format to use with KEY_T0.

See Also:
Constant Field Values

DEFCOARSE

private static final long DEFCOARSE
The default coarseness.

See Also:
Constant Field Values

DEFT0

private static final String DEFT0
The default date. Parsable with the default date format.

See Also:
Constant Field Values

DEFDATEFORMAT

private static final SimpleDateFormat DEFDATEFORMAT
The default date format to use.


watches

private List watches
The list of all roll-over watches controlled by this controller.


reset

private static Timer reset
The timer to controll roll-overs of registered watches.

Constructor Detail

WatchController

protected WatchController(Map prop)
Constructs a new watch controller. The KEY_COARSE, the KEY_T0 and the KEY_DATEFORMAT properties asume their default values if not specified.

Method Detail

rescanned

protected double rescanned(String key,
                           String old,
                           String newval)
We throw an exception if the watches changed.

Overrides:
rescanned in class AbstractParameter

afterAll

public void afterAll()
Initializes this watch controllers. Each entry found in watches is scheduled-at-fixed-rate to reset each RollOverWatch.getRollOverTime(), starting at a date defined with KEY_COARSE and KEY_T0. Note that a roll-over time of zero means no roll-over at all, not even an initial roll-over.
Watches are not started/stopped here.

Specified by:
afterAll in interface AfterRegistering

registerParameter

public void registerParameter(Parameter iswatch)
Registers an additional parameter. If it is a roll-over watch and KEY_ACCEPT matches the flavour of the watch, it is reset by this watch controller every RollOverWatch.getRollOverTime(), starting at a date defined by KEY_COARSE and KEY_T0. Note that a roll-over time of zero means no roll-over at all, not even an initial roll-over.

Specified by:
registerParameter in interface ParameterDepending

getWatches

protected List getWatches()
Returns all the roll-over watches served by this parameter. Intended for sub-classes that need access to the watches.

Returns:
A non-null list of RollOverWatch instances.