|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.rshtech.util.CachedObject<T>
public class CachedObject<T>
A simple Cached implementation which allows you to track the lifecycle of an object (when it was created, whether it has expired, etc). 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 | |
|---|---|
protected long |
creationTime
|
static int |
DISABLED
|
protected long |
expirationLimit
|
protected long |
lastUseTime
|
protected boolean |
manuallyExpired
|
protected long |
unusedExpirationLimit
|
| Constructor Summary | |
|---|---|
protected |
CachedObject()
|
|
CachedObject(T valueObj)
|
|
CachedObject(T valueObj,
long expirationVal,
long unusedExpirationVal)
|
protected |
CachedObject(T valueObj,
long expirationVal,
long unusedExpirationVal,
boolean ignoreNull)
|
| Method Summary | |
|---|---|
boolean |
equals(java.lang.Object rhs)
|
void |
expire()
Forcibly expire the object regardless of its internal state. |
long |
getCreationTime()
Returns the time (in milliseconds) the object was created. |
long |
getExpirationLimit()
Get the expiration limit (in milliseconds). |
long |
getLastUseTime()
Returns the last time (in milliseconds) this object was used or accessed. |
long |
getUnusedExpirationLimit()
Get the expiration limit (in milliseconds). |
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 |
setExpirationLimit(long expirationVal)
Set the expiration limit (in milliseconds). |
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 |
setUnusedExpirationLimit(long expirationVal)
Set the unused expiration limit (in milliseconds). |
void |
setValue(T value)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int DISABLED
protected long creationTime
protected long lastUseTime
protected long expirationLimit
protected long unusedExpirationLimit
protected boolean manuallyExpired
| Constructor Detail |
|---|
public CachedObject(T valueObj)
valueObj - the object to cache
public CachedObject(T valueObj,
long expirationVal,
long unusedExpirationVal)
valueObj - the object to cacheprotected CachedObject()
valueObj - the object to cache
protected CachedObject(T valueObj,
long expirationVal,
long unusedExpirationVal,
boolean ignoreNull)
valueObj - the object to cache| Method Detail |
|---|
public T getValue()
public void setValue(T value)
value - The value to set.public long getCreationTime()
Cached
getCreationTime in interface Cachedpublic long getLastUseTime()
Cached
getLastUseTime in interface Cachedpublic void setLastUseTime()
Cached
setLastUseTime in interface Cachedpublic void setLastUseTime(long lastUseTime)
Cached
setLastUseTime in interface CachedlastUseTime - the milliseconds value to use.public boolean isExpired()
Cached
isExpired in interface Cached
public boolean isExpired(long expirationVal,
long unusedExpirationVal)
Cached
isExpired in interface CachedexpirationVal - 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 Cachedpublic void renew()
Cached
renew in interface Cachedpublic long getExpirationLimit()
Cached
getExpirationLimit in interface Cachedpublic void setExpirationLimit(long expirationVal)
Cached
setExpirationLimit in interface CachedexpirationVal - 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).public long getUnusedExpirationLimit()
Cached
getUnusedExpirationLimit in interface Cachedpublic void setUnusedExpirationLimit(long expirationVal)
Cached
setUnusedExpirationLimit in interface CachedexpirationVal - 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 boolean equals(java.lang.Object rhs)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectprotected void setCreationTime()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||