net.sf.saxon.pattern
Class AnchorPattern

java.lang.Object
  extended by net.sf.saxon.pattern.Pattern
      extended by net.sf.saxon.pattern.AnchorPattern
All Implemented Interfaces:
Serializable, SourceLocator, Container, PatternFinder

public class AnchorPattern
extends Pattern

This is a special pattern that matches the "anchor node"; it is not used for XSLT patterns, but for the selectors that arise when evaluating XPath expressions in streaming mode; the anchor node is the context node for the streamed XPath evaluation.

See Also:
Serialized Form

Constructor Summary
AnchorPattern()
           
 
Method Summary
 Pattern analyze(ExpressionVisitor visitor, ItemType contextItemType)
          Type-check the pattern.
 NodeTest getNodeTest()
          Get a NodeTest that all the nodes matching this pattern must satisfy
protected  boolean internalMatches(NodeInfo node, NodeInfo anchor, XPathContext context)
          Determine whether this Pattern matches the given Node.
 boolean matches(NodeInfo node, XPathContext context)
          Determine whether this Pattern matches the given Node.
 boolean matchesBeneathAnchor(NodeInfo node, NodeInfo anchor, XPathContext context)
          Determine whether this pattern matches a given Node within the subtree rooted at a given anchor node.
 String toString()
          Get the original pattern text
 
Methods inherited from class net.sf.saxon.pattern.Pattern
allocateSlots, getColumnNumber, getContainerGranularity, getDefaultPriority, getDependencies, getExecutable, getFingerprint, getHostLanguage, getLineNumber, getLocationProvider, getNodeKind, getPublicId, getSystemId, iterateSubExpressions, make, makeSearchExpression, promote, replaceSubExpression, resolveCurrent, selectNodes, setExecutable, setLineNumber, setOriginalText, setSystemId, simplify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AnchorPattern

public AnchorPattern()
Method Detail

analyze

public Pattern analyze(ExpressionVisitor visitor,
                       ItemType contextItemType)
                throws XPathException
Type-check the pattern.

Overrides:
analyze in class Pattern
Parameters:
visitor - the expression visitor
contextItemType - the type of the context item at the point where the pattern is defined. Set to null if it is known that the context item is undefined.
Returns:
the optimised Pattern
Throws:
XPathException

matchesBeneathAnchor

public boolean matchesBeneathAnchor(NodeInfo node,
                                    NodeInfo anchor,
                                    XPathContext context)
                             throws XPathException
Determine whether this pattern matches a given Node within the subtree rooted at a given anchor node. This method is used when the pattern is used for streaming.

Overrides:
matchesBeneathAnchor in class Pattern
Parameters:
node - The NodeInfo representing the Element or other node to be tested against the Pattern
anchor - The anchor node, which must match any AnchorPattern subpattern
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
Throws:
XPathException

matches

public boolean matches(NodeInfo node,
                       XPathContext context)
                throws XPathException
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
Throws:
XPathException

internalMatches

protected boolean internalMatches(NodeInfo node,
                                  NodeInfo anchor,
                                  XPathContext context)
                           throws XPathException
Determine whether this Pattern matches the given Node. This is an internal interface used for matching sub-patterns; it does not alter the value of current(). The default implementation is identical to matches().

Overrides:
internalMatches in class Pattern
Parameters:
node - The NodeInfo representing the Element or other node to be tested against the Pattern
anchor -
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
Throws:
XPathException

getNodeTest

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

Specified by:
getNodeTest in class Pattern
Returns:
a NodeTest, as specific as possible, which all the matching nodes satisfy

toString

public String toString()
Description copied from class: Pattern
Get the original pattern text

Overrides:
toString in class Pattern


Copyright (c) 2004-2010 Saxonica Limited. All rights reserved.