public abstract class AbstractFaAction extends java.lang.Object implements java.io.Serializable, FaAction
implements the prototype of an FaAction
with initial
priority zero so that actions can be easily written as anonymous
classes. For a bunch of useful actions have a
look at the subpackage monq.jfa.actions
.
Constructor and Description |
---|
AbstractFaAction()
although this class is abstract, the constructor is needed to create
anonymous subclasses.
|
Modifier and Type | Method and Description |
---|---|
FaAction |
mergeWith(FaAction _other)
is eventually called by
Nfa.compile(monq.jfa.DfaRun.FailedMatchBehaviour, monq.jfa.FaAction) to create a
unified action from this object and another FaAction
object. |
AbstractFaAction |
setPriority(int p) |
public AbstractFaAction()
although this class is abstract, the constructor is needed to create anonymous subclasses.
public AbstractFaAction setPriority(int p)
public FaAction mergeWith(FaAction _other)
FaAction
is eventually called by Nfa.compile(monq.jfa.DfaRun.FailedMatchBehaviour, monq.jfa.FaAction)
to create a
unified action from this object and another FaAction
object. During compilation of an Nfa into a Dfa, two
regular expressions assigned to different actions may have
overlapping matches. In this case one of the actions'
mergeWith
methods is called with the other action as
parameter to create a unified action object.
There are only four permissible results this method may return:
this
completely unchanged,other
completely unchanged,null
to signal that no unified action exists.Both objects, this
and other
must be
treated read-only. Changing them may lead to unexpected
behaviour which is very hard to track down. To understand why
this is so, consider the two regular expressions ax?
and ay?
bound to actions X
and
Y
respectively. Both expressions match the string
"a"
, which will cause a call to
mergeWith
of either one of the actions. If merging
would integrate, say, Y into X and return
X, the changed X would also be run
for the
match "ax"
which most likely was not intended.
To get a simple priority based selection of one of the actions,
consider extending AbstractFaAction
.
Note: For two competing actions it is completely random
which of the mergeWith()
methods is
called. Consequently, implementations of this method should be as
symmetric as possible.