Package net.sf.saxon.expr

## Class EquivalenceComparer

- java.lang.Object
- - net.sf.saxon.expr.sort.GenericAtomicComparer
  - - net.sf.saxon.expr.EquivalenceComparer

- All Implemented Interfaces:
    `AtomicComparer`

      public class EquivalenceComparer
      extends GenericAtomicComparer

  A comparer that compares atomic values for equality, with the properties: - non-comparable types compare false - NaN compares equal to NaN

- - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `EquivalenceComparer​(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.
    `EquivalenceComparer` | `provideContext​(XPathContext context)` | Supply the dynamic context in case this is needed for the comparison
    `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

    - ### Methods inherited from class net.sf.saxon.expr.sort.GenericAtomicComparer

      `compareAtomicValues, equals, getCollator, getContext, getStringCollator, hashCode, makeAtomicComparer`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### EquivalenceComparer

          protected EquivalenceComparer​(StringCollator collator,
                                        XPathContext context)

  - ### Method Detail

    - #### provideContext

          public EquivalenceComparer provideContext​(XPathContext context)

      Description copied from class: `GenericAtomicComparer`
      Supply the dynamic context in case this is needed for the comparison
      Specified by:
        `provideContext` in interface `AtomicComparer`
      Overrides:
        `provideContext` in class `GenericAtomicComparer`
      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 interface `AtomicComparer`
      Overrides:
        `comparesEqual` in class `GenericAtomicComparer`
      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 comparable
        `NoDynamicContextException`

    - #### 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 interface `AtomicComparer`
      Overrides:
        `save` in class `GenericAtomicComparer`
      Returns:
        a string representation of the AtomicComparer