com.icl.saxon.pattern
Class Pattern

java.lang.Object
  |
  +--com.icl.saxon.pattern.Pattern
Direct Known Subclasses:
AnyChildNodePattern, DocumentPattern, IDPattern, KeyPattern, LocationPathPattern, NamedNodePattern, NodeTestPattern, UnionPattern

public abstract class Pattern
extends java.lang.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  StaticContext staticContext
           
 
Constructor Summary
Pattern()
           
 
Method Summary
 double getDefaultPriority()
          Determine the default priority to use if this pattern appears as a match pattern for a template with no explicit priority attribute.
 Name getName()
          Determine the names of nodes to which this pattern applies.
 NameTest getNameTest()
          Determine the names of nodes to which this pattern applies.
 StaticContext getStaticContext()
          Determine the static context used when the pattern was parsed
 int getType()
          Determine the types of nodes to which this pattern applies.
abstract  boolean isRelative()
          Determine whether the pattern uses positional filters
static Pattern make(java.lang.String pattern)
          Parse a pattern using a default compile-time context.
static Pattern make(java.lang.String pattern, StaticContext env)
          Static method to make a Pattern by parsing a String.
abstract  boolean matches(NodeInfo node, Context context)
          Determine whether this Pattern matches the given Node
 void setStaticContext(StaticContext sc)
          Set the static context used when the pattern was parsed
 Pattern simplify()
          Simplify the pattern by applying any context-independent optimisations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

staticContext

protected StaticContext staticContext
Constructor Detail

Pattern

public Pattern()
Method Detail

make

public static Pattern make(java.lang.String pattern,
                           StaticContext env)
                    throws org.xml.sax.SAXException
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

make

public static Pattern make(java.lang.String pattern)
                    throws org.xml.sax.SAXException
Parse a pattern using a default compile-time context. This context does not support the use of context-dependent facilities in expressions, including namespaces, use of variables, or use of the document() function (which needs to know a base URI)
Parameters:
expression - The expression (as a character string)
env - An object giving information about the compile-time context of the expression
Returns:
an object of type Expression

simplify

public Pattern simplify()
                 throws org.xml.sax.SAXException
Simplify the pattern by applying any context-independent optimisations. Default implementation does nothing.
Returns:
the optimised Pattern

setStaticContext

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

getStaticContext

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

matches

public abstract boolean matches(NodeInfo node,
                                Context context)
                         throws org.xml.sax.SAXException
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

getType

public int getType()
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

getName

public Name getName()
Determine the names of nodes to which this pattern applies. Used for optimisation.
Returns:
A Name that the nodes must possess, or null Otherwise return null.

getNameTest

public NameTest getNameTest()
Determine the names of nodes to which this pattern applies. Used for optimisation.
Returns:
A NameTest that the nodes must satisfy, or null

isRelative

public abstract boolean isRelative()
                            throws org.xml.sax.SAXException
Determine whether the pattern uses positional filters

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.