1 22 23 package org.xquark.xquery.parser; 24 25 import java.util.ArrayList ; 26 import java.util.HashSet ; 27 import java.util.Set ; 28 29 import org.xquark.xquery.typing.TypeException; 30 31 public class XQueryExpressionSequence extends XQueryExpression { 32 private static final String RCSRevision = "$Revision: 1.10 $"; 33 private static final String RCSName = "$Name: $"; 34 35 ArrayList subExpressions = null; 37 41 public void accept(ParserVisitor visitor) throws XQueryException { 42 visitor.visit(this); 43 } 44 45 49 public XQueryExpressionSequence(ArrayList subExpressions, XQueryModule parentModule) throws TypeException, XQueryException { 50 setSubExpressions(subExpressions); 51 setParentModule(parentModule); 52 if (parentModule != null && parentModule.getStaticContext().getTypeVisitor() != null) 53 accept(parentModule.getStaticContext().getTypeVisitor()); 54 } 55 56 60 public ArrayList getSubExpressions() { 61 return subExpressions; 62 } 63 public void setSubExpressions(ArrayList subExpressions) throws XQueryException { 64 if (subExpressions == null || subExpressions.isEmpty()) 65 throw new XQueryException("subExpressions of XQueryExpressionSequence cannot be null or empty"); 66 this.subExpressions = subExpressions; 67 for (int j = 0; j < this.subExpressions.size(); j++) { 68 XQueryExpression expression = (XQueryExpression) this.subExpressions.get(j); 69 expression.setParentExpression(this); 70 expression.setParentModule(parentModule); 71 } 72 } 73 74 public void addSubExpressions(XQueryExpression subExpression) throws XQueryException { 75 subExpressions.add(subExpression); 76 subExpression.setParentExpression(this); 77 subExpression.setParentModule(parentModule); 78 } 79 80 public void addSubExpressions(int index, XQueryExpression subExpression) throws XQueryException { 81 subExpressions.add(index, subExpression); 82 subExpression.setParentExpression(this); 83 subExpression.setParentModule(parentModule); 84 } 85 86 public Set getSourceNames() { 87 if (subExpressions == null) 88 return null; 89 Set tmplist = null; 90 for (int i = 0; i < subExpressions.size(); i++) { 91 XQueryExpression expressioni = (XQueryExpression) subExpressions.get(i); 92 if (expressioni.getSourceNames() != null) { 93 if (tmplist == null) 94 tmplist = new HashSet (expressioni.getSourceNames()); 95 else 96 tmplist.addAll(expressioni.getSourceNames()); 97 } 98 } 99 return tmplist; 100 } 101 102 public Set getUrls() { 103 if (subExpressions == null) 104 return null; 105 Set tmplist = null; 106 for (int i = 0; i < subExpressions.size(); i++) { 107 XQueryExpression expressioni = (XQueryExpression) subExpressions.get(i); 108 if (expressioni.getUrls() != null) { 109 if (tmplist == null) 110 tmplist = new HashSet (expressioni.getUrls()); 111 else 112 tmplist.addAll(expressioni.getUrls()); 113 } 114 } 115 return tmplist; 116 } 117 118 public void addParentExpression(XQueryExpression parentExpression) { 122 addParentExpression(parentExpression); 123 for (int j = 0; j < subExpressions.size(); j++) 124 ((XQueryExpression) subExpressions.get(j)).addParentExpression(parentExpression); 125 } 126 127 } 128 | Popular Tags |