View Javadoc

1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2009, 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 chapter10.implicit;
11  
12  import org.xml.sax.Attributes;
13  
14  import ch.qos.logback.core.joran.action.ImplicitAction;
15  import ch.qos.logback.core.joran.spi.InterpretationContext;
16  import ch.qos.logback.core.joran.spi.Pattern;
17  
18  /**
19   * 
20   * A rather trivial implicit action which is applicable if an element has a
21   * printme attribute set to true.
22   * 
23   * @author Ceki Gülcü
24   */
25  public class PrintMeImplicitAction extends ImplicitAction {
26  
27    public boolean isApplicable(Pattern pattern, Attributes attributes,
28        InterpretationContext ec) {
29      String printmeStr = attributes.getValue("printme");
30  
31      return Boolean.valueOf(printmeStr).booleanValue();
32    }
33  
34    public void begin(InterpretationContext ec, String name, Attributes attributes) {
35      System.out.println("Element [" + name + "] asked to be printed.");
36    }
37  
38    public void end(InterpretationContext ec, String name) {
39    }
40  }