1 16 17 package com.sun.org.apache.xerces.internal.jaxp; 18 19 import com.sun.org.apache.xerces.internal.impl.Constants; 20 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter; 21 import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager; 22 import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter; 23 import com.sun.org.apache.xerces.internal.jaxp.validation.XSGrammarPoolContainer; 24 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; 25 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager; 26 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; 27 28 33 final class SchemaValidatorConfiguration implements XMLComponentManager { 34 35 37 38 private static final String SCHEMA_VALIDATION = 39 Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE; 40 41 42 private static final String VALIDATION = 43 Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE; 44 45 46 private static final String USE_GRAMMAR_POOL_ONLY = 47 Constants.XERCES_FEATURE_PREFIX + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE; 48 49 50 private static final String PARSER_SETTINGS = 51 Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS; 52 53 55 56 private static final String ERROR_REPORTER = 57 Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY; 58 59 60 private static final String VALIDATION_MANAGER = 61 Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY; 62 63 64 private static final String XMLGRAMMAR_POOL = 65 Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY; 66 67 71 72 private final XMLComponentManager fParentComponentManager; 73 74 75 private final XMLGrammarPool fGrammarPool; 76 77 81 private final boolean fUseGrammarPoolOnly; 82 83 84 private final ValidationManager fValidationManager; 85 86 public SchemaValidatorConfiguration(XMLComponentManager parentManager, 87 XSGrammarPoolContainer grammarContainer, ValidationManager validationManager) { 88 fParentComponentManager = parentManager; 89 fGrammarPool = grammarContainer.getGrammarPool(); 90 fUseGrammarPoolOnly = grammarContainer.isFullyComposed(); 91 fValidationManager = validationManager; 92 try { 94 XMLErrorReporter errorReporter = (XMLErrorReporter) fParentComponentManager.getProperty(ERROR_REPORTER); 95 if (errorReporter != null) { 96 errorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter()); 97 } 98 } 99 catch (XMLConfigurationException exc) {} 101 } 102 103 115 public boolean getFeature(String featureId) 116 throws XMLConfigurationException { 117 if (PARSER_SETTINGS.equals(featureId)) { 118 return fParentComponentManager.getFeature(featureId); 119 } 120 else if (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId)) { 121 return true; 122 } 123 else if (USE_GRAMMAR_POOL_ONLY.equals(featureId)) { 124 return fUseGrammarPoolOnly; 125 } 126 return fParentComponentManager.getFeature(featureId); 127 } 128 129 141 public Object getProperty(String propertyId) 142 throws XMLConfigurationException { 143 if (XMLGRAMMAR_POOL.equals(propertyId)) { 144 return fGrammarPool; 145 } 146 else if (VALIDATION_MANAGER.equals(propertyId)) { 147 return fValidationManager; 148 } 149 return fParentComponentManager.getProperty(propertyId); 150 } 151 } 152 | Popular Tags |