Package com.saxonica.ee.trans
Class Precondition.StringHashPrecondition
java.lang.Object
com.saxonica.ee.trans.Precondition
com.saxonica.ee.trans.Precondition.StringHashPrecondition
- Enclosing class:
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.saxonica.ee.trans.Precondition
Precondition.BooleanPrecondition, Precondition.NumericComparisonPrecondition, Precondition.StringHashPrecondition
-
Field Summary
Fields inherited from class com.saxonica.ee.trans.Precondition
PRECONDITION_FALSE, PRECONDITION_TRUE, PRECONDITION_UNKNOWN
-
Constructor Summary
ConstructorsConstructorDescriptionStringHashPrecondition
(Characteristic characteristic, AtomicMatchKey required, StringCollator collator) Create aStringHashPrecondition
-
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
protected boolean
testPrecondition
(PreconditionMatcher matcher) Compute the value of the precondition for a given item.toString()
Methods inherited from class com.saxonica.ee.trans.Precondition
isSatisfied, setSlotNumber
-
Constructor Details
-
StringHashPrecondition
public StringHashPrecondition(Characteristic characteristic, AtomicMatchKey required, StringCollator collator) Create aStringHashPrecondition
- 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, givenmatch=*[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 characteristiccollator
- the collation to be used for comparison
-
-
Method Details
-
testPrecondition
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 classPrecondition
- 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() -
equals
-
toString
-