KickJava   Java API By Example, From Geeks To Geeks.

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


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 /*
24  * CaseClauseExpression.java
25  *
26  * Created on 26 septembre 2002, 14:10
27  */

28
29 package org.xquark.xquery.parser;
30
31 import org.xquark.xquery.typing.TypeException;
32
33
34 public class CaseClauseExpression extends XQueryExpression implements Cloneable JavaDoc {
35     
36     private static final String JavaDoc RCSRevision = "$Revision: 1.9 $";
37     private static final String JavaDoc RCSName = "$Name: $";
38     
39     protected SequenceType sequenceType = null;
40     protected Variable variable = null;
41     // cannot be null
42
protected XQueryExpression returnExpression = null;
43     
44     // #############################################################################
45
// VISITOR STUFF
46
// #############################################################################
47

48     public void accept(ParserVisitor visitor) throws XQueryException {
49         visitor.visit(this);
50     }
51     
52     // #############################################################################
53
// CONSTRUCTOR STUFF
54
// #############################################################################
55

56     public CaseClauseExpression(SequenceType sequenceType, Variable variable, XQueryExpression returnExpression, XQueryModule parentModule) throws TypeException, XQueryException {
57         setSequenceType(sequenceType);
58         setVariable(variable);
59         setReturnExpression(returnExpression);
60         setParentModule(parentModule);
61         if (parentModule != null && parentModule.getStaticContext().getTypeVisitor() != null)
62             accept(parentModule.getStaticContext().getTypeVisitor());
63     }
64     
65     // #############################################################################
66
// ATTRIBUTE ACCESS STUFF
67
// #############################################################################
68

69     public void setParentModule(XQueryModule parentUnit) {
70         if (parentUnit == null) return;
71         this.parentModule = parentUnit;
72         super.setParentModule(parentUnit);
73         sequenceType.setParentModule(parentUnit);
74         if (variable != null) variable.setParentModule(parentUnit);
75         returnExpression.setParentModule(parentUnit);
76     }
77     
78     public void setSequenceType(SequenceType sequenceType) throws XQueryException {
79         this.sequenceType = sequenceType;
80         if (sequenceType != null) {
81             this.sequenceType.setParentModule(parentModule);
82             this.sequenceType.setParentExpression(this);
83         }
84     }
85     
86     public SequenceType getSequenceType() { return sequenceType; }
87     
88     public void setVariable(Variable variable) {
89         this.variable = variable;
90         if (variable != null) {
91             this.variable.setParentModule(parentModule);
92             this.variable.setParentExpression(this);
93         }
94     }
95     
96     public Variable getVariable() { return variable; }
97     
98     public void setReturnExpression(XQueryExpression returnExpression) throws XQueryException {
99         // cannot be null
100
if (returnExpression == null) throw new XQueryException("ReturnExpression of a caseClause cannot be null.");
101         this.returnExpression = returnExpression;
102         this.returnExpression.setParentModule(parentModule);
103         this.returnExpression.setParentExpression(this);
104     }
105     
106     public XQueryExpression getReturnExpression() { return returnExpression; }
107         
108 }
109
Popular Tags