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.boolex;
import  org.codehaus.janino.ScriptEvaluator;

Abstract class which sets the groundwork for janino based evaluations.

Parameters:
<E>
Author(s):
Ceki Gülcü
abstract public class JaninoEventEvaluatorBase<E> extends EventEvaluatorBase<E> {
  static Class EXPRESSION_TYPE = boolean.class;
  static Class[] THROWN_EXCEPTIONS = new Class[1];
  static public final int ERROR_THRESHOLD = 4;
  static {
  }
  private String expression;
  ScriptEvaluator scriptEvaluator;
  private int errorCount = 0;
  abstract protected String getDecoratedExpression();
  abstract protected String[] getParameterNames();
  abstract protected Class[] getParameterTypes();
  abstract protected Object[] getParameterValues(E event);
  protected List<MatchermatcherList = new ArrayList<Matcher>();
  public void start() {
    try {
      assert  != null;
       = new ScriptEvaluator(getDecoratedExpression(), ,
      super.start();
    } catch (Exception e) {
      addError(
          "Could not start evaluator with expression [" +  + "]"e);
    }
  }
  public boolean evaluate(E eventthrows EvaluationException {
    if (!isStarted()) {
      throw new IllegalStateException("Evaluator [" + 
          + "] was called in stopped state");
    }
    try {
      Boolean result = (Boolean.evaluate(getParameterValues(event));
      return result.booleanValue();
    } catch (Exception ex) {
      ++;
      if ( >= ) {
        stop();
      }
      throw new EvaluationException("Evaluator [" + 
          + "] caused an exception"ex);
    }
  }
  public String getExpression() {
    return ;
  }
  public void setExpression(String expression) {
    this. = expression;
  }
  public void addMatcher(Matcher matcher) {
    .add(matcher);
  }
  public List getMatcherList() {
    return ;
  }
New to GrepCode? Check out our FAQ X