net.sf.saxon.expr
Class ValueComparison
- ComparisonExpression, EvaluableItem, InstructionInfoProvider, Negatable, SequenceIterable, Serializable, SourceLocator
public final class ValueComparison
ValueComparison: a boolean expression that compares two atomic values
for equals, not-equals, greater-than or less-than. Implements the operators
eq, ne, lt, le, gt, ge
computeCardinality , computeSpecialProperties , displayOperator , equals , explain , getOperands , getOperator , hashCode , isAssociative , isCommutative , isInverse , iterateSubExpressions , optimize , promote , replaceSubExpression , setFlattened , simplify , toString , typeCheck |
addToPathMap , adoptChildExpression , checkPermittedContents , computeCardinality , computeDependencies , computeSpecialProperties , computeStaticProperties , copy , display , doPromotion , dynamicError , effectiveBooleanValue , evaluateAsString , evaluateItem , explain , explain , findParentOf , getCardinality , getColumnNumber , getConstructType , getContainer , getDependencies , getExecutable , getHostLanguage , getImplementationMethod , getInstructionInfo , getIntrinsicDependencies , getItemType , getLineNumber , getLocationId , getLocationProvider , getPublicId , getSlotsUsed , getSpecialProperties , getSystemId , hasLoopingSubexpression , implementsStaticTypeCheck , iterate , iterateEvents , iterateSubExpressions , markTailFunctionCalls , optimize , process , promote , replaceSubExpression , resetLocalStaticProperties , setContainer , setFiltered , setFlattened , setLocationId , simplify , staticTypeCheck , suppressValidation , toString , typeCheck , typeError |
ValueComparison
public ValueComparison(Expression p1,
int op,
Expression p2)
Create a relational expression identifying the two operands and the operator
p1
- the left-hand operandop
- the operator, as a token returned by the Tokenizer (e.g. Token.LT)p2
- the right-hand operand
convertsUntypedToOther
public boolean convertsUntypedToOther()
Determine whether untyped atomic values should be converted to the type of the other operand
- convertsUntypedToOther in interface ComparisonExpression
- true if untyped values should be converted to the type of the other operand, false if they
should be converted to strings.
copy
public Expression copy()
Copy an expression. This makes a deep copy.
- copy in interface Expression
- the copy of the original expression
effectiveBooleanValue
public boolean effectiveBooleanValue(XPathContext context)
throws XPathException
Evaluate the effective boolean value of the expression
- effectiveBooleanValue in interface Expression
context
- the given context for evaluation
- a boolean representing the result of the comparison of the two operands
getAtomicComparer
public AtomicComparer getAtomicComparer()
Get the AtomicComparer used to compare atomic values. This encapsulates any collation that is used.
Note that the comparer is always known at compile time.
- getAtomicComparer in interface ComparisonExpression
getResultWhenEmpty
public BooleanValue getResultWhenEmpty()
Get the result to be returned if one of the operands is an empty sequence
- BooleanValue.TRUE, BooleanValue.FALSE, or null (meaning the empty sequence)
getSingletonOperator
public int getSingletonOperator()
Get the primitive (singleton) operator used: one of Token.FEQ, Token.FNE, Token.FLT, Token.FGT,
Token.FLE, Token.FGE
- getSingletonOperator in interface ComparisonExpression
needsRuntimeComparabilityCheck
public boolean needsRuntimeComparabilityCheck()
Determine whether a run-time check is needed to check that the types of the arguments
are comparable
- true if a run-time check is needed
negate
public Expression negate()
Return the negation of this value comparison: that is, a value comparison that returns true()
if and only if the original returns false(). The result must be the same as not(this) even in the
case where one of the operands is ().
- negate in interface Negatable
optimize
public Expression optimize(ExpressionVisitor visitor,
ItemType contextItemType)
throws XPathException
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.
- optimize in interface BinaryExpression
visitor
- an expression visitorcontextItemType
- 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
Type.ITEM_TYPE
- the original expression, rewritten if appropriate to optimize execution
XPathException
- if an error is discovered during this phase
(typically a type error)
setResultWhenEmpty
public void setResultWhenEmpty(BooleanValue value)
Set the result to be returned if one of the operands is an empty sequence
value
- the result to be returned if an operand is empty. Supply null to mean the empty sequence.