org.inria.ns.reflex.xml.filter
Interface Rule

All Superinterfaces:
Executable
All Known Implementing Classes:
Rule.XPathPattern, RuleAction, RuleSetAction

public interface Rule
extends Executable

A Rule is an XPath pattern or a Regular expression or both or whatever that can be tested upon an XML item.

When testing this rule is a success, it should be executed.

Author:
Philippe Poulard
See Also:
Executable.run(DataSet)

Nested Class Summary
static class Rule.XPathPattern
          A rule built from a XPathPattern.
 
Field Summary
static StaticAction APPLY_RULES_ACTION
          A minimal implementation for applying rules of a matched node : <xcl:apply-rules/>
static Comparator COMPARATOR
          Allow to compare rules according to their priority.
static StaticAction DEFAULT_RULE_ACTION
          The default rule action, as specified in the XCL specification.
static List DEFAULT_RULES
          An immutable list of default rules.
static Rule REMOVE_NODES_RULE
          A rule that removes any node except the root node, that is to say that if no other rule matches, this one delete the node but its content is applied.
static Rule REMOVE_RULE
          A rule that removes any node, that is to say that if no other rule matches, this one delete the node but its content is applied.
 
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 if this rule applies on an item.
 
Methods inherited from interface org.inria.ns.reflex.structures.Executable
run
 

Field Detail

COMPARATOR

static final Comparator COMPARATOR
Allow to compare rules according to their priority. Higher priorities are before lower ones.

*** This comparator imposes orderings that are inconsistent with equals. ***

See Also:
RulesSupport.sort(List)

APPLY_RULES_ACTION

static final StaticAction APPLY_RULES_ACTION
A minimal implementation for applying rules of a matched node : <xcl:apply-rules/>


DEFAULT_RULE_ACTION

static final StaticAction DEFAULT_RULE_ACTION
The default rule action, as specified in the XCL specification.

The default rule action applies rules on the matched node :

<xcl:forward>
     <xcl:apply-rules/>
 </xcl:forward>


DEFAULT_RULES

static final List DEFAULT_RULES
An immutable list of default rules.

The default rules are :

<xcl:rule pattern="/ | node()">
    <xcl:forward>
        <xcl:apply-rules/>
    </xcl:forward>
</xcl:rule>

See Also:
Rule

REMOVE_RULE

static final Rule REMOVE_RULE
A rule that removes any node, that is to say that if no other rule matches, this one delete the node but its content is applied.
<xcl:rule pattern="/ | node()">
    <xcl:apply-rules/>
</xcl:rule>


REMOVE_NODES_RULE

static final Rule REMOVE_NODES_RULE
A rule that removes any node except the root node, that is to say that if no other rule matches, this one delete the node but its content is applied.
<xcl:rule pattern="node()">
    <xcl:apply-rules/>
</xcl:rule>

Method Detail

getPriority

double getPriority()
Return the priority of this rule.

Returns:
The priority of this rule.

test

boolean test(Object item,
             PatternContext context)
             throws PatternEvaluationException
Test if this rule applies on an item.

Parameters:
item - The XML item to test : either a DOM node, a SAX node, an XOperable object, or a String.
context - The context to use.
Returns:
true if this rule is applicable, false otherwise.
Throws:
PatternEvaluationException - When the pattern can't be evaluated.
See Also:
Node, SAXNode, XOperable

normalize

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

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