diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/clojure/lang/XMLHandler.java	Sat Aug 21 06:25:44 2010 -0400
     1.3 @@ -0,0 +1,89 @@
     1.4 +/**
     1.5 + *   Copyright (c) Rich Hickey. All rights reserved.
     1.6 + *   The use and distribution terms for this software are covered by the
     1.7 + *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
     1.8 + *   which can be found in the file epl-v10.html at the root of this distribution.
     1.9 + *   By using this software in any fashion, you are agreeing to be bound by
    1.10 + * 	 the terms of this license.
    1.11 + *   You must not remove this notice, or any other, from this software.
    1.12 + **/
    1.13 +
    1.14 +/* rich Dec 17, 2007 */
    1.15 +
    1.16 +package clojure.lang;
    1.17 +
    1.18 +import org.xml.sax.Attributes;
    1.19 +import org.xml.sax.ContentHandler;
    1.20 +import org.xml.sax.Locator;
    1.21 +import org.xml.sax.SAXException;
    1.22 +import org.xml.sax.helpers.DefaultHandler;
    1.23 +
    1.24 +public class XMLHandler extends DefaultHandler{
    1.25 +ContentHandler h;
    1.26 +
    1.27 +
    1.28 +public XMLHandler(ContentHandler h){
    1.29 +	this.h = h;
    1.30 +}
    1.31 +
    1.32 +public void setDocumentLocator(Locator locator){
    1.33 +	h.setDocumentLocator(locator);
    1.34 +}
    1.35 +
    1.36 +public void startDocument() throws SAXException{
    1.37 +	h.startDocument();
    1.38 +}
    1.39 +
    1.40 +public void endDocument() throws SAXException{
    1.41 +	h.endDocument();
    1.42 +}
    1.43 +
    1.44 +public void startPrefixMapping(String prefix, String uri) throws SAXException{
    1.45 +	h.startPrefixMapping(prefix, uri);
    1.46 +}
    1.47 +
    1.48 +public void endPrefixMapping(String prefix) throws SAXException{
    1.49 +	h.endPrefixMapping(prefix);
    1.50 +}
    1.51 +
    1.52 +public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException{
    1.53 +	h.startElement(uri, localName, qName, atts);
    1.54 +}
    1.55 +
    1.56 +public void endElement(String uri, String localName, String qName) throws SAXException{
    1.57 +	h.endElement(uri, localName, qName);
    1.58 +}
    1.59 +
    1.60 +public void characters(char ch[], int start, int length) throws SAXException{
    1.61 +	h.characters(ch, start, length);
    1.62 +}
    1.63 +
    1.64 +public void ignorableWhitespace(char ch[], int start, int length) throws SAXException{
    1.65 +	h.ignorableWhitespace(ch, start, length);
    1.66 +}
    1.67 +
    1.68 +public void processingInstruction(String target, String data) throws SAXException{
    1.69 +	h.processingInstruction(target, data);
    1.70 +}
    1.71 +
    1.72 +public void skippedEntity(String name) throws SAXException{
    1.73 +	h.skippedEntity(name);
    1.74 +}
    1.75 +
    1.76 +/*
    1.77 +public static void main(String[] args){
    1.78 +	try
    1.79 +		{
    1.80 +		ContentHandler dummy = new DefaultHandler();
    1.81 +		SAXParserFactory f =  SAXParserFactory.newInstance();
    1.82 +		//f.setNamespaceAware(true);
    1.83 +		SAXParser p = f.newSAXParser();
    1.84 +		p.parse("http://arstechnica.com/journals.rssx",new XMLHandler(dummy));
    1.85 +		}
    1.86 +	catch(Exception e)
    1.87 +		{
    1.88 +		e.printStackTrace();
    1.89 +		}
    1.90 +}
    1.91 +//*/
    1.92 +}