1 22 23 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 { 35 36 private static final String RCSRevision = "$Revision: 1.9 $"; 37 private static final String RCSName = "$Name: $"; 38 39 protected SequenceType sequenceType = null; 40 protected Variable variable = null; 41 protected XQueryExpression returnExpression = null; 43 44 48 public void accept(ParserVisitor visitor) throws XQueryException { 49 visitor.visit(this); 50 } 51 52 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 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 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 |