1 22 23 24 package org.xquark.xquery.parser; 25 26 import java.util.ArrayList ; 27 28 public abstract class FunctionCall extends XQueryExpression implements Cloneable { 29 30 private static final String RCSRevision = "$Revision: 1.7 $"; 31 private static final String RCSName = "$Name: $"; 32 33 protected QName funcName = null; 35 protected ArrayList arguments = null; 36 37 41 public void accept(ParserVisitor visitor) throws XQueryException { 42 visitor.visit(this); 43 } 44 45 49 public FunctionCall(QName name,ArrayList arguments) throws XQueryException { 50 setFuncName(name); 51 setArguments(arguments); 52 } 53 54 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 getArguments() { return arguments; } 65 66 public void setArguments(ArrayList 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 (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 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 |