All pastes #739515 Raw Edit

zahidalinaqvi at gmail dot com

public java v1 · immutable
·published 2007-10-17 06:52 UTC
rendered paste body
/* * MySAXApp.java * * Created on September 2, 2007, 4:18 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package autoglo;import java.io.FileReader;import java.util.Vector;import org.xml.sax.SAXParseException;import org.xml.sax.XMLReader;import org.xml.sax.Attributes;import org.xml.sax.InputSource;import org.xml.sax.helpers.XMLReaderFactory;import org.xml.sax.helpers.DefaultHandler;/** * * @author gus */public class MySAXApp extends DefaultHandler {        private Vector files = new Vector();    private XMLReader xr;    private MySAXApp handler;    private FileReader r;        /** Creates a new instance of MySAXApp */    public MySAXApp() {        super();    }        public void parse() throws Exception{        xr = XMLReaderFactory.createXMLReader();	handler = new MySAXApp();	xr.setContentHandler(handler);	xr.setErrorHandler(handler);	r = new FileReader("/home/gus/papers/download/summary.out");	xr.parse(new InputSource(r));    }    public void startDocument (){}    public void endDocument (){}    public void error(SAXParseException e){}    public void fatalError(SAXParseException e){}        public void startElement (String uri, String name, String qName, Attributes atts){        System.out.println(atts.getValue(0));        System.out.println(atts.getValue(1));        System.out.println(atts.getValue(2));        System.out.println(atts.getValue(3));        this.add(atts.getValue(0),atts.getValue(1),atts.getValue(2),atts.getValue(3));    }    public void endElement (String uri, String name, String qName){}        public void characters (char ch[], int start, int length){}        public Vector getFiles(){        return files;    }        private void add(String number, String title, String name, String Abst ){        Vector arr =  new Vector();        arr.add(number);        arr.add(title);        arr.add(name);        arr.add(Abst);        System.out.println(files.add( arr ));    }}