public final class TimeStampedValue extends Object implements Map.Entry<Long,Object>, Comparable<TimeStampedValue>
The key is the time in ms and may be used in a Map.
compares the key.compareTo(TimeStampedValue)
Constructor and Description |
---|
TimeStampedValue(long key,
Object value)
Creates an instance with the given timestamp key and the value to time
stamp.
|
TimeStampedValue(Object value)
Creates an instance for the given value that is time stamped with the
current time.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(TimeStampedValue obj)
Compares the given
TimeStampedValue to this by the internal
getTime() . |
boolean |
equals(Object obj) |
Long |
getKey()
Returns the
Long that marks the time stamp (difference, measured in
milliseconds, between the current time and midnight, January 1, 1970 UTC). |
long |
getTime()
Returns the time stamp (difference, measured in milliseconds, between the
current time and midnight, January 1, 1970 UTC).
|
Object |
getValue()
Returns the time stamp.
|
int |
hashCode() |
boolean |
isPast()
Returns whether the internal time stamp marks a time in the past or not.
|
Object |
setValue(Object value)
Assigns a different value to the timestamp.
|
public TimeStampedValue(long key, Object value)
key
- the time stamp (difference, measured in milliseconds, between the
current time and midnight, January 1, 1970 UTC).value
- the value to time stamp.public TimeStampedValue(Object value)
value
- the value to time stamp.System.currentTimeMillis()
public int compareTo(TimeStampedValue obj)
TimeStampedValue
to this by the internal
getTime()
.
compareTo
in interface Comparable<TimeStampedValue>
obj
- the object to compare this to.Comparable.compareTo(java.lang.Object)
public boolean equals(Object obj)
public Long getKey()
Long
that marks the time stamp (difference, measured in
milliseconds, between the current time and midnight, January 1, 1970 UTC).public long getTime()
public Object getValue()
getValue
in interface Map.Entry<Long,Object>
Map.Entry.getValue()
public int hashCode()
public boolean isPast()
For normal a time stamp represents a value regarded at a time. But it is also thinkable to mark a value for expiration in the future. This method returns true if the internal time- representing key is smaller than the actual time.
public Object setValue(Object value)
setValue
in interface Map.Entry<Long,Object>
value
- the new value to be marked with this timestamp.Map.Entry.setValue(java.lang.Object)
Copyright © 2001 - 2010 LGPL, All Rights Footloose.