com.caucho.xpath
Class Pattern

java.lang.Object
  |
  +--com.caucho.xpath.Pattern

public class Pattern
extends java.lang.Object

A node selection pattern. Patterns represent compiled XPath node selectors. They can be used to find nodes, select nodes, and test if a node matches a pattern.

There are two types of patterns: select patterns and match patterns.

Select patterns match a node relative to another node. find and select use select patterns.

Match patterns match a node in isolation. isMatch uses match patterns.


Field Summary
protected static WriteStream dbg
           
 
Method Summary
 Node find(Node node)
          Returns the first node matching the pattern.
 Node find(Node node, ExprEnvironment env)
          Returns the first node matching the pattern.
 com.caucho.xpath.pattern.AbstractPattern getPattern()
          Returns the underlying pattern implementation.
 boolean isMatch(Node node)
          Test if the node matches the pattern.
 boolean isMatch(Node node, ExprEnvironment env)
          Test if the node matches the pattern.
 com.caucho.xpath.pattern.NodeIterator select(Node node)
          Selects all nodes matching the pattern.
 com.caucho.xpath.pattern.NodeIterator select(Node node, ExprEnvironment env)
          Selects all nodes matching the pattern.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dbg

protected static WriteStream dbg
Method Detail

find

public Node find(Node node)
          throws XPathException
Returns the first node matching the pattern. The pattern should be a select pattern.
Parameters:
node - node represented by '.' and start of match.
Returns:
first matching node

find

public Node find(Node node,
                 ExprEnvironment env)
          throws XPathException
Returns the first node matching the pattern. The pattern should be a select pattern.
Parameters:
node - node represented by '.' and start of match.
env - variable environment.
Returns:
first matching node

select

public com.caucho.xpath.pattern.NodeIterator select(Node node)
                                             throws XPathException
Selects all nodes matching the pattern. The pattern should be a select pattern.
Parameters:
node - node represented by '.' and start of match.
Returns:
iterator of matching nodes

select

public com.caucho.xpath.pattern.NodeIterator select(Node node,
                                                    ExprEnvironment env)
                                             throws XPathException
Selects all nodes matching the pattern. The pattern should be a select pattern.
Parameters:
context - node represented by '.' and start of match.
env - variable environment.
Returns:
iterator of matching nodes

isMatch

public boolean isMatch(Node node)
                throws XPathException
Test if the node matches the pattern. The pattern should be a match pattern.
Parameters:
node - node to test
Returns:
true if the pattern matches.

isMatch

public boolean isMatch(Node node,
                       ExprEnvironment env)
                throws XPathException
Test if the node matches the pattern. The pattern should be a match pattern.
Parameters:
node - node to test
env - variable environment.
Returns:
true if the pattern matches.

getPattern

public com.caucho.xpath.pattern.AbstractPattern getPattern()
Returns the underlying pattern implementation.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object