286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 2001, 2002,2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xerces.internal.xni.parser;
286N/A
286N/Aimport java.io.IOException;
286N/Aimport java.util.Locale;
286N/A
286N/Aimport com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
286N/Aimport com.sun.org.apache.xerces.internal.xni.XMLDTDHandler;
286N/Aimport com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler;
286N/Aimport com.sun.org.apache.xerces.internal.xni.XNIException;
286N/A
286N/A/**
286N/A * Represents a parser configuration. The parser configuration maintains
286N/A * a table of recognized features and properties, assembles components
286N/A * for the parsing pipeline, and is responsible for initiating parsing
286N/A * of an XML document.
286N/A * <p>
286N/A * By separating the configuration of a parser from the specific parser
286N/A * instance, applications can create new configurations and re-use the
286N/A * existing parser components and external API generators (e.g. the
286N/A * DOMParser and SAXParser).
286N/A * <p>
286N/A * The internals of any specific parser configuration instance are hidden.
286N/A * Therefore, each configuration may implement the parsing mechanism any
286N/A * way necessary. However, the parser configuration should follow these
286N/A * guidelines:
286N/A * <ul>
286N/A * <li>
286N/A * Call the <code>reset</code> method on each component before parsing.
286N/A * This is only required if the configuration is re-using existing
286N/A * components that conform to the <code>XMLComponent</code> interface.
286N/A * If the configuration uses all custom parts, then it is free to
286N/A * implement everything as it sees fit as long as it follows the
286N/A * other guidelines.
286N/A * </li>
286N/A * <li>
286N/A * Call the <code>setFeature</code> and <code>setProperty</code> method
286N/A * on each component during parsing to propagate features and properties
286N/A * that have changed. This is only required if the configuration is
286N/A * re-using existing components that conform to the <code>XMLComponent</code>
286N/A * interface. If the configuration uses all custom parts, then it is free
286N/A * to implement everything as it sees fit as long as it follows the other
286N/A * guidelines.
286N/A * </li>
286N/A * <li>
286N/A * Pass the same unique String references for all symbols that are
286N/A * propagated to the registered handlers. Symbols include, but may not
286N/A * be limited to, the names of elements and attributes (including their
286N/A * uri, prefix, and localpart). This is suggested but not an absolute
286N/A * must. However, the standard parser components may require access to
286N/A * the same symbol table for creation of unique symbol references to be
286N/A * propagated in the XNI pipeline.
286N/A * </li>
286N/A * </ul>
286N/A *
286N/A * @author Arnaud Le Hors, IBM
286N/A * @author Andy Clark, IBM
286N/A *
286N/A */
286N/Apublic interface XMLParserConfiguration
286N/A extends XMLComponentManager {
286N/A
286N/A //
286N/A // XMLParserConfiguration methods
286N/A //
286N/A
286N/A // parsing
286N/A
286N/A /**
286N/A * Parse an XML document.
286N/A * <p>
286N/A * The parser can use this method to instruct this configuration
286N/A * to begin parsing an XML document from any valid input source
286N/A * (a character stream, a byte stream, or a URI).
286N/A * <p>
286N/A * Parsers may not invoke this method while a parse is in progress.
286N/A * Once a parse is complete, the parser may then parse another XML
286N/A * document.
286N/A * <p>
286N/A * This method is synchronous: it will not return until parsing
286N/A * has ended. If a client application wants to terminate
286N/A * parsing early, it should throw an exception.
286N/A * <p>
286N/A * When this method returns, all characters streams and byte streams
286N/A * opened by the parser are closed.
286N/A *
286N/A * @param inputSource The input source for the top-level of the
286N/A * XML document.
286N/A *
286N/A * @exception XNIException Any XNI exception, possibly wrapping
286N/A * another exception.
286N/A * @exception IOException An IO exception from the parser, possibly
286N/A * from a byte stream or character stream
286N/A * supplied by the parser.
286N/A */
286N/A public void parse(XMLInputSource inputSource)
286N/A throws XNIException, IOException;
286N/A
286N/A // generic configuration
286N/A
286N/A /**
286N/A * Allows a parser to add parser specific features to be recognized
286N/A * and managed by the parser configuration.
286N/A *
286N/A * @param featureIds An array of the additional feature identifiers
286N/A * to be recognized.
286N/A */
286N/A public void addRecognizedFeatures(String[] featureIds);
286N/A
286N/A /**
286N/A * Sets the state of a feature. This method is called by the parser
286N/A * and gets propagated to components in this parser configuration.
286N/A *
286N/A * @param featureId The feature identifier.
286N/A * @param state The state of the feature.
286N/A *
286N/A * @throws XMLConfigurationException Thrown if there is a configuration
286N/A * error.
286N/A */
286N/A public void setFeature(String featureId, boolean state)
286N/A throws XMLConfigurationException;
286N/A
286N/A /**
286N/A * Returns the state of a feature.
286N/A *
286N/A * @param featureId The feature identifier.
286N/A *
286N/A * @throws XMLConfigurationException Thrown if there is a configuration
286N/A * error.
286N/A */
286N/A public boolean getFeature(String featureId)
286N/A throws XMLConfigurationException;
286N/A
286N/A /**
286N/A * Allows a parser to add parser specific properties to be recognized
286N/A * and managed by the parser configuration.
286N/A *
286N/A * @param propertyIds An array of the additional property identifiers
286N/A * to be recognized.
286N/A */
286N/A public void addRecognizedProperties(String[] propertyIds);
286N/A
286N/A /**
286N/A * Sets the value of a property. This method is called by the parser
286N/A * and gets propagated to components in this parser configuration.
286N/A *
286N/A * @param propertyId The property identifier.
286N/A * @param value The value of the property.
286N/A *
286N/A * @throws XMLConfigurationException Thrown if there is a configuration
286N/A * error.
286N/A */
286N/A public void setProperty(String propertyId, Object value)
286N/A throws XMLConfigurationException;
286N/A
286N/A /**
286N/A * Returns the value of a property.
286N/A *
286N/A * @param propertyId The property identifier.
286N/A *
286N/A * @throws XMLConfigurationException Thrown if there is a configuration
286N/A * error.
286N/A */
286N/A public Object getProperty(String propertyId)
286N/A throws XMLConfigurationException;
286N/A
286N/A // handlers
286N/A
286N/A /**
286N/A * Sets the error handler.
286N/A *
286N/A * @param errorHandler The error resolver.
286N/A */
286N/A public void setErrorHandler(XMLErrorHandler errorHandler);
286N/A
286N/A /** Returns the registered error handler. */
286N/A public XMLErrorHandler getErrorHandler();
286N/A
286N/A /**
286N/A * Sets the document handler to receive information about the document.
286N/A *
286N/A * @param documentHandler The document handler.
286N/A */
286N/A public void setDocumentHandler(XMLDocumentHandler documentHandler);
286N/A
286N/A /** Returns the registered document handler. */
286N/A public XMLDocumentHandler getDocumentHandler();
286N/A
286N/A /**
286N/A * Sets the DTD handler.
286N/A *
286N/A * @param dtdHandler The DTD handler.
286N/A */
286N/A public void setDTDHandler(XMLDTDHandler dtdHandler);
286N/A
286N/A /** Returns the registered DTD handler. */
286N/A public XMLDTDHandler getDTDHandler();
286N/A
286N/A /**
286N/A * Sets the DTD content model handler.
286N/A *
286N/A * @param dtdContentModelHandler The DTD content model handler.
286N/A */
286N/A public void setDTDContentModelHandler(XMLDTDContentModelHandler dtdContentModelHandler);
286N/A
286N/A /** Returns the registered DTD content model handler. */
286N/A public XMLDTDContentModelHandler getDTDContentModelHandler();
286N/A
286N/A // other settings
286N/A
286N/A /**
286N/A * Sets the entity resolver.
286N/A *
286N/A * @param entityResolver The new entity resolver.
286N/A */
286N/A public void setEntityResolver(XMLEntityResolver entityResolver);
286N/A
286N/A /** Returns the registered entity resolver. */
286N/A public XMLEntityResolver getEntityResolver();
286N/A
286N/A /**
286N/A * Set the locale to use for messages.
286N/A *
286N/A * @param locale The locale object to use for localization of messages.
286N/A *
286N/A * @exception XNIException Thrown if the parser does not support the
286N/A * specified locale.
286N/A */
286N/A public void setLocale(Locale locale) throws XNIException;
286N/A
286N/A /** Returns the locale. */
286N/A public Locale getLocale();
286N/A
286N/A} // interface XMLParserConfiguration