org.inria.ns.reflex.xml.provider.jaxen
Class JaxenPattern

java.lang.Object
  extended by org.inria.ns.reflex.xml.provider.jaxen.JaxenPattern
All Implemented Interfaces:
Pattern

public class JaxenPattern
extends Object
implements Pattern

A pattern is a string that is interpreted as a pattern in XSLT.

Variables are supported in predicates.

Author:
Philippe Poulard

Field Summary
 
Fields inherited from interface org.inria.ns.reflex.xml.xpath.pattern.Pattern
MATCH_ALL, MATCH_ALL_NODES
 
Constructor Summary
JaxenPattern(String pattern)
          Parse a pattern with Jaxen.
 
Method Summary
 Pattern asPattern()
          Return this expression.
 boolean equals(Object pattern)
          Indicates whether some other JaxenPattern is "equal to" this one.
 String getPattern()
          Returns the expression string used to compile the Pattern.
 double getPriority()
          Return the priority of this pattern.
 XFactory getXFactory()
          Return the factory that built this compiled pattern.
 int hashCode()
          Returns a hash code value for the Expression.
 boolean matches(Object node, PatternContext context)
          Test whether a node matches this pattern or not.
 List splitUnionPattern()
          Split this pattern to a list of patterns if it is an union pattern.
 String toString()
          Return the XPath pattern.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JaxenPattern

public JaxenPattern(String pattern)
             throws BadPatternException
Parse a pattern with Jaxen.

Parameters:
pattern - The string to wrap.
Throws:
BadPatternException - If the given expression is not a valid pattern.
Method Detail

getPattern

public String getPattern()
Returns the expression string used to compile the Pattern.

Returns:
The expression string used to compile the Expression.

asPattern

public Pattern asPattern()
                  throws BadPatternException
Return this expression.

Returns:
This.
Throws:
BadPatternException - Never thrown.
See Also:
CompiledExpression.asPattern()

hashCode

public int hashCode()
Returns a hash code value for the Expression.

Overrides:
hashCode in class Object
Returns:
A hash code value for this Expression.

equals

public boolean equals(Object pattern)
Indicates whether some other JaxenPattern is "equal to" this one.

Overrides:
equals in class Object
Parameters:
pattern - The pattern to compare.
Returns:
true if this JaxenPattern is the same as the pattern argument; false otherwise.

matches

public boolean matches(Object node,
                       PatternContext context)
                throws PatternEvaluationException
Test whether a node matches this pattern or not.

Specified by:
matches in interface Pattern
Parameters:
node - The node to test.
context - The context to use.
Returns:
true if the given node matches this pattern, false otherwise.
Throws:
PatternEvaluationException

getPriority

public double getPriority()
Return the priority of this pattern.

Specified by:
getPriority in interface Pattern
Returns:
The priority of this pattern.
See Also:
Pattern.getPriority()

getXFactory

public XFactory getXFactory()
Return the factory that built this compiled pattern.

Specified by:
getXFactory in interface Pattern
Returns:
The Jaxen XFactory.
See Also:
JaxenXFactory

toString

public String toString()
Return the XPath pattern.

Overrides:
toString in class Object
See Also:
Object.toString()

splitUnionPattern

public List splitUnionPattern()
Split this pattern to a list of patterns if it is an union pattern.

Specified by:
splitUnionPattern in interface Pattern
Returns:
A non-null list of patterns if this pattern is an union pattern. The list is empty if this pattern is not an union pattern.
See Also:
Pattern.splitUnionPattern()