com.icl.saxon.pattern

Class Pattern

public abstract class Pattern extends Object

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().
Field Summary
protected StringoriginalText
protected StaticContextstaticContext
Method Summary
doublegetDefaultPriority()
Determine the default priority to use if this pattern appears as a match pattern for a template with no explicit priority attribute.
intgetFingerprint()
Determine the name fingerprint of nodes to which this pattern applies.
intgetLineNumber()
Get the line number on which the pattern was defined
shortgetNodeType()
Determine the types of nodes to which this pattern applies.
StaticContextgetStaticContext()
Determine the static context used when the pattern was parsed
StringgetSystemId()
Get the system id of the entity in which the pattern occurred
static Patternmake(String pattern, StaticContext env)
Static method to make a Pattern by parsing a String.
abstract booleanmatches(NodeInfo node, Context context)
Determine whether this Pattern matches the given Node
voidsetOriginalText(String text)
Set the original text of the pattern for use in diagnostics
voidsetStaticContext(StaticContext sc)
Set the static context used when the pattern was parsed
Patternsimplify()
Simplify the pattern by applying any context-independent optimisations.
StringtoString()
Get the original pattern text

Field Detail

originalText

protected String originalText

staticContext

protected StaticContext staticContext

Method Detail

getDefaultPriority

public double getDefaultPriority()
Determine the default priority to use if this pattern appears as a match pattern for a template with no explicit priority attribute.

getFingerprint

public int getFingerprint()
Determine the name fingerprint of nodes to which this pattern applies. Used for optimisation.

Returns: A fingerprint that the nodes must match, or null Otherwise return null.

getLineNumber

public int getLineNumber()
Get the line number on which the pattern was defined

getNodeType

public short getNodeType()
Determine the types of nodes to which this pattern applies. Used for optimisation. For patterns that match nodes of several types, return NodeInfo.NODE

Returns: the type of node matched by this pattern. e.g. NodeInfo.ELEMENT or NodeInfo.TEXT

getStaticContext

public StaticContext getStaticContext()
Determine the static context used when the pattern was parsed

getSystemId

public String getSystemId()
Get the system id of the entity in which the pattern occurred

make

public static Pattern make(String pattern, StaticContext env)
Static method to make a Pattern by parsing a String.

Parameters: pattern The pattern text as a String env An object defining the compile-time context for the expression

Returns: The pattern object

matches

public abstract boolean matches(NodeInfo node, Context context)
Determine whether this Pattern matches the given Node

Parameters: node The NodeInfo representing the Element or other node to be tested against the Pattern context The context in which the match is to take place. Only relevant if the pattern uses variables.

Returns: true if the node matches the Pattern, false otherwise

setOriginalText

public void setOriginalText(String text)
Set the original text of the pattern for use in diagnostics

setStaticContext

public final void setStaticContext(StaticContext sc)
Set the static context used when the pattern was parsed

simplify

public Pattern simplify()
Simplify the pattern by applying any context-independent optimisations. Default implementation does nothing.

Returns: the optimised Pattern

toString

public String toString()
Get the original pattern text