package com.rimfaxe.xml.xmlreader;
import java.io.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.XMLReaderAdapter;
import org.xml.sax.helpers.DefaultHandler;
/** JAXP compatible XMLReader wrapper for Sparta.
<blockquote><small> Copyright (C) 2002 Hewlett-Packard Company.
This file is part of Sparta, an XML Parser, DOM, and XPath library.
This library is free software; you can redistribute it and/or
modify it under the terms of the <a href="doc-files/LGPL.txt">GNU
Lesser General Public License</a> as published by the Free Software
Foundation; either version 2.1 of the License, or (at your option)
any later version. This library is distributed in the hope that it
will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. </small></blockquote>
@version $Date: 2002/12/05 04:37:14 $ $Revision: 1.2 $
@author Sergio Marti
*/
public class SAXParserImpl extends SAXParser
{
private final XMLReaderImpl reader_;
private boolean nsAware_ = false;
public SAXParserImpl(boolean nsAware) {
super();
nsAware_ = nsAware;
reader_ = new XMLReaderImpl(nsAware);
}
/** Returns the SAX parser that is encapsultated by the implementation
of this class.
@deprecated because org.xml.sax.Parser is deprecated
*/
public org.xml.sax.Parser getParser() {
return new XMLReaderAdapter(reader_);
}
// Returns the XMLReader that is encapsulated by the implementation of
// this class.
public XMLReader getXMLReader() {
return reader_;
}
// Returns the particular property requested for in the underlying
// implementation of XMLReader.
public java.lang.Object getProperty(java.lang.String name) {
return reader_.getProperty(name);
}
// Sets the particular property in the underlying implementation of
// XMLReader.
public void setProperty(java.lang.String name, java.lang.Object value) {
reader_.setProperty(name, value);
}
// Indicates whether or not this parser is configured to understand
// namespaces.
public boolean isNamespaceAware() {
return nsAware_;
}
// Indicates whether or not this parser is configured to validate XML
// documents.
public boolean isValidating() {
return false;
}
// Parse the content of the file specified as XML using the specified
// DefaultHandler.
public void parse(java.io.File f, DefaultHandler dh)
throws SAXException, IOException {
reader_.init(dh);
try {
Parser.parse(f, reader_);
} catch (ParseException pe) {
dh.fatalError(new SAXParseException(pe.getMessage(),
"", f.toString(),
-1, -1,
pe));
}
}
// Parse the content given InputSource as XML using the specified
// DefaultHandler.
public void parse(InputSource is, DefaultHandler dh)
throws SAXException, IOException {
reader_.init(dh);
reader_.parse(is);
}
// Parse the content of the given InputStream instance as XML using
// the specified DefaultHandler.
public void parse(java.io.InputStream is, DefaultHandler dh)
throws SAXException, IOException {
parse(new InputSource(is), dh);
}
// Parse the content of the given InputStream instance as XML using
// the specified DefaultHandler.
public void parse(java.io.InputStream is, DefaultHandler dh,
java.lang.String systemId)
throws SAXException, IOException {
reader_.init(dh);
try {
Parser.parse(systemId, is, reader_);
} catch (ParseException pe) {
dh.fatalError(new SAXParseException(pe.getMessage(),
"", systemId,
-1, -1,
pe));
}
}
// Parse the content described by the giving Uniform Resource Identifier
// (URI) as XML using the specified DefaultHandler.
public void parse(java.lang.String uri, DefaultHandler dh)
throws SAXException, IOException {
reader_.init(dh);
reader_.parse(uri);
}
}