ehcache

net.sf.ehcache
Class Element

java.lang.Object
  extended bynet.sf.ehcache.Element
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Element
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

A Cache Element, consisting of a key, value and attributes.

Version:
$Id: Element.java,v 1.19 2004/09/25 03:58:07 gregluck Exp $
Author:
Greg Luck
See Also:
Serialized Form

Field Summary
(package private) static long serialVersionUID
          serial version
 
Constructor Summary
Element(java.io.Serializable key, java.io.Serializable value)
          Constructor
Element(java.io.Serializable key, java.io.Serializable value, long version)
          A full constructor.
 
Method Summary
 java.lang.Object clone()
          Clones an Element.
 long getCreationTime()
          Gets the creationTime attribute of the ElementAttributes object
 long getHitCount()
          Gets the hit count on this element.
 java.io.Serializable getKey()
          Gets the key attribute of the Element object
 long getLastAccessTime()
          Gets the last access time.
(package private)  long getNextToLastAccessTime()
          Gets the next to last access time.
 long getSerializedSize()
          The size of this object in serialized form.
 java.io.Serializable getValue()
          Gets the value attribute of the Element object
 long getVersion()
          Gets the version attribute of the ElementAttributes object
 int hashCode()
          Description of the Method
 void resetAccessStatistics()
          Resets the hit count to 0 and the last access time to 0
 void setCreateTime()
          Sets the creationTime attribute of the ElementAttributes object
 void setVersion(long version)
          Sets the version attribute of the ElementAttributes object
 java.lang.String toString()
          Returns a String representation of the Element
 void updateAccessStatistics()
          Sets the last access time to now.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
serial version

See Also:
Constant Field Values
Constructor Detail

Element

public Element(java.io.Serializable key,
               java.io.Serializable value,
               long version)
A full constructor.

Creation time is set to the current time. Last Access Time and Previous To Last Access Time are not set.


Element

public Element(java.io.Serializable key,
               java.io.Serializable value)
Constructor

Parameters:
key -
value -
Method Detail

getKey

public java.io.Serializable getKey()
Gets the key attribute of the Element object

Returns:
The key value

getValue

public java.io.Serializable getValue()
Gets the value attribute of the Element object

Returns:
The value value

hashCode

public int hashCode()
Description of the Method


setVersion

public void setVersion(long version)
Sets the version attribute of the ElementAttributes object

Parameters:
version - The new version value

getCreationTime

public long getCreationTime()
Gets the creationTime attribute of the ElementAttributes object

Returns:
The creationTime value

setCreateTime

public void setCreateTime()
Sets the creationTime attribute of the ElementAttributes object


getVersion

public long getVersion()
Gets the version attribute of the ElementAttributes object

Returns:
The version value

getLastAccessTime

public long getLastAccessTime()
Gets the last access time. Access means get or put. So a newly created Element will have a last access time equal to its create time.


getNextToLastAccessTime

long getNextToLastAccessTime()
Gets the next to last access time. This is package protected as it should not be used outside internal Cache housekeeping

See Also:
getLastAccessTime()

getHitCount

public long getHitCount()
Gets the hit count on this element.


resetAccessStatistics

public void resetAccessStatistics()
Resets the hit count to 0 and the last access time to 0


updateAccessStatistics

public void updateAccessStatistics()
Sets the last access time to now.


toString

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


clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones an Element. A completely new object is created, with no common references with the existing one.

Warning: This can be very slow on large object graphs. If you use this method you should write a performance test to verify suitability.

Returns:
a new Element, with exactly the same field values as the one it was cloned from.
Throws:
java.lang.CloneNotSupportedException

getSerializedSize

public long getSerializedSize()
The size of this object in serialized form. This is not the same thing as the memory size, which is JVM dependent. Relative values should be meaningful, however.

Warning: This method can be very slow for values which contain large object graphs.

Returns:
The serialized size in bytes

ehcache