| /* |
| * The Apache Software License, Version 1.1 |
| * |
| * |
| * Copyright (c) 1999,2000 The Apache Software Foundation. All rights |
| * reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions |
| * are met: |
| * |
| * 1. Redistributions of source code must retain the above copyright |
| * notice, this list of conditions and the following disclaimer. |
| * |
| * 2. Redistributions in binary form must reproduce the above copyright |
| * notice, this list of conditions and the following disclaimer in |
| * the documentation and/or other materials provided with the |
| * distribution. |
| * |
| * 3. The end-user documentation included with the redistribution, |
| * if any, must include the following acknowledgment: |
| * "This product includes software developed by the |
| * Apache Software Foundation (http://www.apache.org/)." |
| * Alternately, this acknowledgment may appear in the software itself, |
| * if and wherever such third-party acknowledgments normally appear. |
| * |
| * 4. The names "Xerces" and "Apache Software Foundation" must |
| * not be used to endorse or promote products derived from this |
| * software without prior written permission. For written |
| * permission, please contact apache@apache.org. |
| * |
| * 5. Products derived from this software may not be called "Apache", |
| * nor may "Apache" appear in their name, without prior written |
| * permission of the Apache Software Foundation. |
| * |
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR |
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| * SUCH DAMAGE. |
| * ==================================================================== |
| * |
| * This software consists of voluntary contributions made by many |
| * individuals on behalf of the Apache Software Foundation and was |
| * originally based on software copyright (c) 1999, International |
| * Business Machines, Inc., http://www.apache.org. For more |
| * information on the Apache Software Foundation, please see |
| * <http://www.apache.org/>. |
| */ |
| |
| package org.apache.xerces.parsers; |
| |
| import java.io.IOException; |
| import java.util.Hashtable; |
| import java.util.Locale; |
| |
| import org.apache.xerces.util.SymbolTable; |
| import org.apache.xerces.xni.XMLComponentManager; |
| import org.apache.xerces.xni.XMLDocumentHandler; |
| import org.apache.xerces.xni.XMLDTDHandler; |
| import org.apache.xerces.xni.XMLDTDContentModelHandler; |
| |
| import org.xml.sax.EntityResolver; |
| import org.xml.sax.ErrorHandler; |
| import org.xml.sax.InputSource; |
| import org.xml.sax.Locator; |
| import org.xml.sax.SAXException; |
| import org.xml.sax.SAXNotRecognizedException; |
| import org.xml.sax.SAXNotSupportedException; |
| |
| /** |
| * Base class of all parser configuration classes. |
| * |
| * @author Arnaud Le Hors, IBM |
| * |
| * @version $Id$ |
| */ |
| public abstract class ParserConfiguration |
| implements XMLComponentManager { |
| |
| // |
| // Constructors |
| // |
| |
| protected ParserConfiguration() { |
| } // <init> |
| |
| // |
| // Public methods |
| // |
| |
| /** |
| * Parses the input source specified by the given system identifier. |
| * <p> |
| * This method is equivalent to the following: |
| * <pre> |
| * parse(new InputSource(systemId)); |
| * </pre> |
| * |
| * @param source The input source. |
| * |
| * @exception org.xml.sax.SAXException Throws exception on SAX error. |
| * @exception java.io.IOException Throws exception on i/o error. |
| */ |
| public abstract void parse(String systemId) |
| throws SAXException, IOException; |
| |
| /** |
| * parse |
| * |
| * @param inputSource |
| * |
| * @exception org.xml.sax.SAXException |
| * @exception java.io.IOException |
| */ |
| public abstract void parse(InputSource inputSource) |
| throws SAXException, IOException; |
| |
| /** |
| * set document handler |
| */ |
| public abstract void setDocumentHandler(XMLDocumentHandler handler); |
| |
| /** |
| * set DTD handler |
| */ |
| public abstract void setDTDHandler(XMLDTDHandler handler); |
| |
| /** |
| * set DTD Content Model handler |
| */ |
| public abstract void |
| setDTDContentModelHandler(XMLDTDContentModelHandler handler); |
| |
| /** |
| * Sets the resolver used to resolve external entities. The EntityResolver |
| * interface supports resolution of public and system identifiers. |
| * |
| * @param resolver The new entity resolver. Passing a null value will |
| * uninstall the currently installed resolver. |
| */ |
| public abstract void setEntityResolver(EntityResolver resolver); |
| |
| /** |
| * Return the current entity resolver. |
| * |
| * @return The current entity resolver, or null if none |
| * has been registered. |
| * @see #setEntityResolver |
| */ |
| public abstract EntityResolver getEntityResolver(); |
| |
| /** |
| * Allow an application to register an error event handler. |
| * |
| * <p>If the application does not register an error handler, all |
| * error events reported by the SAX parser will be silently |
| * ignored; however, normal processing may not continue. It is |
| * highly recommended that all SAX applications implement an |
| * error handler to avoid unexpected bugs.</p> |
| * |
| * <p>Applications may register a new or different handler in the |
| * middle of a parse, and the SAX parser must begin using the new |
| * handler immediately.</p> |
| * |
| * @param errorHandler The error handler. |
| * @exception java.lang.NullPointerException If the handler |
| * argument is null. |
| * @see #getErrorHandler |
| */ |
| public abstract void setErrorHandler(ErrorHandler errorHandler); |
| |
| /** |
| * Return the current error handler. |
| * |
| * @return The current error handler, or null if none |
| * has been registered. |
| * @see #setErrorHandler |
| */ |
| public abstract ErrorHandler getErrorHandler(); |
| |
| /** |
| * Set the state of a feature. |
| * |
| * Set the state of any feature in a SAX2 parser. The parser |
| * might not recognize the feature, and if it does recognize |
| * it, it might not be able to fulfill the request. |
| * |
| * @param featureId The unique identifier (URI) of the feature. |
| * @param state The requested state of the feature (true or false). |
| * |
| * @exception org.xml.sax.SAXNotRecognizedException If the |
| * requested feature is not known. |
| * @exception org.xml.sax.SAXNotSupportedException If the |
| * requested feature is known, but the requested |
| * state is not supported. |
| * @exception org.xml.sax.SAXException If there is any other |
| * problem fulfilling the request. |
| */ |
| public abstract void setFeature(String featureId, boolean state) |
| throws SAXNotRecognizedException, SAXNotSupportedException; |
| |
| /** |
| * setProperty |
| * |
| * @param propertyId |
| * @param value |
| */ |
| public abstract void setProperty(String propertyId, Object value) |
| throws SAXNotRecognizedException, SAXNotSupportedException; |
| |
| /** |
| * Set the locale to use for messages. |
| * |
| * @param locale The locale object to use for localization of messages. |
| * |
| * @exception SAXException An exception thrown if the parser does not |
| * support the specified locale. |
| * |
| * @see org.xml.sax.Parser |
| */ |
| public abstract void setLocale(Locale locale) throws SAXException; |
| |
| // |
| // XMLComponentManager methods |
| // |
| |
| /** |
| * Returns the state of a feature. |
| * |
| * @param featureId The feature identifier. |
| * |
| * @throws SAXNotRecognizedException Thrown if the feature is not |
| * recognized. |
| * @throws SAXNotSupportedException Thrown if the feature is not |
| * supported. |
| */ |
| public abstract boolean getFeature(String featureId) |
| throws SAXNotRecognizedException, SAXNotSupportedException; |
| |
| /** |
| * Returns the value of a property. |
| * |
| * @param propertyId The property identifier. |
| * |
| * @throws SAXNotRecognizedException Thrown if the feature is not |
| * recognized. |
| * @throws SAXNotSupportedException Thrown if the feature is not |
| * supported. |
| */ |
| public abstract Object getProperty(String propertyId) |
| throws SAXNotRecognizedException, SAXNotSupportedException; |
| |
| /* |
| * Return locator |
| */ |
| public abstract Locator getLocator(); |
| |
| /* |
| * Return symbol table |
| */ |
| public abstract SymbolTable getSymbolTable(); |
| |
| /* |
| * Return features table |
| */ |
| public abstract Hashtable getFeatureTable(); |
| |
| /* |
| * Return properties table |
| */ |
| public abstract Hashtable getPropertyTable(); |
| |
| // |
| // Protected methods |
| // |
| |
| /** |
| * reset all components before parsing |
| */ |
| protected abstract void reset() throws SAXException; |
| |
| } // class ParserConfiguration |