Class SimpleTypeComparison
- java.lang.Object
-
- net.sf.saxon.expr.sort.SimpleTypeComparison
-
- All Implemented Interfaces:
EqualityMatcher<AtomicSequence>
- Direct Known Subclasses:
SimpleTypeIdentityComparison
public class SimpleTypeComparison extends java.lang.Object implements EqualityMatcher<AtomicSequence>
This class implements equality and ordering comparisons between values of simple types: that is, atomic values, and sequences of atomic values, following the XSD-defined rules for equality and ordering comparisons. These are not always the same as the XPath-defined rules. In particular, under XSD rules values are generally only comparable with others of the same primitive type; a double and a float, for example, never compare equal.For ordered data types, the compare() functions follow the usual convention: the return value is -1, 0, or +1 according as the first value is less than, equal to, or greater than the second. For non-ordered data types, if the values are not equal then the functions return
SequenceTool.INDETERMINATE_ORDERING.The class can be used directly to perform comparison between atomic values and sequences. It can also be used to parameterise a
CustomSetorCustomMap, to provide a set or map that uses explicit equals() logic rather than relying on theequals()andhashCode()methods of the supplied objects - thus avoiding the need to create wrapper objects purely to redefine equality semantics.The class is a singleton that cannot be externally instantiated.
-
-
Constructor Summary
Constructors Constructor Description SimpleTypeComparison()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareItems(AtomicValue a1, AtomicValue a2)intcompareSequences(AtomicSequence a1, AtomicSequence a2)booleanequal(AtomicSequence a, AtomicSequence b)Compare two objects for equalitybooleanequalOrIdentical(AtomicSequence a1, AtomicSequence a2)static SimpleTypeComparisongetInstance()Get the singleton instance of the classinthash(AtomicSequence a)Compute a hash code for an object
-
-
-
Method Detail
-
getInstance
public static SimpleTypeComparison getInstance()
Get the singleton instance of the class- Returns:
- the singleton instance
-
compareSequences
public int compareSequences(AtomicSequence a1, AtomicSequence a2)
-
compareItems
public int compareItems(AtomicValue a1, AtomicValue a2)
-
equal
public boolean equal(AtomicSequence a, AtomicSequence b)
Description copied from interface:EqualityMatcherCompare two objects for equality- Specified by:
equalin interfaceEqualityMatcher<AtomicSequence>- Parameters:
a- one objectb- another object- Returns:
- true if the two objects are deemed equal
-
hash
public int hash(AtomicSequence a)
Description copied from interface:EqualityMatcherCompute a hash code for an object- Specified by:
hashin interfaceEqualityMatcher<AtomicSequence>- Parameters:
a- an object- Returns:
- a hash code, which has the property that if two objects are equal, then they must have the same hash code
-
equalOrIdentical
public boolean equalOrIdentical(AtomicSequence a1, AtomicSequence a2)
-
-