|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.rshtech.util.CachedObject<T>
com.rshtech.util.SoftCachedObject<T>
public class SoftCachedObject<T>
A simple Cached implementation which allows you to track the lifecycle of an object (when it was created, whether it has expired, etc) and uses a SoftReference to hold the value. This enclosure allows you to handle single object caching; that is, if you do not need a collection of keyed objects (see ObjectCache) but just one object.
| Field Summary | |
|---|---|
static int |
DISABLED
|
| Fields inherited from class com.rshtech.util.CachedObject |
|---|
creationTime, expirationLimit, lastUseTime, manuallyExpired, unusedExpirationLimit |
| Constructor Summary | |
|---|---|
SoftCachedObject(T valueObj)
|
|
SoftCachedObject(T valueObj,
long expirationVal,
long unusedExpirationVal)
|
|
| Method Summary | |
|---|---|
boolean |
equals(java.lang.Object rhs)
|
void |
expire()
Forcibly expire the object regardless of its internal state. |
T |
getValue()
|
int |
hashCode()
|
boolean |
isExpired()
Is the implementation expired (should it be removed from a cache or discarded)? |
boolean |
isExpired(long expirationVal,
long unusedExpirationVal)
Is the implementation expired (should it be removed from a cache or discarded) based on the supplied criteria? |
void |
renew()
Renew an object (at least removing a forcible expiration, possibly resetting internal state). |
protected void |
setCreationTime()
|
void |
setLastUseTime()
Notify the implementation that it should mark the last use time using the current time. |
void |
setLastUseTime(long lastUseTime)
Set the last use time for the implementation using the specified value (in milliseconds). |
void |
setValue(T value)
|
java.lang.String |
toString()
|
| Methods inherited from class com.rshtech.util.CachedObject |
|---|
getCreationTime, getExpirationLimit, getLastUseTime, getUnusedExpirationLimit, setExpirationLimit, setUnusedExpirationLimit |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int DISABLED
| Constructor Detail |
|---|
public SoftCachedObject(T valueObj)
valueObj - the object to cache
public SoftCachedObject(T valueObj,
long expirationVal,
long unusedExpirationVal)
valueObj - the object to cache| Method Detail |
|---|
public T getValue()
getValue in class CachedObject<T>public void setValue(T value)
setValue in class CachedObject<T>value - The value to set.public void setLastUseTime()
Cached
setLastUseTime in interface CachedsetLastUseTime in class CachedObject<T>public void setLastUseTime(long lastUseTime)
Cached
setLastUseTime in interface CachedsetLastUseTime in class CachedObject<T>lastUseTime - the milliseconds value to use.public boolean isExpired()
Cached
isExpired in interface CachedisExpired in class CachedObject<T>
public boolean isExpired(long expirationVal,
long unusedExpirationVal)
Cached
isExpired in interface CachedisExpired in class CachedObject<T>expirationVal - the amount of milliseconds that can pass since
the creation time before the implementation is considered
expired. A value of -1 is considered a "disabled"
value and such values should then be ignored (that is
the implementation should never expire on the creation
time).unusedExpirationVal - the amount of milliseconds that can pass since
the last use time before the implementation is considered
expired. A value of -1 is considered a "disabled"
value and such values should then be ignored (that is
the implementation should never expire on the last use
time).
public void expire()
Cached
expire in interface Cachedexpire in class CachedObject<T>public void renew()
Cached
renew in interface Cachedrenew in class CachedObject<T>public boolean equals(java.lang.Object rhs)
equals in class CachedObject<T>public int hashCode()
hashCode in class CachedObject<T>public java.lang.String toString()
toString in class CachedObject<T>protected void setCreationTime()
setCreationTime in class CachedObject<T>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||