stella.parameter
Class IntegerId

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.AbstractValue
                      extended by stella.parameter.IntegerId
All Implemented Interfaces:
Cloneable, Parameter, StatePreserving, Value, ExitCleaning, Initializable, LocalizedSupplying, Preserving, PropertySupplying, ResourceSupplying

public class IntegerId
extends AbstractValue
implements StatePreserving

An ID describable as an integer. Preserves its state. Has the capability to be increased and returned by a single command getNextId().
Used as an counter for TPL command.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static int DEFMAXID
          Maximum value, defaults to Integer.MAX_VALUE
private static int DEFSTARTID
          Start value, defaults to 1.
private  int id
          The current value.
static String KEY_MAXID
          Maximum value, defaults to Integer.MAX_VALUE
static String KEY_STARTID
          Start value, defaults to 1.
 
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
IntegerId()
          Defaults all.
IntegerId(Map<String,String> prop)
          Constructs a new IntegerId.
 
Method Summary
 int getNextId()
          Returns the next id readily as an integer.
 Number getValue()
          Gets the current unique name identifier.
 void init()
          We scout for a file that hold the last unique value.
 boolean preserve()
          On exit, we save our current state if the serialize property is set.
 boolean restore()
          We restore our old value by reading the last date and target count from a serialization file.
 Number setValue(Number 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.AbstractValue
get, set
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, exit, 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 util.ExitCleaning
exit
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_STARTID

public static final String KEY_STARTID
Start value, defaults to 1.

See Also:
Constant Field Values

KEY_MAXID

public static final String KEY_MAXID
Maximum value, defaults to Integer.MAX_VALUE

See Also:
Constant Field Values

DEFSTARTID

private static final int DEFSTARTID
Start value, defaults to 1.

See Also:
Constant Field Values

DEFMAXID

private static final int DEFMAXID
Maximum value, defaults to Integer.MAX_VALUE

See Also:
Constant Field Values

id

private int id
The current value.

Constructor Detail

IntegerId

public IntegerId()
Defaults all.


IntegerId

public IntegerId(Map<String,String> prop)
Constructs a new IntegerId. The value is restored in the init section.

Method Detail

init

public void init()
We scout for a file that hold the last unique value. If this is not present or given, we use the default start value.

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

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

getValue

public Number getValue()
Gets the current unique name identifier.

Specified by:
getValue in interface Value

setValue

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

Specified by:
setValue in interface Value
Throws:
UnsupportedOperationException

getNextId

public int getNextId()
Returns the next id readily as an integer.