Package org.simpleframework.http.core
Class Timer
java.lang.Object
org.simpleframework.http.core.Timer
The
Timer object is used to set the time a specific
event occurred at. The time can be set only once from that point
on all attempts to set the time are ignored. This makes this
timer useful when there is a desire to record when a certain
scenario was first encountered, for example when a request is
first read from the underlying transport.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
unit
This is the time unit that this timer provides the time in. -
time
private volatile long timeThis is the time in milliseconds used to record the event.
-
-
Constructor Details
-
Timer
Constructor for theTimer
object. This is used to record when a specific event occurs. The provided time unit is used to determine how the time is retrieved.- Parameters:
unit
- this time unit this timer will be using
-
-
Method Details
-
isSet
public boolean isSet()This is used to determine if the timer has been set. If theset
method has been called on this instance before then this will return true, otherwise false.- Returns:
- this returns true if the timer has been set
-
set
public void set()This is used to set the time for a specific event. Invoking this method multiple times will have no effect as the time is set for the first invocation only. Setting the time in this manner enables start times to be recorded effectively. -
get
public long get()This is used to get the time for a specific event. The time returned by this method is given in the time unit specified on construction of the instance.- Returns:
- this returns the time recorded by the timer
-