1   
2   
3   
4   
5   
6   
7   
8   package net.sf.jour.config.impl.runtime;
9   
10  import org.xml.sax.Attributes;
11  import org.xml.sax.SAXException;
12  
13  /***
14   * UnmarshallingEventHandler implementation that discards the whole sub-tree.
15   * 
16   * @author
17   *     Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
18   */
19  class Discarder implements UnmarshallingEventHandler {
20      
21      private final UnmarshallingContext context;
22  
23      
24      private int depth = 0;
25      
26      
27      public Discarder(UnmarshallingContext _ctxt) {
28          this.context = _ctxt;
29      }
30  
31      public void enterAttribute(String uri, String local, String qname) throws SAXException {
32      }
33  
34      public void enterElement(String uri, String local, String qname, Attributes atts) throws SAXException {
35          depth++;
36      }
37  
38      public void leaveAttribute(String uri, String local, String qname) throws SAXException {
39      }
40  
41      public void leaveElement(String uri, String local, String qname) throws SAXException {
42          depth--;
43          if(depth==0)
44              context.popContentHandler();
45      }
46  
47      public Object owner() {
48          return null;
49      }
50  
51      public void text(String s) throws SAXException {
52      }
53  
54      public void leaveChild(int nextState) throws SAXException {
55      }
56  
57  }