com.icl.saxon.pattern
Class LocationPathPattern

java.lang.Object
  |
  +--com.icl.saxon.pattern.Pattern
        |
        +--com.icl.saxon.pattern.LocationPathPattern
Direct Known Subclasses:
FirstElementPattern

public 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
 Pattern ancestorPattern
           
protected  Expression extent
           
protected  java.util.Vector filters
           
 NameTest nameTest
           
 int nodeType
           
 Pattern parentPattern
           
 
Fields inherited from class com.icl.saxon.pattern.Pattern
staticContext
 
Constructor Summary
LocationPathPattern()
           
 
Method Summary
 void addFilter(Expression filter)
          Add a filter to the pattern (while under construction)
 Name getName()
          If this pattern will match only nodes of a single name, return the relevant name.
 NameTest getNameTest()
          Return the name test
 int getType()
          Determine the types of nodes to which this pattern applies.
 boolean isRelative()
          Determine if the pattern uses positional filters
 boolean matches(NodeInfo node, Context context)
          Determine whether this Pattern matches the given Node
 boolean matchesX(NodeInfo node, Context context)
          Determine whether the pattern matches a given node.
 Pattern simplify()
          Simplify the pattern: perform any context-independent optimisations
protected  boolean testFilters(NodeInfo node, Context context)
          The testFilters() method is separated out for subclassing purposes
 java.lang.String toString()
          Return the pattern as a string
 
Methods inherited from class com.icl.saxon.pattern.Pattern
getDefaultPriority, getStaticContext, make, make, setStaticContext
 
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

nameTest

public NameTest nameTest

nodeType

public int nodeType

filters

protected java.util.Vector filters

extent

protected Expression extent
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()
                 throws org.xml.sax.SAXException
Simplify the pattern: perform any context-independent optimisations
Overrides:
simplify in class Pattern
Following copied from class: com.icl.saxon.pattern.Pattern
Returns:
the optimised Pattern

matchesX

public boolean matchesX(NodeInfo node,
                        Context context)
                 throws org.xml.sax.SAXException
Determine whether the pattern matches a given node.
Parameters:
node - the ElementInfo or other node to be tested
Returns:
true if the pattern matches, else false

matches

public boolean matches(NodeInfo node,
                       Context context)
                throws org.xml.sax.SAXException
Description copied from class: Pattern
Determine whether this Pattern matches the given Node
Overrides:
matches in class Pattern
Following copied from class: com.icl.saxon.pattern.Pattern
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

testFilters

protected boolean testFilters(NodeInfo node,
                              Context context)
                       throws org.xml.sax.SAXException
The testFilters() method is separated out for subclassing purposes

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 Node.NODE
Overrides:
getType in class Pattern
Returns:
the type of node matched by this pattern. e.g. Node.ELEMENT or Node.TEXT

getName

public Name getName()
If this pattern will match only nodes of a single name, return the relevant name. This is used for quick elimination of patterns that will never match.
Overrides:
getName in class Pattern
Following copied from class: com.icl.saxon.pattern.Pattern
Returns:
A Name that the nodes must possess, or null Otherwise return null.

getNameTest

public NameTest getNameTest()
Return the name test
Overrides:
getNameTest in class Pattern
Following copied from class: com.icl.saxon.pattern.Pattern
Returns:
A NameTest that the nodes must satisfy, or null

toString

public java.lang.String toString()
Return the pattern as a string
Overrides:
toString in class java.lang.Object

isRelative

public boolean isRelative()
                   throws org.xml.sax.SAXException
Determine if the pattern uses positional filters
Overrides:
isRelative in class Pattern
Returns:
true if there is a numeric filter in the pattern, or one that uses the position() or last() functions