|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.services.cache.mru.KeyInfo
Package visibility class used by the MRUCache to store a reference to the key object along with the last accessed time and expiration time for that key/value in milliseconds.
Implements the java.lang.Comparable interface, to allow fast sorting of KeyInfo objects in a Collection - or in this case, a TreeSet. Comparision is based on the lastAccessedTime for the key (which is set by the MRUCache each time the key is passed into a call to get. If the lastAccessedTime of two KeyInfo objects is the same the compareTo method of the Comparable interface is invoked on the key object to determine the natural ordering.
Copyright 2000 Sapient
Field Summary | |
private long |
expirationTime
Internal variable to hold the time when this key's element will expire |
private Object |
key
Internal variable to hold the key. |
private long |
lastAccessTime
Internal variable to hold the time this key was last accessed. |
Constructor Summary | |
(package private) |
KeyInfo(Object key,
long expirationInterval)
Default constructor, which constructs a KeyInfo object from a key, and initialized the lastAccessTime to the current time. |
Method Summary | |
int |
compareTo(Object other)
Implementation of the compareTo method from the Comparable interface. |
boolean |
equals(Object other)
Checks if the KeyInfo objects are equal. |
(package private) long |
getExpirationTime()
Simple getter for the expirationTime held inside this KeyInfo object. |
(package private) Object |
getKey()
Simple getter for the key held inside this KeyInfo object. |
(package private) boolean |
hasExpired()
A simple method to determine whether or not the element has expired |
int |
hashCode()
Returns a hash code value for the object based on the key. |
String |
toString()
Overrides the toString() method to return the toString() of the key object, prints the lastAccessTime and expirationTime in milliseconds. |
(package private) void |
updateAccessTime()
Updates the lastAccessedTime of the KeyInfo, which is used to determine its natural ordering for the compareTo method. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
private Object key
private long lastAccessTime
private long expirationTime
Constructor Detail |
KeyInfo(Object key, long expirationInterval)
Default constructor, which constructs a KeyInfo object from a key, and initialized the lastAccessTime to the current time.
key
- The object representing the key for this KeyInfo.expirationInterval
- duration of time of the element in
milliseconds.Method Detail |
Object getKey()
Simple getter for the key held inside this KeyInfo object.
long getExpirationTime()
Simple getter for the expirationTime held inside this KeyInfo object.
boolean hasExpired()
A simple method to determine whether or not the element has expired
void updateAccessTime()
Updates the lastAccessedTime of the KeyInfo, which is used to determine its natural ordering for the compareTo method.
public final int compareTo(Object other)
compareTo
in interface Comparable
other
- Another KeyInfo object to compare this one to.
Comparable
public final boolean equals(Object other)
Checks if the KeyInfo objects are equal.
equals
in class Object
other
- The other object to check for equality.
public int hashCode()
hashCode
in class Object
public String toString()
Overrides the toString() method to return the toString() of the key object, prints the lastAccessTime and expirationTime in milliseconds.
toString
in class Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |