1 22 23 package org.xquark.xquery.parser; 24 25 import java.util.ArrayList ; 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 { 31 32 private static final String RCSRevision = "$Revision: 1.12 $"; 33 private static final String RCSName = "$Name: $"; 34 35 int kind = -1; 37 ArrayList variables = null; 39 40 44 public void accept(ParserVisitor visitor) throws XQueryException { 45 visitor.visit(this); 46 } 47 48 52 public QuantifiedExpression(int kind, ArrayList 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 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 getConstraintExpresson() { 76 return expression; 77 } 78 79 public void setConstraintExpresson(XQueryExpression constraintExpression) throws XQueryException { 81 setExpression(constraintExpression); 82 } 83 84 public Variable getVariable(int index) { 88 return (Variable) variables.get(index); 89 } 90 public ArrayList getVariables() { 91 return variables; 92 } 93 public void setVariables(ArrayList 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 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 |