net.sf.saxon.expr

Class SingletonComparison

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 ().
Constructor Summary
SingletonComparison(Expression p1, int operator, Expression p2, boolean checkTypes)
Create a singleton comparison - that is, a comparison between two singleton (0:1) sequences using the general comparison semantics
Method Summary
intcomputeCardinality()
Determine the static cardinality.
booleanconvertsUntypedToOther()
Determine whether untyped atomic values should be converted to the type of the other operand
Expressioncopy()
Copy an expression.
booleaneffectiveBooleanValue(XPathContext context)
Evaluate the expression in a boolean context
ItemevaluateItem(XPathContext context)
Evaluate the expression in a given context
protected voidexplainExtraAttributes(ExpressionPresenter out)
AtomicComparergetAtomicComparer()
ItemTypegetItemType(TypeHierarchy th)
Determine the data type of the expression
intgetSingletonOperator()
booleanneedsRuntimeComparabilityCheck()
Determine whether a run-time check is needed to check that the types of the arguments are comparable
voidsetAtomicComparer(AtomicComparer comp)

Constructor Detail

SingletonComparison

public SingletonComparison(Expression p1, int operator, Expression p2, boolean checkTypes)
Create a singleton comparison - that is, a comparison between two singleton (0:1) sequences using the general comparison semantics

Parameters: p1 the first operand operator the operator p2 the second operand checkTypes true if a run-time check for comparability of the operand types is needed

Method Detail

computeCardinality

public int computeCardinality()
Determine the static cardinality. Returns [1..1]

convertsUntypedToOther

public boolean convertsUntypedToOther()
Determine whether untyped atomic values should be converted to the type of the other operand

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.

Returns: the copy of the original expression

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)
Evaluate the expression in a boolean context

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)
Evaluate the expression in a given context

Parameters: context the given context for evaluation

Returns: a BooleanValue representing the result of the numeric comparison of the two operands

explainExtraAttributes

protected void explainExtraAttributes(ExpressionPresenter out)

getAtomicComparer

public AtomicComparer getAtomicComparer()

getItemType

public ItemType getItemType(TypeHierarchy th)
Determine the data type of the expression

Parameters: th the type hierarchy cache

Returns: Type.BOOLEAN

getSingletonOperator

public int getSingletonOperator()

needsRuntimeComparabilityCheck

public boolean needsRuntimeComparabilityCheck()
Determine whether a run-time check is needed to check that the types of the arguments are comparable

Returns: true if a run-time check is needed

setAtomicComparer

public void setAtomicComparer(AtomicComparer comp)