1   /**
2    * LOGBack: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 1999-2006, 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  
11  package ch.qos.logback.core.joran.action.ext;
12  
13  import org.xml.sax.Attributes;
14  
15  import ch.qos.logback.core.joran.action.Action;
16  import ch.qos.logback.core.joran.spi.ActionException;
17  import ch.qos.logback.core.joran.spi.InterpretationContext;
18  
19  
20  
21  public class IncAction extends Action {
22  
23    static public int  beginCount;
24    static public int  endCount;
25    static public int  errorCount;
26  
27    static public void reset() {
28      beginCount = 0;
29      endCount = 0;
30      errorCount = 0;
31    }
32    /**
33     * Instantiates an layout of the given class and sets its name.
34     *
35     */
36    public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException {
37      //System.out.println("IncAction Begin called");
38      beginCount++;
39      String val = attributes.getValue("increment");
40      if(!"1".equals(val)) {
41        errorCount++;
42        throw new ActionException();
43      }
44    }
45  
46    /**
47     * Once the children elements are also parsed, now is the time to activate
48     * the appender options.
49     */
50    public void end(InterpretationContext ec, String name) {
51      endCount++;
52    }
53  }