KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > mediator > algebra > AlgEval


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.mediator.algebra;
24
25 import java.util.ArrayList JavaDoc;
26
27 import org.xquark.mediator.decomposer.GetUsedVariablesVisitor;
28 import org.xquark.mediator.decomposer.IsolateWhereVisitor;
29 import org.xquark.mediator.plan.ExecutionPlan;
30 import org.xquark.mediator.plan.OpEval;
31 import org.xquark.mediator.plan.Operator;
32 import org.xquark.mediator.runtime.MediatorException;
33 import org.xquark.xquery.parser.Variable;
34 import org.xquark.xquery.parser.XQueryException;
35 import org.xquark.xquery.parser.XQueryExpression;
36
37 /**
38  * This class represent a terminal leaf of the dependancy tree on first step
39  * of creation (before atomization).
40  *
41  */

42 public class AlgEval extends Algebra {
43     // **********************************************************************
44
// * VERSIONING
45
// **********************************************************************
46
private static final String JavaDoc RCSRevision = "$Revision: 1.5 $";
47     private static final String JavaDoc RCSName = "$Name: $";
48     
49     private XQueryExpression condition = null;
50     // ************************************************************************
51
// * INITIALIZATION
52
// ************************************************************************
53
/**
54      *
55      * @param typevisitor
56      * @param expression
57      * @param var
58      * @param parent
59      */

60     public AlgEval(XQueryExpression expression, Variable var, AlgebraManager depmanager, boolean islet) throws MediatorException {
61         super(expression, var, depmanager, islet) ;
62         // check if where clause
63
if (var != null && var.getParentFLWRExpression().getWhereClause() != null) {
64             ArrayList JavaDoc tmplist = new ArrayList JavaDoc(1);
65             tmplist.add(var);
66             IsolateWhereVisitor isolateVisitor = new IsolateWhereVisitor(tmplist);
67             try {
68                 var.getParentFLWRExpression().getWhereClause().accept(isolateVisitor);
69             } catch (XQueryException xqe) {
70                 throw new MediatorException(xqe.getMessage());
71             }
72             condition = isolateVisitor.getIsolatedExpression();
73             if (condition != null)
74                 var.getParentFLWRExpression().setWhereClause(isolateVisitor.getRemainingExpression());
75         }
76         // get variables depending on
77
GetUsedVariablesVisitor guvv = new GetUsedVariablesVisitor();
78         try {
79             expression.accept(guvv);
80         } catch (XQueryException xqe){
81         }
82         addDependSourceVariables(guvv.getVariables());
83         // verify is variable is identifier
84
if (depmanager.getIdVars().contains(var)) this.hasIdentifier = true;
85     }
86     
87     // ******************************************************************
88
// * METHODS
89
// ******************************************************************
90

91     public void ParentHasIdentifier() {
92         hasIdentifier = true;
93     }
94     
95     // ******************************************************************
96
// * CREATE EXECUTION PLAN
97
// ******************************************************************
98
/**
99      *
100      * @param plan
101      * @return
102      */

103     public Operator createOperator(ExecutionPlan plan) throws MediatorException {
104         //if (true) throw new MediatorException("createAlgebra not supported in DepValue");
105
Operator operator = new OpEval(plan, this, condition, hasIdentifier) ;
106         operator.isLet(islet);
107         return operator ;
108     }
109     
110     /**
111      *
112      * @return
113      */

114     public ArrayList JavaDoc getVarsThatDepend() throws MediatorException {
115         return new ArrayList JavaDoc() ;
116     }
117     
118     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
119         AlgEval newobj = (AlgEval)super.clone();
120         return newobj;
121     }
122     
123     public void execute(ExecutionPlan plan) throws MediatorException {
124     }
125     
126     // ******************************************************************
127
// * DEBUGGING
128
// ******************************************************************
129

130 }
131
Popular Tags