1 22 23 package org.xquark.xquery.parser; 24 25 import java.util.ArrayList ; 26 27 import org.xquark.xquery.typing.TypeException; 28 29 public class SortedExpression extends XQueryListUnaryOperatorExpression implements Cloneable { 30 private static final String RCSRevision = "$Revision: 1.9 $"; 31 private static final String RCSName = "$Name: $"; 32 33 protected ArrayList sortClauses = null; 35 36 protected boolean stable = false; 39 public SortedExpression(XQueryExpression expression, ArrayList sortClauses, boolean stable, XQueryModule parentModule) throws TypeException, XQueryException { 43 super(expression); 44 45 setStable(stable); 47 setSortClauses(sortClauses); 48 49 setParentModule(parentModule); 50 if (parentModule != null && parentModule.getStaticContext().getTypeVisitor() != null) 51 accept(parentModule.getStaticContext().getTypeVisitor()); 52 } 53 54 public void accept(ParserVisitor visitor) throws XQueryException { 58 visitor.visit(this); 59 } 60 61 public void setParentModule(XQueryModule parentUnit) { 65 if (parentUnit == null) { 66 return; 67 } 68 69 this.parentModule = parentUnit; 70 super.setParentModule(parentUnit); 71 72 for (int i = 0; i < sortClauses.size(); i++) 73 ((XQueryExpression) sortClauses.get(i)).setParentModule(parentUnit); 74 } 75 76 public ArrayList getSortClauses() { 77 return sortClauses; 78 } 79 80 public void setSortClauses(ArrayList sortClauses) throws XQueryException { 81 if ((sortClauses == null) || sortClauses.isEmpty()) { 83 throw new XQueryException("sortClauses of SortedExpression cannot be null or empty"); 84 } 85 86 this.sortClauses = sortClauses; 87 88 for (int i = 0; i < this.sortClauses.size(); i++) { 89 XQueryExpression expr = (XQueryExpression) this.sortClauses.get(i); 90 expr.setParentModule(parentModule); 91 expr.setParentExpression(this); 92 } 93 } 94 95 public void setStable(boolean stable) { 97 this.stable = stable; 98 } 99 100 public boolean getStable() { 101 return stable; 102 } 103 104 public void addParentExpression(XQueryExpression parentExpression) { 108 addParentExpression(parentExpression); 109 expression.addParentExpression(parentExpression); 110 111 for (int i = 0; i < sortClauses.size(); i++) 112 ((XQueryExpression) sortClauses.get(i)).addParentExpression(parentExpression); 113 } 114 115 } 116 | Popular Tags |