net.sf.saxon.pattern
Class LocationPathPattern

java.lang.Object
  |
  +--net.sf.saxon.pattern.Pattern
        |
        +--net.sf.saxon.pattern.LocationPathPattern
All Implemented Interfaces:
Container, java.io.Serializable, javax.xml.transform.SourceLocator

public final class LocationPathPattern
extends Pattern

A LocationPathPattern represents a path, for example of the form A/B/C... The components are represented as a linked list, each component pointing to its predecessor

See Also:
Serialized Form

Field Summary
 Pattern ancestorPattern
           
protected  Expression equivalentExpr
           
protected  Expression[] filters
           
protected  boolean firstElementPattern
           
protected  boolean lastElementPattern
           
 NodeTest nodeTest
           
protected  int numberOfFilters
           
 Pattern parentPattern
           
protected  boolean specialFilter
           
 
Constructor Summary
LocationPathPattern()
           
 
Method Summary
 void addFilter(Expression filter)
          Add a filter to the pattern (while under construction)
 int getFingerprint()
          Determine the fingerprint of nodes to which this pattern applies.
 int getNodeKind()
          Determine the types of nodes to which this pattern applies.
 NodeTest getNodeTest()
          Get a NodeTest that all the nodes matching this pattern must satisfy
protected  boolean internalMatches(NodeInfo node, XPathContext context)
          Test whether the pattern matches, but without changing the current() node
 boolean matches(NodeInfo node, XPathContext context)
          Determine whether this Pattern matches the given Node.
 boolean matchesX(NodeInfo node, XPathContext context)
          Determine whether the pattern matches a given node.
 Pattern simplify(StaticContext env)
          Simplify the pattern: perform any context-independent optimisations
 Pattern typeCheck(StaticContext env, ItemType contextItemType)
          Type-check the pattern, performing any type-dependent optimizations.
 
Methods inherited from class net.sf.saxon.pattern.Pattern
getColumnNumber, getDefaultPriority, getExecutable, getLineNumber, getPublicId, getSystemId, make, setExecutable, setLineNumber, setOriginalText, setSystemId, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parentPattern

public Pattern parentPattern

ancestorPattern

public Pattern ancestorPattern

nodeTest

public NodeTest nodeTest

filters

protected Expression[] filters

numberOfFilters

protected int numberOfFilters

equivalentExpr

protected Expression equivalentExpr

firstElementPattern

protected boolean firstElementPattern

lastElementPattern

protected boolean lastElementPattern

specialFilter

protected boolean specialFilter
Constructor Detail

LocationPathPattern

public LocationPathPattern()
Method Detail

addFilter

public void addFilter(Expression filter)
Add a filter to the pattern (while under construction)

Parameters:
filter - The predicate (a boolean expression or numeric expression) to be added

simplify

public Pattern simplify(StaticContext env)
                 throws XPathException
Simplify the pattern: perform any context-independent optimisations

Overrides:
simplify in class Pattern
Returns:
the optimised Pattern
XPathException

typeCheck

public Pattern typeCheck(StaticContext env,
                         ItemType contextItemType)
                  throws XPathException
Type-check the pattern, performing any type-dependent optimizations.

Overrides:
typeCheck in class Pattern
Returns:
the optimised Pattern
XPathException

matchesX

public boolean matchesX(NodeInfo node,
                        XPathContext context)
                 throws XPathException
Determine whether the pattern matches a given node.

Parameters:
node - the node to be tested
Returns:
true if the pattern matches, else false
XPathException

matches

public boolean matches(NodeInfo node,
                       XPathContext context)
                throws XPathException
Description copied from class: Pattern
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:
matches in class Pattern
Parameters:
node - The NodeInfo representing the Element or other node to be tested against the Pattern
context - The dynamic context. Only relevant if the pattern uses variables, or contains calls on functions such as document() or key().
Returns:
true if the node matches the Pattern, false otherwise
XPathException

internalMatches

protected boolean internalMatches(NodeInfo node,
                                  XPathContext context)
                           throws XPathException
Test whether the pattern matches, but without changing the current() node

Overrides:
internalMatches in class Pattern
Parameters:
node - The NodeInfo representing the Element or other node to be tested against the Pattern
context - The dynamic context. Only relevant if the pattern uses variables, or contains calls on functions such as document() or key().
Returns:
true if the node matches the Pattern, false otherwise
XPathException

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 Node.NODE

Overrides:
getNodeKind in class Pattern
Returns:
the type of node matched by this pattern. e.g. Node.ELEMENT or Node.TEXT

getFingerprint

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

Overrides:
getFingerprint in class Pattern
Returns:
the fingerprint of nodes matched by this pattern.

getNodeTest

public NodeTest getNodeTest()
Get a NodeTest that all the nodes matching this pattern must satisfy

Specified by:
getNodeTest in class Pattern