org.inria.ns.reflex.xml.dom
Class DOMFilter

java.lang.Object
  extended by org.inria.ns.reflex.xml.filter.AbstractFilter
      extended by org.inria.ns.reflex.xml.dom.DOMFilter
All Implemented Interfaces:
Filter, RuleBasedFilter, RunnableRuleBasedFilter

public class DOMFilter
extends AbstractFilter

Browse a DOM tree in order to apply rules.

Author:
Philippe Poulard

Constructor Summary
DOMFilter(List rules, boolean normalize, PatternContext context, FilterContextFactory filterContextFactory)
          Create a new DOM filter.
DOMFilter(RuleBasedFilter filterDef, PatternContext context)
          Create a new DOM filter.
 
Method Summary
 void applyRules(Object node, DataSet dataSet)
          Apply the filter on the children of the given node.
 void forward(QName[] channelNames, Executable action, DataSet dataSet)
          Forward some content to some channels.
 void ignore(Object node)
          Ignore the node : don't produce any output.
 void normalize(Object node)
          Merge adjacent text nodes in the direct children of a given node.
 
Methods inherited from class org.inria.ns.reflex.xml.filter.AbstractFilter
applyFilter, getFilterContextFactory, getPatternContext, getRules, normalize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMFilter

public DOMFilter(RuleBasedFilter filterDef,
                 PatternContext context)
Create a new DOM filter.

Parameters:
filterDef - The definition of the filter that contains the rules to apply to the node and its children.
context - The context to use.
See Also:
AbstractFilter.AbstractFilter(RuleBasedFilter, boolean, PatternContext)

DOMFilter

public DOMFilter(List rules,
                 boolean normalize,
                 PatternContext context,
                 FilterContextFactory filterContextFactory)
Create a new DOM filter.

*** The rules MUST have been sorted previously. This filter doesn't sort the rules by itself. ***

Parameters:
rules - The list of sorted rules.
context - The context to use when running rules.
normalize - The default value for text normalization if not specified at rule level.
filterContextFactory - The factory that can create a new filter context.
See Also:
Rule, Rule.COMPARATOR
Method Detail

ignore

public void ignore(Object node)
            throws ExecutionException
Ignore the node : don't produce any output.

Parameters:
node - The node to ignore.
Throws:
ExecutionException - Propagation from RunnableRuleBasedFilter.applyFilter(Object).
See Also:
RunnableRuleBasedFilter.ignore(java.lang.Object)

applyRules

public void applyRules(Object node,
                       DataSet dataSet)
                throws ExecutionException
Apply the filter on the children of the given node. Left the node as-is, and apply the filter on its content if any.

Parameters:
node - The current node.
dataSet - The current data set.
Throws:
ExecutionException - Propagation from RunnableRuleBasedFilter.applyFilter(Object).
See Also:
RunnableRuleBasedFilter.applyRules(Object, DataSet)

forward

public void forward(QName[] channelNames,
                    Executable action,
                    DataSet dataSet)
             throws ExecutionException
Forward some content to some channels.

Parameters:
channelNames - The name of the channels to forward to, or null.
action - Contains the subactions to run before. This may produce some XML content to forward.
dataSet - The set of datas to use when running.
Throws:
ExecutionException
See Also:
RunnableRuleBasedFilter.forward(QName[], Executable, DataSet)

normalize

public void normalize(Object node)
Merge adjacent text nodes in the direct children of a given node.

Specified by:
normalize in class AbstractFilter
Parameters:
node - The DOM node to normalize.
See Also:
AbstractFilter.normalize(java.lang.Object)