com.oroad.stxx.cache
Class CacheWrapper

java.lang.Object
  extended byjava.lang.ref.Reference
      extended byjava.lang.ref.SoftReference
          extended bycom.oroad.stxx.cache.CacheWrapper
All Implemented Interfaces:
Cacheable

public class CacheWrapper
extends java.lang.ref.SoftReference
implements Cacheable

Simple wrapper for an object that wants to be cached.

Author:
Don Brown

Constructor Summary
CacheWrapper(java.lang.Object id, long expiryTime, long modTime, java.lang.Object o)
          Wraps an object to cache
CacheWrapper(java.lang.Object id, long expiryTime, java.lang.Object o)
          Wraps an object to cache
 
Method Summary
 long getExpiryTime()
          Gets the time (in milliseconds) when this object will expire
 java.lang.Object getIdentifier()
          Gets the identifier for the object
 long getLastAccessedTime()
          Gets the last accessed time in milliseconds
 long getLastModifiedTime()
          Gets the time the object was last modified
 java.lang.Object getWrapped()
          Gets the wrapped object
 boolean isExpired()
          Gets whether the cached object is expired
 void setLastAccessedTime(long time)
          Sets the last time this object was accessed
 void setLastModifiedTime(long time)
          Sets the last modified time
 
Methods inherited from class java.lang.ref.SoftReference
get
 
Methods inherited from class java.lang.ref.Reference
clear, enqueue, isEnqueued
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheWrapper

public CacheWrapper(java.lang.Object id,
                    long expiryTime,
                    java.lang.Object o)
Wraps an object to cache

Parameters:
id - The unique identifier of the object
expiryTime - The expiration time as a timestamp
o - The object to cache

CacheWrapper

public CacheWrapper(java.lang.Object id,
                    long expiryTime,
                    long modTime,
                    java.lang.Object o)
Wraps an object to cache

Parameters:
id - The unique identifier of the object
expiryTime - The expiration time as a timestamp
modTime - The last modified time as a timestamp
o - The object to cache
Method Detail

setLastModifiedTime

public void setLastModifiedTime(long time)
Sets the last modified time

Specified by:
setLastModifiedTime in interface Cacheable
Parameters:
time - The last modified time in milliseconds

getLastModifiedTime

public long getLastModifiedTime()
Gets the time the object was last modified

Specified by:
getLastModifiedTime in interface Cacheable
Returns:
The time in milliseconds

getIdentifier

public java.lang.Object getIdentifier()
Gets the identifier for the object

Specified by:
getIdentifier in interface Cacheable
Returns:
The identifier value

getLastAccessedTime

public long getLastAccessedTime()
Gets the last accessed time in milliseconds

Specified by:
getLastAccessedTime in interface Cacheable
Returns:
The lastAccessedTime value

setLastAccessedTime

public void setLastAccessedTime(long time)
Sets the last time this object was accessed

Specified by:
setLastAccessedTime in interface Cacheable
Parameters:
time - Time in milliseconds

getExpiryTime

public long getExpiryTime()
Gets the time (in milliseconds) when this object will expire

Specified by:
getExpiryTime in interface Cacheable
Returns:
The expiryTime value

getWrapped

public java.lang.Object getWrapped()
Gets the wrapped object

Returns:
The wrapped value

isExpired

public boolean isExpired()
Gets whether the cached object is expired

Specified by:
isExpired in interface Cacheable
Returns:
True if the object has expired