KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > expression > booleanvalueexpression > booleantest


1 package com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression;
2
3 import com.daffodilwoods.daffodildb.server.serversystem.*;
4 import com.daffodilwoods.daffodildb.server.sql99.common.*;
5 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.condition.*;
6 import com.daffodilwoods.daffodildb.server.sql99.expression.rowvalueexpression.*;
7 import com.daffodilwoods.daffodildb.server.sql99.utils.*;
8 import com.daffodilwoods.database.resource.*;
9
10 /**
11  * <p>Title: BooleanTest</p>
12  * <p>Description:
13  * This class represets Predicate/ParenthesizedBVE/TRUE/FALSE with one of its
14  * optional attribute which is [IS [NOT] TRUE/FALSE/UNKNOWN].
15  * It provides the functionality of Bve Execution Plan and execution of the
16  * condition.
17  * </p>
18  * <p>Copyright: Copyright (c) 2003</p>
19  * <p>Company: Daffodil S/W Ltd.</p>
20  * @author SelectTeam
21  * @version 1.0
22  */

23
24 public class booleantest extends AbstractBooleanValueExpression implements com.daffodilwoods.daffodildb.utils.parser.StatementExecuter {
25
26    public SRESERVEDWORD1206543922OptSRESERVEDWORD1206543922truthvalue _OptSRESERVEDWORD1206543922OptSRESERVEDWORD1206543922truthvalue0;
27    public booleanprimary _booleanprimary1;
28
29    public booleantest() {
30    }
31
32    public booleantest(booleanprimary object) {
33       _booleanprimary1 = object;
34    }
35
36    /**
37     * Returns the cost of evaluating this condition on passed number of rows, by
38     * considering the factor of index.
39     * @param rowCount
40     * @param index
41     * @return cost
42     * @throws DException
43     */

44
45    public double getCost(long rowCount, boolean index) throws DException {
46       return ( (AbstractBooleanValueExpression) _booleanprimary1).getCost(rowCount, index);
47    }
48
49    /**
50     * This method is called from qualified join. Passed TableDetails are of
51     * Right plans in case of LOJ and of Left Table Plans in case of ROJ.
52     * With the help of this method we identify whether 'on condition' is solvable
53     * on SingleTablePlan or on Qualified Join Level.
54     * @param tableDetails
55     * @return
56     * @throws DException
57     */

58
59    public _QualifiedBVE getQualifiedBVE(TableDetails[] tableDetails) throws DException {
60      return _OptSRESERVEDWORD1206543922OptSRESERVEDWORD1206543922truthvalue0 == null
61           ? ( (AbstractBooleanValueExpression) _booleanprimary1).getQualifiedBVE(tableDetails)
62           : new QualifiedBVE(null, this);
63    }
64
65    /**
66     * This method tells whether this condition can be used for seek or not.
67     * The criteria for seek is -
68     * Individual predicates is Equal Predicate with one column of type
69     * Reference on each side of Equal Predicate.
70     * @return
71     * @throws DException
72     */

73
74    public int canUseForSeek() throws DException {
75       return _OptSRESERVEDWORD1206543922OptSRESERVEDWORD1206543922truthvalue0 != null
76           ? TypeConstants.NOSEEK
77           : ( (AbstractBooleanValueExpression) _booleanprimary1).canUseForSeek();
78
79    }
80
81    /**
82     * This method is called from top level condition class. And that top level
83     * class represents the condition of SingleTable. Now this method separates the
84     * condition of individual predicates based on the columnName as well as
85     * the condition which can't be used in index like not predicate etc.
86     * @param allColumnPredicates
87     * @throws DException
88     */

89
90    public void setColumnPredicates(_AllColumnPredicates allColumnPredicates) throws DException {
91       if (_OptSRESERVEDWORD1206543922OptSRESERVEDWORD1206543922truthvalue0 != null) {
92          allColumnPredicates.addToNonIndex(new booleanfactor(this));
93       } else {
94          ( (AbstractBooleanValueExpression) _booleanprimary1).setColumnPredicates(allColumnPredicates);
95       }
96    }
97
98    public int getConditionType() throws DException {
99       return ( (AbstractBooleanValueExpression) _booleanprimary1).getConditionType();
100    }
101
102    /**
103     * This method returns the ExecutionPlan of the condition. Execution Plan
104     * contains the following information -
105     * 1. Array of BveSingleTablePlans, the condition which can be solved on
106     * single table level.
107     * 2. BveAllTablePlan which contains the condition in which two tables are
108     * involved(join condition) and it also contains remaining condition
109     * 3. BveAggregatePlan which contains the condition of aggregate columns.
110     * This condition can involve in having clause only.
111     * as remaining condition.
112     * @return
113     * @throws DException
114     */

115
116    public _BVEPlan getExecutionPlan() throws DException {
117       return ( (AbstractBooleanValueExpression) _booleanprimary1).getExecutionPlan();
118    }
119
120    public Object JavaDoc run(Object JavaDoc object) throws com.daffodilwoods.database.resource.DException {
121       return _booleanprimary1.run(object);
122    }
123
124    /**
125     * This method is called from Browser, when Parameterized query is fired from Browser.
126     * With the help of ParameterInfo Browser open ups daialog box(labelled by its corresponding name)
127     * for each question mark to put the values of question mark.
128     * @return
129     * @throws DException
130     */

131
132    public ParameterInfo[] getParameterInfo() throws DException {
133       ParameterInfo[] p1 = _booleanprimary1.getParameterInfo();
134       return p1;
135    }
136
137    /**
138     * This method returns all the children of this class. It is needed in
139     * Abstract classes, so as to move common methods in Abstract class.
140     * @return
141     */

142
143    public AbstractRowValueExpression[] getChilds() {
144       AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] { (AbstractRowValueExpression) (_booleanprimary1)};
145       return childs;
146    }
147
148    /**
149     * This method returns the estimate of the rows remaining after the execution
150     * of this condition on passed number of rows.
151     * @param noOfRows
152     * @return
153     * @throws DException
154     */

155
156    public long getEstimatedRows(long noOfRows) throws DException {
157       return ( (AbstractBooleanValueExpression) _booleanprimary1).getEstimatedRows(noOfRows);
158    }
159
160    /**
161     * This method tells whether null predicate is present in the condition or not.
162     * This is needed while shifting the condition to single table in case of
163     * Loj/Roj to identify whether to shift condition or not. As if null predicate
164     * is present in condition on right table of LOJ and left table of Roj, then
165     * we can't shift the condition to single table level.
166     * @return
167     * @throws DException
168     */

169
170    public boolean isNullPredicate() throws DException {
171       return ( (AbstractBooleanValueExpression) _booleanprimary1).isNullPredicate();
172    }
173
174    public String JavaDoc toString() {
175       StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
176       sb.append(" ");
177       sb.append(_booleanprimary1);
178       sb.append(" ");
179       if (_OptSRESERVEDWORD1206543922OptSRESERVEDWORD1206543922truthvalue0 != null) {
180          sb.append(_OptSRESERVEDWORD1206543922OptSRESERVEDWORD1206543922truthvalue0);
181       }
182       return sb.toString();
183    }
184
185    public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
186       booleantest tempClass = new booleantest();
187       if (_OptSRESERVEDWORD1206543922OptSRESERVEDWORD1206543922truthvalue0 != null) {
188          tempClass._OptSRESERVEDWORD1206543922OptSRESERVEDWORD1206543922truthvalue0 = (SRESERVEDWORD1206543922OptSRESERVEDWORD1206543922truthvalue) _OptSRESERVEDWORD1206543922OptSRESERVEDWORD1206543922truthvalue0.clone();
189       }
190       tempClass._booleanprimary1 = (booleanprimary) _booleanprimary1.clone();
191       return tempClass;
192    }
193
194    public _Reference[] checkSemantic(_ServerSession parent) throws DException {
195       if (! (_booleanprimary1 instanceof AbstractBooleanValueExpression)) {
196          getColumnDetails();
197          throw new DException("DSE6007", new Object JavaDoc[] {_booleanprimary1.toString()});
198       }
199       return _booleanprimary1.checkSemantic(parent);
200    }
201
202 }
203
Popular Tags