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.joran.action;
 
 import java.util.Map;
 
 
 
 abstract public class AbstractEventEvaluatorAction extends Action {
 
   boolean inError = false;

  
Instantiates an evaluator of the given class and sets its name.
 
   public void begin(InterpretationContext ecString nameAttributes attributes) {
     // Let us forget about previous errors (in this instance)
      = false;
      = null;
 
     String className = attributes.getValue();
     if (OptionHelper.isEmpty(className)) {
       className = defaultClassName();
       addInfo("Assuming default evaluator class [" + className + "]");
     }
 
     if (OptionHelper.isEmpty(className)) {
       className = defaultClassName();
        = true;
       addError("Mandatory \"" + 
           + "\" attribute not set for <evaluator>");
       return;
     }
 
     String evaluatorName = attributes.getValue(.);
     if (OptionHelper.isEmpty(evaluatorName)) {
        = true;
       addError("Mandatory \"" + 
           + "\" attribute not set for <evaluator>");
       return;
     }
     try {
        = (EventEvaluator) OptionHelper.instantiateByClassName(
           classNamech.qos.logback.core.boolex.EventEvaluator.class);
 
       .setContext(this.);
       .setName(evaluatorName);
 
       ec.pushObject();
       addInfo("Adding evaluator named [" + evaluatorName
           + "] to the object stack");
 
     } catch (Exception oops) {
        = true;
       addError("Could not create evaluator of type " + className + "]."oops);
     }
   }

  
Returns a default class name in case the class attribute is not specified

Returns:
 
   abstract protected String defaultClassName();

  
Once the children elements are also parsed, now is the time to activate the evaluator options.
 
   @SuppressWarnings("unchecked")
   public void end(InterpretationContext ecString e) {
     if () {
       return;
     }
 
     if ( instanceof LifeCycle) {
       ((LifeCycle).start();
       addInfo("Starting evaluator named [" + .getName() + "]");
     }
 
     Object o = ec.peekObject();
    if (o != ) {
      addWarn("The object on the top the of the stack is not the evaluator pushed earlier.");
    } else {
      ec.popObject();
      try {
        Map<StringEventEvaluatorevaluatorMap = (Map<StringEventEvaluator>) 
            .getObject(.);
        if(evaluatorMap == null) {
          addError("Could not find EvaluatorMap");
        } else {
          evaluatorMap.put(.getName(), );
        }
      } catch (Exception ex) {
        addError("Could not set evaluator named [" +  + "]."ex);
      }
    }
  }
  public void finish(InterpretationContext ec) {
  }
New to GrepCode? Check out our FAQ X