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 java.lang.Boolean
getPreconditionState(int slot)
Get the state of a given precondition.<T> T
obtainCharacteristic(Characteristic<T> 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.
-
-
-
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 java.lang.Boolean getPreconditionState(int slot)
Get the state of a given precondition.- Parameters:
slot
- the slot number allocated to the precondition- Returns:
- true if the precondition is known to be true for the item being matched; false if it is known to be false; or null 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.
-
obtainCharacteristic
public <T> T obtainCharacteristic(Characteristic<T> 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- Type Parameters:
T
- the type of value of this characteristic- Parameters:
chic
- the characteristic to be evaluated- Returns:
- the value of the characteristic
- Throws:
XPathException
- if evaluation of the characteristic failed
-
-