00001 /** 00002 * C-JDBC: Clustered JDBC. 00003 * Copyright (C) 2002-2004 French National Institute For Research In Computer 00004 * Science And Control (INRIA). 00005 * Contact: c-jdbc@objectweb.org 00006 * 00007 * This library is free software; you can redistribute it and/or modify it 00008 * under the terms of the GNU Lesser General Public License as published by the 00009 * Free Software Foundation; either version 2.1 of the License, or any later 00010 * version. 00011 * 00012 * This library is distributed in the hope that it will be useful, but WITHOUT 00013 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 00015 * for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public License 00018 * along with this library; if not, write to the Free Software Foundation, 00019 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00020 * 00021 * Initial developer(s): Nicolas Modrzyk 00022 * Contributor(s): Emmanuel Cecchet. 00023 */ 00024 00025 package org.objectweb.cjdbc.controller.cache.result.entries; 00026 00027 import org.objectweb.cjdbc.common.sql.SelectRequest; 00028 import org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet; 00029 00030 /** 00031 * This describes a reauest cache entry. 00032 */ 00033 public interface CacheEntry 00034 { 00035 00036 /** This entry has no deadline */ 00037 int NO_DEADLINE = -1; 00038 00039 /** State this entry is valid */ 00040 int CACHE_VALID = 0; 00041 /** This entry is dirty */ 00042 int CACHE_DIRTY = 1; 00043 /** This entry is no more valid and is not consistent with real data. */ 00044 int CACHE_INVALID = 2; 00045 00046 /** 00047 * Get the type of this entry as a string 00048 * 00049 * @return NoCache or Eager or Relaxed 00050 */ 00051 String getType(); 00052 00053 /** 00054 * Get the state of this entry as a string 00055 * 00056 * @return Valid or Dirty or Invalid 00057 */ 00058 String getState(); 00059 00060 /** 00061 * Return <code>true</code> if cache entry state is valid (state is 00062 * {@link #CACHE_VALID}). 00063 * 00064 * @return a <code>boolean</code> value 00065 */ 00066 boolean isValid(); 00067 00068 /** 00069 * Returns <code>true</code> if cache entry state is marked dirty (state is 00070 * {@link #CACHE_DIRTY}). 00071 * 00072 * @return a <code>boolean</code> value 00073 */ 00074 boolean isDirty(); 00075 00076 /** 00077 * Returns the <code>SELECT</code> request of this cache entry. 00078 * 00079 * @return a <code>SelectRequest</code> value 00080 */ 00081 SelectRequest getRequest(); 00082 00083 /** 00084 * Returns the <code>ControllerResultSet</code> of the cached select request 00085 * 00086 * @return a <code>ControllerResultSet</code> value 00087 */ 00088 ControllerResultSet getResult(); 00089 00090 /** 00091 * Set a new <code>ControllerResultSet</code> of the cached select request 00092 * (cache update). 00093 * <p> 00094 * The cache state is automatically set to valid ({@link #CACHE_VALID}). 00095 * 00096 * @param result a <code>ControllerResultSet</code> value 00097 */ 00098 void setResult(ControllerResultSet result); 00099 00100 /** 00101 * Invalidates this cache entry (removes the <code>ResultSet</code> and turn 00102 * state to {@link #CACHE_INVALID}). 00103 */ 00104 void invalidate(); 00105 00106 /** 00107 * Marks this entry dirty (state becomes {@link #CACHE_DIRTY}). 00108 * <p> 00109 * The <code>ResultSet</code> if not affected by this method. 00110 */ 00111 void markDirty(); 00112 00113 /** 00114 * Marks this entry valid (state becomes {@link #CACHE_VALID}). 00115 */ 00116 void setValid(); 00117 00118 /** 00119 * Gets the value of next <code>ResultCacheEntry</code> in LRU. 00120 * 00121 * @return value of next. 00122 */ 00123 CacheEntry getNext(); 00124 00125 /** 00126 * Sets the value of next <code>CacheEntry</code> in LRU. 00127 * 00128 * @param next value to assign to next. 00129 */ 00130 void setNext(CacheEntry next); 00131 00132 /** 00133 * Gets the value of previous <code>CacheEntry</code> in LRU. 00134 * 00135 * @return value of previous. 00136 */ 00137 CacheEntry getPrev(); 00138 00139 /** 00140 * Sets the value of previous <code>CacheEntry</code> in LRU. 00141 * 00142 * @param prev value to assign to prev. 00143 */ 00144 void setPrev(CacheEntry prev); 00145 00146 /** 00147 * Get data about this entry 00148 * 00149 * @return an array [request,type,status(valid,notvalid,dirty),deadLine] 00150 */ 00151 String[] toStringTable(); 00152 00153 /** 00154 * Size of the result in bytes 00155 * 00156 * @return an integer 00157 */ 00158 int getSizeOfResult(); 00159 }