⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmldtdloader.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * that do not affect the operation of the component.     *      * @param featureId The feature identifier.     * @param state     The state of the feature.     *     * @throws SAXNotRecognizedException The component should not throw     *                                   this exception.     * @throws SAXNotSupportedException The component should not throw     *                                  this exception.     */    public void setFeature(String featureId, boolean state)            throws XMLConfigurationException {        if(featureId.equals(VALIDATION)) {            fValidation = state;        } else if(featureId.equals(WARN_ON_DUPLICATE_ATTDEF)) {            fWarnDuplicateAttdef = state;        } else if(featureId.equals(NOTIFY_CHAR_REFS)) {            fDTDScanner.setFeature(featureId, state);        } else if(featureId.equals(STANDARD_URI_CONFORMANT_FEATURE)) {            fStrictURI = state;        }  else {            throw new XMLConfigurationException(XMLConfigurationException.NOT_RECOGNIZED, featureId);        }    } // setFeature(String,boolean)    /**     * Returns a list of property identifiers that are recognized by     * this component. This method may return null if no properties     * are recognized by this component.     */    public String[] getRecognizedProperties() {        return (String[])(LOADER_RECOGNIZED_PROPERTIES.clone());    } // getRecognizedProperties():String[]    /**     * Returns the state of a property.     *      * @param propertyId The property identifier.     *      * @throws XMLConfigurationException Thrown on configuration error.     */    public Object getProperty(String propertyId)             throws XMLConfigurationException {        if(propertyId.equals( SYMBOL_TABLE)) {            return fSymbolTable;        } else if(propertyId.equals( ERROR_REPORTER)) {            return fErrorReporter;        } else if(propertyId.equals( ERROR_HANDLER)) {            return fErrorReporter.getErrorHandler();        } else if(propertyId.equals( ENTITY_RESOLVER)) {            return fEntityResolver;        } else if(propertyId.equals( GRAMMAR_POOL)) {            return fGrammarPool;        } else if(propertyId.equals( DTD_VALIDATOR)) {            return fValidator;        }         throw new XMLConfigurationException(XMLConfigurationException.NOT_RECOGNIZED, propertyId);    } // getProperty(String):  Object    /**     * Sets the value of a property. This method is called by the component     * manager any time after reset when a property changes value.      * <p>     * <strong>Note:</strong> Components should silently ignore properties     * that do not affect the operation of the component.     *      * @param propertyId The property identifier.     * @param value      The value of the property.     *     * @throws SAXNotRecognizedException The component should not throw     *                                   this exception.     * @throws SAXNotSupportedException The component should not throw     *                                  this exception.     */    public void setProperty(String propertyId, Object value)            throws XMLConfigurationException {        if(propertyId.equals( SYMBOL_TABLE)) {            fSymbolTable = (SymbolTable)value;            fDTDScanner.setProperty(propertyId, value);            fEntityManager.setProperty(propertyId, value);        } else if(propertyId.equals( ERROR_REPORTER)) {            fErrorReporter = (XMLErrorReporter)value;            // Add XML message formatter if there isn't one.            if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {                XMLMessageFormatter xmft = new XMLMessageFormatter();                fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);                fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);            }            fDTDScanner.setProperty(propertyId, value);            fEntityManager.setProperty(propertyId, value);        } else if(propertyId.equals( ERROR_HANDLER)) {            fErrorReporter.setProperty(propertyId, value);        } else if(propertyId.equals( ENTITY_RESOLVER)) {            fEntityResolver = (XMLEntityResolver)value;        } else if(propertyId.equals( GRAMMAR_POOL)) {            fGrammarPool = (XMLGrammarPool)value;        } else {            throw new XMLConfigurationException(XMLConfigurationException.NOT_RECOGNIZED, propertyId);        }    } // setProperty(String,Object)    /**     * Returns the state of a feature.     *      * @param featureId The feature identifier.     *      * @throws XMLConfigurationException Thrown on configuration error.     */    public boolean getFeature(String featureId)             throws XMLConfigurationException {        if(featureId.equals( VALIDATION)) {            return fValidation;        } else if(featureId.equals( WARN_ON_DUPLICATE_ATTDEF)) {            return fWarnDuplicateAttdef;        } else if(featureId.equals( NOTIFY_CHAR_REFS)) {            return fDTDScanner.getFeature(featureId);        }        throw new XMLConfigurationException(XMLConfigurationException.NOT_RECOGNIZED, featureId);    } //getFeature(String):  boolean    /**     * Set the locale to use for messages.     *     * @param locale The locale object to use for localization of messages.     *     * @exception XNIException Thrown if the parser does not support the     *                         specified locale.     */    public void setLocale(Locale locale) {        fLocale = locale;    } // setLocale(Locale)    /** Return the Locale the XMLGrammarLoader is using. */    public Locale getLocale() {        return fLocale;    } // getLocale():  Locale    /**     * Sets the error handler.     *     * @param errorHandler The error handler.     */    public void setErrorHandler(XMLErrorHandler errorHandler) {        fErrorReporter.setProperty(ERROR_HANDLER, errorHandler);    } // setErrorHandler(XMLErrorHandler)    /** Returns the registered error handler.  */    public XMLErrorHandler getErrorHandler() {        return fErrorReporter.getErrorHandler();    } // getErrorHandler():  XMLErrorHandler    /**     * Sets the entity resolver.     *     * @param entityResolver The new entity resolver.     */    public void setEntityResolver(XMLEntityResolver entityResolver) {        fEntityResolver = entityResolver;    } // setEntityResolver(XMLEntityResolver)    /** Returns the registered entity resolver.  */    public XMLEntityResolver getEntityResolver() {        return fEntityResolver;    } // getEntityResolver():  XMLEntityResolver    /**     * Returns a Grammar object by parsing the contents of the     * entity pointed to by source.     *     * @param source        the location of the entity which forms     *                          the starting point of the grammar to be constructed.     * @throws IOException      When a problem is encountered reading the entity     *          XNIException    When a condition arises (such as a FatalError) that requires parsing     *                              of the entity be terminated.     */    public Grammar loadGrammar(XMLInputSource source)            throws IOException, XNIException {        reset();        // First chance checking strict URI        String eid = XMLEntityManager.expandSystemId(source.getSystemId(), source.getBaseSystemId(), fStrictURI);        fDTDGrammar = new DTDGrammar(fSymbolTable, new XMLDTDDescription(source.getPublicId(), source.getSystemId(), source.getBaseSystemId(), eid, null));        fGrammarBucket = new DTDGrammarBucket();        fGrammarBucket.setStandalone(false);        fGrammarBucket.setActiveGrammar(fDTDGrammar);         // no reason to use grammar bucket's "put" method--we        // know which grammar it is, and we don't know the root name anyway...        // actually start the parsing!        try {            fDTDScanner.setInputSource(source);            fDTDScanner.scanDTDExternalSubset(true);        } catch (EOFException e) {            // expected behaviour...        }        finally {            // Close all streams opened by the parser.            fEntityManager.closeReaders();        }        if(fDTDGrammar != null && fGrammarPool != null) {            fGrammarPool.cacheGrammars(XMLDTDDescription.XML_DTD, new Grammar[] {fDTDGrammar});        }        return fDTDGrammar;    } // loadGrammar(XMLInputSource):  Grammar    // reset all the components that we rely upon    protected void reset() {        super.reset();        fDTDScanner.reset();        fEntityManager.reset();        fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner());    }} // class XMLDTDLoader

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -