Class 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
  • Constructor Details

  • Method Details

    • 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 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:
      ClassCastException - if the objects are not comparable
      NoDynamicContextException - if no dynamic context has been supplied, and a dynamic context is needed (for example, because the comparison uses the implicit timezone)
    • save

      public 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