KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > execute > GenericScanQualifier


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.GenericScanQualifier
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.execute;
23
24 import org.apache.derby.iapi.services.sanity.SanityManager;
25
26 import org.apache.derby.iapi.error.StandardException;
27
28 import org.apache.derby.iapi.sql.execute.ScanQualifier;
29
30 import org.apache.derby.iapi.store.access.Qualifier;
31
32 import org.apache.derby.iapi.types.DataValueDescriptor;
33
34
35 /**
36  * This is the implementation for ScanQualifier. It is used for system and user
37  * scans.
38  *
39  * @version 0.1
40  * @author Jerry Brenner
41  */

42
43 public class GenericScanQualifier implements ScanQualifier
44 {
45
46     private int columnId = -1;
47     private DataValueDescriptor orderable = null;
48     private int operator = -1;
49     private boolean negateCR = false;
50     private boolean orderedNulls = false;
51     private boolean unknownRV = false;
52
53     private boolean properInit = false;
54
55     public GenericScanQualifier()
56     {
57     }
58
59     /*
60      * Qualifier interface
61      */

62
63     /**
64      * @see Qualifier#getColumnId
65      */

66     public int getColumnId()
67     {
68         if (SanityManager.DEBUG)
69             SanityManager.ASSERT(properInit, "properInit is expected to be true");
70         return columnId;
71     }
72
73     /**
74      * @see Qualifier#getOrderable
75      */

76     public DataValueDescriptor getOrderable()
77     {
78         if (SanityManager.DEBUG)
79             SanityManager.ASSERT(properInit, "properInit is expected to be true");
80         return orderable;
81     }
82
83     /** Get the operator to use in the comparison.
84      *
85      * @see Qualifier#getOperator
86      **/

87     public int getOperator()
88     {
89         if (SanityManager.DEBUG)
90             SanityManager.ASSERT(properInit, "properInit is expected to be true");
91         return operator;
92     }
93
94     /** Should the result from the compare operation be negated? If true
95      * then only rows which fail the compare operation will qualify.
96      *
97      * @see Qualifier#negateCompareResult
98      **/

99     public boolean negateCompareResult()
100     {
101         if (SanityManager.DEBUG)
102             SanityManager.ASSERT(properInit, "properInit is expected to be true");
103         return negateCR;
104     }
105
106     /** Get the getOrderedNulls argument to use in the comparison.
107      *
108      * @see Qualifier#getOrderedNulls
109      **/

110     public boolean getOrderedNulls()
111     {
112         if (SanityManager.DEBUG)
113             SanityManager.ASSERT(properInit, "properInit is expected to be true");
114         return orderedNulls;
115     }
116
117     /** Get the getOrderedNulls argument to use in the comparison.
118      *
119      * @see Qualifier#getUnknownRV
120      **/

121     public boolean getUnknownRV()
122     {
123         if (SanityManager.DEBUG)
124             SanityManager.ASSERT(properInit, "properInit is expected to be true");
125         return unknownRV;
126     }
127
128     /** Clear the DataValueDescriptor cache, if one exists.
129      * (The DataValueDescriptor can be 1 of 3 types:
130      * o VARIANT - cannot be cached as its value can
131      * vary within a scan
132      * o SCAN_INVARIANT - can be cached within a scan as its
133      * value will not change within a scan
134      * o QUERY_INVARIANT- can be cached across the life of the query
135      * as its value will never change
136      * o CONSTANT - immutable
137      *
138      * @see Qualifier#getUnknownRV
139      */

140     public void clearOrderableCache()
141     {
142         // No Orderable caching in ScanQualifiers
143
}
144
145     /**
146      * This method reinitializes all the state of
147      * the Qualifier. It is used to distinguish between
148      * resetting something that is query invariant
149      * and something that is constant over every
150      * execution of a query. Basically, clearOrderableCache()
151      * will only clear out its cache if it is a VARIANT
152      * or SCAN_INVARIANT value. However, each time a
153      * query is executed, the QUERY_INVARIANT qualifiers need
154      * to be reset.
155      */

156     public void reinitialize()
157     {
158     }
159
160     /*
161      * ScanQualifier interface
162      */

163
164     /**
165      * @see ScanQualifier#setQualifier
166      */

167     public void setQualifier(
168     int columnId,
169     DataValueDescriptor orderable,
170     int operator,
171     boolean negateCR,
172     boolean orderedNulls,
173     boolean unknownRV)
174     {
175         this.columnId = columnId;
176         this.orderable = orderable;
177         this.operator = operator;
178         this.negateCR = negateCR;
179         this.orderedNulls = orderedNulls;
180         this.unknownRV = unknownRV;
181         properInit = true;
182     }
183 }
184
185
186
187
188
Popular Tags