KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > dql > plan > table > TemporaryMerge


1 package com.daffodilwoods.daffodildb.server.sql99.dql.plan.table;
2
3 import com.daffodilwoods.daffodildb.client.*;
4 import com.daffodilwoods.daffodildb.server.sql99.dql.common.*;
5 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.*;
6 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.condition.*;
7 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*;
8 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.predicates.*;
9 import com.daffodilwoods.database.resource.*;
10
11 /**
12  * It represents unexecutable plan. It comes in to picture when more than two
13  * single table order are shifted to single table and join condition is present
14  * on tables which are not at consecutive place in OrderSequencePlan.
15  * <p>Title: </p>
16  * <p>Description: </p>
17  * <p>Copyright: Copyright (c) 2003</p>
18  * <p>Company: </p>
19  * @author unascribed
20  * @version 1.0
21  */

22
23 public class TemporaryMerge extends OrderTablePlanAbstract implements ExecutionPlanConstants, _TablePlan /*, _TemporaryMerge*/ {
24
25    public TemporaryMerge() {
26    }
27
28    /**
29     * Returns the condition present on this table.
30     * @return
31     * @throws DException
32     */

33
34    public booleanvalueexpression getCondition() throws DException {
35       return remainingCondition;
36    }
37
38    /**
39     * Returns the type of this plan.
40     * @return
41     * @throws DException
42     */

43
44    public int getType() throws DException {
45       return TableExpressionConstants.TEMPORARYMERGE;
46    }
47
48    /**
49     * This method is used to add passed plan to the array of underlying plans.
50     * @param tablePlan
51     * @throws DException
52     */

53
54    public void addTablePlan(_TablePlan tablePlan) throws DException {
55       if (this.childPlans != null) {
56          int len = this.childPlans.length;
57          _TablePlan[] tempTablePlans = new _TablePlan[len + 1];
58          System.arraycopy(this.childPlans, 0, tempTablePlans, 0, len);
59          tempTablePlans[len] = tablePlan;
60          this.childPlans = tempTablePlans;
61       } else {
62          this.childPlans = new _TablePlan[] {tablePlan};
63       }
64    }
65
66    /**
67     * This method is used to add the passed condition to the condition present
68     * on this plan.
69     * @param bve
70     * @throws DException
71     */

72
73    public void addCondition(booleanvalueexpression bve) throws DException {
74       remainingCondition = BVEPlanMerger.addAndConditions(remainingCondition, bve);
75    }
76
77    public String JavaDoc toString() {
78       StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
79       stringBuffer.append("TemporaryMerge");
80       for (int i = 0; i < childPlans.length; i++) {
81          stringBuffer.append("[");
82          stringBuffer.append(childPlans[i].toString());
83          stringBuffer.append("]");
84       }
85       if (remainingCondition != null) {
86          stringBuffer.append("[");
87          stringBuffer.append(remainingCondition.toString());
88          stringBuffer.append("]");
89       }
90       return stringBuffer.toString();
91    }
92
93    public String JavaDoc getVerifier() throws DException {
94       StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
95       stringBuffer.append("TemporaryMerge");
96       for (int i = 0; i < childPlans.length; i++) {
97          stringBuffer.append("[");
98          stringBuffer.append(childPlans[i].toString());
99          stringBuffer.append("]");
100       }
101       if (remainingCondition != null) {
102          stringBuffer.append("[");
103          stringBuffer.append(remainingCondition.toString());
104          stringBuffer.append("]");
105       }
106       return stringBuffer.toString();
107    }
108
109    /**
110     * Returns the plan for TemporaryMerge.
111     * @return
112     * @throws DException
113     */

114
115    public _QueryPlan getQueryPlan() throws DException {
116       int length = childPlans.length;
117       _QueryPlan[] cplans = new _QueryPlan[length];
118       for (int i = 0; i < length; i++) {
119          cplans[i] = childPlans[i].getQueryPlan();
120       }
121       String JavaDoc bve = remainingCondition == null ? null : ("" + remainingCondition);
122       return new QueryPlan("TemporaryMerge", cplans, bve, null);
123    }
124 }
125
Popular Tags