org.inria.ns.reflex.processor.xcl
Class RuleAction

java.lang.Object
  extended by org.inria.ns.reflex.processor.core.AbstractAction
      extended by org.inria.ns.reflex.processor.xcl.RuleAction
All Implemented Interfaces:
Executable, Presentable, Rule, NamespaceContextFactory
Direct Known Subclasses:
RuleSetAction

public class RuleAction
extends AbstractAction
implements Rule

The <xcl:rule> element defines a pattern or a regular expression on behalf of a filter.

Author:
Philippe Poulard
See Also:
FilterAction, Rule

Nested Class Summary
 
Nested classes/interfaces inherited from class org.inria.ns.reflex.processor.core.AbstractAction
AbstractAction.ParameterAdapter, AbstractAction.UselessAction
 
Nested classes/interfaces inherited from interface org.inria.ns.reflex.xml.filter.Rule
Rule.XPathPattern
 
Field Summary
 
Fields inherited from class org.inria.ns.reflex.processor.core.AbstractAction
actions, parent, processorInstance
 
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
 
Constructor Summary
RuleAction(Pattern pattern, double priority, Boolean normalize, Node node, AbstractAction parent)
          Create a new RuleAction.
RuleAction(Pattern pattern, Double priority, Boolean normalize, Node node, AbstractAction parent)
          Create a new RuleAction.
RuleAction(RuleAction ruleAction, Pattern pattern)
          Create a copy of RuleAction except its pattern.
 
Method Summary
 double getPriority()
          Return the priority of this rule.
 Boolean normalize()
          Indicates when this rule matches an item, whether it must be normalized.
 boolean test(Object item, PatternContext context)
          Test this rule over an item.
 String toString()
          Return the XPath pattern and the regular expression of this rule.
static AbstractAction unmarshal(AbstractAction parent, Element element)
          XML unmarshaller for RuleAction.
 
Methods inherited from class org.inria.ns.reflex.processor.core.AbstractAction
addAction, addFallbackAction, createContext, getCanonicalPath, getFallbackAction, getLocalFallbackAction, getLogger, getNamespaceContext, getNode, getParent, recover, recover, removeFallbackAction, reorganize, run, runAction, runActions, toPrettyString, toPrettyString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.inria.ns.reflex.structures.Executable
run
 

Constructor Detail

RuleAction

public RuleAction(Pattern pattern,
                  Double priority,
                  Boolean normalize,
                  Node node,
                  AbstractAction parent)
Create a new RuleAction.

Parameters:
pattern - The non-null pattern to match.
priority - The priority of this rule if it is explicitely given, or null.
normalize - true if the text nodes within the node that matches must be merged, false otherwise.
node - The node from which the action has been unmarshalled. Used for namespace prefix resolution when performing XPath expressions.
parent - The action depending from.

RuleAction

public RuleAction(RuleAction ruleAction,
                  Pattern pattern)
Create a copy of RuleAction except its pattern.

Parameters:
ruleAction - The rule action to copy.
pattern - The non-null pattern of the new rule.

RuleAction

public RuleAction(Pattern pattern,
                  double priority,
                  Boolean normalize,
                  Node node,
                  AbstractAction parent)
Create a new RuleAction.

Parameters:
pattern - The non-null pattern to match.
priority - The priority of this rule.
normalize - true if the text nodes within the node that matches must be merged, false otherwise, and null if not specified (use the default value).
node - The node from which the action has been unmarshalled. Used for namespace prefix resolution when performing XPath expressions.
parent - The action depending from.
Method Detail

unmarshal

public static AbstractAction unmarshal(AbstractAction parent,
                                       Element element)
                                throws XMLException
XML unmarshaller for RuleAction.

Parameters:
parent - The action depending from
element - The XML element to unmarshall.
Returns:
The RuleAction created.
Throws:
UnmarshalException - When the element and its content is not those expected.
XMLException

getPriority

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

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

test

public boolean test(Object item,
                    PatternContext context)
             throws PatternEvaluationException
Test this rule over an item.

Specified by:
test in interface Rule
Parameters:
item - The item to test.
context - The pattern context.
Returns:
true if this rule is applicable, false otherwise.
Throws:
PatternEvaluationException
See Also:
Rule.test(Object, PatternContext)

normalize

public Boolean normalize()
Indicates when this rule matches an item, whether it must be normalized.

Specified by:
normalize in interface Rule
Returns:
true if adjacent text nodes must be merged, false otherwise, and null if not specified (use the default value).

toString

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

Overrides:
toString in class AbstractAction
Returns:
The string representation of this action.
See Also:
Object.toString()