Class Precondition.StringHashPrecondition

java.lang.Object
com.saxonica.ee.trans.Precondition
com.saxonica.ee.trans.Precondition.StringHashPrecondition
Enclosing class:
Precondition

public static class Precondition.StringHashPrecondition extends Precondition
A StringHashPrecondition compares a characteristic in the form of a set of integer hash codes against a constant hash code; the precondition is satisfied if the constant hash code is present in the set.

It is used in two situations:

(a) for a predicate pattern in the form *[EXP = 'constant'] where the constant hash code is the hash code of the collation key of the constant string, and the characteristic is the set of hash codes corresponding to the collation keys of the strings selected by evaluating EXP.

(b) for a predicate pattern in the form *[contains(EXP, ' constant ')], typically encountered in DITA stylesheets, where the constant hash code is the hash code of the collation key of the token being matched (the constant with whitespace trimmed), and the characteristic is the set of hash codes corresponding to the collation keys of the tokens found by evaluating EXP and splitting on whitespace boundaries.

  • Constructor Details

    • StringHashPrecondition

      public StringHashPrecondition(Characteristic characteristic, AtomicMatchKey required, StringCollator collator)
      Create a StringHashPrecondition
      Parameters:
      characteristic - the characteristic that is tested by this precondition. This must evaluate to a set of hashcodes for permitted string values. The precondition is satisfied if the set of hash codes obtained as the value of the characteristic includes the hash code of the required key value. For example, given match=*[author='Kay'], the characteristic will be the set of hash codes of the values of 'author' children of the context item; the precondition is satisfied if this includes the hash code of the string 'Kay' under the specified collation.
      required - the required key value, whose hash code must match one of the values in the IntSet value of the characteristic
      collator - the collation to be used for comparison
  • Method Details

    • testPrecondition

      protected boolean testPrecondition(PreconditionMatcher matcher) throws XPathException
      Description copied from class: Precondition
      Compute the value of the precondition for a given item. The item in question is the context item in the dynamic context held in the PreconditionMatcher
      Specified by:
      testPrecondition in class Precondition
      Parameters:
      matcher - the PreconditionMatcher: holds the dynamic context for evaluation.
      Returns:
      true if the precondition is satisfied
      Throws:
      XPathException - if evaluation of the precondition fails with a dynamic error
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object