org.writersforge.catalan.process.workers.dispatch
Class MatchRunner

java.lang.Object
  extended byorg.writersforge.catalan.process.workers.dispatch.MatchRunner

public class MatchRunner
extends java.lang.Object

Single match constraint for the dispatcher.

Author:
jsheets

Constructor Summary
MatchRunner(java.lang.Class matchClass, IWorker[] workers, boolean isExclusive)
          Creates a new instance of MatchRunner that processes all nodes that implement a given class or interface.
MatchRunner(IWorker[] workers)
          Creates a new instance of MatchRunner that matches all nodes.
MatchRunner(java.lang.String matchPattern, IWorker[] workers, boolean isExclusive)
          Creates a new instance of MatchRunner that compares text to a regular expression.
 
Method Summary
 boolean isExclusive()
          Returns true if this MatchRunner is an exclusive processor.
 boolean isMatch(java.lang.Object node)
          Determines if the given node should be processed by this MatchRunner.
 java.lang.Object[] processNode(java.lang.Object node, IWorkProperties runtimeProps, IWorkspace workspace)
          Runs the data node through all workers associated with this MatchRunner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatchRunner

public MatchRunner(IWorker[] workers)
Creates a new instance of MatchRunner that matches all nodes.

Parameters:
workers - workers to send the input node through on matches

MatchRunner

public MatchRunner(java.lang.String matchPattern,
                   IWorker[] workers,
                   boolean isExclusive)
Creates a new instance of MatchRunner that compares text to a regular expression.

Parameters:
matchPattern - regular expression to match nodes against
workers - workers to send the input node through on matches
isExclusive - true to exclude matched nodes from other Matchers

MatchRunner

public MatchRunner(java.lang.Class matchClass,
                   IWorker[] workers,
                   boolean isExclusive)
Creates a new instance of MatchRunner that processes all nodes that implement a given class or interface.

Parameters:
matchClass - class or interface of nodes to match
workers - workers to send the input node through on matches
isExclusive - true to exclude matched nodes from other Matchers
Method Detail

isExclusive

public boolean isExclusive()
Returns true if this MatchRunner is an exclusive processor. All exclusive matchers run before non-exclusive matchers; all nodes successfully processed by an exclusive matcher are immediately removed from further processing.

Returns:
true if this is an exclusive matcher

isMatch

public boolean isMatch(java.lang.Object node)
Determines if the given node should be processed by this MatchRunner.

Parameters:
node - input data node
Returns:
true if this node should be processed

processNode

public java.lang.Object[] processNode(java.lang.Object node,
                                      IWorkProperties runtimeProps,
                                      IWorkspace workspace)
                               throws ProcessException
Runs the data node through all workers associated with this MatchRunner.

Parameters:
node - input data node
runtimeProps - extra runtime parameters
workspace - processing environment
Returns:
an array of processed nodes
Throws:
ProcessException - if an error occurs during worker processing