|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.jaret.util.date.timemachine.TimeMachine
public class TimeMachine
Implementation of a time supplier that can be controlled by various options. This is useful to cut dependencies on system time. The class should usually be used as a singleton, but is no singleton itself.
Constructor Summary | |
---|---|
TimeMachine(long initialTime)
Construct the time machine with an initial time. |
Method Summary | |
---|---|
void |
addTimeMachineListener(ITimeMachineListener timeMachineListener)
Add a listener to the timemachine. |
protected void |
fireTimeChanged(long oldTime,
long newTime)
Inform listeners about a change. |
Date |
getCurentTimeAsDate()
Retrieve the current time as a Date object. |
long |
getCurrentTime()
Retrieve the current time. |
boolean |
isAutoIncrement()
If autoincrement is true the time will be incremented by 1 millisecond with each time request. |
boolean |
isForwardOnly()
true if the time will always be going towards the future. |
boolean |
isRealTime()
If this return true the time machine is in real time mode always providing the system's current
time. |
void |
remTimeMachineListener(ITimeMachineListener timeMachineListener)
Remove a listener from the time machine. |
void |
setAutoIncrement(boolean autoIncrement)
set autoincrement mode. |
void |
setForwardOnly(boolean forwardOnly)
Set forward protection: if set to true time shifts going before the current time will be
disallowed. |
void |
setRealTime(boolean realTime)
Set the realtime mode. |
void |
setTime(long time)
Set the time of the timemachine. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TimeMachine(long initialTime)
initialTime
- time (millis)Method Detail |
---|
public long getCurrentTime()
getCurrentTime
in interface ITimeProvider
public Date getCurentTimeAsDate()
getCurentTimeAsDate
in interface ITimeProvider
public void setTime(long time)
time
- millispublic void addTimeMachineListener(ITimeMachineListener timeMachineListener)
timeMachineListener
- time machine listenerpublic void remTimeMachineListener(ITimeMachineListener timeMachineListener)
timeMachineListener
- listener to removeprotected void fireTimeChanged(long oldTime, long newTime)
oldTime
- last timenewTime
- current (= new) timepublic boolean isForwardOnly()
true
for ongoing time onlypublic void setForwardOnly(boolean forwardOnly)
true
time shifts going before the current time will be
disallowed. Forward only is the default.
forwardOnly
- true
for forward only mode.public boolean isAutoIncrement()
true
the time will be incremented by 1 millisecond with each time request.
true
if autoincrement is setpublic void setAutoIncrement(boolean autoIncrement)
autoIncrement
- if sert to true
the time will be increased by 1 millisecond which each
requestpublic boolean isRealTime()
true
the time machine is in real time mode always providing the system's current
time.
public void setRealTime(boolean realTime)
realTime
- if set to true
the time machine will be disabled, always returning the systems's
current time
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |