org.inria.ns.reflex.xml.filter
Class Rule.XPathPattern

java.lang.Object
  extended by org.inria.ns.reflex.xml.filter.Rule.XPathPattern
All Implemented Interfaces:
Executable, Unwrappable, Rule
Enclosing interface:
Rule

public static class Rule.XPathPattern
extends Object
implements Rule, Unwrappable

A rule built from a XPathPattern.

Author:
Philippe Poulard

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.inria.ns.reflex.xml.filter.Rule
Rule.XPathPattern
 
Nested classes/interfaces inherited from interface org.inria.ns.reflex.structures.Unwrappable
Unwrappable.Unwrapper
 
Field Summary
 
Fields inherited from interface org.inria.ns.reflex.xml.filter.Rule
APPLY_RULES_ACTION, COMPARATOR, DEFAULT_RULE_ACTION, DEFAULT_RULES, REMOVE_NODES_RULE, REMOVE_RULE
 
Fields inherited from interface org.inria.ns.reflex.structures.Unwrappable
UNWRAPPER
 
Constructor Summary
Rule.XPathPattern(Executable executable, String pattern)
          A pattern-based rule.
Rule.XPathPattern(Pattern pattern, Executable executable)
          A pattern-based rule.
Rule.XPathPattern(String pattern, Executable executable)
          A pattern-based rule.
 
Method Summary
 double getPriority()
          Return the priority of the underlying pattern.
 Boolean normalize()
          Indicates when this rule matches an item, that it must be normalized as specified in the host filter.
 void run(DataSet dataSet)
          Perform the underlying action.
 boolean test(Object item, PatternContext context)
          Test the underlying pattern on an item.
 String toString()
          Return the XPath pattern and the regular expression of this rule.
 Object unwrap()
          Return the underlying pattern.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rule.XPathPattern

public Rule.XPathPattern(Pattern pattern,
                         Executable executable)
A pattern-based rule.

Parameters:
pattern - The pattern to wrap.
executable - The action to perform when the pattern matches. May be null.

Rule.XPathPattern

public Rule.XPathPattern(String pattern,
                         Executable executable)
                  throws BadPatternException
A pattern-based rule.

Parameters:
pattern - The pattern to wrap.
executable - The action to perform when the pattern matches. May be null.
Throws:
BadPatternException - If the pattern can't be compiled.

Rule.XPathPattern

public Rule.XPathPattern(Executable executable,
                         String pattern)
A pattern-based rule.

*** If this constructor is used, the pattern must compile : exceptions are ignored. This means that this convenient constructor should be used for well-tried patterns only, for example in order to build constants. ***

Parameters:
executable - The action to perform when the pattern matches. May be null.
pattern - The pattern to wrap.
Method Detail

getPriority

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

Specified by:
getPriority in interface Rule
Returns:
The priority of the underlying pattern.
See Also:
Rule.getPriority(), Pattern.getPriority()

test

public boolean test(Object item,
                    PatternContext context)
Test the underlying pattern on an item.

Specified by:
test in interface Rule
Parameters:
item - The item on which the pattern will be tested.
context - The context to use.
Returns:
true if this rule is applicable, false otherwise.
See Also:
Rule.test(Object, PatternContext)

normalize

public Boolean normalize()
Indicates when this rule matches an item, that it must be normalized as specified in the host filter.

Specified by:
normalize in interface Rule
Returns:
null.

run

public void run(DataSet dataSet)
         throws ExecutionException
Perform the underlying action.

Specified by:
run in interface Executable
Parameters:
dataSet - The set of datas to use.
Throws:
ExecutionException - If the action can't be performed.
See Also:
Executable.run(org.inria.ns.reflex.processor.DataSet)

unwrap

public Object unwrap()
Return the underlying pattern.

Specified by:
unwrap in interface Unwrappable
Returns:
The pattern.
See Also:
Unwrappable.unwrap(), Pattern

toString

public String toString()
Return the XPath pattern and the regular expression of this rule.

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