KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > requests > AbstractWriteRequest


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: sequoia@continuent.org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * Initial developer(s): Emmanuel Cecchet.
20  * Contributor(s): ______________________________________.
21  */

22
23 package org.continuent.sequoia.controller.requests;
24
25 import java.util.ArrayList JavaDoc;
26
27 import org.continuent.sequoia.common.i18n.Translate;
28
29 /**
30  * <code>AbstractWriteRequest</code> is the super-class of all requests which
31  * do NOT return any ResultSet. They do have side-effects (else what would they
32  * useful for?!)
33  *
34  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
35  * @version 1.0
36  */

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

46   protected transient ArrayList JavaDoc columns;
47
48   /** Primary key value */
49   protected transient String JavaDoc pkValue = null;
50
51   /**
52    * True if the request requires to take a global lock.
53    */

54   protected boolean requiresGlobalLock = false;
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    * Clones table name and columns from an already parsed request.
75    *
76    * @param abstractWriteRequest the already parsed request
77    */

78   protected void cloneTableNameAndColumns(
79       AbstractWriteRequest abstractWriteRequest)
80   {
81     tableName = abstractWriteRequest.getTableName();
82     columns = abstractWriteRequest.getColumns();
83     pkValue = abstractWriteRequest.getPk();
84     cacheable = abstractWriteRequest.getCacheAbility();
85     writeLockedTables = abstractWriteRequest.getWriteLockedDatabaseTables();
86   }
87
88   /**
89    * Returns an <code>ArrayList</code> of <code>TableColumn</code> objects
90    * representing the columns affected by this statement.
91    *
92    * @return an <code>ArrayList</code> value
93    */

94   public ArrayList JavaDoc getColumns()
95   {
96     return columns;
97   }
98
99   /**
100    * @return Returns the pk.
101    */

102   public String JavaDoc getPk()
103   {
104     return pkValue;
105   }
106
107   /**
108    * Returns the name of the table affected by this statement.
109    *
110    * @return a <code>String</code> value
111    */

112   public String JavaDoc getTableName()
113   {
114     return tableName;
115   }
116
117   /**
118    * @see org.continuent.sequoia.controller.requests.AbstractRequest#getParsingResultsAsString()
119    */

120   public String JavaDoc getParsingResultsAsString()
121   {
122     StringBuffer JavaDoc sb = new StringBuffer JavaDoc(super.getParsingResultsAsString());
123     sb.append(Translate.get("request.table.involved", tableName));
124     if (columns != null && columns.size() > 0)
125     {
126       sb.append(Translate.get("request.table.column"));
127       for (int i = 0; i < columns.size(); i++)
128       {
129         sb.append(Translate.get("request.table.column", columns.get(i)));
130       }
131     }
132     sb.append(Translate.get("request.primary.key", pkValue));
133     return sb.toString();
134   }
135
136   /**
137    * Return true if the query requires a global locking.
138    *
139    * @return the requiresGlobalLock value.
140    */

141   public boolean requiresGlobalLock()
142   {
143     return requiresGlobalLock;
144   }
145 }
Popular Tags