1 22 23 package org.xquark.xquery.parser; 24 25 import java.util.ArrayList ; 26 27 import org.xquark.xpath.Axis; 28 import org.xquark.xquery.typing.TypeException; 29 30 public class SchemaContextPath extends XQueryExpression implements Cloneable { 31 32 private static final String RCSRevision = "$Revision: 1.8 $"; 33 private static final String RCSName = "$Name: $"; 34 35 protected ArrayList steps = null; 37 38 42 public void accept(ParserVisitor visitor) throws XQueryException { 43 visitor.visit(this); 44 } 45 46 50 public SchemaContextPath(ArrayList steps, XQueryModule parentModule) throws TypeException, XQueryException { 51 this.steps = steps; 52 setParentModule(parentModule); 53 } 56 57 58 62 public SchemaContextStep getStep(int num) { 63 if (num >= steps.size()) 64 return null; 65 return (SchemaContextStep) steps.get(num); 66 } 67 public ArrayList getSteps() { 71 return steps; 72 } 73 public void setSteps(ArrayList steps) throws XQueryException { 74 if (steps == null || steps.isEmpty()) 76 throw new XQueryException("steps of SchemaContextPath cannot be null or empty"); 77 this.steps = steps; 78 for (int i = 0; i < this.steps.size(); i++) { 79 SchemaContextStep step = (SchemaContextStep) this.steps.get(i); 80 step.setParentExpression(this); 81 step.setParentModule(parentModule); 82 } 83 } 84 85 public void addStep(SchemaContextStep step) throws XQueryException { 86 if (step == null) 87 return; 88 if (steps == null) 89 steps = new ArrayList (1); 90 steps.add(step); 91 setSteps(steps); 92 } 93 94 public void addSteps(ArrayList steps) throws XQueryException { 95 if (steps == null || steps.isEmpty()) 96 return; 97 if (this.steps == null || this.steps.isEmpty()) { 98 setSteps(steps); 99 return; 100 } 101 this.steps.addAll(steps); 102 setSteps(this.steps); 103 } 104 105 public void addStepsAt(int index, ArrayList steps) throws XQueryException { 106 if (steps == null || steps.isEmpty()) 107 return; 108 if (this.steps == null || this.steps.isEmpty()) { 109 setSteps(steps); 110 return; 111 } 112 this.steps.addAll(index, steps); 113 setSteps(this.steps); 114 } 115 116 public boolean isRelativeExpression() { 117 Step step0 = (Step)steps.get(0); 118 if (step0.getAxis() == Axis.NONE && !step0.hasSeparator()) 119 return false; 120 return true; 121 } 122 123 public void addParentExpression(XQueryExpression parentExpression) { 127 addParentExpression(parentExpression); 128 for (int i = 0; i < steps.size(); i++) 129 ((SchemaContextStep) steps.get(i)).addParentExpression(parentExpression); 130 } 131 132 } 133 | Popular Tags |