stella.parameter
Class AbstractParameter

java.lang.Object
  extended by util.PropertyContainer
      extended by stella.parameter.AbstractParameter
All Implemented Interfaces:
Cloneable, Parameter, ExitCleaning, Initializable, PropertyBearing
Direct Known Subclasses:
AbstractCachedParameter, AbstractDatabaseParameter, AbstractRemoteParameter, AbstractTargetParameter, AbstractTrigger, AbstractValue, ConstantOffset, DateFromJd, DerotatorCenter, FlatGroup, FlatPointing, FocusQuality, HostAddress, JSliderParameter, Moon, ParameterStub, SimpleParameter, SnapshotParameter, TargetList, WatchController, WcsString

public abstract class AbstractParameter
extends PropertyContainer
implements Parameter, ExitCleaning

An abstract base class for all parameter. Provides a protected constructor out of a Map object and a createParameter(java.util.Map) method to construct a parameter.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyContainer
PropertyContainer.URLResource
 
Field Summary
static String KEY_FORMAT
          The (decimal) formatter used for getFormatted().
static String KEY_NAME
          The key to the unique trigger name.
static String KEY_PRESERVE
          Convenience parameter for StatePreserving parameters.
static String UNKNOWN
          The unknown identifier.
 
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 AbstractParameter()
          Protected empty constructor.
protected AbstractParameter(Map info)
          Constructs a new trigger.
 
Method Summary
static Parameter createParameter(Map prop)
          Creates a new trigger instance using the class key found in the properties.
protected static boolean delivers(Parameter p)
          Checks if the parameter handed over is non-null and delivers non-null values.
 void exit()
          If we preserve our state, we do this at exit.
 String getFormatted()
          A formatted string representation of the value of this paramter.
 String getFormatted(Object myval)
          Returns the formatted version of a given object.
 String getName()
          Scans the properties of this global for the KEY_NAME key.
protected  File getPreserveFile(boolean onlyexisting)
          For state preserving parameters that use a file, this method returns the file the KEY_PRESERVE parameter points to.
 String getString()
          A string representation of the value of this paramter.
protected  String getString(Object myval)
          A string representation of the given object.
 void init()
          Initializes the parameter with its class name.
protected static boolean register(Parameter p, Class as, String name)
          Checks if the parameter is of the required class type and has the correct name.
protected  double rescanned(String key, String old, String newval)
          If we have a known format set, we try to parse from that class.
protected  void setName(String newname)
          Sets the name of the parameter.
 String toString()
          A string representation of this paramter.
 
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.Parameter
get, 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
 

Field Detail

KEY_NAME

public static final String KEY_NAME
The key to the unique trigger name.

See Also:
Constant Field Values

KEY_FORMAT

public static final String KEY_FORMAT
The (decimal) formatter used for getFormatted().

See Also:
Constant Field Values

KEY_PRESERVE

public static final String KEY_PRESERVE
Convenience parameter for StatePreserving parameters.

See Also:
Constant Field Values

UNKNOWN

public static final String UNKNOWN
The unknown identifier.

See Also:
Constant Field Values
Constructor Detail

AbstractParameter

protected AbstractParameter()
Protected empty constructor.


AbstractParameter

protected AbstractParameter(Map info)
Constructs a new trigger. All its functionality is stored in the properties. Use of this constructor ensures that the PropertyBearing.KEY_CLASS property is set. To not spoil any default name setting, the name (KEY_NAME) remains unassigned.

Method Detail

createParameter

public static final Parameter createParameter(Map prop)
Creates a new trigger instance using the class key found in the properties. If the PropertyBearing.KEY_CLASS property is defined, a new Trigger with the stated class name is created, the supplied properties used as an argument in the constructor.


rescanned

protected double rescanned(String key,
                           String old,
                           String newval)
If we have a known format set, we try to parse from that class.

Overrides:
rescanned in class PropertyContainer

getName

public String getName()
Scans the properties of this global for the KEY_NAME key. Returns the mapped value or null if undefined.

Specified by:
getName in interface Parameter

setName

protected void setName(String newname)
Sets the name of the parameter.


init

public void init()
Initializes the parameter with its class name.

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

exit

public void exit()
If we preserve our state, we do this at exit.

Specified by:
exit in interface ExitCleaning

toString

public String toString()
A string representation of this paramter.

Overrides:
toString in class PropertyContainer

getString

public String getString()
A string representation of the value of this paramter.

Specified by:
getString in interface Parameter

getString

protected String getString(Object myval)
A string representation of the given object.


getFormatted

public String getFormatted()
A formatted string representation of the value of this paramter.

Specified by:
getFormatted in interface Parameter

getFormatted

public String getFormatted(Object myval)
Returns the formatted version of a given object.


getPreserveFile

protected File getPreserveFile(boolean onlyexisting)
For state preserving parameters that use a file, this method returns the file the KEY_PRESERVE parameter points to.

Parameters:
onlyexisting - If true, file must also exist and be readable.

delivers

protected static boolean delivers(Parameter p)
Checks if the parameter handed over is non-null and delivers non-null values.


register

protected static boolean register(Parameter p,
                                  Class as,
                                  String name)
Checks if the parameter is of the required class type and has the correct name.