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.
  • Field Details

  • 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 message
      locationLess - 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

      public void addRegion(String docId, int from, int to)
      Evident
    • addRegion

      public void addRegion(D docId, int from, int to)
      Evident
    • addRegion

      public void addRegion(Location<D> loc)
      Evident
    • removeRegion

      Evident
    • removeRegion

      public void removeRegion(String docId, int from, int to)
      Evident
    • removeRegion

      public void removeRegion(D docId, int from, int to)
      Evident
    • removeRegion

      public void removeRegion(Location<D> loc)
      Evident
    • match

      public boolean match(Location<D> loc)
      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

      public void receive(SimpleMessage<D> m)
      Pass the message to the SingleSender.receiver, if the filter criterion is met.
      Specified by:
      receive in interface MessageReceiver<D>
    • dump

      public void dump(PrintStream p)
      Prints the complete filter state.