Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, QOS.ch. All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
package ch.qos.logback.core.filter;
The value of the AbstractMatcherFilter.onMatch and AbstractMatcherFilter.onMismatch attributes is set to ch.qos.logback.core.spi.FilterReply.NEUTRAL, so that a badly configured evaluator filter does not disturb the functioning of the filter chain.

It is expected that one of the two attributes will have its value changed to ch.qos.logback.core.spi.FilterReply.ACCEPT or ch.qos.logback.core.spi.FilterReply.DENY. That way, it is possible to decide if a given result must be returned after the evaluation either failed or succeeded.

For more information about filters, please refer to the online manual at http://logback.qos.ch/manual/filters.html

Author(s):
Ceki Gülcü
Sébastien Pennec
public class EvaluatorFilter<E> extends AbstractMatcherFilter<E> {
  public void start() {
    if ( != null) {
      super.start();
    } else {
      addError("No evaluator set for filter " + this.getName());
    }
  }
  public EventEvaluator<E> getEvaluator() {
    return ;
  }
  public void setEvaluator(EventEvaluator<E> evaluator) {
    this. = evaluator;
  }
  public FilterReply decide(E event) {
    // let us not throw an exception
    // see also bug #17.
    if (!isStarted() || !.isStarted()) {
      return .;
    }
    try {
      if (.evaluate(event)) {
        return ;
      } else {
        return ;
      }
    } catch (EvaluationException e) {
      addError("Evaluator " + .getName() + " threw an exception"e);
      return .;
    }
  }
New to GrepCode? Check out our FAQ X