KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > tools > generator > SAXBindingsHandlerImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.tools.generator;
20
21 import org.xml.sax.*;
22
23 public class SAXBindingsHandlerImpl implements SAXBindingsHandler {
24
25     private ParsletBindings parslets = new ParsletBindings();
26     private ElementBindings elements = new ElementBindings();
27
28     private static final String JavaDoc ATT_PARSLET = "parslet"; // NOI18N
29
private static final String JavaDoc ATT_RETURN = "return"; // NOI18N
30

31     private static final String JavaDoc ATT_ELEMENT = "element"; // NOI18N
32
private static final String JavaDoc ATT_TYPE = "type"; // NOI18N
33
private static final String JavaDoc ATT_METHOD = "method"; // NOI18N
34

35     public ParsletBindings getParsletBindings() {
36         if (parslets.isEmpty()) return null;
37         return parslets;
38     }
39     
40     public ElementBindings getElementBindings() {
41         if (elements.isEmpty()) return null;
42         return elements;
43     }
44     
45     public void handle_parslet(final Attributes meta) throws SAXException {
46         if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("handle_parslet: " + meta); // NOI18N
47

48         String JavaDoc parslet = meta.getValue(ATT_PARSLET);
49         String JavaDoc back = meta.getValue(ATT_RETURN);
50         
51         parslets.put(parslet, back);
52     }
53     
54     public void start_SAX_bindings(final Attributes meta) throws SAXException {
55         if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("start_SAX_bindings: " + meta); // NOI18N
56

57     }
58     
59     public void end_SAX_bindings() throws SAXException {
60         if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("end_SAX_bindings()"); // NOI18N
61
}
62     
63     public void start_bind(final Attributes meta) throws SAXException {
64         if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("start_bind: " + meta); // NOI18N
65

66         String JavaDoc element = meta.getValue(ATT_ELEMENT);
67         String JavaDoc method = meta.getValue(ATT_METHOD);
68         String JavaDoc parslet = meta.getValue(ATT_PARSLET);
69         String JavaDoc type = meta.getValue(ATT_TYPE);
70         
71         elements.put(element, method, parslet, type);
72     }
73     
74     public void end_bind() throws SAXException {
75         if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("end_bind()"); // NOI18N
76
}
77     
78     /**
79      * An empty element event handling method.
80      * @param data value or null
81      */

82     public void handle_attbind(Attributes meta) throws SAXException {
83     }
84     
85 }
86
Popular Tags