net.sf.swan.xpath
Class Matcher

java.lang.Object
  |
  +--net.sf.swan.xpath.XPathSupport
        |
        +--net.sf.swan.xpath.Matcher

public class Matcher
extends XPathSupport

Utility for XSLT pattern matching of nodes. This can be used to facilitate simple rule-based processing, or for associating arbitrary metadata with nodes based on matching patterns.

Note:The match operation is a thread-safe operation; however, other operations on this component such as adding patterns or adding and changing variables are not thread-safe. This component should only be used across multiple threads when no further changes are being made. If one wishes to set variable values for specific matches in a thread-safe manner, then first create a MatchContext to use in that thread. One can then set the variable values on it and pass it as a parameter to the match method. Alternatively, one can create a whole new matcher.


Fields inherited from class net.sf.swan.xpath.XPathSupport
defaultParseAdapter, verifyVars
 
Constructor Summary
Matcher()
           
Matcher(Matcher prototype)
           
Matcher(org.jaxen.Navigator navigator)
           
Matcher(XPathSupport prototype)
           
 
Method Summary
 void add(Pattern pattern, java.lang.Object data)
          Add a pattern and associated rule or metadata to the Matcher.
 void add(Pattern pattern, java.lang.Object data, double priority)
          Add a pattern and associated rule or metadata to the Matcher.
 void add(Pattern filter, java.lang.String expr, java.lang.Object data)
           
 void add(Pattern filter, java.lang.String expr, java.lang.Object data, double priority)
           
 void add(java.lang.String expr, java.lang.Object data)
          Add a pattern and associated rule or metadata to the Matcher.
 void add(java.lang.String expr, java.lang.Object data, double priority)
          Add a pattern and associated rule or metadata to the Matcher.
 void addAll(Matcher matcher)
          Merge all of the rules in the specified Matcher into this one.
 MatchContext createMatchContext()
          Create a MatchContext object that may be used to iterate through matching rules, and to manipulate variables for matching in a thread-safe manner.
 void loadTemplates(java.lang.Object rootNode, java.lang.String pattern, java.lang.String use)
           
 void loadTemplates(java.lang.Object rootNode, java.lang.String pattern, java.lang.String use, java.lang.String usePriority)
           
 java.lang.Object match(java.lang.Object node)
          Obtain the object associated with the first rule that matches the specified node.
 void match(java.lang.Object node, Match match)
          Prepare a Match object that may be used to iterate through matching rules in order of priority.
protected  Pattern[] parsePattern(Pattern filter, java.lang.String expr)
           
 
Methods inherited from class net.sf.swan.xpath.XPathSupport
createContextSupport, createFunctionContext, createMatcher, createNamespaceContext, createSelector, createVariableContext, getContextSupport, getDocument, getFunctionContext, getNavigator, getReader, getVariableValue, getVariableValue, getVariableValue, keyMap, parseAVT, parseAVT, parsePattern, parsePattern, parseXPath, parseXPath, putNamespace, putVariableValue, putVariableValue, resolveNamespacePrefix, setFunctionContext, setNavigator, toBoolean, toList, toSingle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Matcher

public Matcher()

Matcher

public Matcher(org.jaxen.Navigator navigator)

Matcher

public Matcher(Matcher prototype)

Matcher

public Matcher(XPathSupport prototype)
Method Detail

add

public void add(java.lang.String expr,
                java.lang.Object data)
         throws org.saxpath.SAXPathException
Add a pattern and associated rule or metadata to the Matcher.

add

public void add(java.lang.String expr,
                java.lang.Object data,
                double priority)
         throws org.saxpath.SAXPathException
Add a pattern and associated rule or metadata to the Matcher.

add

public void add(Pattern filter,
                java.lang.String expr,
                java.lang.Object data)
         throws org.saxpath.SAXPathException

add

public void add(Pattern filter,
                java.lang.String expr,
                java.lang.Object data,
                double priority)
         throws org.saxpath.SAXPathException

addAll

public void addAll(Matcher matcher)
Merge all of the rules in the specified Matcher into this one.

loadTemplates

public void loadTemplates(java.lang.Object rootNode,
                          java.lang.String pattern,
                          java.lang.String use)
                   throws org.saxpath.SAXPathException

loadTemplates

public void loadTemplates(java.lang.Object rootNode,
                          java.lang.String pattern,
                          java.lang.String use,
                          java.lang.String usePriority)
                   throws org.saxpath.SAXPathException

add

public void add(Pattern pattern,
                java.lang.Object data)
Add a pattern and associated rule or metadata to the Matcher.

add

public void add(Pattern pattern,
                java.lang.Object data,
                double priority)
Add a pattern and associated rule or metadata to the Matcher.

match

public java.lang.Object match(java.lang.Object node)
                       throws org.jaxen.JaxenException
Obtain the object associated with the first rule that matches the specified node.

match

public void match(java.lang.Object node,
                  Match match)
           throws org.jaxen.JaxenException
Prepare a Match object that may be used to iterate through matching rules in order of priority.

createMatchContext

public MatchContext createMatchContext()
Create a MatchContext object that may be used to iterate through matching rules, and to manipulate variables for matching in a thread-safe manner.
Overrides:
createMatchContext in class XPathSupport

parsePattern

protected Pattern[] parsePattern(Pattern filter,
                                 java.lang.String expr)
                          throws org.saxpath.SAXPathException