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

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.cache.result.entries.AbstractResultCacheEntry
Direct Known Subclasses:
ResultCacheEntryEager, ResultCacheEntryNoCache, ResultCacheEntryRelaxed

public abstract class AbstractResultCacheEntry
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
static int CACHE_DIRTY
          This entry is dirty
static int CACHE_INVALID
          This entry is no more valid and is not consistent with real data.
static int CACHE_VALID
          State this entry is valid
private  AbstractResultCacheEntry next
           
static int NO_DEADLINE
          This entry has no deadline
private  AbstractResultCacheEntry prev
           
protected  SelectRequest request
           
protected  ControllerResultSet result
           
protected  int state
           
 
Constructor Summary
AbstractResultCacheEntry(SelectRequest request, ControllerResultSet result)
          Creates a new CacheEntry instance.
 
Method Summary
 AbstractResultCacheEntry getNext()
          Gets the value of next AbstractResultCacheEntry in LRU.
 AbstractResultCacheEntry getPrev()
          Gets the value of previous AbstractResultCacheEntry 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 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(AbstractResultCacheEntry next)
          Sets the value of next AbstractResultCacheEntry in LRU.
 void setPrev(AbstractResultCacheEntry prev)
          Sets the value of previous AbstractResultCacheEntry 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 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 AbstractResultCacheEntry next

prev

private AbstractResultCacheEntry prev

NO_DEADLINE

public static final int NO_DEADLINE
This entry has no deadline

See Also:
Constant Field Values

CACHE_VALID

public static final int CACHE_VALID
State this entry is valid

See Also:
Constant Field Values

CACHE_DIRTY

public static final int CACHE_DIRTY
This entry is dirty

See Also:
Constant Field Values

CACHE_INVALID

public static final int CACHE_INVALID
This entry is no more valid and is not consistent with real data.

See Also:
Constant Field Values
Constructor Detail

AbstractResultCacheEntry

public AbstractResultCacheEntry(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

Returns:
NoCache or Eager or Relaxed

getState

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

Returns:
Valid or Dirty or Invalid

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 ControllerResultSet getResult()
Returns the ControllerResultSet of the cached select request

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 (CACHE_VALID).

Parameters:
result - a ControllerResultSet value

invalidate

public abstract 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 AbstractResultCacheEntry getNext()
Gets the value of next AbstractResultCacheEntry in LRU.

Returns:
value of next.

setNext

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

Parameters:
next - value to assign to next.

getPrev

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

Returns:
value of previous.

setPrev

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

Parameters:
prev - value to assign to prev.

toStringTable

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

Returns:
an array [request,type,status(valid,notvalid,dirty),deadLine]

getSizeOfResult

public int getSizeOfResult()
Size of the result in bytes

Returns:
an integer


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