|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.saxon.pattern.Pattern
public abstract class Pattern
A Pattern represents the result of parsing an XSLT pattern string.
Patterns are created by calling the static method Pattern.make(string).
The pattern is used to test a particular node by calling match().
Constructor Summary | |
---|---|
Pattern()
|
Method Summary | |
---|---|
int |
allocateSlots(StaticContext env,
SlotManager slotManager,
int nextFree)
Allocate slots to any variables used within the pattern |
Pattern |
analyze(ExpressionVisitor visitor,
ExpressionVisitor.ContextItemType contextItemType)
Type-check the pattern. |
int |
getColumnNumber()
Get the column number (always -1) |
int |
getContainerGranularity()
Get the granularity of the container. |
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. |
Executable |
getExecutable()
Get the executable containing this 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 |
int |
getLineNumber()
Get the line number on which the pattern was defined |
LocationProvider |
getLocationProvider()
Get the LocationProvider allowing location identifiers to be resolved. |
int |
getNodeKind()
Determine the types of nodes to which this pattern applies. |
String |
getPublicId()
Get the public ID (always null) |
String |
getSystemId()
Get the system id of the entity in which the pattern occurred |
protected boolean |
internalMatches(NodeInfo node,
NodeInfo anchor,
XPathContext context)
Determine whether this Pattern matches the given Node. |
Iterator |
iterateSubExpressions()
Iterate over the subexpressions within this pattern |
static Pattern |
make(String pattern,
StaticContext env,
Executable exec)
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. |
void |
promote(PromotionOffer offer,
Expression parent)
Offer promotion for subexpressions within this pattern. |
boolean |
replaceSubExpression(Expression original,
Expression replacement)
Replace a subexpression by a replacement subexpression |
void |
resolveCurrent(LetExpression let,
PromotionOffer offer,
boolean topLevel)
If the pattern contains any calls on current(), this method is called to modify such calls to become variable references to a variable declared in a specially-allocated local variable |
SequenceIterator<? extends NodeInfo> |
selectNodes(DocumentInfo doc,
XPathContext context)
Select nodes in a document using this PatternFinder. |
void |
setExecutable(Executable executable)
Set the executable containing this pattern |
void |
setLineNumber(int lineNumber)
Set the line number where the pattern occurred |
void |
setOriginalText(String text)
Set the original text of the pattern for use in diagnostics |
void |
setSystemId(String systemId)
Set the system ID where the pattern occurred |
Pattern |
simplify(ExpressionVisitor visitor)
Simplify the pattern by applying any context-independent optimisations. |
String |
toString()
Get the original pattern text |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Pattern()
Method Detail |
---|
public static Pattern make(String pattern, StaticContext env, Executable exec) throws XPathException
pattern
- The pattern text as a Stringenv
- An object defining the compile-time context for the expressionexec
- The executable containing this pattern
XPathException
- if the pattern is invalidpublic Executable getExecutable()
getExecutable
in interface Container
public void setExecutable(Executable executable)
executable
- the executablepublic LocationProvider getLocationProvider()
getLocationProvider
in interface Container
public int getContainerGranularity()
getContainerGranularity
in interface Container
public void setOriginalText(String text)
text
- the original text of the patternpublic Pattern simplify(ExpressionVisitor visitor) throws XPathException
visitor
- the expression visitor
XPathException
public Pattern analyze(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType) throws XPathException
visitor
- the expression visitorcontextItemType
- 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
public int getDependencies()
public Iterator iterateSubExpressions()
public int allocateSlots(StaticContext env, SlotManager slotManager, int nextFree)
env
- the static context in the XSLT stylesheetslotManager
- the slot manager representing the stack frame for local variablesnextFree
- the next slot that is free to be allocated
public void resolveCurrent(LetExpression let, PromotionOffer offer, boolean topLevel) throws XPathException
let
- the expression that assigns the local variable. This returns a dummy result, and is executed
just before evaluating the pattern, to get the value of the context item into the variable.offer
- A PromotionOffer used to process the expressions and change the call on current() into
a variable referencetopLevel
-
XPathException
public void promote(PromotionOffer offer, Expression parent) throws XPathException
Unlike the corresponding method on Expression
, this method does not return anything:
it can make internal changes to the pattern, but cannot return a different pattern. Only certain
kinds of promotion are applicable within a pattern: specifically, promotions affecting local
variable references within the pattern.
offer
- details of the offer, for example the offer to move
expressions that don't depend on the context to an outer level in
the containing expressionparent
-
XPathException
- if any error is detectedpublic void setSystemId(String systemId)
systemId
- the URI of the module containing the patternpublic void setLineNumber(int lineNumber)
lineNumber
- the line number of the pattern in the source modulepublic abstract boolean matches(Item item, XPathContext context) throws XPathException
item
- The NodeInfo representing the Element or other node to be tested against the Patterncontext
- The dynamic context. Only relevant if the pattern
uses variables, or contains calls on functions such as document() or key().
XPathException
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
protected boolean internalMatches(NodeInfo node, NodeInfo anchor, XPathContext context) throws XPathException
node
- The NodeInfo representing the Element or other node to be tested against the Patternanchor
- context
- The dynamic context. Only relevant if the pattern
uses variables, or contains calls on functions such as document() or key(). @return true if the node matches the Pattern, false otherwise
XPathException
public SequenceIterator<? extends NodeInfo> selectNodes(DocumentInfo doc, XPathContext context) throws XPathException
selectNodes
in interface PatternFinder
doc
- the document node at the root of a treecontext
- the dynamic evaluation context
XPathException
public int getNodeKind()
public int getFingerprint()
public abstract ItemType getItemType()
public double getDefaultPriority()
public String getSystemId()
getSystemId
in interface SourceLocator
public int getLineNumber()
getLineNumber
in interface SourceLocator
public int getColumnNumber()
getColumnNumber
in interface SourceLocator
public String getPublicId()
getPublicId
in interface SourceLocator
public String toString()
toString
in class Object
public int getHostLanguage()
getHostLanguage
in interface Container
Configuration.XSLT
or Configuration.XQUERY
public boolean replaceSubExpression(Expression original, Expression replacement)
original
- the expression to be replacedreplacement
- the new expression to be inserted in its place
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |