stella.parameter
Class SettableTime

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.AbstractTime
                          extended by stella.parameter.Time
                              extended by stella.parameter.SettableTime
All Implemented Interfaces:
Cloneable, Parameter, AfterRegistering, Increasing<Number>, ParameterDepending, Value, WeatherDependingParameter, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, Reloadable, ResourceSupplying
Direct Known Subclasses:
AcceleratedTime

public class SettableTime
extends Time
implements WeatherDependingParameter, ParameterDepending, AfterRegistering

A general variable representing time. This time is settable and advancable, making it useful for simulators that want to mimic different times.

This class uses a dirty trick. By implementing the WeatherDependingParameter interface, we get a hold of the weather station that will be notified in case of time advances, if it supports this.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static DateFormat DEFDATEFORMAT
          The default date formatter.
private  long faketime
          The time that should be faked.
static String KEY_DATEFORMAT
          The key mapping to the date format to use.
static String KEY_DUSKSTART
          If present, only the day is deduced from offset, time from twilight.
static String KEY_OFFSET
          The key mapping to the starting time offset of the accelerated time.
static String KEY_TIMEZONE
          The key mapping to the time zone format to use.
private  Longitude lambda
          For twilight fakes, this is the longitude.
static String OFFSETSYSPROP
          If acceleration is set, we export to the system properties.
private  Latitude phi
          For twilight fakes, this is the latitude.
private  SimulatorWeather simul
          A weather station based on time.
 
Fields inherited from class stella.parameter.Time
DEFNAME
 
Fields inherited from class stella.parameter.AbstractTime
ISO, ISOSTANDARD, UTC
 
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
SettableTime(Map<String,String> prop)
          Constructs a new global representing a faked time.
 
Method Summary
 void advance(long add)
          Advances the time for the stated amount of milliseconds.
 void afterAll()
          For twilight times we are only ready once we have longitude and latitude.
 Object getForWeather(WeatherSurveying weather)
          Dummy method.
 Number getValue()
          Returns the time as an Long object.
 void registerParameter(Parameter p)
          If parameter is a latitude, we keep it.
 void registerWeather(WeatherSurveying weather)
          Registers the weather surveyor.
 double rescanned(String key, String old, String newval)
          If offset or date format change, we act.
 Object set(Object date)
          Links the Parameter.set(java.lang.Object) to the setDate(java.lang.String) method.
 void setDate(Date fake)
          Sets a fake date.
 boolean setDate(String fake)
          Sets the fake time to the date represented by the argument string.
private  void setFakeTime(long ms)
           
 void setJd(double jd)
          Sets a JD.
 
Methods inherited from class stella.parameter.Time
getAscendTime, getTime
 
Methods inherited from class stella.parameter.AbstractTime
getFormatted, setValue
 
Methods inherited from class stella.parameter.AbstractValue
get
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, exit, 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
get, 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_OFFSET

public static final String KEY_OFFSET
The key mapping to the starting time offset of the accelerated time.

See Also:
Constant Field Values

KEY_DUSKSTART

public static final String KEY_DUSKSTART
If present, only the day is deduced from offset, time from twilight.

See Also:
Constant Field Values

KEY_DATEFORMAT

public static final String KEY_DATEFORMAT
The key mapping to the date format to use.

See Also:
Constant Field Values

KEY_TIMEZONE

public static final String KEY_TIMEZONE
The key mapping to the time zone format to use.

See Also:
Constant Field Values

DEFDATEFORMAT

private static final DateFormat DEFDATEFORMAT
The default date formatter.


OFFSETSYSPROP

public static final String OFFSETSYSPROP
If acceleration is set, we export to the system properties.

See Also:
Constant Field Values

faketime

private long faketime
The time that should be faked.


simul

private SimulatorWeather simul
A weather station based on time.


lambda

private Longitude lambda
For twilight fakes, this is the longitude.


phi

private Latitude phi
For twilight fakes, this is the latitude.

Constructor Detail

SettableTime

public SettableTime(Map<String,String> prop)
Constructs a new global representing a faked time.

Method Detail

afterAll

public void afterAll()
For twilight times we are only ready once we have longitude and latitude.

Specified by:
afterAll in interface AfterRegistering

registerParameter

public void registerParameter(Parameter p)
If parameter is a latitude, we keep it.

Specified by:
registerParameter in interface ParameterDepending

rescanned

public double rescanned(String key,
                        String old,
                        String newval)
If offset or date format change, we act.

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

set

public Object set(Object date)
Links the Parameter.set(java.lang.Object) to the setDate(java.lang.String) method.

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

registerWeather

public void registerWeather(WeatherSurveying weather)
Registers the weather surveyor. If it is a SimulatorWeather, we keep a reference for possible time advances.

Specified by:
registerWeather in interface WeatherDependingParameter

getForWeather

public Object getForWeather(WeatherSurveying weather)
Dummy method. In cases we are called on this method, we forward the weather station to the registerWeather(stella.sensor.WeatherSurveying) method.

Specified by:
getForWeather in interface WeatherDependingParameter
Returns:
AbstractValue.get()

setDate

public boolean setDate(String fake)
Sets the fake time to the date represented by the argument string.


setDate

public void setDate(Date fake)
Sets a fake date.


setJd

public void setJd(double jd)
Sets a JD.


setFakeTime

private void setFakeTime(long ms)

advance

public void advance(long add)
Advances the time for the stated amount of milliseconds.


getValue

public Number getValue()
Returns the time as an Long object. Returns the value of the time as it was either set, using setDate(java.lang.String) or advanced, using advance(long).

Specified by:
getValue in interface Value
Overrides:
getValue in class Time