KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > common > sql > AbstractWriteRequest


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): ______________________________________.
23  */

24
25 package org.objectweb.cjdbc.common.sql;
26
27 import java.io.IOException JavaDoc;
28 import java.util.ArrayList JavaDoc;
29
30 import org.objectweb.cjdbc.common.stream.CJDBCInputStream;
31
32 /**
33  * An <code>AbstractWriteRequest</code> defines the skeleton of read requests
34  * that are sent from the driver to the controller.
35  *
36  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
37  * @version 1.0
38  */

39 public abstract class AbstractWriteRequest extends AbstractRequest
40 {
41   /** Name of the table involved in this write query. */
42   protected transient String JavaDoc tableName;
43
44   /**
45    * <code>ArrayList</code> of <code>TableColumn</code> involved in this
46    * write query.
47    */

48   protected transient ArrayList JavaDoc columns;
49
50   /** <code>true</code> if this request might block. */
51   protected transient boolean blocking = true;
52
53   /** Primary key value */
54   protected transient String JavaDoc pkValue = null;
55
56   /**
57    * Creates a new <code>AbstractWriteRequest</code> object
58    *
59    * @param sqlQuery the SQL query
60    * @param escapeProcessing should the driver to escape processing before
61    * sending to the database ?
62    * @param timeout an <code>int</code> value
63    * @param lineSeparator the line separator used in the query
64    * @param requestType the request type as defined in RequestType class
65    * @see RequestType
66    */

67   public AbstractWriteRequest(String JavaDoc sqlQuery, boolean escapeProcessing,
68       int timeout, String JavaDoc lineSeparator, int requestType)
69   {
70     super(sqlQuery, escapeProcessing, timeout, lineSeparator, requestType);
71   }
72
73   /**
74    * Creates a new <code>AbstractWriteRequest</code> object
75    *
76    * @param in the input stream to read the request from
77    * @param requestType the request type as defined in RequestType class
78    * @throws IOException if an error occurs
79    * @see RequestType
80    * @see AbstractRequest#AbstractRequest(CJDBCInputStream, int)
81    */

82   public AbstractWriteRequest(CJDBCInputStream in, int requestType)
83       throws IOException JavaDoc
84   {
85     super(in, requestType);
86   }
87
88   /**
89    * Returns the name of the table affected by this statement.
90    *
91    * @return a <code>String</code> value
92    */

93   public String JavaDoc getTableName()
94   {
95     return tableName;
96   }
97
98   /**
99    * Returns an <code>ArrayList</code> of <code>TableColumn</code> objects
100    * representing the columns affected by this statement.
101    *
102    * @return an <code>ArrayList</code> value
103    */

104   public ArrayList JavaDoc getColumns()
105   {
106     return columns;
107   }
108
109   /**
110    * Clones table name and columns from an already parsed request.
111    *
112    * @param abstractWriteRequest the already parsed request
113    */

114   protected void cloneTableNameAndColumns(
115       AbstractWriteRequest abstractWriteRequest)
116   {
117     tableName = abstractWriteRequest.getTableName();
118     columns = abstractWriteRequest.getColumns();
119     pkValue = abstractWriteRequest.getPk();
120     cacheable = abstractWriteRequest.getCacheAbility();
121   }
122
123   /**
124    * Tests if this request might block.
125    *
126    * @return <code>true</code> if this request might block
127    */

128   public boolean mightBlock()
129   {
130     return blocking;
131   }
132
133   /**
134    * Sets if this request might block.
135    *
136    * @param blocking a <code>boolean</code> value
137    */

138   public void setBlocking(boolean blocking)
139   {
140     this.blocking = blocking;
141   }
142
143   /**
144    * @return Returns the pk.
145    */

146   public String JavaDoc getPk()
147   {
148     return pkValue;
149   }
150
151 }
Popular Tags