public class StopWatch extends AbstractValue implements ParameterDepending, StatePreserving, Reloadable
stop() method. After a call to
start() it starts accumulating time again. To reset the time counter
to zero, call reset() which is an abreviation to setValue(java.lang.Number)
with a zero Long.PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private Long |
acttime
The value of the stop watch at the last
stop() call. |
private static long |
DEFINIT
The default initial time of the stop watch.
|
private static String |
DEFTIME
The default name of the time to use.
|
static String |
KEY_INIT
The key linked to a start value of the stop watch.
|
static String |
KEY_TIME
The key linked to the name of the time to use.
|
private long |
starttime
The long recording the time at a {link #start} call.
|
private Value |
timer
The parameter denoting time.
|
KEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWNKEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASSKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME| Constructor and Description |
|---|
StopWatch(Map<String,String> prop)
Constructs a new stop watch.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getFormatted()
Formats the output to show seconds instead of milliseconds.
|
private long |
getTime()
Returns the current time.
|
Number |
getValue()
Gets the current value of the stop watch.
|
boolean |
isCounting()
Returns true if the stop watch is currently running.
|
boolean |
preserve()
Preserves the overall true time of the trigger.
|
void |
registerParameter(Parameter time)
Registers the time parameter to this trigger.
|
double |
rescanned(String key,
String old,
String newval)
It is not possible to rescan the time parameter name.
|
void |
reset()
Resets the counter of the stop watch.
|
void |
restart()
Resets the counter of the stop watch and starts it, if not already
running.
|
boolean |
restore()
Initializes the trigger.
|
Number |
setValue(Number newval)
Sets the value of the stop watch.
|
void |
start()
Stats the stop watch.
|
void |
stop()
Stops the stop watch.
|
get, setcreateParameter, delivers, exit, getFormatted, getName, getPreserveFile, getString, getString, init, overrideDefaultName, register, setName, toStringclone, createFrom, createFrom, createFrom, createInstance, getApplet, getAsResources, getLocate, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, hasLocalURLs, initProperties, keyCreate, keyCreate, reload, setAppletaugment, augment, 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, parseObject, reload, removeProperty, requires, setObject, setProperties, setProperty, stringPropertiesequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdefaultBoolean, 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, stringPropertiesinitexitreloadpublic static final String KEY_INIT
public static final String KEY_TIME
private static final long DEFINIT
private static final String DEFTIME
private Value timer
private long starttime
public double rescanned(String key, String old, String newval)
rescanned in interface Reloadablerescanned in class AbstractParameterpublic Number setValue(Number newval)
public Number getValue()
public void registerParameter(Parameter time)
registerParameter in interface ParameterDependingpublic boolean restore()
restore in interface Preservingpublic boolean preserve()
preserve in interface Preservingpublic void start()
starttime is set to the
current time.public void stop()
public void reset()
setValue(java.lang.Number) with a zero-valued Long. The running/stoped state of
the watch is inaffected.public void restart()
public boolean isCounting()
public String getFormatted()
getFormatted in interface ParametergetFormatted in class AbstractParameterprivate long getTime()
timer parameter has been set,
this time is used, otherwise the system time is grabbed.