com.caucho.xpath
Class Pattern

java.lang.Object
  extended by 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 java.util.logging.Logger log
           
 
Method Summary
 org.w3c.dom.Node find(org.w3c.dom.Node node)
          Returns the first node matching the pattern.
 org.w3c.dom.Node find(org.w3c.dom.Node node, ExprEnvironment env)
          Returns the first node matching the pattern.
 AbstractPattern getPattern()
          Returns the underlying pattern implementation.
 boolean isMatch(org.w3c.dom.Node node)
          Test if the node matches the pattern.
 boolean isMatch(org.w3c.dom.Node node, ExprEnvironment env)
          Test if the node matches the pattern.
 NodeIterator select(org.w3c.dom.Node node)
          Selects all nodes matching the pattern.
 NodeIterator select(org.w3c.dom.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

log

protected static final java.util.logging.Logger log
Method Detail

find

public org.w3c.dom.Node find(org.w3c.dom.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
Throws:
XPathException

find

public org.w3c.dom.Node find(org.w3c.dom.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
Throws:
XPathException

select

public NodeIterator select(org.w3c.dom.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
Throws:
XPathException

select

public NodeIterator select(org.w3c.dom.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
Throws:
XPathException

isMatch

public boolean isMatch(org.w3c.dom.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.
Throws:
XPathException

isMatch

public boolean isMatch(org.w3c.dom.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.
Throws:
XPathException

getPattern

public AbstractPattern getPattern()
Returns the underlying pattern implementation.


toString

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