Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

CachingGranularities.java

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): Emmanuel Cecchet.
00022  * Contributor(s): Sara Bouchenak.
00023  */
00024 
00025 package org.objectweb.cjdbc.controller.cache.result;
00026 
00027 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags;
00028 
00029 /**
00030  * This class defines request cache granularities.
00031  * 
00032  * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet</a>
00033  * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk</a>
00034  * @version 1.0
00035  */
00036 public class CachingGranularities
00037 {
00038   /**
00039    * Database granularity: entries in the cache are invalidated every time a
00040    * write (INSERT/UPDATE/DELETE/DROP/...) is sent to the database.
00041    */
00042   public static final int DATABASE = 0;
00043 
00044   /**
00045    * Table granularity: entries in the cache are invalidated based on table
00046    * dependencies.
00047    */
00048   public static final int TABLE = 1;
00049 
00050   /**
00051    * Column granularity: entries in the cache are invalidated based on column
00052    * dependencies.
00053    */
00054   public static final int COLUMN = 2;
00055 
00056   /**
00057    * Column granularity with <code>UNIQUE</code> queries: same as <code>COLUMN</code>
00058    * except that <code>UNIQUE</code> queries that selects a single row based
00059    * on a key are invalidated only when needed.
00060    */
00061   public static final int COLUMN_UNIQUE = 3;
00062 
00063   /**
00064    * Gets the name corresponding to a cache granularity level.
00065    * 
00066    * @param cacheGrain cache granularity level
00067    * @return the name of the granularity level
00068    */
00069   public static final String getGranularityName(int cacheGrain)
00070   {
00071     switch (cacheGrain)
00072     {
00073       case DATABASE :
00074         return "DATABASE";
00075       case TABLE :
00076         return "TABLE";
00077       case COLUMN :
00078         return "COLUMN";
00079       case COLUMN_UNIQUE :
00080         return "COLUMN_UNIQUE";
00081       default :
00082         return "UNSUPPORTED";
00083     }
00084   }
00085 
00086   /**
00087    * This method is needed to convert the value into the corresponding xml
00088    * attribute value. If fails, returns noInvalidation granularity value so the
00089    * xml retrieved can be used.
00090    * 
00091    * @param cacheGrain cache granularity level
00092    * @return the xml attribute value of the granularity level
00093    */
00094   public static final String getGranularityXml(int cacheGrain)
00095   {
00096     switch (cacheGrain)
00097     {
00098       case DATABASE :
00099         return DatabasesXmlTags.VAL_database;
00100       case TABLE :
00101         return DatabasesXmlTags.VAL_table;
00102       case COLUMN :
00103         return DatabasesXmlTags.VAL_column;
00104       case COLUMN_UNIQUE :
00105         return DatabasesXmlTags.VAL_columnUnique;
00106       default :
00107         return DatabasesXmlTags.VAL_noInvalidation;
00108     }
00109   }
00110 }

Generated on Mon Apr 11 22:01:29 2005 for C-JDBC by  doxygen 1.3.9.1