stella.parameter
Class SnapshotParameter

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.SnapshotParameter
All Implemented Interfaces:
Cloneable, ErrorDependingParameter, Parameter, ParameterDepending, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, Reloadable, ResourceSupplying
Direct Known Subclasses:
SnapshotValue

public class SnapshotParameter
extends AbstractParameter
implements ParameterDepending, ErrorDependingParameter, Reloadable

A snapshot parameter records the value of an other parameter at a certain time. As unpredicted points-in-time are asociated with errors, this value-fixation should be triggered by an error received in the main ParameterClustering instance.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
static String KEY_ERROR
          The class name of the error that serves as a snapshot-trigger.
static String KEY_PARAMETER
          The name of the parameter which value should be recorded on error.
private  Object record
          The value of the asociated parameter at time of snapshot.
private  Parameter snapshot
          The asociated parameter.
 
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 stella.ErrorDependingParameter
NAMING_EXTENSION
 
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
SnapshotParameter(Map prop)
          Constructs a new snapshot parameter.
 
Method Summary
 Object get()
          Gets the last snapshot value.
 Object getForError(ErrorEvent err)
          Checks if the error received is of the type specified in the KEY_ERROR property.
private  boolean myError(ErrorEvent err)
          Returns true if we act on this error.
 void registerError(ErrorEvent err)
          Registers the error.
 void registerParameter(Parameter watch)
          Registers the asociated parameter which value should be recorded.
 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.
 Object set(Object newval)
          Sets the snapshot value.
 
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
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.Reloadable
reload
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_PARAMETER

public static final String KEY_PARAMETER
The name of the parameter which value should be recorded on error.

See Also:
Constant Field Values

KEY_ERROR

public static final String KEY_ERROR
The class name of the error that serves as a snapshot-trigger.

See Also:
Constant Field Values

snapshot

private Parameter snapshot
The asociated parameter.


record

private Object record
The value of the asociated parameter at time of snapshot.

Constructor Detail

SnapshotParameter

public SnapshotParameter(Map prop)
Constructs a new snapshot parameter.

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 watch)
Registers the asociated parameter which value should be recorded. Checks the name of the parameter handed over against KEY_PARAMETER

Specified by:
registerParameter in interface ParameterDepending

getForError

public Object getForError(ErrorEvent err)
Checks if the error received is of the type specified in the KEY_ERROR property. If so, the current value of the observed parameter is returned, otherwise null is returned.

Specified by:
getForError in interface ErrorDependingParameter

registerError

public void registerError(ErrorEvent err)
Registers the error. If the error is recognized, i.e. the #getFor method return a non-null value, the value of this parameter is adjusted to reflect the value of the served parameter at the time this error was registered.

Specified by:
registerError in interface ErrorDependingParameter

myError

private boolean myError(ErrorEvent err)
Returns true if we act on this error.


get

public Object get()
Gets the last snapshot value. If a no error specified in KEY_ERROR was received since the watched parameter registration, null is returned.

Specified by:
get in interface Parameter

set

public Object set(Object newval)
Sets the snapshot value. Not allowed.

Specified by:
set in interface Parameter
Returns:
The previous value of this parameter.