stella.parameter
Class Unique

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.AbstractRemoteParameter
                      extended by stella.parameter.Unique
All Implemented Interfaces:
Cloneable, Remote, ErrorDependingParameter, Parameter, StatePreserving, RemoteParameter, ExitCleaning, Initializable, LocalizedSupplying, Preserving, PropertySupplying, Reloadable, ResourceSupplying, RmiCaster

public class Unique
extends AbstractRemoteParameter
implements ErrorDependingParameter, StatePreserving, Reloadable

This parameter provides a unique identifier string that may be used in acquire/guide frames, scientific exposures or similar. It uses the current date and a running number and constructs a string similar to 20060312-0001 out of it. It should be set by the master mind and transproted via RMI to interested clients (like the adapter master or the CCD).


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
static String DEFBINDNAME
          The default name of this value.
static String DEFNAME
          The default name of this value.
static DateFormat df
          The date formatter to get from now to a guider/acquire/ccd fits name.
static String KEY_SEPARATOR
          A separator string after the date, before MINUS and count.
static String MINUS
          The separator between date and running number.
static NumberFormat nf
          The number format for running counts.
static String nq
          A query operator for running counts.
private  int targetcount
          The target acquired at this date.
static NumberFormat tf
          The number format for running tries.
static String tq
          A query operator for running tries.
private  Date usedate
          For naming of acquire/guide/ccd frames.
 
Fields inherited from class stella.parameter.AbstractRemoteParameter
DEFBIND, KEY_BIND
 
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
Unique(Map<String,String> prop)
          We are not allowed to change any properties.
 
Method Summary
 Object get()
          Gets the current unique name identifier.
 Object getForError(ErrorEvent ee)
          Querying the unique parameter for an error returns the current unique number, advancing is only done by registering.
 String getUniqueTarget()
          The unique target ID.
 void init()
          We scout for a file that hold the last unique values.
private  void next()
          If the exposure count is to be included in the unique numbering, this is how it is formatted and attached to it /** Increases the current number.
 boolean preserve()
          On exit, we save our current state if the serialize property is set.
 void registerError(ErrorEvent ee)
          If the error registered is a TargetPicked, we advance the unique number.
 double rescanned(String key, String old, String newval)
          We throw an illegal argument exception if export port changed
 boolean restore()
          We restore our old value by reading the last date and target count from a serialization file.
 Object set(Object val)
          Setting the unique number is only allowed vai a call to next, therefore this method throws an UnsupportedOperationException.
 
Methods inherited from class stella.parameter.AbstractRemoteParameter
addRmiListener, bindToRegistry, exit, isValid, remoteGet, removeRmiListener, unbindFromRegistry
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, getFormatted, getFormatted, getName, getPreserveFile, getString, getString, 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.ExitCleaning
exit
 
Methods inherited from interface util.Reloadable
reload
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

df

public static final DateFormat df
The date formatter to get from now to a guider/acquire/ccd fits name.


nf

public static final NumberFormat nf
The number format for running counts.


tf

public static final NumberFormat tf
The number format for running tries.


tq

public static final String tq
A query operator for running tries.

See Also:
Constant Field Values

nq

public static final String nq
A query operator for running counts.

See Also:
Constant Field Values

MINUS

public static final String MINUS
The separator between date and running number.

See Also:
Constant Field Values

DEFNAME

public static final String DEFNAME
The default name of this value.

See Also:
Constant Field Values

DEFBINDNAME

public static final String DEFBINDNAME
The default name of this value.

See Also:
Constant Field Values

KEY_SEPARATOR

public static final String KEY_SEPARATOR
A separator string after the date, before MINUS and count.

See Also:
Constant Field Values

usedate

private Date usedate
For naming of acquire/guide/ccd frames.


targetcount

private int targetcount
The target acquired at this date.

Constructor Detail

Unique

public Unique(Map<String,String> prop)
       throws RemoteException
We are not allowed to change any properties.

Throws:
RemoteException
Method Detail

init

public void init()
We scout for a file that hold the last unique values. If this is not present or given, we use the current date and zero.

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

rescanned

public double rescanned(String key,
                        String old,
                        String newval)
We throw an illegal argument exception if export port changed

Specified by:
rescanned in interface Reloadable
Overrides:
rescanned in class AbstractRemoteParameter

restore

public boolean restore()
We restore our old value by reading the last date and target count from a serialization file.

Specified by:
restore in interface Preserving
Returns:
False, if restoring the value was not possible.

preserve

public boolean preserve()
On exit, we save our current state if the serialize property is set. First the date, then the targetnumber is writtn.

Specified by:
preserve in interface Preserving
Returns:
false, if preserving the current state was not possible

getUniqueTarget

public String getUniqueTarget()
The unique target ID.


get

public Object get()
Gets the current unique name identifier.

Specified by:
get in interface Parameter

set

public Object set(Object val)
           throws UnsupportedOperationException
Setting the unique number is only allowed vai a call to next, therefore this method throws an UnsupportedOperationException.

Specified by:
set in interface Parameter
Returns:
The previous value of this parameter.
Throws:
UnsupportedOperationException - If this parameter is read-only.

registerError

public void registerError(ErrorEvent ee)
If the error registered is a TargetPicked, we advance the unique number.

Specified by:
registerError in interface ErrorDependingParameter

getForError

public Object getForError(ErrorEvent ee)
Querying the unique parameter for an error returns the current unique number, advancing is only done by registering.

Specified by:
getForError in interface ErrorDependingParameter
Returns:
null, if not a TargetPicked, otherwise get()

next

private void next()
If the exposure count is to be included in the unique numbering, this is how it is formatted and attached to it /** Increases the current number. If the date format changed the formatting of the current date to the last date, the targetcount is reset.