stella.parameter
Class ObservableList

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.AbstractTargetParameter
                      extended by stella.parameter.AbstractTargetValue
                          extended by stella.parameter.ObservableList
All Implemented Interfaces:
Cloneable, ErrorDependingParameter, Parameter, TargetDependingValue, ParameterDepending, TargetDepending, TargetDependingParameter, TargetProviderDepending, Value, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying

public class ObservableList
extends AbstractTargetValue
implements ParameterDepending, TargetProviderDepending, ErrorDependingParameter

A parameter that is capable of cumulating a list of observable targets along with their highest-ever merit. This is done in a way that the parameter's AbstractTargetValue.set(java.lang.Object) method expects a list of TargetDefinitions, preferrably Appointables, which is stored in an internal Map along with the target's merit. Whenever the set method is called, all targets already present are checked for their last merit. The current merit is stored if it exceeds the last one, allowing retrieval of a map of target definitions to merits using the parameter's AbstractTargetValue.get() method.

Additionally, as this parameter is also relevant for scheduling simulation, the parameter hosts a mapping of targets to all positive merits of the target, which are stored as date and merit at that date. This mapping of target definitions to a list of 2-element objects (Long, Double) can be retrieved with a call to getMeritCourse(stella.TargetDefinition).

This parameter is exit cleaning, meaning that depending on the keys KEY_DUMPOBSERVE and KEY_DUMPCOURSE the map of target definitions to highest merits is dumped as target names to highest merits and the dates (as longs) with the particular merits is dumped. In the current version, KEY_DUMPOBSERVE points to an ascii-file name and KEY_DUMPCOURSE points to a directory.


Nested Class Summary
private static class ObservableList.DateMerit
          A combination of a date and a merit.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  Map<TargetDefinition,Shelf<ObservableList.DateMerit>> course
          A map of parsed targets to merit course.
private  TargetDefinition current
          If a target/error was registered.
private static int DEFMAXENTRIES
          The default size of the date-merit list.
static String DEFNAME
          The default name of the target list.
private static String DEFTARGETMERIT
          The default name of the target list.
private static String DEFTIME
          The default name of the target list.
static String KEY_DUMPCOURSE
          The directory into which the per-target merit course is writtn to.
static String KEY_DUMPOBSERVE
          The file name where the target names vs.
static String KEY_IGNORE
          The key to the comma-list of unwanted targets.
static String KEY_MAXENTRIES
          The file name where the target names vs.
static String KEY_ONLY
          The key to the comma-list of only wanted targets.
static String KEY_TARGETMERIT
          The name of the parameter that hold the target merit.
static String KEY_TIME
          The name of the parameter that holds the time.
private  TargetDependingParameter merit
          The target depending parameter giving the merit of the target.
private  Map<TargetDefinition,Float> targets
          A map of parsed targets to highest merit.
private  Time time
          The current time.
 
Fields inherited from class stella.parameter.AbstractTargetParameter
KEY_INDEX
 
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
ObservableList(Map<String,String> sprop)
          Constructs a new observable targets list.
 
Method Summary
 void clearObservables()
          Clears the list of observable targets.
 void exit()
          Exits this parameter.
 Object getForError(ErrorEvent ee)
          Picks the highest-ever recorded merit for the target delivered with this error.
 Number getForTarget(TargetDefinition td)
          Picks the highest-ever recorded merit for this target.
 List<ObservableList.DateMerit> getMeritCourse(TargetDefinition key)
          Returns the course of this target merits.
 Number getValue()
          Returns the same object as Parameter.get() but already cast into a Number.
 void init()
          Transforms the KEY_IGNORE property into a list of target names that should be discarded.
 void registerError(ErrorEvent ee)
          Registers a target-picked error.
 void registerParameter(Parameter possmerit)
          Registers the target merit parameter used to deduce the highest merit during an observing period.
 void registerProvider(TargetProviding<? extends TargetDefinition> list)
          On target registering, we create a new mapping of targets to highest merits and the linking of targets to the merit course.
 void registerTarget(TargetDefinition td)
          Target picked is the error that issues an update.
 Number setValue(Number list)
          Whenever this method is called with a collection of TargetDefinitions as its argument, the internal list of observable targets is updated: Targets present in the KEY_IGNORE list are discarded. All targets not present in targets are added with their current merit. All targets already present are checked for their current merit.
private  void update(TargetDefinition td)
          /** Tries to get the merit of the target from the associated target merit.
 
Methods inherited from class stella.parameter.AbstractTargetValue
get, set
 
Methods inherited from class stella.parameter.AbstractTargetParameter
getAsStar, getConstant, getFormattedFor, getSetup
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, getFormatted, getFormatted, getName, getPreserveFile, getString, getString, register, rescanned, 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 stella.TargetDependingParameter
getFormattedFor
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_TIME

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

See Also:
Constant Field Values

KEY_TARGETMERIT

public static final String KEY_TARGETMERIT
The name of the parameter that hold the target merit.

See Also:
Constant Field Values

KEY_IGNORE

public static final String KEY_IGNORE
The key to the comma-list of unwanted targets.

See Also:
Constant Field Values

KEY_ONLY

public static final String KEY_ONLY
The key to the comma-list of only wanted targets.

See Also:
Constant Field Values

KEY_MAXENTRIES

public static final String KEY_MAXENTRIES
The file name where the target names vs. highest merits are writtn to.

See Also:
Constant Field Values

KEY_DUMPOBSERVE

public static final String KEY_DUMPOBSERVE
The file name where the target names vs. highest merits are writtn to.

See Also:
Constant Field Values

KEY_DUMPCOURSE

public static final String KEY_DUMPCOURSE
The directory into which the per-target merit course is writtn to.

See Also:
Constant Field Values

DEFNAME

public static final String DEFNAME
The default name of the target list.

See Also:
Constant Field Values

DEFMAXENTRIES

private static final int DEFMAXENTRIES
The default size of the date-merit list.

See Also:
Constant Field Values

DEFTIME

private static final String DEFTIME
The default name of the target list.

See Also:
Constant Field Values

DEFTARGETMERIT

private static final String DEFTARGETMERIT
The default name of the target list.

See Also:
Constant Field Values

targets

private Map<TargetDefinition,Float> targets
A map of parsed targets to highest merit.


course

private Map<TargetDefinition,Shelf<ObservableList.DateMerit>> course
A map of parsed targets to merit course.


merit

private TargetDependingParameter merit
The target depending parameter giving the merit of the target.


time

private Time time
The current time.


current

private TargetDefinition current
If a target/error was registered.

Constructor Detail

ObservableList

public ObservableList(Map<String,String> sprop)
Constructs a new observable targets list.

Method Detail

init

public void init()
Transforms the KEY_IGNORE property into a list of target names that should be discarded. Set the time zone to GMT on the date formatter.

Specified by:
init in interface Initializable
Overrides:
init in class AbstractParameter

exit

public void exit()
Exits this parameter. If any of the KEY_DUMPOBSERVE or KEY_DUMPCOURSE is set, the mapping of targets to their highest merits is writtn to KEY_DUMPOBSERVE, or the course of the particular target's merit is writtn as a file named after the target into the directory KEY_DUMPCOURSE.

Specified by:
exit in interface ExitCleaning
Overrides:
exit in class AbstractParameter

registerParameter

public void registerParameter(Parameter possmerit)
Registers the target merit parameter used to deduce the highest merit during an observing period.

Specified by:
registerParameter in interface ParameterDepending

setValue

public Number setValue(Number list)
Whenever this method is called with a collection of TargetDefinitions as its argument, the internal list of observable targets is updated:

Specified by:
setValue in interface Value
Returns:
The collection of all objects that are in the observable list.

registerProvider

public void registerProvider(TargetProviding<? extends TargetDefinition> list)
On target registering, we create a new mapping of targets to highest merits and the linking of targets to the merit course.

Specified by:
registerProvider in interface TargetProviderDepending

registerTarget

public void registerTarget(TargetDefinition td)
Target picked is the error that issues an update.

Specified by:
registerTarget in interface TargetDepending

getForTarget

public Number getForTarget(TargetDefinition td)
Picks the highest-ever recorded merit for this target. First, the target merit for this object is queried.

Specified by:
getForTarget in interface TargetDependingValue
Specified by:
getForTarget in interface TargetDependingParameter

getForError

public Object getForError(ErrorEvent ee)
Picks the highest-ever recorded merit for the target delivered with this error. Is identically to calling getFor with the target definition in the error

Specified by:
getForError in interface ErrorDependingParameter

getValue

public Number getValue()
Description copied from interface: Value
Returns the same object as Parameter.get() but already cast into a Number. Primitive data types can directly be extracted from this number without any further explicit casting.

Specified by:
getValue in interface Value

registerError

public void registerError(ErrorEvent ee)
Registers a target-picked error. This means, that we retrieve the merit of the picked target and store it.

Specified by:
registerError in interface ErrorDependingParameter

update

private void update(TargetDefinition td)
/** Tries to get the merit of the target from the associated target merit. If successful, a time-to-merit is stored in the target's list. If the current merit is the highest merit recorded ever, this merit is stored.


getMeritCourse

public List<ObservableList.DateMerit> getMeritCourse(TargetDefinition key)
Returns the course of this target merits.

Parameters:
key - A target definition.

clearObservables

public void clearObservables()
Clears the list of observable targets. Call this method once at the start of the observing period.