mev-4.0.01/source/org/tigr/remote/protocol/parser/XMLResponseParser.java

Code
Comments
Other
Rev Date Author Line
2 26 Feb 07 jari 1 /*
2 26 Feb 07 jari 2 Copyright @ 1999-2003, The Institute for Genomic Research (TIGR).
2 26 Feb 07 jari 3 All rights reserved.
2 26 Feb 07 jari 4 */
2 26 Feb 07 jari 5 /*
2 26 Feb 07 jari 6  * $RCSfile: XMLResponseParser.java,v $
2 26 Feb 07 jari 7  * $Revision: 1.3 $
2 26 Feb 07 jari 8  * $Date: 2005/03/10 15:28:23 $
2 26 Feb 07 jari 9  * $Author: braistedj $
2 26 Feb 07 jari 10  * $State: Exp $
2 26 Feb 07 jari 11  */
2 26 Feb 07 jari 12 package org.tigr.remote.protocol.parser;
2 26 Feb 07 jari 13
2 26 Feb 07 jari 14 import org.tigr.util.ConfMap;
2 26 Feb 07 jari 15 import org.xml.sax.InputSource;
2 26 Feb 07 jari 16 import org.xml.sax.XMLReader;
2 26 Feb 07 jari 17
2 26 Feb 07 jari 18 public class XMLResponseParser extends Parser {
2 26 Feb 07 jari 19
2 26 Feb 07 jari 20     /**
2 26 Feb 07 jari 21      * Creates a <code>XMLResponseParser</code> with specified configuration.
2 26 Feb 07 jari 22      */
2 26 Feb 07 jari 23     public XMLResponseParser( ConfMap cfg ) {
2 26 Feb 07 jari 24         this.cfg = cfg;
2 26 Feb 07 jari 25     }
2 26 Feb 07 jari 26
2 26 Feb 07 jari 27     /**
2 26 Feb 07 jari 28      * Parses the specified input stream and returns a <code>Response</code>.
2 26 Feb 07 jari 29      */
2 26 Feb 07 jari 30     public org.tigr.remote.protocol.Response parseResponse( java.io.InputStream in ) throws ParserException {
2 26 Feb 07 jari 31         try {
2 26 Feb 07 jari 32             XMLReader reader = ParserUtil.createReader( cfg );
2 26 Feb 07 jari 33             SAXResponseHandler handler = new SAXResponseHandler( cfg );
2 26 Feb 07 jari 34             reader.setContentHandler( handler );
2 26 Feb 07 jari 35             reader.setErrorHandler( handler );
2 26 Feb 07 jari 36             reader.parse( new InputSource(in) );
2 26 Feb 07 jari 37
2 26 Feb 07 jari 38             return handler.getResponse();
2 26 Feb 07 jari 39         } catch (Exception e) {
2 26 Feb 07 jari 40             throw new ParserException("XML response parsing error", e );
2 26 Feb 07 jari 41         }
2 26 Feb 07 jari 42     }
2 26 Feb 07 jari 43
2 26 Feb 07 jari 44     private ConfMap cfg;
2 26 Feb 07 jari 45 }
2 26 Feb 07 jari 46