1 package net.sf.saxon.expr; 2 import net.sf.saxon.om.Item; 3 import net.sf.saxon.om.NamePool; 4 import net.sf.saxon.trans.XPathException; 5 import net.sf.saxon.type.ItemType; 6 import net.sf.saxon.type.Type; 7 import net.sf.saxon.value.BooleanValue; 8 9 import java.io.PrintStream ; 10 11 12 15 16 public final class IsLastExpression extends ComputedExpression { 17 18 private boolean condition; 19 20 24 25 public IsLastExpression(boolean condition){ 26 this.condition = condition; 27 }; 28 29 public boolean getCondition() { 30 return condition; 31 } 32 33 public Expression simplify(StaticContext env) { 34 return this; 35 } 36 37 public Expression typeCheck(StaticContext env, ItemType contextItemType) { 38 return this; 39 } 40 41 public Expression optimize(Optimizer opt, StaticContext env, ItemType contextItemType) { 42 return this; 43 } 44 45 49 50 public int computeSpecialProperties() { 51 int p = super.computeSpecialProperties(); 52 return p | StaticProperty.NON_CREATIVE; 53 } 54 55 public Item evaluateItem(XPathContext c) throws XPathException { 56 return BooleanValue.get(condition==c.isAtLast()); 57 } 58 59 63 64 public ItemType getItemType() { 65 return Type.BOOLEAN_TYPE; 66 } 67 68 71 72 public int computeCardinality() { 73 return StaticProperty.EXACTLY_ONE; 74 } 75 76 79 80 public int getIntrinsicDependencies() { 81 return StaticProperty.DEPENDS_ON_POSITION | StaticProperty.DEPENDS_ON_LAST; 82 } 83 84 87 88 public void display(int level, NamePool pool, PrintStream out) { 89 out.println(ExpressionTool.indent(level) + (condition ? "" : "not ") + "isLast()"); 90 } 91 92 } 93 94 | Popular Tags |