Mercurial > lasercutter
comparison 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 |
comparison
equal
deleted
inserted
replaced
9:35cf337adfcf | 10:ef7dbbd6452c |
---|---|
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 **/ | |
10 | |
11 /* rich Dec 17, 2007 */ | |
12 | |
13 package clojure.lang; | |
14 | |
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; | |
20 | |
21 public class XMLHandler extends DefaultHandler{ | |
22 ContentHandler h; | |
23 | |
24 | |
25 public XMLHandler(ContentHandler h){ | |
26 this.h = h; | |
27 } | |
28 | |
29 public void setDocumentLocator(Locator locator){ | |
30 h.setDocumentLocator(locator); | |
31 } | |
32 | |
33 public void startDocument() throws SAXException{ | |
34 h.startDocument(); | |
35 } | |
36 | |
37 public void endDocument() throws SAXException{ | |
38 h.endDocument(); | |
39 } | |
40 | |
41 public void startPrefixMapping(String prefix, String uri) throws SAXException{ | |
42 h.startPrefixMapping(prefix, uri); | |
43 } | |
44 | |
45 public void endPrefixMapping(String prefix) throws SAXException{ | |
46 h.endPrefixMapping(prefix); | |
47 } | |
48 | |
49 public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException{ | |
50 h.startElement(uri, localName, qName, atts); | |
51 } | |
52 | |
53 public void endElement(String uri, String localName, String qName) throws SAXException{ | |
54 h.endElement(uri, localName, qName); | |
55 } | |
56 | |
57 public void characters(char ch[], int start, int length) throws SAXException{ | |
58 h.characters(ch, start, length); | |
59 } | |
60 | |
61 public void ignorableWhitespace(char ch[], int start, int length) throws SAXException{ | |
62 h.ignorableWhitespace(ch, start, length); | |
63 } | |
64 | |
65 public void processingInstruction(String target, String data) throws SAXException{ | |
66 h.processingInstruction(target, data); | |
67 } | |
68 | |
69 public void skippedEntity(String name) throws SAXException{ | |
70 h.skippedEntity(name); | |
71 } | |
72 | |
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 } |