Package eu.bandm.tools.message
Class MessageLocationFilter<D>
java.lang.Object
eu.bandm.tools.message.SingleSender<SimpleMessage<D>>
eu.bandm.tools.message.MessageLocationFilter<D>
- 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
Evidentvoid
Evident(package private) void
Evidentvoid
Evidentvoid
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) Evidentvoid
removeRegion
(Location<D> loc) Evident(package private) void
Evidentvoid
removeRegion
(String docId, int from, int to) Evidentvoid
setEmptyList
(boolean el) Evidentvoid
setPassLocationLess
(boolean ll) EvidentMethods inherited from class eu.bandm.tools.message.SingleSender
getReceiver, send, setReceiver
-
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:
emptyList
- whether no region set means to let pass every messagelocationLess
- whether messages without locations are let pass.
-
-
Method Details
-
removeAll
public void removeAll()Evident -
setPassLocationLess
public void setPassLocationLess(boolean ll) Evident -
setEmptyList
public void setEmptyList(boolean el) Evident -
addRegion
Evident -
addRegion
Evident -
addRegion
Evident -
addRegion
Evident -
removeRegion
Evident -
removeRegion
Evident -
removeRegion
Evident -
removeRegion
Evident -
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. -
receive
Pass the message to theSingleSender.receiver
, if the filter criterion is met.- Specified by:
receive
in interfaceMessageReceiver<D>
-
dump
Prints the complete filter state.
-