net.sf.saxon.functions

Class Existence

public class Existence extends SystemFunction implements Negatable

Implement the exists() and empty() functions *
Field Summary
static intEMPTY
static intEXISTS
Method Summary
voidcheckArguments(ExpressionVisitor visitor)
Static analysis: prevent sorting of the argument
booleaneffectiveBooleanValue(XPathContext c)
Evaluate the function in a boolean context
ItemevaluateItem(XPathContext c)
Evaluate in a general context
booleanisNegatable(ExpressionVisitor visitor)
Check whether this specific instance of the expression is negatable
Expressionnegate()
Return the negation of the expression
Expressionoptimize(ExpressionVisitor visitor, ItemType contextItemType)
Perform optimisation of an expression and its subexpressions.

Field Detail

EMPTY

public static final int EMPTY

EXISTS

public static final int EXISTS

Method Detail

checkArguments

public void checkArguments(ExpressionVisitor visitor)
Static analysis: prevent sorting of the argument

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext c)
Evaluate the function in a boolean context

evaluateItem

public Item evaluateItem(XPathContext c)
Evaluate in a general context

isNegatable

public boolean isNegatable(ExpressionVisitor visitor)
Check whether this specific instance of the expression is negatable

Returns: true if it is

negate

public Expression negate()
Return the negation of the expression

Returns: the negation of the expression

optimize

public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType)
Perform optimisation of an expression and its subexpressions.

This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.

Parameters: visitor an expression visitor contextItemType the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set to ITEM_TYPE

Returns: the original expression, rewritten if appropriate to optimize execution

Throws: net.sf.saxon.trans.XPathException if an error is discovered during this phase (typically a type error)