Package net.sf.saxon.expr
Class SwitchCaseComparer
- java.lang.Object
-
- net.sf.saxon.expr.sort.GenericAtomicComparer
-
- net.sf.saxon.expr.SwitchCaseComparer
-
- All Implemented Interfaces:
AtomicComparer
public class SwitchCaseComparer extends GenericAtomicComparer
A comparer that compares atomic values for equality, with the properties: - non-comparable types compare false - NaN compares equal to NaN Used for comparisons in XQuery Switch expressions
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.saxon.expr.sort.GenericAtomicComparer
GenericAtomicComparer.AtomicComparisonFunction
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SwitchCaseComparer(StringCollator collator, XPathContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
comparesEqual(AtomicValue a, AtomicValue b)
Compare two AtomicValue objects for equality according to the rules for their data type.SwitchCaseComparer
provideContext(XPathContext context)
Supply the dynamic context in case this is needed for the comparisonjava.lang.String
save()
Create a string representation of this AtomicComparer that can be saved in a compiled package and used to reconstitute the AtomicComparer when the package is reloaded-
Methods inherited from class net.sf.saxon.expr.sort.GenericAtomicComparer
compareAtomicValues, equals, getCollator, getContext, getStringCollator, hashCode, makeAtomicComparer, makeAtomicComparisonFunction
-
-
-
-
Constructor Detail
-
SwitchCaseComparer
protected SwitchCaseComparer(StringCollator collator, XPathContext context)
-
-
Method Detail
-
provideContext
public SwitchCaseComparer provideContext(XPathContext context)
Description copied from class:GenericAtomicComparer
Supply the dynamic context in case this is needed for the comparison- Specified by:
provideContext
in interfaceAtomicComparer
- Overrides:
provideContext
in classGenericAtomicComparer
- Parameters:
context
- the dynamic evaluation context- Returns:
- either the original AtomicComparer, or a new AtomicComparer in which the context is known. The original AtomicComparer is not modified
-
comparesEqual
public boolean comparesEqual(AtomicValue a, AtomicValue b) throws NoDynamicContextException
Compare two AtomicValue objects for equality according to the rules for their data type. UntypedAtomic values are compared as if they were strings; if different semantics are wanted, the conversion must be done by the caller.- Specified by:
comparesEqual
in interfaceAtomicComparer
- Overrides:
comparesEqual
in classGenericAtomicComparer
- Parameters:
a
- the first object to be compared. If it is a StringValue, the collator is used to compare the values, otherwise the value must implement the equals() method.b
- the second object to be compared. This must be comparable with the first object: for example, if one is a string, they must both be strings.- Returns:
- true if the values are equal, false if not
- Throws:
java.lang.ClassCastException
- if the objects are not comparableNoDynamicContextException
- if no dynamic context has been supplied, and a dynamic context is needed (for example, because the comparison uses the implicit timezone)
-
save
public java.lang.String save()
Create a string representation of this AtomicComparer that can be saved in a compiled package and used to reconstitute the AtomicComparer when the package is reloaded- Specified by:
save
in interfaceAtomicComparer
- Overrides:
save
in classGenericAtomicComparer
- Returns:
- a string representation of the AtomicComparer
-
-