net.sf.saxon.expr

Class SingletonComparison

Implemented Interfaces:
ComparisonExpression, EvaluableItem, InstructionInfoProvider, SequenceIterable, Serializable, SourceLocator

public class SingletonComparison
extends BinaryExpression
implements ComparisonExpression

Class to handle comparisons of singletons. Unlike ValueComparison, this class converts untyped atomic values to the type of the other argument, and returns false (rather than ()) if either operand is ().

Field Summary

Fields inherited from class net.sf.saxon.expr.BinaryExpression

operand0, operand1, operator

Fields inherited from class net.sf.saxon.expr.Expression

EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD, locationId, staticProperties

Constructor Summary

SingletonComparison(Expression p1, int operator, Expression p2)

Method Summary

int
computeCardinality()
Determine the static cardinality.
boolean
convertsUntypedToOther()
Determine whether untyped atomic values should be converted to the type of the other operand
Expression
copy()
Copy an expression.
protected String
displayOperator()
boolean
effectiveBooleanValue(XPathContext context)
Evaluate the expression in a boolean context
Item
evaluateItem(XPathContext context)
Evaluate the expression in a given context
AtomicComparer
getAtomicComparer()
Get the AtomicComparer used to compare atomic values.
ItemType
getItemType(TypeHierarchy th)
Determine the data type of the expression
int
getSingletonOperator()
Get the primitive (singleton) operator used: one of Token.FEQ, Token.FNE, Token.FLT, Token.FGT, Token.FLE, Token.FGE
void
setAtomicComparer(AtomicComparer comp)

Methods inherited from class net.sf.saxon.expr.BinaryExpression

computeCardinality, computeSpecialProperties, displayOperator, equals, explain, getOperands, getOperator, hashCode, isAssociative, isCommutative, isInverse, iterateSubExpressions, optimize, promote, replaceSubExpression, setFlattened, simplify, toString, typeCheck

Methods inherited from class net.sf.saxon.expr.Expression

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

Constructor Details

SingletonComparison

public SingletonComparison(Expression p1,
                           int operator,
                           Expression p2)

Method Details

computeCardinality

public int computeCardinality()
Determine the static cardinality. Returns [1..1]
Overrides:
computeCardinality in interface BinaryExpression

convertsUntypedToOther

public boolean convertsUntypedToOther()
Determine whether untyped atomic values should be converted to the type of the other operand
Specified by:
convertsUntypedToOther in interface ComparisonExpression
Returns:
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.
Overrides:
copy in interface Expression
Returns:
the copy of the original expression

displayOperator

protected String displayOperator()
Overrides:
displayOperator in interface BinaryExpression

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)
            throws XPathException
Evaluate the expression in a boolean context
Overrides:
effectiveBooleanValue in interface Expression
Parameters:
context - the given context for evaluation
Returns:
a boolean representing the result of the numeric comparison of the two operands

evaluateItem

public Item evaluateItem(XPathContext context)
            throws XPathException
Evaluate the expression in a given context
Specified by:
evaluateItem in interface EvaluableItem
Overrides:
evaluateItem in interface Expression
Parameters:
context - the given context for evaluation
Returns:
a BooleanValue representing the result of the numeric comparison of the two operands

getAtomicComparer

public AtomicComparer getAtomicComparer()
Get the AtomicComparer used to compare atomic values. This encapsulates any collation that is used
Specified by:
getAtomicComparer in interface ComparisonExpression

getItemType

public ItemType getItemType(TypeHierarchy th)
Determine the data type of the expression
Overrides:
getItemType in interface Expression
Parameters:
th - the type hierarchy cache
Returns:
Type.BOOLEAN

getSingletonOperator

public int getSingletonOperator()
Get the primitive (singleton) operator used: one of Token.FEQ, Token.FNE, Token.FLT, Token.FGT, Token.FLE, Token.FGE
Specified by:
getSingletonOperator in interface ComparisonExpression

setAtomicComparer

public void setAtomicComparer(AtomicComparer comp)