view src/clojure/lang/XMLHandler.java @ 10:ef7dbbd6452c

added clojure source goodness
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Aug 2010 06:25:44 -0400
parents
children
line wrap: on
line source
1 /**
2 * Copyright (c) Rich Hickey. All rights reserved.
3 * The use and distribution terms for this software are covered by the
4 * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
5 * which can be found in the file epl-v10.html at the root of this distribution.
6 * By using this software in any fashion, you are agreeing to be bound by
7 * the terms of this license.
8 * You must not remove this notice, or any other, from this software.
9 **/
11 /* rich Dec 17, 2007 */
13 package clojure.lang;
15 import org.xml.sax.Attributes;
16 import org.xml.sax.ContentHandler;
17 import org.xml.sax.Locator;
18 import org.xml.sax.SAXException;
19 import org.xml.sax.helpers.DefaultHandler;
21 public class XMLHandler extends DefaultHandler{
22 ContentHandler h;
25 public XMLHandler(ContentHandler h){
26 this.h = h;
27 }
29 public void setDocumentLocator(Locator locator){
30 h.setDocumentLocator(locator);
31 }
33 public void startDocument() throws SAXException{
34 h.startDocument();
35 }
37 public void endDocument() throws SAXException{
38 h.endDocument();
39 }
41 public void startPrefixMapping(String prefix, String uri) throws SAXException{
42 h.startPrefixMapping(prefix, uri);
43 }
45 public void endPrefixMapping(String prefix) throws SAXException{
46 h.endPrefixMapping(prefix);
47 }
49 public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException{
50 h.startElement(uri, localName, qName, atts);
51 }
53 public void endElement(String uri, String localName, String qName) throws SAXException{
54 h.endElement(uri, localName, qName);
55 }
57 public void characters(char ch[], int start, int length) throws SAXException{
58 h.characters(ch, start, length);
59 }
61 public void ignorableWhitespace(char ch[], int start, int length) throws SAXException{
62 h.ignorableWhitespace(ch, start, length);
63 }
65 public void processingInstruction(String target, String data) throws SAXException{
66 h.processingInstruction(target, data);
67 }
69 public void skippedEntity(String name) throws SAXException{
70 h.skippedEntity(name);
71 }
73 /*
74 public static void main(String[] args){
75 try
76 {
77 ContentHandler dummy = new DefaultHandler();
78 SAXParserFactory f = SAXParserFactory.newInstance();
79 //f.setNamespaceAware(true);
80 SAXParser p = f.newSAXParser();
81 p.parse("http://arstechnica.com/journals.rssx",new XMLHandler(dummy));
82 }
83 catch(Exception e)
84 {
85 e.printStackTrace();
86 }
87 }
88 //*/
89 }