KickJava   Java API By Example, From Geeks To Geeks.

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


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.IsolateWhereVisitor;
28 import org.xquark.mediator.plan.ExecutionPlan;
29 import org.xquark.mediator.plan.OpValue;
30 import org.xquark.mediator.plan.Operator;
31 import org.xquark.mediator.runtime.MediatorException;
32 import org.xquark.xquery.parser.Variable;
33 import org.xquark.xquery.parser.XQueryException;
34 import org.xquark.xquery.parser.XQueryExpression;
35
36 /**
37  * This class represent a terminal leaf of the dependancy tree on first step
38  * of creation (before atomization).
39  *
40  */

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

59     public AlgValue(XQueryExpression expression, Variable var, AlgebraManager depmanager, boolean islet) {
60         super(expression, var, depmanager, islet) ;
61         // check if where clause
62
if (var != null && var.getParentFLWRExpression().getWhereClause() != null) {
63             ArrayList JavaDoc tmplist = new ArrayList JavaDoc(1);
64             tmplist.add(var);
65             IsolateWhereVisitor isolateVisitor = new IsolateWhereVisitor(tmplist);
66             try {
67                 var.getParentFLWRExpression().getWhereClause().accept(isolateVisitor);
68                 condition = isolateVisitor.getIsolatedExpression();
69                 if (condition != null)
70                     var.getParentFLWRExpression().setWhereClause(isolateVisitor.getRemainingExpression());
71             } catch (XQueryException e) {
72             }
73         }
74         // verify is variable is identifier
75
if (depmanager.getIdVars().contains(var)) this.hasIdentifier = true;
76     }
77     
78     // ******************************************************************
79
// * METHODS
80
// ******************************************************************
81

82     public void ParentHasIdentifier() {
83         hasIdentifier = true;
84     }
85     
86     // ******************************************************************
87
// * CREATE EXECUTION PLAN
88
// ******************************************************************
89
/**
90      *
91      * @param plan
92      * @return
93      */

94     public Operator createOperator(ExecutionPlan plan) throws MediatorException {
95         //if (true) throw new MediatorException("createAlgebra not supported in DepValue");
96
Operator operator = new OpValue(plan, this, condition, hasIdentifier) ;
97         operator.isLet(islet);
98         return operator ;
99     }
100     
101     /**
102      *
103      * @return
104      */

105     public ArrayList JavaDoc getVarsThatDepend() throws MediatorException {
106         return new ArrayList JavaDoc() ;
107     }
108     
109     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
110         AlgValue newobj = (AlgValue)super.clone();
111         return newobj;
112     }
113     
114     public void execute(ExecutionPlan plan) throws MediatorException {
115     }
116     
117     // ******************************************************************
118
// * DEBUGGING
119
// ******************************************************************
120

121 }
122
Popular Tags