public abstract class Pattern extends PseudoExpression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD
Constructor and Description |
---|
Pattern() |
Modifier and Type | Method and Description |
---|---|
int |
allocateSlots(SlotManager slotManager,
int nextFree)
Allocate slots to any variables used within the pattern
|
void |
bindCurrent(LocalBinding binding)
Replace any calls on current() by a variable reference bound to the supplied binding
|
Pattern |
convertToTypedPattern(java.lang.String val)
Convert the pattern to a typed pattern, in which an element name is treated as
schema-element(N)
|
abstract Pattern |
copy(RebindingMap rebindings)
Copy an expression.
|
boolean |
effectiveBooleanValue(XPathContext context)
Evaluate a pattern as a boolean expression, returning true if the context item matches the pattern
|
abstract void |
export(ExpressionPresenter presenter)
Diagnostic print of expression structure.
|
double |
getDefaultPriority()
Determine the default priority to use if this pattern appears as a match pattern
for a template with no explicit priority attribute.
|
int |
getDependencies()
Get the dependencies of the pattern.
|
int |
getFingerprint()
Determine the name fingerprint of nodes to which this pattern applies.
|
int |
getHostLanguage()
Get the host language (XSLT, XQuery, XPath) used to implement the code in this container
|
abstract ItemType |
getItemType()
Get an ItemType that all the items matching this pattern must satisfy
|
abstract UType |
getUType()
Get a UType indicating which kinds of items this Pattern can match.
|
protected void |
handleDynamicError(XPathException ex,
XPathContext context) |
boolean |
isLiftable(boolean forStreaming)
Ask whether the expression can be lifted out of a loop, assuming it has no dependencies
on the controlling variable/focus of the loop
|
boolean |
isMotionless()
Test whether a pattern is motionless, that is, whether it can be evaluated against a node
without repositioning the input stream.
|
boolean |
isRecoverable() |
static Pattern |
make(java.lang.String pattern,
StaticContext env,
PackageData packageData)
Static factory method to make a Pattern by parsing a String.
|
abstract boolean |
matches(Item item,
XPathContext context)
Determine whether this Pattern matches the given item.
|
boolean |
matchesBeneathAnchor(NodeInfo node,
NodeInfo anchor,
XPathContext context)
Determine whether this pattern matches a given Node within the subtree rooted at a given
anchor node.
|
boolean |
matchesCurrentGroup()
Ask whether the pattern is anchored on a call on current-group()
|
Pattern |
optimize(ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo)
Perform optimisation of an expression and its subexpressions.
|
static boolean |
patternContainsVariable(Pattern pattern)
Ask whether a pattern has dependencies on local variables
|
protected static void |
replaceCurrent(Expression exp,
LocalBinding binding)
Replace any call to current() within a contained expression by a reference to a variable
|
SequenceIterator |
selectNodes(TreeInfo document,
XPathContext context)
Select all nodes in a document that match this pattern.
|
void |
setOriginalText(java.lang.String text)
Set the original text of the pattern for use in diagnostics
|
void |
setPriority(double priority)
Set a priority to override the default priority.
|
void |
setRecoverable(boolean recoverable) |
Pattern |
simplify()
Simplify the pattern by applying any context-independent optimisations.
|
java.lang.String |
toShortString()
Produce a short string identifying the expression for use in error messages
|
java.lang.String |
toString()
Get a string representation of the pattern.
|
Pattern |
typeCheck(ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo)
Type-check the pattern.
|
computeCardinality, evaluateAsString, evaluateItem, getImplementationMethod, iterate, process
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeSpecialProperties, computeStaticProperties, dynamicError, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getConstructType, getCost, getEvaluationMethod, getExpressionName, getExtraProperty, getIntegerBounds, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, hasCompatibleStaticContext, hashCode, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isCallOnSystemFunction, isIdentical, isInstruction, isMultiThreaded, isSameExpression, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operands, operandSparseList, optimizeChildren, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, typeCheckChildren, typeError, unordered, verifyParentPointers, verifyParentPointers
public static Pattern make(java.lang.String pattern, StaticContext env, PackageData packageData) throws XPathException
pattern
- The pattern text as a Stringenv
- An object defining the compile-time context for the expressionpackageData
- The package containing this patternXPathException
- if the pattern is invalidprotected static void replaceCurrent(Expression exp, LocalBinding binding)
exp
- the expression in which the replacement is to take place (which must not itself be
a call to current())binding
- the binding for the variable referencepublic static boolean patternContainsVariable(Pattern pattern)
pattern
- the pattern (typically a pattern in an xsl:number or xsl:for-each-group); or nullpublic boolean isLiftable(boolean forStreaming)
isLiftable
in class Expression
forStreaming
- public void bindCurrent(LocalBinding binding)
public boolean matchesCurrentGroup()
public void setOriginalText(java.lang.String text)
text
- the original text of the patternpublic boolean isRecoverable()
public void setRecoverable(boolean recoverable)
protected void handleDynamicError(XPathException ex, XPathContext context) throws XPathException
XPathException
public Pattern simplify() throws XPathException
simplify
in class Expression
XPathException
- if an error is discovered during expression
rewritingpublic Pattern typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
typeCheck
in class Expression
visitor
- the expression visitorcontextInfo
- the type of the context item at the point where the pattern
is defined. Set to null if it is known that the context item is undefined.XPathException
- if an error is discovered during this phase
(typically a type error)public int getDependencies()
getDependencies
in class Expression
public int allocateSlots(SlotManager slotManager, int nextFree)
slotManager
- the slot manager representing the stack frame for local variablesnextFree
- the next slot that is free to be allocatedpublic boolean isMotionless()
public final boolean effectiveBooleanValue(XPathContext context) throws XPathException
effectiveBooleanValue
in class PseudoExpression
context
- the evaluation contextXPathException
- if an error occurs during pattern matchingpublic abstract boolean matches(Item item, XPathContext context) throws XPathException
item
- The item to be tested against the Patterncontext
- The dynamic context.XPathException
- if an error occurs while matching the pattern (the caller will usually
treat this the same as a false result)public boolean matchesBeneathAnchor(NodeInfo node, NodeInfo anchor, XPathContext context) throws XPathException
node
- The NodeInfo representing the Element or other node to be tested against the Patternanchor
- The anchor node, which must match any AnchorPattern subpatterncontext
- The dynamic context. Only relevant if the pattern
uses variables, or contains calls on functions such as document() or key().XPathException
- if an error occurs while matching the pattern (the caller will usually
treat this the same as a false result)public SequenceIterator selectNodes(TreeInfo document, XPathContext context) throws XPathException
document
- the documentcontext
- the dynamic evaluation contextXPathException
public abstract UType getUType()
public int getFingerprint()
public abstract ItemType getItemType()
getItemType
in class PseudoExpression
public void setPriority(double priority)
priority
- the priority to be used if no explicit priority is given in the template rulepublic double getDefaultPriority()
public java.lang.String toString()
toString
in class Expression
public int getHostLanguage()
Configuration.XSLT
or Configuration.XQUERY
public Pattern convertToTypedPattern(java.lang.String val) throws XPathException
val
- either "strict" or "lax" depending on the value of xsl:mode/@typedXPathException
- if the pattern cannot be convertedpublic abstract void export(ExpressionPresenter presenter) throws XPathException
Expression
export
in interface ExportAgent
export
in class Expression
presenter
- the expression presenter used to display the structureXPathException
- if the export fails, for example if an expression is found that won't work
in the target environment.public abstract Pattern copy(RebindingMap rebindings)
Expression
copy
in class Expression
rebindings
- a mutable list of (old binding, new binding) pairs
that is used to update the bindings held in any
local variable references that are copied.public Pattern optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.
optimize
in class Expression
visitor
- an expression visitorcontextInfo
- the static type of "." at the point where this expression is invoked.
The parameter is set to null if it is known statically that the context item will be undefined.
If the type of the context item is not known statically, the argument is set to
Type.ITEM_TYPE
XPathException
- if an error is discovered during this phase
(typically a type error)public java.lang.String toShortString()
Expression
toShortString
in class Expression
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.