Package com.saxonica.ee.trans
Class PreconditionMatcher
- java.lang.Object
-
- net.sf.saxon.trans.rules.RuleSearchState
-
- com.saxonica.ee.trans.PreconditionMatcher
-
public class PreconditionMatcher extends RuleSearchState
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
Constructors Constructor Description PreconditionMatcher(RuleChain chain, XPathContext context)
Allocate a PreconditionMatcher for a given set of rules
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkPreconditions(Rule rule)
Use this search state to check whether the preconditions for a particular rule are satisfiedint
getPreconditionState(int slot)
Get the state of a given precondition.java.lang.Object
obtainCharacteristic(Characteristic chic)
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 usevoid
setPreconditionState(int slot, boolean value)
Set the value of a given precondition.-
Methods inherited from class net.sf.saxon.trans.rules.RuleSearchState
getInstance
-
-
-
-
Constructor Detail
-
PreconditionMatcher
public PreconditionMatcher(RuleChain chain, XPathContext context)
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 Detail
-
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_TRUE
if the precondition is known to be true for the item being matched;Precondition.PRECONDITION_FALSE
if it is known to be false; orPrecondition.PRECONDITION_UNKNOWN
if 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
public boolean checkPreconditions(Rule rule) throws XPathException
Use this search state to check whether the preconditions for a particular rule are satisfied- Overrides:
checkPreconditions
in 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
public java.lang.Object obtainCharacteristic(Characteristic chic) throws XPathException
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
-
-