Package net.sf.saxon.pattern
Class NodeTestPattern
java.lang.Object
net.sf.saxon.pattern.Pattern
net.sf.saxon.pattern.NodeTestPattern
- All Implemented Interfaces:
Serializable,SourceLocator,Container
A NodeTestPattern is a pattern that consists simply of a NodeTest.
- Author:
- Michael H. Kay
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal doubleDetermine the default priority of this node test when used on its own as a PatternintDetermine the name fingerprint of nodes to which this pattern applies.intDetermine the types of nodes to which this pattern applies.Get a NodeTest that all the nodes matching this pattern must satisfybooleanmatches(NodeInfo node, XPathContext context) Determine whether this Pattern matches the given Node.voidsetNodeTest(NodeTest test) toString()Display the pattern for diagnosticsMethods inherited from class net.sf.saxon.pattern.Pattern
analyze, getColumnNumber, getDependencies, getExecutable, getHostLanguage, getLineNumber, getLocationProvider, getPublicId, getSystemId, internalMatches, iterateSubExpressions, make, promote, replaceSubExpression, setExecutable, setLineNumber, setOriginalText, setSystemId, simplify
-
Constructor Details
-
NodeTestPattern
public NodeTestPattern() -
NodeTestPattern
-
-
Method Details
-
setNodeTest
-
matches
Determine whether this Pattern matches the given Node. This is the main external interface for matching patterns: it sets current() to the node being tested- Specified by:
matchesin classPattern- Parameters:
node- The NodeInfo representing the Element or other node to be tested against the Patterncontext- The context in which the match is to take place. Only relevant if the pattern uses variables, or contains calls on functions such as document() or key(). Not used (and can be set to null) in the case of patterns that are NodeTests- Returns:
- true if the node matches the Pattern, false otherwise
-
getNodeTest
Get a NodeTest that all the nodes matching this pattern must satisfy- Specified by:
getNodeTestin classPattern
-
getDefaultPriority
public final double getDefaultPriority()Determine the default priority of this node test when used on its own as a Pattern- Overrides:
getDefaultPriorityin classPattern
-
getNodeKind
public int getNodeKind()Determine the types of nodes to which this pattern applies. Used for optimisation. For patterns that match nodes of several types, return Type.NODE- Overrides:
getNodeKindin classPattern- Returns:
- the type of node matched by this pattern. e.g. Type.ELEMENT or Type.TEXT
-
getFingerprint
public int getFingerprint()Determine the name fingerprint of nodes to which this pattern applies. Used for optimisation.- Overrides:
getFingerprintin classPattern- Returns:
- A fingerprint that the nodes must match, or -1 if it can match multiple fingerprints
-
toString
Display the pattern for diagnostics
-