1 package com.icl.saxon.expr; 2 import com.icl.saxon.Context; 3 4 5 10 11 class PositionRange extends Expression { 12 13 private int minPosition; 14 private int maxPosition; 15 16 19 20 public PositionRange(int min, int max) { 21 minPosition = min; 22 maxPosition = max; 23 } 24 25 29 30 public Expression simplify() throws XPathException { 31 return this; 32 } 33 34 39 40 public Value evaluate(Context c) throws XPathException { 41 return new BooleanValue(evaluateAsBoolean(c)); 42 } 43 44 49 50 public boolean evaluateAsBoolean(Context c) throws XPathException { 51 int p = c.getContextPosition(); 52 return p >= minPosition && p <= maxPosition; 53 } 54 55 59 60 public int getDataType() { 61 return Value.BOOLEAN; 62 } 63 64 67 68 public int getDependencies() { 69 return Context.POSITION; 70 } 71 72 80 81 public Expression reduce(int dependencies, Context context) throws XPathException { 82 83 if ((Context.POSITION & dependencies) != 0 ) { 84 return evaluate(context); 85 } 86 return this; 87 } 88 89 92 93 protected int getMinPosition() { 94 return minPosition; 95 } 96 97 100 101 protected int getMaxPosition() { 102 return maxPosition; 103 } 104 105 108 109 public void display(int level) { 110 System.err.println(indent(level) + "positionRange(" + minPosition + "," + maxPosition + ")"); 111 } 112 } 113 114 | Popular Tags |