KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.xquark.xquery.parser;
25
26 import org.xquark.xquery.typing.TypeException;
27
28
29
30 public class ITEExpression extends XQueryExpression 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 null
36
protected XQueryExpression ifExpression = null;
37     // cannot be null
38
protected XQueryExpression thenExpression = null;
39     // cannot be null
40
protected XQueryExpression elseExpression = null;
41     
42     // #############################################################################
43
// VISITOR STUFF
44
// #############################################################################
45

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

54     public ITEExpression(XQueryExpression ifExpression, XQueryExpression thenExpression, XQueryExpression elseExpression, XQueryModule parentModule) throws TypeException, XQueryException {
55         setIfExpression(ifExpression);
56         setThenExpression(thenExpression);
57         setElseExpression(elseExpression);
58         setParentModule(parentModule);
59         if (parentModule != null && parentModule.getStaticContext().getTypeVisitor() != null)
60             accept(parentModule.getStaticContext().getTypeVisitor());
61     }
62     
63     // #############################################################################
64
// ATTRIBUTE ACCESS STUFF
65
// #############################################################################
66

67     public XQueryExpression getIfExpression() { return ifExpression; }
68     public void setIfExpression(XQueryExpression expression) throws XQueryException {
69         // cannot be null
70
if (expression == null) throw new XQueryException("ifExpression of ITEExpression cannot be null");
71         this.ifExpression = expression;
72         this.ifExpression.setParentModule(parentModule);
73         this.ifExpression.setParentExpression(this);
74     }
75     
76     public XQueryExpression getThenExpression() { return thenExpression; }
77     public void setThenExpression(XQueryExpression expression) throws XQueryException {
78         // cannot be null
79
if (expression == null) throw new XQueryException("thenExpression of ITEExpression cannot be null");
80         this.thenExpression = expression;
81         this.thenExpression.setParentModule(parentModule);
82         this.thenExpression.setParentExpression(this);
83     }
84     
85     public XQueryExpression getElseExpression() { return elseExpression; }
86     public void setElseExpression(XQueryExpression expression) throws XQueryException {
87         // cannot be null
88
if (expression == null) throw new XQueryException("elseExpression of ITEExpression cannot be null");
89         this.elseExpression = expression;
90         this.elseExpression.setParentModule(parentModule);
91         this.elseExpression.setParentExpression(this);
92     }
93         
94     // #############################################################################
95
// CLONE STUFF
96
// #############################################################################
97
public void addParentExpression(XQueryExpression parentExpression) {
98         addParentExpression(parentExpression) ;
99         ifExpression.addParentExpression(parentExpression);
100         thenExpression.addParentExpression(parentExpression);
101         elseExpression.addParentExpression(parentExpression);
102     }
103     
104 }
105
106
107
108
Popular Tags