Package com.saxonica.ee.trans
Class PreconditionMatcher
java.lang.Object
net.sf.saxon.trans.rules.RuleSearchState
com.saxonica.ee.trans.PreconditionMatcher
This class contains the stateful part of the precondition checker. A new PreconditionMatcher is allocated
when searching a rule chain to find the best matching rule for a given node (or other item). It holds the
values of preconditions and characteristics. A precondition is a boolean property of an item that must
be true if the item is to match a particular pattern; once the precondition has been evaluated, its value
can be used to eliminate other rules with the same precondition. A characteristic is a property of an item
that must match a corresponding property of a rule if the rule is to match; for example, a property might
be "name of parent element". Once the value of a characteristic (for example, the name of the parent element)
has been evaluated, a rule can be eliminated if it requires a different value for the characteristic.
-
Constructor Summary
ConstructorsConstructorDescriptionPreconditionMatcher(RuleChain chain, XPathContext context) Allocate a PreconditionMatcher for a given set of rules -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckPreconditions(Rule rule) Use this search state to check whether the preconditions for a particular rule are satisfiedintgetPreconditionState(int slot) Get the state of a given precondition.Get the value of a particular characteristic of the item being matched, evaluating it if it has not already been evaluated, and retaining its value for future usevoidsetPreconditionState(int slot, boolean value) Set the value of a given precondition.Methods inherited from class net.sf.saxon.trans.rules.RuleSearchState
getInstance
-
Constructor Details
-
PreconditionMatcher
Allocate a PreconditionMatcher for a given set of rules- Parameters:
chain- the set of rules being matchedcontext- the XPath evaluation context; the context item is the item being matched against the set of rules
-
-
Method Details
-
getPreconditionState
public int getPreconditionState(int slot) Get the state of a given precondition.- Parameters:
slot- the slot number allocated to the precondition- Returns:
Precondition.PRECONDITION_TRUEif the precondition is known to be true for the item being matched;Precondition.PRECONDITION_FALSEif it is known to be false; orPrecondition.PRECONDITION_UNKNOWNif its value is not known
-
setPreconditionState
public void setPreconditionState(int slot, boolean value) Set the value of a given precondition.- Parameters:
slot- the slot number allocated to the preconditionvalue- true if the precondition (for the item being matched) is known to be true, false if it is known to be false.
-
checkPreconditions
Use this search state to check whether the preconditions for a particular rule are satisfied- Overrides:
checkPreconditionsin classRuleSearchState- Parameters:
rule- the rule being tested- Returns:
- true if all preconditions are satisfied; in the HE implementation, there are no preconditions, so this is always true.
- Throws:
XPathException- if evaluation of preconditions fails.
-
obtainCharacteristic
Get the value of a particular characteristic of the item being matched, evaluating it if it has not already been evaluated, and retaining its value for future use- Parameters:
chic- the characteristic to be evaluated- Returns:
- the value of the characteristic
- Throws:
XPathException- if evaluation of the characteristic failed
-