KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.ArrayList JavaDoc;
27
28 public abstract class FunctionCall extends XQueryExpression implements Cloneable JavaDoc {
29
30     private static final String JavaDoc RCSRevision = "$Revision: 1.7 $";
31     private static final String JavaDoc RCSName = "$Name: $";
32
33     // cannot be null or empty string
34
protected QName funcName = null;
35     protected ArrayList JavaDoc arguments = null;
36     
37     // #############################################################################
38
// VISITOR STUFF
39
// #############################################################################
40

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

49     public FunctionCall(QName name,ArrayList JavaDoc arguments) throws XQueryException {
50         setFuncName(name);
51         setArguments(arguments);
52     }
53     
54     // #############################################################################
55
// ATTRIBUTE ACCESS STUFF
56
// #############################################################################
57

58     public XQueryExpression getArgument(int pos) {
59         if (arguments == null) return null;
60         if (pos >= arguments.size()) return null;
61         return (XQueryExpression) this.arguments.get(pos);
62     }
63     
64     public ArrayList JavaDoc getArguments() { return arguments; }
65     
66     public void setArguments(ArrayList JavaDoc arguments) throws XQueryException {
67         this.arguments = arguments;
68         if (this.arguments != null)
69             for (int i=0;i<this.arguments.size();i++) {
70                 XQueryExpression expr = (XQueryExpression)this.arguments.get(i);
71                 expr.setParentExpression(this);
72                 expr.setParentModule(parentModule);
73             }
74     }
75         
76     public QName getFuncName() { return funcName; }
77     public void setFuncName(QName funcName) throws XQueryException {
78         if (funcName == null || funcName.getName().equals("")) throw new XQueryException("funcName of FunctionCall cannot be null");
79         this.funcName = funcName;
80     }
81     
82     public void addArguments(XQueryExpression subExpression) throws XQueryException {
83         if (arguments == null) arguments = new ArrayList JavaDoc(1);
84         arguments.add(subExpression);
85         subExpression.setParentExpression(this);
86         subExpression.setParentModule(parentModule);
87     }
88     
89     public void addArguments(int index,XQueryExpression subExpression) throws XQueryException {
90         if (arguments == null || arguments.size() < index) return;
91         arguments.add(index,subExpression);
92         subExpression.setParentExpression(this);
93         subExpression.setParentModule(parentModule);
94     }
95         
96     // #############################################################################
97
// CLONE STUFF
98
// #############################################################################
99
public void addParentExpression(XQueryExpression parentExpression) {
100         addParentExpression(parentExpression) ;
101         funcName.addParentExpression(parentExpression);
102         if (arguments != null)
103             for (int i=0;i<arguments.size();i++)
104                 ((XQueryExpression)arguments.get(i)).addParentExpression(parentExpression);
105     }
106     
107 }
108
109
110
111
Popular Tags