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  
14  import org.xml.sax.Attributes;
15  
16  import ch.qos.logback.core.joran.action.Action;
17  import ch.qos.logback.core.joran.spi.InterpretationContext;
18  
19  
20  
21  public class TouchAction extends Action {
22  
23    public static final String KEY = "touched";
24    
25    public TouchAction() {
26    }
27    /**
28     * Instantiates an layout of the given class and sets its name.
29     *
30     */
31    public void begin(InterpretationContext ec, String name, Attributes attributes) {
32      Integer i = (Integer) ec.getContext().getObject(KEY);
33      if(i == null) {
34        ec.getContext().putObject(KEY, new Integer(1));
35      } else {
36        ec.getContext().putObject(KEY, new Integer(i.intValue()+1));
37      }
38    }
39  
40    /**
41     * Once the children elements are also parsed, now is the time to activate
42     * the appender options.
43     */
44    public void end(InterpretationContext ec, String name) {
45    }
46  }