Package com.saxonica.ee.trans
Class Precondition
java.lang.Object
com.saxonica.ee.trans.Precondition
- Direct Known Subclasses:
Precondition.BooleanPrecondition
,Precondition.NumericComparisonPrecondition
,Precondition.StringHashPrecondition
A Precondition is a boolean condition that must be true if a pattern is to match (but in general
is not a sufficient condition for the pattern to match).
Preconditions may be defined in terms of "characteristics": that is, properties of the item
being matched.
When an item is matched against a RuleChain to find the best matching rule, subexpressions used
by more than one rule may be evaluated as characteristics, so they are not evaluated repeatedly.
Preconditions are shared by multiple rules. Evaluating a precondition for one rule may ensure
that the patterns for other rules do not need to be evaluated.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
ABooleanPrecondition
can in principle test any boolean characteristic of a pattern.static class
A numeric comparison precondition is used for patterns containing a predicate that compares some expression E with a numeric constant.static class
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. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
isSatisfied
(PreconditionMatcher matcher) Ask whether the precondition is satisfied, making use of cachingvoid
setSlotNumber
(int slotNumber) Allocate a slot number indicating where in the data maintained by thePreconditionMatcher
the value of this precondition should be heldprotected abstract boolean
testPrecondition
(PreconditionMatcher matcher) Compute the value of the precondition for a given item.
-
Field Details
-
PRECONDITION_UNKNOWN
public static final int PRECONDITION_UNKNOWN- See Also:
-
PRECONDITION_FALSE
public static final int PRECONDITION_FALSE- See Also:
-
PRECONDITION_TRUE
public static final int PRECONDITION_TRUE- See Also:
-
-
Constructor Details
-
Precondition
public Precondition()
-
-
Method Details
-
setSlotNumber
public void setSlotNumber(int slotNumber) Allocate a slot number indicating where in the data maintained by thePreconditionMatcher
the value of this precondition should be held- Parameters:
slotNumber
- the slot number to be used for the value of this precondition
-
isSatisfied
Ask whether the precondition is satisfied, making use of caching- Parameters:
matcher
- ThePreconditionMatcher
holds the values of conditions that have already been matched, which is therefore used as a cache of values that do not need to be evaluated repeatedly. In addition it holds the dynamic evaluation context; the context item is the item being matched.- Returns:
- true if the precondition is satisfied
- Throws:
XPathException
- if evaluation of the precondition fails with a dynamic error
-
testPrecondition
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- 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
-