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

  • 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

      public void addRegion(String docId, int from, int to)
      Evident.
      Parameters:
      docId - the document id
      from - the starting line number.
      to - the ending line number, inclisive.
    • addRegion

      public void addRegion(D docId, int from, int to)
      Evident.
      Parameters:
      docId - the document id
      from - the starting line number.
      to - the ending line number, inclisive.
    • addRegion

      public void addRegion(Location<D> loc)
      Evident.
      Parameters:
      loc - the only location in the new region.
    • removeRegion

      Evident.
      Parameters:
      reg - the region to remove.
    • removeRegion

      public void removeRegion(String docId, int from, int to)
      Evident.
      Parameters:
      docId - the document id
      from - the starting line number.
      to - the ending line number, inclisive.
    • removeRegion

      public void removeRegion(D docId, int from, int to)
      Evident.
      Parameters:
      docId - the document id
      from - the starting line number.
      to - the ending line number, inclisive.
    • removeRegion

      public void removeRegion(Location<D> loc)
      Evident.
      Parameters:
      loc - the location for which (a previously added) singleton region shall be removed.
    • 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.)
      Parameters:
      loc - the location to test
      Returns:
      the test verdict
    • 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>
      Parameters:
      m - message to propagate.
    • dump

      public void dump(PrintStream p)
      Prints the complete filter state.
      Parameters:
      p - print stream for the text output.