KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > mediator > plan > ZeroOp


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.plan ;
24
25 import org.xquark.mediator.decomposer.Utils;
26 import org.xquark.mediator.runtime.MediatorException;
27 import org.xquark.xquery.parser.XQueryExpression;
28
29 public abstract class ZeroOp extends Operator {
30     // **********************************************************************
31
// * VERSIONING
32
// **********************************************************************
33
private static final String JavaDoc RCSRevision = "$Revision: 1.6 $";
34     private static final String JavaDoc RCSName = "$Name: $";
35     // **********************************************************************
36
// * CLASS VARIABLES
37
// **********************************************************************
38

39     // ***********************************************************************
40
// * INITIALIZATION
41
// ***********************************************************************
42
/**
43      *
44      */

45     public ZeroOp(ExecutionPlan plan, XQueryExpression expression) throws MediatorException {
46         super(plan, expression) ;
47     }
48     // #############################################################################
49
// VISITOR STUFF
50
// #############################################################################
51

52     public void accept(OperatorVisitor visitor) throws MediatorException {
53         visitor.visit(this);
54     }
55
56     // ***********************************************************************
57
// * EXECUTE QUERY
58
// ***********************************************************************
59
/**
60      *
61      */

62     public ResultSet executeQuery(DynamicContext context) throws MediatorException {
63         return getResultSet(context);
64     }
65     
66  
67     /**
68      */

69     protected abstract ResultSet getResultSet(DynamicContext context) throws MediatorException;
70
71     // ***********************************************************************
72
// * OPTIMIZE
73
// ***********************************************************************
74
/**
75      * If the set of sources handled by this node are exactly the same (order
76      * not important) then return true.
77      * An AlgZeroOp is alway true.
78      * @return true
79      */

80     protected boolean shareSameSources() {
81         return true ;
82     }
83     
84     /**
85      * Return true if the node is of type source.
86      * An AlgZeroOp is alway a source.
87      * @return true
88      */

89     public boolean isSource() {
90         return true ;
91     }
92     
93     public void terminate() {
94         // do nothing
95
}
96     public void setPrepared() throws MediatorException {
97         if (prepared) return;
98         prepared = true;
99         // do nothing
100
}
101     
102     /**
103      * Merge *this* node with the subnode(s). As it should be called
104      * only from source, the returned node must be of type AlgZeroOp.
105      * For AlgZeroOp it is the node itself.
106      */

107     // protected Algebra mergeWithSub() throws MediatorException { return this ; }
108

109     public String JavaDoc toCompleteString(int indent) {
110         StringBuffer JavaDoc buf = new StringBuffer JavaDoc() ;
111         buf.append(Utils.makeIndent(indent) + "<" + getClass().getName() + " isLet=\"" + isLet() + "\">\n") ;
112         buf.append(Utils.makeIndent(indent + 1) + "<Expression>\n") ;
113         buf.append(Utils.makeIndent(indent + 2) + expression + "\n") ;
114         buf.append(Utils.makeIndent(indent + 1) + "</Expression>\n") ;
115 // if (variables != null) {
116
// buf.append(Utils.makeIndent(indent + 1) + "<Variables>\n") ;
117
// for (int i = 0 ; i < variables.size() ; i ++) {
118
// buf.append(Utils.makeIndent(indent + 2) + "<Variable>" + variables.get(i) + "</Variable>\n") ;
119
// }
120
// buf.append(Utils.makeIndent(indent + 1) + "</Variables>\n") ;
121
// }
122
if (paths != null) {
123             buf.append(Utils.makeIndent(indent + 1) + "<Paths>\n") ;
124             for (int i = 0 ; i < paths.size() ; i ++) {
125                 buf.append(Utils.makeIndent(indent + 2) + "<Path>" + paths.get(i) + "</Path>\n") ;
126             }
127             buf.append(Utils.makeIndent(indent + 1) + "</Paths>\n") ;
128         }
129         buf.append(Utils.makeIndent(indent) + "</" + getClass().getName() + ">\n") ;
130         return buf.toString() ;
131     }
132 }
133
Popular Tags