xmlschemavalidatorcomponentmanager.java
来自「JAVA 所有包」· Java 代码 · 共 420 行 · 第 1/2 页
JAVA
420 行
return true; } else if (USE_GRAMMAR_POOL_ONLY.equals(featureId)) { return fUseGrammarPoolOnly; } else if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) { return getProperty(SECURITY_MANAGER) != null; } return super.getFeature(featureId); } /** * Set the state of a feature. * * @param featureId The unique identifier (URI) of the feature. * @param state The requested state of the feature (true or false). * * @exception XMLConfigurationException If the requested feature is not known. */ public void setFeature(String featureId, boolean value) throws XMLConfigurationException { if (PARSER_SETTINGS.equals(featureId)) { throw new XMLConfigurationException(XMLConfigurationException.NOT_SUPPORTED, featureId); } else if (value == false && (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId))) { throw new XMLConfigurationException(XMLConfigurationException.NOT_SUPPORTED, featureId); } else if (USE_GRAMMAR_POOL_ONLY.equals(featureId) && value != fUseGrammarPoolOnly) { throw new XMLConfigurationException(XMLConfigurationException.NOT_SUPPORTED, featureId); } fConfigUpdated = true; if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) { setProperty(SECURITY_MANAGER, value ? new SecurityManager() : null); return; } fEntityManager.setFeature(featureId, value); fErrorReporter.setFeature(featureId, value); fSchemaValidator.setFeature(featureId, value); super.setFeature(featureId, value); } /** * Returns the value of a property. * * @param propertyId The property identifier. * @return the value of the property * * @throws XMLConfigurationException Thrown for configuration error. * In general, components should * only throw this exception if * it is <strong>really</strong> * a critical error. */ public Object getProperty(String propertyId) throws XMLConfigurationException { final Object component = fComponents.get(propertyId); if (component != null) { return component; } else if (fComponents.containsKey(propertyId)) { return null; } return super.getProperty(propertyId); } /** * 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(XMLConfigurationException.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; } super.setProperty(propertyId, value); } /** * Adds all of the component's recognized features and properties * to the list of default recognized features and properties, and * sets default values on the configuration for features and * properties which were previously absent from the configuration. * * @param component The component whose recognized features * and properties will be added to the configuration */ public void addRecognizedParamsAndSetDefaults(XMLComponent component) { // register component's recognized features final String[] recognizedFeatures = component.getRecognizedFeatures(); addRecognizedFeatures(recognizedFeatures); // register component's recognized properties final String[] recognizedProperties = component.getRecognizedProperties(); addRecognizedProperties(recognizedProperties); // set default values setFeatureDefaults(component, recognizedFeatures); setPropertyDefaults(component, recognizedProperties); } /** Calls reset on each of the components owned by this component manager. **/ public void reset() throws XNIException { fNamespaceContext.reset(); fValidationManager.reset(); fEntityManager.reset(this); fErrorReporter.reset(this); fSchemaValidator.reset(this); // Mark configuration as fixed. fConfigUpdated = false; } void setErrorHandler(ErrorHandler errorHandler) { fErrorHandler = errorHandler; setProperty(ERROR_HANDLER, (errorHandler != null) ? new ErrorHandlerWrapper(errorHandler) : new ErrorHandlerWrapper(DraconianErrorHandler.getInstance())); } ErrorHandler getErrorHandler() { return fErrorHandler; } void setResourceResolver(LSResourceResolver resourceResolver) { fResourceResolver = resourceResolver; setProperty(ENTITY_RESOLVER, new DOMEntityResolverWrapper(resourceResolver)); } public LSResourceResolver getResourceResolver() { return fResourceResolver; } /** Cleans out configuration, restoring it to its initial state. */ void restoreInitialState() { fConfigUpdated = true; // Clear feature and property tables. fFeatures.clear(); fProperties.clear(); // Remove error resolver and error handler fComponents.put(ENTITY_RESOLVER, null); fComponents.put(ERROR_HANDLER, null); // Restore component defaults. setFeatureDefaults(fEntityManager, fEntityManager.getRecognizedFeatures()); setPropertyDefaults(fEntityManager, fEntityManager.getRecognizedProperties()); setFeatureDefaults(fErrorReporter, fErrorReporter.getRecognizedFeatures()); setPropertyDefaults(fErrorReporter, fErrorReporter.getRecognizedProperties()); setFeatureDefaults(fSchemaValidator, fSchemaValidator.getRecognizedFeatures()); setPropertyDefaults(fSchemaValidator, fSchemaValidator.getRecognizedProperties()); } /** Sets feature defaults for the given component on this configuration. */ private void setFeatureDefaults(final XMLComponent component, final String [] recognizedFeatures) { if (recognizedFeatures != null) { for (int i = 0; i < recognizedFeatures.length; ++i) { String featureId = recognizedFeatures[i]; Boolean state = component.getFeatureDefault(featureId); if (state != null) { // Do not overwrite values already set on the configuration. if (!fFeatures.containsKey(featureId)) { fFeatures.put(featureId, state); // For newly added components who recognize this feature // but did not offer a default value, we need to make // sure these components will get an opportunity to read // the value before parsing begins. fConfigUpdated = true; } } } } } /** Sets property defaults for the given component on this configuration. */ private void setPropertyDefaults(final XMLComponent component, final String [] recognizedProperties) { if (recognizedProperties != null) { for (int i = 0; i < recognizedProperties.length; ++i) { String propertyId = recognizedProperties[i]; Object value = component.getPropertyDefault(propertyId); if (value != null) { // Do not overwrite values already set on the configuration. if (!fProperties.containsKey(propertyId)) { fProperties.put(propertyId, value); // For newly added components who recognize this property // but did not offer a default value, we need to make // sure these components will get an opportunity to read // the value before parsing begins. fConfigUpdated = true; } } } } } } // XMLSchemaValidatorComponentManager
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?