xmlschemavalidator.java

来自「JAVA的一些源码 JAVA2 STANDARD EDITION DEVELO」· Java 代码 · 共 1,551 行 · 第 1/5 页

JAVA
1,551
字号
            fSubGroupHandler,            fCMBuilder);                        fState4XsiType.setExtraChecking(false);            fState4ApplyDefault.setFacetChecking(false);                    } // <init>()            /*     * Resets the component. The component can query the component manager     * about any features and properties that affect the operation of the     * component.     *     * @param componentManager The component manager.     *     * @throws SAXException Thrown by component on finitialization error.     *                      For example, if a feature or property is     *                      required for the operation of the component, the     *                      component manager may throw a     *                      SAXNotRecognizedException or a     *                      SAXNotSupportedException.     */        public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {                                    fIdConstraint = false;            //reset XSDDescription            fLocationPairs.clear();                        // cleanup id table            fValidationState.resetIDTables();                        //pass the component manager to the factory..            nodeFactory.reset(componentManager);                        // reset schema loader            fSchemaLoader.reset(componentManager);                        // initialize state            fCurrentElemDecl = null;            fCurrentCM = null;            fCurrCMState = null;            fSkipValidationDepth = -1;            fNFullValidationDepth = -1;            fNNoneValidationDepth = -1;            fElementDepth = -1;            fSubElement = false;            fSchemaDynamicValidation = false;                        // datatype normalization            fEntityRef = false;            fInCDATA = false;                        fMatcherStack.clear();                                    if (!fMayMatchFieldMap.isEmpty()) {                // should only clear this if the last schema had identity constraints.                fMayMatchFieldMap.clear();            }                        // get error reporter            fXSIErrorReporter.reset((XMLErrorReporter) componentManager.getProperty(ERROR_REPORTER));                        boolean parser_settings;            try {                parser_settings = componentManager.getFeature(PARSER_SETTINGS);            }            catch (XMLConfigurationException e){                parser_settings = true;            }                        if (!parser_settings){                // parser settings have not been changed                fValidationManager.addValidationState(fValidationState);                return;            }                                                // get symbol table. if it's a new one, add symbols to it.            SymbolTable symbolTable = (SymbolTable)componentManager.getProperty(SYMBOL_TABLE);            if (symbolTable != fSymbolTable) {                fSymbolTable = symbolTable;            }                        try {                fDynamicValidation = componentManager.getFeature(DYNAMIC_VALIDATION);            } catch (XMLConfigurationException e) {                fDynamicValidation = false;            }                        if (fDynamicValidation) {                fDoValidation = true;            } else {                try {                    fDoValidation = componentManager.getFeature(VALIDATION);                } catch (XMLConfigurationException e) {                    fDoValidation = false;                }            }                        if (fDoValidation) {                try {                    fDoValidation = componentManager.getFeature(XMLSchemaValidator.SCHEMA_VALIDATION);                } catch (XMLConfigurationException e) {                }            }                        try {                fFullChecking = componentManager.getFeature(SCHEMA_FULL_CHECKING);            } catch (XMLConfigurationException e) {                fFullChecking = false;            }                        try {                fNormalizeData = componentManager.getFeature(NORMALIZE_DATA);            } catch (XMLConfigurationException e) {                fNormalizeData = false;            }                        try {                fSchemaElementDefault = componentManager.getFeature(SCHEMA_ELEMENT_DEFAULT);            } catch (XMLConfigurationException e) {                fSchemaElementDefault = false;            }                        try {                fAugPSVI = componentManager.getFeature(SCHEMA_AUGMENT_PSVI);            } catch (XMLConfigurationException e) {                fAugPSVI = true;            }            try {                fSchemaType =                (String)componentManager.getProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE);            } catch (XMLConfigurationException e) {                fSchemaType = null;            }                        try {                fIgnoreXsiSchemaLocationHints = componentManager.getFeature(IGNORE_SCHEMA_LOCATION_HINTS);            } catch( XMLConfigurationException e) {                fIgnoreXsiSchemaLocationHints = false;            }                        try {                fTurnIgnorableCharactersIntoIgnorableWhitespaces = componentManager.getFeature(CHANGE_IGNORABLE_CHARACTERS_INTO_IGNORABLE_WHITESPACES);            } catch( XMLConfigurationException e) {                fTurnIgnorableCharactersIntoIgnorableWhitespaces = false;            }                        fEntityResolver = (XMLEntityResolver)componentManager.getProperty(ENTITY_MANAGER);                        fValidationManager = (ValidationManager)componentManager.getProperty(VALIDATION_MANAGER);            fValidationManager.addValidationState(fValidationState);            fValidationState.setSymbolTable(fSymbolTable);                        // get schema location properties            try {                fExternalSchemas = (String)componentManager.getProperty(SCHEMA_LOCATION);                fExternalNoNamespaceSchema = (String)componentManager.getProperty(SCHEMA_NONS_LOCATION);            } catch (XMLConfigurationException e) {                fExternalSchemas = null;                fExternalNoNamespaceSchema = null;            }                        // store the external schema locations. they are set when reset is called,            // so any other schemaLocation declaration for the same namespace will be            // effectively ignored. becuase we choose to take first location hint            // available for a particular namespace.            XMLSchemaLoader.processExternalHints(fExternalSchemas, fExternalNoNamespaceSchema,            fLocationPairs, fXSIErrorReporter.fErrorReporter);                        try {                fJaxpSchemaSource = componentManager.getProperty(JAXP_SCHEMA_SOURCE);            } catch (XMLConfigurationException e){                fJaxpSchemaSource = null;            }            fResourceIdentifier.clear();                        // clear grammars, and put the one for schema namespace there            try {                fGrammarPool = (XMLGrammarPool)componentManager.getProperty(XMLGRAMMAR_POOL);            } catch (XMLConfigurationException e){                fGrammarPool = null;            }            fSchemaLoader.setProperty(XMLGRAMMAR_POOL, fGrammarPool);                        fState4XsiType.setSymbolTable(symbolTable);            fState4ApplyDefault.setSymbolTable(symbolTable);                    } // reset(XMLComponentManager)                //        // FieldActivator methods        //                /**         * Start the value scope for the specified identity constraint. This         * method is called when the selector matches in order to initialize         * the value store.         *         * @param identityConstraint The identity constraint.         */        public void startValueScopeFor(IdentityConstraint identityConstraint, int initialDepth) {                        ValueStoreBase valueStore =            fValueStoreCache.getValueStoreFor(identityConstraint, initialDepth);            valueStore.startValueScope();                    } // startValueScopeFor(IdentityConstraint identityConstraint)                /**         * Request to activate the specified field. This method returns the         * matcher for the field.         *         * @param field The field to activate.         */        public XPathMatcher activateField(Field field, int initialDepth) {            ValueStore valueStore =            fValueStoreCache.getValueStoreFor(field.getIdentityConstraint(), initialDepth);            setMayMatch(field, Boolean.TRUE);            XPathMatcher matcher = field.createMatcher(this, valueStore);            fMatcherStack.addMatcher(matcher);            matcher.startDocumentFragment();            return matcher;        } // activateField(Field):XPathMatcher                /**         * Ends the value scope for the specified identity constraint.         *         * @param identityConstraint The identity constraint.         */        public void endValueScopeFor(IdentityConstraint identityConstraint, int initialDepth) {                        ValueStoreBase valueStore =            fValueStoreCache.getValueStoreFor(identityConstraint, initialDepth);            valueStore.endValueScope();                    } // endValueScopeFor(IdentityConstraint)                /**         * Sets whether the given field is permitted to match a value.         * This should be used to catch instance documents that try         * and match a field several times in the same scope.         *         * @param field The field that may be permitted to be matched.         * @param state Boolean indiciating whether the field may be matched.         */        public void setMayMatch(Field field, Boolean state) {            fMayMatchFieldMap.put(field, state);        } // setMayMatch(Field, Boolean)                /**         * Returns whether the given field is permitted to match a value.         *         * @param field The field that may be permitted to be matched.         * @return Boolean indicating whether the field may be matched.         */        public Boolean mayMatch(Field field) {            return (Boolean) fMayMatchFieldMap.get(field);        } // mayMatch(Field):Boolean                // a utility method for Identity constraints        private void activateSelectorFor(IdentityConstraint ic) {            Selector selector = ic.getSelector();            FieldActivator activator = this;            if (selector == null)                return;            XPathMatcher matcher = selector.createMatcher(activator, fElementDepth);            fMatcherStack.addMatcher(matcher);            matcher.startDocumentFragment();        }                        //        // Protected methods        //                /** ensure element stack capacity */        void ensureStackCapacity() {                        if (fElementDepth == fElemDeclStack.length) {                int newSize = fElementDepth + INC_STACK_SIZE;                boolean[] newArrayB = new boolean[newSize];                System.arraycopy(fSubElementStack, 0, newArrayB, 0, fElementDepth);                fSubElementStack = newArrayB;                                XSElementDecl[] newArrayE = new XSElementDecl[newSize];                System.arraycopy(fElemDeclStack, 0, newArrayE, 0, fElementDepth);                fElemDeclStack = newArrayE;                                newArrayB = new boolean[newSize];                System.arraycopy(fNilStack, 0, newArrayB, 0, fElementDepth);                fNilStack = newArrayB;                                XSNotationDecl[] newArrayN = new XSNotationDecl[newSize];                System.arraycopy(fNotationStack, 0, newArrayN, 0, fElementDepth);                fNotationStack = newArrayN;                                XSTypeDefinition[] newArrayT = new XSTypeDefinition[newSize];                System.arraycopy(fTypeStack, 0, newArrayT, 0, fElementDepth);                fTypeStack = newArrayT;                                XSCMValidator[] newArrayC = new XSCMValidator[newSize];                System.arraycopy(fCMStack, 0, newArrayC, 0, fElementDepth);                fCMStack = newAr

⌨️ 快捷键说明

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