org.objectweb.cjdbc.controller.cache
Class QueryCacheEntry

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.cache.QueryCacheEntry

public class QueryCacheEntry
extends java.lang.Object

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 static int CACHE_DIRTY
           
private static int CACHE_INVALID
           
private static int CACHE_VALID
           
private  QueryCacheEntry next
           
private  QueryCacheEntry prev
           
private  SelectRequest request
           
private  java.sql.ResultSet result
           
private  int state
           
 
Constructor Summary
QueryCacheEntry(SelectRequest request, java.sql.ResultSet result)
          Creates a new CacheEntry instance.
 
Method Summary
 QueryCacheEntry getNext()
          Gets the value of next QueryCacheEntry in LRU.
 QueryCacheEntry getPrev()
          Gets the value of previous QueryCacheEntry in LRU.
 SelectRequest getRequest()
          Returns the SELECT request of this cache entry.
 java.sql.ResultSet getResult()
          Returns the ResultSet of the cached select request
 void invalidate()
          Invalidates this cache entry (removes the ResultSet and turn state to CACHE_INVALID).
 boolean isDirty()
          Returns true if cache entry state is marked dirty (state is CACHE_DIRTY).
 boolean isValid()
          Return true if cache entry state is valid (state is CACHE_VALID).
 void markDirty()
          Marks this entry dirty (state becomes CACHE_DIRTY).
 void setNext(QueryCacheEntry next)
          Sets the value of next QueryCacheEntry in LRU.
 void setPrev(QueryCacheEntry prev)
          Sets the value of previous QueryCacheEntry in LRU.
 void setResult(java.sql.ResultSet result)
          Set a new ResultSet of the cached select request (cache update).
 void setValid()
          Marks this entry valid (state becomes CACHE_VALID).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

request

private SelectRequest request

result

private java.sql.ResultSet result

state

private int state

next

private QueryCacheEntry next

prev

private QueryCacheEntry prev

CACHE_VALID

private static final int CACHE_VALID
See Also:
Constant Field Values

CACHE_DIRTY

private static final int CACHE_DIRTY
See Also:
Constant Field Values

CACHE_INVALID

private static final int CACHE_INVALID
See Also:
Constant Field Values
Constructor Detail

QueryCacheEntry

public QueryCacheEntry(SelectRequest request,
                       java.sql.ResultSet result)
Creates a new CacheEntry instance.

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

isValid

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

Returns:
a boolean value

isDirty

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

Returns:
a boolean value

getRequest

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

Returns:
a SelectRequest value

getResult

public java.sql.ResultSet getResult()
Returns the ResultSet of the cached select request

Returns:
a ResultSet value

setResult

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

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

Parameters:
result - a ResultSet value

invalidate

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


markDirty

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

The ResultSet if not affected by this method.


setValid

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


getNext

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

Returns:
value of next.

setNext

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

Parameters:
next - value to assign to next.

getPrev

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

Returns:
value of previous.

setPrev

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

Parameters:
prev - value to assign to prev.


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