org.objectweb.cjdbc.controller.cache.result.entries
Class ResultCacheEntry

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.cache.result.entries.ResultCacheEntry
All Implemented Interfaces:
CacheEntry
Direct Known Subclasses:
ResultCacheEntryEager, ResultCacheEntryNoCache, ResultCacheEntryRelaxed

public abstract class ResultCacheEntry
extends java.lang.Object
implements CacheEntry

A CacheEntry represents a SQL select request with its reponse. The cache entry can have 3 states:

Version:
1.0
Author:
Emmanuel Cecchet

Field Summary
private  CacheEntry next
           
private  CacheEntry prev
           
protected  SelectRequest request
           
protected  ControllerResultSet result
           
protected  int state
           
 
Fields inherited from interface org.objectweb.cjdbc.controller.cache.result.entries.CacheEntry
CACHE_DIRTY, CACHE_INVALID, CACHE_VALID, NO_DEADLINE
 
Constructor Summary
ResultCacheEntry(SelectRequest request, ControllerResultSet result)
          Creates a new CacheEntry instance.
 
Method Summary
 CacheEntry getNext()
          Gets the value of next ResultCacheEntry in LRU.
 CacheEntry getPrev()
          Gets the value of previous ResultCacheEntry in LRU.
 SelectRequest getRequest()
          Returns the SELECT request of this cache entry.
 ControllerResultSet getResult()
          Returns the ControllerResultSet of the cached select request
 int getSizeOfResult()
          Size of the result in bytes
 java.lang.String getState()
          Get the state of this entry as a string
abstract  java.lang.String getType()
          Get the type of this entry as a string
abstract  void invalidate()
          Invalidates this cache entry (removes the ResultSet and turn state to CacheEntry.CACHE_INVALID).
 boolean isDirty()
          Returns true if cache entry state is marked dirty (state is CacheEntry.CACHE_DIRTY).
 boolean isValid()
          Return true if cache entry state is valid (state is CacheEntry.CACHE_VALID).
 void markDirty()
          Marks this entry dirty (state becomes CacheEntry.CACHE_DIRTY).
 void setNext(CacheEntry next)
          Sets the value of next ResultCacheEntry in LRU.
 void setPrev(CacheEntry prev)
          Sets the value of previous ResultCacheEntry in LRU.
 void setResult(ControllerResultSet result)
          Set a new ControllerResultSet of the cached select request (cache update).
 void setValid()
          Marks this entry valid (state becomes CacheEntry.CACHE_VALID).
abstract  java.lang.String[] toStringTable()
          Get data about this entry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

request

protected SelectRequest request

result

protected ControllerResultSet result

state

protected int state

next

private CacheEntry next

prev

private CacheEntry prev
Constructor Detail

ResultCacheEntry

public ResultCacheEntry(SelectRequest request,
                        ControllerResultSet result)
Creates a new CacheEntry instance.

Parameters:
request - a SelectRequest value
result - a ControllerResultSet value
Method Detail

getType

public abstract java.lang.String getType()
Get the type of this entry as a string

Specified by:
getType in interface CacheEntry
Returns:
NoCache or Eager or Relaxed

getState

public java.lang.String getState()
Get the state of this entry as a string

Specified by:
getState in interface CacheEntry
Returns:
Valid or Dirty or Invalid

isValid

public boolean isValid()
Return true if cache entry state is valid (state is CacheEntry.CACHE_VALID).

Specified by:
isValid in interface CacheEntry
Returns:
a boolean value

isDirty

public boolean isDirty()
Returns true if cache entry state is marked dirty (state is CacheEntry.CACHE_DIRTY).

Specified by:
isDirty in interface CacheEntry
Returns:
a boolean value

getRequest

public SelectRequest getRequest()
Returns the SELECT request of this cache entry.

Specified by:
getRequest in interface CacheEntry
Returns:
a SelectRequest value

getResult

public ControllerResultSet getResult()
Returns the ControllerResultSet of the cached select request

Specified by:
getResult in interface CacheEntry
Returns:
a ControllerResultSet value

setResult

public void setResult(ControllerResultSet result)
Set a new ControllerResultSet of the cached select request (cache update).

The cache state is automatically set to valid (CacheEntry.CACHE_VALID).

Specified by:
setResult in interface CacheEntry
Parameters:
result - a ControllerResultSet value

invalidate

public abstract void invalidate()
Invalidates this cache entry (removes the ResultSet and turn state to CacheEntry.CACHE_INVALID).

Specified by:
invalidate in interface CacheEntry

markDirty

public void markDirty()
Marks this entry dirty (state becomes CacheEntry.CACHE_DIRTY).

The ResultSet if not affected by this method.

Specified by:
markDirty in interface CacheEntry

setValid

public void setValid()
Marks this entry valid (state becomes CacheEntry.CACHE_VALID).

Specified by:
setValid in interface CacheEntry

getNext

public CacheEntry getNext()
Gets the value of next ResultCacheEntry in LRU.

Specified by:
getNext in interface CacheEntry
Returns:
value of next.

setNext

public void setNext(CacheEntry next)
Sets the value of next ResultCacheEntry in LRU.

Specified by:
setNext in interface CacheEntry
Parameters:
next - value to assign to next.

getPrev

public CacheEntry getPrev()
Gets the value of previous ResultCacheEntry in LRU.

Specified by:
getPrev in interface CacheEntry
Returns:
value of previous.

setPrev

public void setPrev(CacheEntry prev)
Sets the value of previous ResultCacheEntry in LRU.

Specified by:
setPrev in interface CacheEntry
Parameters:
prev - value to assign to prev.

toStringTable

public abstract java.lang.String[] toStringTable()
Get data about this entry

Specified by:
toStringTable in interface CacheEntry
Returns:
an array [request,type,status(valid,notvalid,dirty),deadLine]

getSizeOfResult

public int getSizeOfResult()
Size of the result in bytes

Specified by:
getSizeOfResult in interface CacheEntry
Returns:
an integer


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.