View Javadoc

1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2008, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  package ch.qos.logback.classic.turbo;
11  
12  import ch.qos.logback.core.spi.FilterReply;
13  
14  /**
15   * An abstract class containing support for {@link #onMatch} on {@link #onMismatch} 
16   * attributes, shared by many but not all tubo filters.
17   *  
18   * @author Ceki Gulcu
19   */
20  public abstract class MatchingFilter extends TurboFilter {
21  
22    protected FilterReply onMatch = FilterReply.NEUTRAL;
23    protected FilterReply onMismatch = FilterReply.NEUTRAL;
24      
25    final public void setOnMatch(String action) {
26      if ("NEUTRAL".equals(action)) {
27        onMatch = FilterReply.NEUTRAL;
28      } else if ("ACCEPT".equals(action)) {
29        onMatch = FilterReply.ACCEPT;
30      } else if ("DENY".equals(action)) {
31        onMatch = FilterReply.DENY;
32      }
33    }
34  
35    final public void setOnMismatch(String action) {
36      if ("NEUTRAL".equals(action)) {
37        onMismatch = FilterReply.NEUTRAL;
38      } else if ("ACCEPT".equals(action)) {
39        onMismatch = FilterReply.ACCEPT;
40      } else if ("DENY".equals(action)) {
41        onMismatch = FilterReply.DENY;
42      }
43    }
44  }