freemarker.template.cache
Class CacheElement

java.lang.Object
  extended by freemarker.template.cache.CacheElement
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public final class CacheElement
extends java.lang.Object
implements java.lang.Comparable, java.lang.Cloneable

Represent a single entry in the cache.

Version:
$Id: CacheElement.java 1153 2013-04-15 10:59:37Z run2000 $

Constructor Summary
CacheElement(CacheElement ce)
          Create a new shallow clone of a given CacheElement.
CacheElement(java.lang.String name, java.lang.String type, Cacheable object, long lastModified)
          Create a new CacheElement.
 
Method Summary
 void age()
          Age this element in the cache.
 java.lang.Object clone()
          Performs a shallow clone of the CacheElement.
 int compareTo(CacheElement target)
          Compares another CacheElement against this one.
 int compareTo(java.lang.Object obj)
          Compares an object against this CacheElement.
 java.lang.String getName()
          Retrieve the name of the element being cached.
 Cacheable getObject()
          Retrieve the object being cached.
 java.lang.String getType()
          Retrieve the type of object being cached.
 boolean isExpired(int age)
          Has the object in this cache element expired?
 long lastModified()
          Retrieve the time the element was last modified, according to the cache.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheElement

public CacheElement(java.lang.String name,
                    java.lang.String type,
                    Cacheable object,
                    long lastModified)
Create a new CacheElement.

Parameters:
name - the canonical name of the element
type - the type of object
object - the object to be stored
lastModified - the time the object was last modified in the data store

CacheElement

public CacheElement(CacheElement ce)
Create a new shallow clone of a given CacheElement.

Parameters:
ce - the cache element to be cloned
Method Detail

getName

public java.lang.String getName()
Retrieve the name of the element being cached.

Returns:
the name of the cache element

lastModified

public long lastModified()
Retrieve the time the element was last modified, according to the cache.

Returns:
the last modified time of the element in the cache

getObject

public Cacheable getObject()
Retrieve the object being cached.

Returns:
the cached object

getType

public java.lang.String getType()
Retrieve the type of object being cached.

Returns:
the type of the object being cached

age

public void age()
Age this element in the cache.


isExpired

public boolean isExpired(int age)
Has the object in this cache element expired?

Parameters:
age - the age at which this element would expire
Returns:
true if the element has expired, otherwise false

compareTo

public int compareTo(java.lang.Object obj)
Compares an object against this CacheElement.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - the object to be compared
Returns:
whether the object is less than, equal to, or greater than the current object
Throws:
java.lang.ClassCastException - the object cannot be compared

compareTo

public int compareTo(CacheElement target)
Compares another CacheElement against this one.

Parameters:
target - the CacheElement to be compared
Returns:
whether the object is less than, equal to, or greather than the current object

clone

public java.lang.Object clone()
Performs a shallow clone of the CacheElement. The object being cached is not cloned, only a reference to it.

Overrides:
clone in class java.lang.Object
Returns:
a clone of the current CacheElement

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the object