Package eu.bandm.tools.message
Class MessageLocationFilter<D>
java.lang.Object
eu.bandm.tools.message.SingleSender<SimpleMessage<D>>
eu.bandm.tools.message.MessageLocationFilter<D>
- Type Parameters:
D
- the document identifier type.
- All Implemented Interfaces:
MessageReceiver<SimpleMessage<D>>
public class MessageLocationFilter<D>
extends SingleSender<SimpleMessage<D>>
implements MessageReceiver<SimpleMessage<D>>
A filter which propagates only those messages which lie in certain
areas of locations.
These are given by triples (String, fromLine, toLine), with toLine
exclusive.
Only the line numbers of locations are compared.
The string must appear as a SUFFIX of the "String.valueOf()" of the DocId.
This seems a "crude" method, but is very adequate to practice.
All add/remove methods of filter elements convert to this format.
Additional boolean parameters determine whether to pass or suppress location-less messages, and if no regions specified means ALL or NONE to pass.
Additional boolean parameters determine whether to pass or suppress location-less messages, and if no regions specified means ALL or NONE to pass.
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Whether no region set means to let pass every messageprotected boolean
Whether messages without locations are let pass.Set of all enabled reagions.Fields inherited from class eu.bandm.tools.message.SingleSender
receiver
-
Constructor Summary
ConstructorDescriptionMessageLocationFilter
(MessageReceiver<SimpleMessage<D>> d, boolean emptyList, boolean locationLess) Only constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Evident.void
Evident.(package private) void
Evident.void
Evident.void
dump
(PrintStream p) Prints the complete filter state.boolean
Test whether the location is completely contained in one of the regions.void
receive
(SimpleMessage<D> m) Pass the message to theSingleSender.receiver
, if the filter criterion is met.void
Evidentvoid
removeRegion
(D docId, int from, int to) Evident.void
removeRegion
(Location<D> loc) Evident.(package private) void
Evident.void
removeRegion
(String docId, int from, int to) Evident.void
setEmptyList
(boolean el) Evident.void
setPassLocationLess
(boolean ll) Evident.Methods inherited from class eu.bandm.tools.message.SingleSender
getReceiver, send, setReceiver
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface eu.bandm.tools.message.MessageReceiver
ifSubcriticalThen, ifSubcriticalThen, ifSubcriticalThenElse
-
Field Details
-
regions
Set of all enabled reagions. -
locationLess
protected boolean locationLessWhether messages without locations are let pass. -
emptyList
protected boolean emptyListWhether no region set means to let pass every message
-
-
Constructor Details
-
MessageLocationFilter
public MessageLocationFilter(MessageReceiver<SimpleMessage<D>> d, boolean emptyList, boolean locationLess) Only constructor.- Parameters:
d
- the target of all messages passed.emptyList
- whether no region set means to let pass every message.locationLess
- whether messages without locations are let pass.
-
-
Method Details
-
removeAll
public void removeAll()Evident -
setPassLocationLess
public void setPassLocationLess(boolean ll) Evident.- Parameters:
ll
- the new value of the flag.
-
setEmptyList
public void setEmptyList(boolean el) Evident.- Parameters:
el
- the new value of the flag.
-
addRegion
Evident.- Parameters:
reg
- region to add to the filter.
-
addRegion
Evident.- Parameters:
docId
- the document idfrom
- the starting line number.to
- the ending line number, inclisive.
-
addRegion
Evident.- Parameters:
docId
- the document idfrom
- the starting line number.to
- the ending line number, inclisive.
-
addRegion
Evident.- Parameters:
loc
- the only location in the new region.
-
removeRegion
Evident.- Parameters:
reg
- the region to remove.
-
removeRegion
Evident.- Parameters:
docId
- the document idfrom
- the starting line number.to
- the ending line number, inclisive.
-
removeRegion
Evident.- Parameters:
docId
- the document idfrom
- the starting line number.to
- the ending line number, inclisive.
-
removeRegion
Evident.- Parameters:
loc
- the location for which (a previously added) singleton region shall be removed.
-
match
Test whether the location is completely contained in one of the regions. The document id must only end with the specified String. (Heuristically, it may also end with the string plus an appended double quote.)- Parameters:
loc
- the location to test- Returns:
- the test verdict
-
receive
Pass the message to theSingleSender.receiver
, if the filter criterion is met.- Specified by:
receive
in interfaceMessageReceiver<D>
- Parameters:
m
- message to propagate.
-
dump
Prints the complete filter state.- Parameters:
p
- print stream for the text output.
-