com.icl.saxon.pattern

Class LocationPathPattern

public final class LocationPathPattern extends Pattern

A LocationPathPattern represents a path, e.g. of the form A/B/C... The components are represented as a linked list, each component pointing to its predecessor
Field Summary
PatternancestorPattern
protected ExpressionequivalentExpr
protected Expression[]filters
protected booleanfirstElementPattern
protected booleanlastElementPattern
NodeTestnodeTest
protected intnumberOfFilters
PatternparentPattern
protected booleanspecialFilter
Method Summary
voidaddFilter(Expression filter)
Add a filter to the pattern (while under construction)
intgetFingerprint()
Determine the fingerprint of nodes to which this pattern applies.
shortgetNodeType()
Determine the types of nodes to which this pattern applies.
booleanisRelative()
Determine if the pattern uses positional filters
booleanmatches(NodeInfo node, Context context)
booleanmatchesX(NodeInfo node, Context context)
Determine whether the pattern matches a given node.
Patternsimplify()
Simplify the pattern: perform any context-independent optimisations

Field Detail

ancestorPattern

public Pattern ancestorPattern

equivalentExpr

protected Expression equivalentExpr

filters

protected Expression[] filters

firstElementPattern

protected boolean firstElementPattern

lastElementPattern

protected boolean lastElementPattern

nodeTest

public NodeTest nodeTest

numberOfFilters

protected int numberOfFilters

parentPattern

public Pattern parentPattern

specialFilter

protected boolean specialFilter

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

getFingerprint

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

Returns: the fingerprint of nodes matched by this pattern.

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

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

isRelative

public boolean isRelative()
Determine if the pattern uses positional filters

Returns: true if there is a numeric filter in the pattern, or one that uses the position() or last() functions

matches

public boolean matches(NodeInfo node, Context context)

matchesX

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

Parameters: node the node to be tested

Returns: true if the pattern matches, else false

simplify

public Pattern simplify()
Simplify the pattern: perform any context-independent optimisations