KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > tools > xjc > runtime > Discarder


1 package com.sun.tools.xjc.runtime;
2
3 import org.xml.sax.Attributes JavaDoc;
4 import org.xml.sax.SAXException JavaDoc;
5
6 /**
7  * UnmarshallingEventHandler implementation that discards the whole sub-tree.
8  *
9  * @author
10  * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
11  */

12 class Discarder implements UnmarshallingEventHandler {
13     
14     private final UnmarshallingContext context;
15
16     // nest level of elements.
17
private int depth = 0;
18     
19     
20     public Discarder(UnmarshallingContext _ctxt) {
21         this.context = _ctxt;
22     }
23
24     public void enterAttribute(String JavaDoc uri, String JavaDoc local, String JavaDoc qname) throws SAXException JavaDoc {
25     }
26
27     public void enterElement(String JavaDoc uri, String JavaDoc local, String JavaDoc qname, Attributes JavaDoc atts) throws SAXException JavaDoc {
28         depth++;
29     }
30
31     public void leaveAttribute(String JavaDoc uri, String JavaDoc local, String JavaDoc qname) throws SAXException JavaDoc {
32     }
33
34     public void leaveElement(String JavaDoc uri, String JavaDoc local, String JavaDoc qname) throws SAXException JavaDoc {
35         depth--;
36         if(depth==0)
37             context.popContentHandler();
38     }
39
40     public Object JavaDoc owner() {
41         return null;
42     }
43
44     public void text(String JavaDoc s) throws SAXException JavaDoc {
45     }
46
47     public void leaveChild(int nextState) throws SAXException JavaDoc {
48     }
49
50 }
51
Popular Tags