KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > xquery > parser > QuantifiedExpression


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.xquery.parser;
24
25 import java.util.ArrayList JavaDoc;
26
27 import org.xquark.xquery.parser.util.Constants;
28 import org.xquark.xquery.typing.TypeException;
29
30 public class QuantifiedExpression extends XQueryListUnaryOperatorExpression implements Cloneable JavaDoc {
31
32     private static final String JavaDoc RCSRevision = "$Revision: 1.12 $";
33     private static final String JavaDoc RCSName = "$Name: $";
34
35     // cannot be -1
36
int kind = -1;
37     // cannot be null
38
ArrayList JavaDoc variables = null;
39
40     // #############################################################################
41
// VISITOR STUFF
42
// #############################################################################
43

44     public void accept(ParserVisitor visitor) throws XQueryException {
45         visitor.visit(this);
46     }
47
48     // #############################################################################
49
// CONSTRUCTOR STUFF
50
// #############################################################################
51

52     public QuantifiedExpression(int kind, ArrayList JavaDoc variables, XQueryExpression constraintExpression, XQueryModule parentModule) throws TypeException, XQueryException {
53         super(constraintExpression);
54         setKind(kind);
55         setVariables(variables);
56         setParentModule(parentModule);
57         if (parentModule != null && parentModule.getStaticContext().getTypeVisitor() != null)
58             accept(parentModule.getStaticContext().getTypeVisitor());
59     }
60
61     // #############################################################################
62
// ATTRIBUTE ACCESS STUFF
63
// #############################################################################
64

65     public int getKind() {
66         return kind;
67     }
68     public void setKind(int kind) throws XQueryException {
69         if (kind == -1 || kind > Constants.MAX_QUANTIFIER)
70             throw new XQueryException("kind of QuantifiedExpression has incorrect value " + kind);
71         this.kind = kind;
72     }
73
74     //public XQueryExpression getMainExpresson() { return variable.getExpression(); }
75
public XQueryExpression getConstraintExpresson() {
76         return expression;
77     }
78
79     // W3C WD 16 August 2002
80
public void setConstraintExpresson(XQueryExpression constraintExpression) throws XQueryException {
81         setExpression(constraintExpression);
82     }
83
84 // public Variable getVariable() {
85
// return (Variable) variables.get(0);
86
// }
87
public Variable getVariable(int index) {
88         return (Variable) variables.get(index);
89     }
90     public ArrayList JavaDoc getVariables() {
91         return variables;
92     }
93     public void setVariables(ArrayList JavaDoc variables) throws XQueryException {
94         if (variables == null || variables.isEmpty())
95             throw new XQueryException("variables of QuantifiedExpression cannot be null or empty");
96         this.variables = variables;
97         for (int i = 0; i < variables.size(); i++) {
98             ((Variable) variables.get(i)).setParentExpression(this);
99             ((Variable) variables.get(i)).setParentModule(parentModule);
100         }
101     }
102
103     // #############################################################################
104
// CLONE STUFF
105
// #############################################################################
106
public void addParentExpression(XQueryExpression parentExpression) {
107         addParentExpression(parentExpression);
108         for (int i = 0; i < variables.size(); i++)
109              ((Variable) variables.get(i)).addParentExpression(parentExpression);
110         expression.addParentExpression(parentExpression);
111     }
112
113 }
114
Popular Tags