com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DOMParser.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public void setProperty0(String propertyId, Object value)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    try {
        fConfiguration.setProperty(propertyId, value);
    }
    catch (XMLConfigurationException e) {
        String identifier = e.getIdentifier();
        if (e.getType() == Status.NOT_RECOGNIZED) {
            throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
                "property-not-recognized", new Object [] {identifier}));
        }
        else {
            throw new SAXNotSupportedException(
                SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
                "property-not-supported", new Object [] {identifier}));
        }
    }

}
 
Example #2
Source File: DOMParser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the current entity resolver.
 *
 * @return The current entity resolver, or null if none
 *         has been registered.
 * @see #setEntityResolver
 */
public EntityResolver getEntityResolver() {

    EntityResolver entityResolver = null;
    try {
        XMLEntityResolver xmlEntityResolver =
            (XMLEntityResolver)fConfiguration.getProperty(ENTITY_RESOLVER);
        if (xmlEntityResolver != null) {
            if (xmlEntityResolver instanceof EntityResolverWrapper) {
                entityResolver =
                    ((EntityResolverWrapper) xmlEntityResolver).getEntityResolver();
            }
            else if (xmlEntityResolver instanceof EntityResolver2Wrapper) {
                entityResolver =
                    ((EntityResolver2Wrapper) xmlEntityResolver).getEntityResolver();
            }
        }
    }
    catch (XMLConfigurationException e) {
        // do nothing
    }
    return entityResolver;

}
 
Example #3
Source File: SAXParserImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private void setSchemaValidatorFeature(String name, boolean value)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    try {
        fSAXParser.fSchemaValidator.setFeature(name, value);
    }
    // This should never be thrown from the schema validator.
    catch (XMLConfigurationException e) {
        String identifier = e.getIdentifier();
        if (e.getType() == Status.NOT_RECOGNIZED) {
            throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
                "feature-not-recognized", new Object [] {identifier}));
        }
        else {
            throw new SAXNotSupportedException(
                SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
                "feature-not-supported", new Object [] {identifier}));
        }
    }
}
 
Example #4
Source File: SAXParserImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void setSchemaValidatorProperty(String name, Object value)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    try {
        fSAXParser.fSchemaValidator.setProperty(name, value);
    }
    // This should never be thrown from the schema validator.
    catch (XMLConfigurationException e) {
        String identifier = e.getIdentifier();
        if (e.getType() == Status.NOT_RECOGNIZED) {
            throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
                "property-not-recognized", new Object [] {identifier}));
        }
        else {
            throw new SAXNotSupportedException(
                SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
                "property-not-supported", new Object [] {identifier}));
        }
    }
}
 
Example #5
Source File: XIncludeHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void copyFeatures1(
    Enumeration features,
    String featurePrefix,
    XMLComponentManager from,
    XMLParserConfiguration to) {
    while (features.hasMoreElements()) {
        String featureId = featurePrefix + (String)features.nextElement();
        boolean value = from.getFeature(featureId);

        try {
            to.setFeature(featureId, value);
        }
        catch (XMLConfigurationException e) {
            // componentManager doesn't support this feature,
            // so we won't worry about it
        }
    }
}
 
Example #6
Source File: XMLDTDLoader.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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(LOCALE)) {
        return getLocale();
    }
    else if (propertyId.equals(GRAMMAR_POOL)) {
        return fGrammarPool;
    }
    else if (propertyId.equals(DTD_VALIDATOR)) {
        return fValidator;
    }
    throw new XMLConfigurationException(Status.NOT_RECOGNIZED, propertyId);
}
 
Example #7
Source File: ValidatorHandlerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException();
    }
    try {
        return fComponentManager.getFeature(name);
    }
    catch (XMLConfigurationException e) {
        final String identifier = e.getIdentifier();
        final String key = e.getType() == Status.NOT_RECOGNIZED ?
                "feature-not-recognized" : "feature-not-supported";
        throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                key, new Object [] {identifier}));
    }
}
 
Example #8
Source File: ValidatorHandlerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public Object getProperty(String name)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException();
    }
    try {
        return fComponentManager.getProperty(name);
    }
    catch (XMLConfigurationException e) {
        final String identifier = e.getIdentifier();
        final String key = e.getType() == Status.NOT_RECOGNIZED ?
                "property-not-recognized" : "property-not-supported";
        throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                key, new Object [] {identifier}));
    }
}
 
Example #9
Source File: BasicParserConfiguration.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId)
    throws XMLConfigurationException {

    //
    // Xerces Features
    //
    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // special performance feature: no one by component manager is allowed to set it
        //
        if (suffixLength == Constants.PARSER_SETTINGS.length() &&
            featureId.endsWith(Constants.PARSER_SETTINGS)) {
            return FeatureState.NOT_SUPPORTED;
        }
    }

    return super.checkFeature(featureId);
 }
 
Example #10
Source File: XMLDocumentScannerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the state of a feature. This method is called by the component
 * manager any time after reset when a feature changes state.
 * <p>
 * <strong>Note:</strong> Components should silently ignore features
 * 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 {

    super.setFeature(featureId, state);

    // Xerces properties
    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        if (suffixLength == Constants.LOAD_EXTERNAL_DTD_FEATURE.length() &&
            featureId.endsWith(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
            fLoadExternalDTD = state;
            return;
        }
        else if (suffixLength == Constants.DISALLOW_DOCTYPE_DECL_FEATURE.length() &&
            featureId.endsWith(Constants.DISALLOW_DOCTYPE_DECL_FEATURE)) {
            fDisallowDoctype = state;
            return;
        }
    }

}
 
Example #11
Source File: XMLSchemaFactory.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
                "FeatureNameNull", null));
    }
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return (fSecurityManager != null && fSecurityManager.isSecureProcessing());
    }
    try {
        return fXMLSchemaLoader.getFeature(name);
    }
    catch (XMLConfigurationException e) {
        String identifier = e.getIdentifier();
        if (e.getType() == Status.NOT_RECOGNIZED) {
            throw new SAXNotRecognizedException(
                    SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
                    "feature-not-recognized", new Object [] {identifier}));
        }
        else {
            throw new SAXNotSupportedException(
                    SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
                    "feature-not-supported", new Object [] {identifier}));
        }
    }
}
 
Example #12
Source File: ValidatorImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public void setProperty(String name, Object object)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException();
    }
    try {
        fComponentManager.setProperty(name, object);
    }
    catch (XMLConfigurationException e) {
        final String identifier = e.getIdentifier();
        final String key = e.getType() == Status.NOT_RECOGNIZED ?
                "property-not-recognized" : "property-not-supported";
        throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                key, new Object [] {identifier}));
    }
    fConfigurationChanged = true;
}
 
Example #13
Source File: ValidatorImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean getFeature(String name)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException();
    }
    try {
        return fComponentManager.getFeature(name);
    }
    catch (XMLConfigurationException e) {
        final String identifier = e.getIdentifier();
        final String key = e.getType() == Status.NOT_RECOGNIZED ?
                "feature-not-recognized" : "feature-not-supported";
        throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                key, new Object [] {identifier}));
    }
}
 
Example #14
Source File: XMLNamespaceBinder.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the value of a property during parsing.
 *
 * @param propertyId
 * @param value
 */
public void setProperty(String propertyId, Object value)
    throws XMLConfigurationException {

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
            final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();

        if (suffixLength == Constants.SYMBOL_TABLE_PROPERTY.length() &&
            propertyId.endsWith(Constants.SYMBOL_TABLE_PROPERTY)) {
            fSymbolTable = (SymbolTable)value;
        }
        else if (suffixLength == Constants.ERROR_REPORTER_PROPERTY.length() &&
            propertyId.endsWith(Constants.ERROR_REPORTER_PROPERTY)) {
            fErrorReporter = (XMLErrorReporter)value;
        }
        return;
    }

}
 
Example #15
Source File: SchemaValidatorConfiguration.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public SchemaValidatorConfiguration(XMLComponentManager parentManager,
        XSGrammarPoolContainer grammarContainer, ValidationManager validationManager) {
    fParentComponentManager = parentManager;
    fGrammarPool = grammarContainer.getGrammarPool();
    fUseGrammarPoolOnly = grammarContainer.isFullyComposed();
    fValidationManager = validationManager;
    // add schema message formatter to error reporter
    try {
        XMLErrorReporter errorReporter = (XMLErrorReporter) fParentComponentManager.getProperty(ERROR_REPORTER);
        if (errorReporter != null) {
            errorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
        }
    }
    // Ignore exception.
    catch (XMLConfigurationException exc) {}
}
 
Example #16
Source File: XMLDocumentScannerImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 {

    super.setProperty(propertyId, value);

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();

        if (suffixLength == Constants.DTD_SCANNER_PROPERTY.length() &&
            propertyId.endsWith(Constants.DTD_SCANNER_PROPERTY)) {
            fDTDScanner = (XMLDTDScanner)value;
        }
        if (suffixLength == Constants.NAMESPACE_CONTEXT_PROPERTY.length() &&
            propertyId.endsWith(Constants.NAMESPACE_CONTEXT_PROPERTY)) {
            if (value != null) {
                fNamespaceContext = (NamespaceContext)value;
            }
        }

        return;
    }

}
 
Example #17
Source File: ParserConfigurationSettings.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Check a feature. If feature is known and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @exception com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException If the
 *            requested feature is not known.
 */
protected FeatureState checkFeature(String featureId)
    throws XMLConfigurationException {

    // check feature
    if (!fRecognizedFeatures.contains(featureId)) {
        if (fParentSettings != null) {
            return fParentSettings.getFeatureState(featureId);
        }
        else {
            return FeatureState.NOT_RECOGNIZED;
        }
    }

    // TODO: reasonable default?
    return FeatureState.RECOGNIZED;
}
 
Example #18
Source File: XMLDocumentScannerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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 {

    super.setProperty(propertyId, value);

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();

        if (suffixLength == Constants.DTD_SCANNER_PROPERTY.length() &&
            propertyId.endsWith(Constants.DTD_SCANNER_PROPERTY)) {
            fDTDScanner = (XMLDTDScanner)value;
        }
        if (suffixLength == Constants.NAMESPACE_CONTEXT_PROPERTY.length() &&
            propertyId.endsWith(Constants.NAMESPACE_CONTEXT_PROPERTY)) {
            if (value != null) {
                fNamespaceContext = (NamespaceContext)value;
            }
        }

        return;
    }

}
 
Example #19
Source File: ValidatorHandlerImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void setFeature(String name, boolean value)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException();
    }
    try {
        fComponentManager.setFeature(name, value);
    }
    catch (XMLConfigurationException e) {
        final String identifier = e.getIdentifier();
        final String key;
        if (e.getType() == Status.NOT_ALLOWED) {
            //for now, the identifier can only be (XMLConstants.FEATURE_SECURE_PROCESSING)
            throw new SAXNotSupportedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                "jaxp-secureprocessing-feature", null));
        } else if (e.getType() == Status.NOT_RECOGNIZED) {
            key = "feature-not-recognized";
        } else {
            key = "feature-not-supported";
        }
        throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                key, new Object [] {identifier}));
    }
}
 
Example #20
Source File: XMLDTDLoader.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the state of a feature. This method is called by the component
 * manager any time after reset when a feature changes state.
 * <p>
 * <strong>Note:</strong> Components should silently ignore features
 * 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(WARN_ON_UNDECLARED_ELEMDEF)) {
        fWarnOnUndeclaredElemdef = state;
    }
    else if (featureId.equals(NOTIFY_CHAR_REFS)) {
        fDTDScanner.setFeature(featureId, state);
    }
    else if (featureId.equals(STANDARD_URI_CONFORMANT_FEATURE)) {
        fStrictURI = state;
    }
    else if (featureId.equals(BALANCE_SYNTAX_TREES)) {
        fBalanceSyntaxTrees = state;
    }
    else {
        throw new XMLConfigurationException(Status.NOT_RECOGNIZED, featureId);
    }
}
 
Example #21
Source File: ParserConfigurationSettings.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check a feature. If feature is known and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @exception com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException If the
 *            requested feature is not known.
 */
protected FeatureState checkFeature(String featureId)
    throws XMLConfigurationException {

    // check feature
    if (!fRecognizedFeatures.contains(featureId)) {
        if (fParentSettings != null) {
            return fParentSettings.getFeatureState(featureId);
        }
        else {
            return FeatureState.NOT_RECOGNIZED;
        }
    }

    // TODO: reasonable default?
    return FeatureState.RECOGNIZED;
}
 
Example #22
Source File: XMLNamespaceBinder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the value of a property during parsing.
 *
 * @param propertyId
 * @param value
 */
public void setProperty(String propertyId, Object value)
    throws XMLConfigurationException {

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
            final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();

        if (suffixLength == Constants.SYMBOL_TABLE_PROPERTY.length() &&
            propertyId.endsWith(Constants.SYMBOL_TABLE_PROPERTY)) {
            fSymbolTable = (SymbolTable)value;
        }
        else if (suffixLength == Constants.ERROR_REPORTER_PROPERTY.length() &&
            propertyId.endsWith(Constants.ERROR_REPORTER_PROPERTY)) {
            fErrorReporter = (XMLErrorReporter)value;
        }
        return;
    }

}
 
Example #23
Source File: XIncludeAwareParserConfiguration.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setFeature(String featureId, boolean state)
    throws XMLConfigurationException {
    if (featureId.equals(XINCLUDE_FEATURE)) {
        fXIncludeEnabled = state;
        fConfigUpdated = true;
        return;
    }
    super.setFeature(featureId,state);
}
 
Example #24
Source File: DocumentBuilderImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private void resetSchemaValidator() throws SAXException {
    try {
        fSchemaValidator.reset(fSchemaValidatorComponentManager);
    }
    // This should never be thrown from the schema validator.
    catch (XMLConfigurationException e) {
        throw new SAXException(e);
    }
}
 
Example #25
Source File: DTDGrammarUtil.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void reset(XMLComponentManager componentManager)
throws XMLConfigurationException {

    fDTDGrammar = null;
    fInElementContent = false;
    fCurrentElementIndex = -1;
    fCurrentContentSpecType = -1;
    fNamespaces = componentManager.getFeature(NAMESPACES, true);
    fSymbolTable = (SymbolTable) componentManager.getProperty(
            Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY);
    fElementDepth = -1;
}
 
Example #26
Source File: XMLDTDLoader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
        fEntityManager.setProperty(propertyId, value);
    }
    else if (propertyId.equals(LOCALE)) {
        setLocale((Locale) value);
    }
    else if(propertyId.equals(GRAMMAR_POOL)) {
        fGrammarPool = (XMLGrammarPool)value;
    }
    else {
        throw new XMLConfigurationException(Status.NOT_RECOGNIZED, propertyId);
    }
}
 
Example #27
Source File: NonValidatingConfiguration.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void setProperty(String propertyId, Object value)
    throws XMLConfigurationException {
    fConfigUpdated = true;
    if (LOCALE.equals(propertyId)) {
        setLocale((Locale) value);
    }
    super.setProperty(propertyId, value);
}
 
Example #28
Source File: XMLScanner.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public boolean getFeature(String featureId)
throws XMLConfigurationException {

    if (VALIDATION.equals(featureId)) {
        return fValidation;
    } else if (NOTIFY_CHAR_REFS.equals(featureId)) {
        return fNotifyCharRefs;
    }
    throw new XMLConfigurationException(Status.NOT_RECOGNIZED, featureId);
}
 
Example #29
Source File: XMLSchemaValidatorComponentManager.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the state of a property.
 *
 * @param propertyId The unique identifier (URI) of the property.
 * @param value The requested state of the property.
 *
 * @exception XMLConfigurationException If the requested property is not known.
 */
public void setProperty(String propertyId, Object value) throws XMLConfigurationException {
    if ( ENTITY_MANAGER.equals(propertyId) || ERROR_REPORTER.equals(propertyId) ||
         NAMESPACE_CONTEXT.equals(propertyId) || SCHEMA_VALIDATOR.equals(propertyId) ||
         SYMBOL_TABLE.equals(propertyId) || VALIDATION_MANAGER.equals(propertyId) ||
         XMLGRAMMAR_POOL.equals(propertyId)) {
        throw new XMLConfigurationException(Status.NOT_SUPPORTED, propertyId);
    }
    fConfigUpdated = true;
    fEntityManager.setProperty(propertyId, value);
    fErrorReporter.setProperty(propertyId, value);
    fSchemaValidator.setProperty(propertyId, value);
    if (ENTITY_RESOLVER.equals(propertyId) || ERROR_HANDLER.equals(propertyId) ||
            SECURITY_MANAGER.equals(propertyId)) {
        fComponents.put(propertyId, value);
        return;
    }
    else if (LOCALE.equals(propertyId)) {
        setLocale((Locale) value);
        fComponents.put(propertyId, value);
        return;
    }
    //check if the property is managed by security manager
    if (fInitSecurityManager == null ||
            !fInitSecurityManager.setLimit(propertyId, XMLSecurityManager.State.APIPROPERTY, value)) {
        //check if the property is managed by security property manager
        if (fSecurityPropertyMgr == null ||
                !fSecurityPropertyMgr.setValue(propertyId, XMLSecurityPropertyManager.State.APIPROPERTY, value)) {
            //fall back to the existing property manager
            if (!fInitProperties.containsKey(propertyId)) {
                fInitProperties.put(propertyId, super.getProperty(propertyId));
            }
            super.setProperty(propertyId, value);
        }
    }
}
 
Example #30
Source File: ValidatorImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void setFeature(String name, boolean value)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException();
    }
    try {
        fComponentManager.setFeature(name, value);
    }
    catch (XMLConfigurationException e) {
        final String identifier = e.getIdentifier();
        final String key;
        if (e.getType() == Status.NOT_ALLOWED) {
            //for now, the identifier can only be (XMLConstants.FEATURE_SECURE_PROCESSING)
            throw new SAXNotSupportedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                "jaxp-secureprocessing-feature", null));
        } else if (e.getType() == Status.NOT_RECOGNIZED) {
            key = "feature-not-recognized";
        } else {
            key = "feature-not-supported";
        }
        throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                key, new Object [] {identifier}));
    }
    fConfigurationChanged = true;
}