1 package com.icl.saxon.expr; 2 import com.icl.saxon.Context; 3 4 5 8 9 public final class IsLastExpression extends Expression { 10 11 private boolean condition; 12 13 17 18 public IsLastExpression(boolean condition){ 19 this.condition = condition; 20 }; 21 22 public boolean getCondition() { 23 return condition; 24 } 25 26 public Expression simplify() { 27 return this; 28 } 29 30 public Value evaluate(Context c) throws XPathException { 31 return new BooleanValue(evaluateAsBoolean(c)); 32 } 33 34 public boolean evaluateAsBoolean(Context c) throws XPathException { 35 return condition==c.isAtLast(); 36 } 37 38 42 43 public int getDataType() { 44 return Value.BOOLEAN; 45 } 46 47 50 51 public int getDependencies() { 52 return Context.POSITION | Context.LAST; 53 } 54 55 63 64 public Expression reduce(int dependencies, Context context) throws XPathException { 65 if (((Context.LAST | Context.POSITION) & dependencies) != 0 ) { 66 return new BooleanValue(context.isAtLast()); 67 } else { 68 return this; 69 } 70 } 71 72 75 76 public void display(int level) { 77 System.err.println(indent(level) + "isLast()"); 78 } 79 80 } 81 82 | Popular Tags |