class RegexFilteringInterceptor implements Interceptor {

  @Override
  /**
   * Returns the event if it passes the regular expression filter and null
   * otherwise.
   */
  public Event intercept(Event event) {
    // We've already ensured here that at most one of includeRegex and
    // excludeRegex are defined.

    if (!excludeEvents) {
      if (regex.matcher(new String(event.getBody())).find()) {
        return event;
      } else {
        return null;
      }
    } else {
      if (regex.matcher(new String(event.getBody())).find()) {
        return null;
      } else {
        return event;
      }
    }
  }

  private  RegexFilteringInterceptor(Pattern regex, boolean excludeEvents);

}