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

AbstractWriteRequest.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): ______________________________________.
00023  */
00024 
00025 package org.objectweb.cjdbc.common.sql;
00026 
00027 import java.util.ArrayList;
00028 
00029 /**
00030  * An <code>AbstractWriteRequest</code> defines the skeleton of read requests
00031  * that are sent from the driver to the controller.
00032  * 
00033  * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
00034  * @version 1.0
00035  */
00036 public abstract class AbstractWriteRequest extends AbstractRequest
00037 {
00038   /** Name of the table involved in this write query. */
00039   protected transient String    tableName;
00040 
00041   /**
00042    * <code>ArrayList</code> of <code>TableColumn</code> involved in this
00043    * write query.
00044    */
00045   protected transient ArrayList columns;
00046 
00047   /** <code>true</code> if this request might block. */
00048   protected transient boolean   blocking = true;
00049 
00050   /** Primary key value */
00051   protected transient String    pkValue  = null;
00052 
00053   /**
00054    * Creates a new <code>AbstractWriteRequest</code> object
00055    * 
00056    * @param sqlQuery the SQL query
00057    * @param escapeProcessing should the driver to escape processing before
00058    *          sending to the database ?
00059    * @param timeout an <code>int</code> value
00060    * @param lineSeparator the line separator used in the query
00061    */
00062   public AbstractWriteRequest(String sqlQuery, boolean escapeProcessing,
00063       int timeout, String lineSeparator)
00064   {
00065     super(sqlQuery, escapeProcessing, timeout, lineSeparator);
00066   }
00067 
00068   /**
00069    * @return <code>false</code>
00070    * @see org.objectweb.cjdbc.common.sql.AbstractRequest#isReadRequest()
00071    */
00072   public boolean isReadRequest()
00073   {
00074     return false;
00075   }
00076 
00077   /**
00078    * @return <code>true</code>
00079    * @see org.objectweb.cjdbc.common.sql.AbstractRequest#isWriteRequest()
00080    */
00081   public boolean isWriteRequest()
00082   {
00083     return true;
00084   }
00085 
00086   /**
00087    * @return <code>false</code>
00088    * @see org.objectweb.cjdbc.common.sql.AbstractRequest#isUnknownRequest()
00089    */
00090   public boolean isUnknownRequest()
00091   {
00092     return false;
00093   }
00094 
00095   /**
00096    * Returns <code>true</code> if this request in an <code>INSERT</code>
00097    * statement.
00098    * 
00099    * @return a <code>boolean</code> value
00100    */
00101   public abstract boolean isInsert();
00102 
00103   /**
00104    * Returns <code>true</code> if this request in an <code>UPDATE</code>
00105    * statement.
00106    * 
00107    * @return a <code>boolean</code> value
00108    */
00109   public abstract boolean isUpdate();
00110 
00111   /**
00112    * Returns <code>true</code> if this request in a <code>DELETE</code>
00113    * statement.
00114    * 
00115    * @return a <code>boolean</code> value
00116    */
00117   public abstract boolean isDelete();
00118   
00119   /**
00120    * Returns <code>true</code> if this request in a <code>ALTER</code>
00121    * statement.
00122    * 
00123    * @return a <code>boolean</code> value
00124    */
00125   public abstract boolean isAlter();
00126 
00127   /**
00128    * Returns <code>true</code> if this request in a <code>CREATE</code>
00129    * statement.
00130    * 
00131    * @return a <code>boolean</code> value
00132    */
00133   public abstract boolean isCreate();
00134 
00135   /**
00136    * Returns <code>true</code> if this request in a <code>DROP</code>
00137    * statement.
00138    * 
00139    * @return a <code>boolean</code> value
00140    */
00141   public abstract boolean isDrop();
00142 
00143   /**
00144    * Returns the name of the table affected by this statement.
00145    * 
00146    * @return a <code>String</code> value
00147    */
00148   public String getTableName()
00149   {
00150     return tableName;
00151   }
00152 
00153   /**
00154    * Returns an <code>ArrayList</code> of <code>TableColumn</code> objects
00155    * representing the columns affected by this statement.
00156    * 
00157    * @return an <code>ArrayList</code> value
00158    */
00159   public ArrayList getColumns()
00160   {
00161     return columns;
00162   }
00163 
00164   /**
00165    * Clones table name and columns from an already parsed request.
00166    * 
00167    * @param abstractWriteRequest the already parsed request
00168    */
00169   protected void cloneTableNameAndColumns(
00170       AbstractWriteRequest abstractWriteRequest)
00171   {
00172     tableName = abstractWriteRequest.getTableName();
00173     columns = abstractWriteRequest.getColumns();
00174     pkValue = abstractWriteRequest.getPk();
00175     cacheable = abstractWriteRequest.getCacheAbility();
00176   }
00177 
00178   /**
00179    * Tests if this request might block.
00180    * 
00181    * @return <code>true</code> if this request might block
00182    */
00183   public boolean mightBlock()
00184   {
00185     return blocking;
00186   }
00187 
00188   /**
00189    * Sets if this request might block.
00190    * 
00191    * @param blocking a <code>boolean</code> value
00192    */
00193   public void setBlocking(boolean blocking)
00194   {
00195     this.blocking = blocking;
00196   }
00197 
00198   /**
00199    * @return Returns the pk.
00200    */
00201   public String getPk()
00202   {
00203     return pkValue;
00204   }
00205 
00206 }

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