KickJava   Java API By Example, From Geeks To Geeks.

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


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

21
22 package org.continuent.sequoia.controller.requests;
23
24 import java.sql.SQLException JavaDoc;
25
26 import org.continuent.sequoia.controller.semantic.SemanticBehavior;
27 import org.continuent.sequoia.controller.sql.schema.DatabaseSchema;
28
29 /**
30  * This class defines an UnknownReadRequest used for all SQL statements that are
31  * not SELECT but should be executed as read requests.<br>
32  * An UnknownReadRequest is a request that returns a ResultSet and that we are
33  * not able to parse (we cannot know which tables are accessed, if any).
34  *
35  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet</a>
36  * @version 1.0
37  */

38 public class UnknownReadRequest extends SelectRequest
39 {
40   private static final long serialVersionUID = -1056060047939721758L;
41
42   /**
43    * Creates a new <code>UnknownReadRequest</code> object
44    *
45    * @param sqlQuery the SQL query
46    * @param escapeProcessing should the driver to escape processing before
47    * sending to the database ?
48    * @param timeout an <code>int</code> value
49    * @param lineSeparator the line separator used in the query
50    */

51   public UnknownReadRequest(String JavaDoc sqlQuery, boolean escapeProcessing,
52       int timeout, String JavaDoc lineSeparator)
53   {
54     super(sqlQuery, escapeProcessing, timeout, lineSeparator,
55         RequestType.UNKNOWN_READ);
56     setMacrosAreProcessed(true); // no macro processing needed
57
}
58
59   /**
60    * Clone the default semantic information.
61    *
62    * @see AbstractRequest#cloneParsing(AbstractRequest)
63    */

64   public void cloneParsing(AbstractRequest request)
65   {
66     super.cloneParsingCommons(request);
67     isParsed = true;
68   }
69
70   /**
71    * Request is not parsed but a default semantic information is applied.
72    *
73    * @see org.continuent.sequoia.controller.requests.AbstractRequest#parse(org.continuent.sequoia.controller.sql.schema.DatabaseSchema,
74    * int, boolean)
75    */

76   public void parse(DatabaseSchema schema, int granularity,
77       boolean isCaseSensitive) throws SQLException JavaDoc
78   { // No parsing for unknown read request
79
// Just let database try to execute the request
80
isParsed = true;
81     setSemantic(new SemanticBehavior(null, null, null, altersDatabaseSchema(),
82         altersMetadataCache(), altersQueryResultCache(), altersUsers(),
83         isReadOnly, needsMacroProcessing(),
84         SemanticBehavior.SERIALIZABLE_ORDER, requiresConnectionPoolFlush
85             ? SemanticBehavior.FLUSH_ALL_USERS
86             : SemanticBehavior.FLUSH_NONE));
87   }
88
89   /**
90    * Always returns RequestType.UNCACHEABLE
91    *
92    * @see org.continuent.sequoia.controller.requests.AbstractRequest#getCacheAbility()
93    */

94   public int getCacheAbility()
95   {
96     return RequestType.UNCACHEABLE;
97   }
98
99   /**
100    * Always returns true since the request cannot be parsed anyway.
101    *
102    * @see org.continuent.sequoia.controller.requests.AbstractRequest#isParsed()
103    */

104   public boolean isParsed()
105   {
106     return true;
107   }
108
109 }
110
Popular Tags