Class CompoundMessageFilter

java.lang.Object
org.bzdev.drama.common.MessageFilter
org.bzdev.drama.common.CompoundMessageFilter

public class CompoundMessageFilter extends MessageFilter
A message filter that applies a series of message filters sequentially. The filters are applied in the order in which they are added by calls to addFilter. By default and for efficiency reasons regarding the use of this class in GenericDomain, no test for a circular filter (one in which a filter is added to itself) is done. A method named circularityTest is provided for cases in which such a test is necessary. A circularity test is not needed in the case where a CompoundMessageFilter is created and never added to another CompoundMessageFilter.
  • Constructor Details

    • CompoundMessageFilter

      public CompoundMessageFilter()
  • Method Details

    • addFilter

      public void addFilter(MessageFilter filter)
      Add a filter.
      Parameters:
      filter - the filter to add
    • circularityTest

      public boolean circularityTest(MessageFilter filter)
      Test that adding a filter will not create a circular compound filter - one whose filterMessage method will never terminate.
      Parameters:
      filter - the message filter that would be added
      Returns:
      true if the circularity test passes; false otherwise
    • filterMessage

      public Object filterMessage(Object msg)
      Description copied from class: MessageFilter
      Filter a message.
      Overrides:
      filterMessage in class MessageFilter
      Parameters:
      msg - the original message
      Returns:
      a modified message; MessageFilter.DELETED if the message should be dropped