src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/BasicParserConfiguration.java
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
child 48409 5ab69533994b
equal deleted inserted replaced
47358:d07d5f7cab35 47359:e1a6c0168741
     1 /*
     1 /*
     2  * reserved comment block
     2  * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT REMOVE OR ALTER!
     3  * @LastModified: Oct 2017
     4  */
     4  */
     5 /*
     5 /*
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     7  * contributor license agreements.  See the NOTICE file distributed with
     7  * contributor license agreements.  See the NOTICE file distributed with
     8  * this work for additional information regarding copyright ownership.
     8  * this work for additional information regarding copyright ownership.
    18  * See the License for the specific language governing permissions and
    18  * See the License for the specific language governing permissions and
    19  * limitations under the License.
    19  * limitations under the License.
    20  */
    20  */
    21 
    21 
    22 package com.sun.org.apache.xerces.internal.parsers;
    22 package com.sun.org.apache.xerces.internal.parsers;
    23 
       
    24 import java.io.IOException;
       
    25 import java.util.ArrayList;
       
    26 import java.util.HashMap;
       
    27 import java.util.Locale;
       
    28 
    23 
    29 import com.sun.org.apache.xerces.internal.impl.Constants;
    24 import com.sun.org.apache.xerces.internal.impl.Constants;
    30 import com.sun.org.apache.xerces.internal.util.FeatureState;
    25 import com.sun.org.apache.xerces.internal.util.FeatureState;
    31 import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
    26 import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
    32 import com.sun.org.apache.xerces.internal.util.PropertyState;
    27 import com.sun.org.apache.xerces.internal.util.PropertyState;
    42 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
    37 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
    43 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
    38 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
    44 import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
    39 import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
    45 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
    40 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
    46 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
    41 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
       
    42 import java.io.IOException;
       
    43 import java.util.ArrayList;
       
    44 import java.util.HashMap;
       
    45 import java.util.List;
       
    46 import java.util.Locale;
    47 
    47 
    48 /**
    48 /**
    49  * A very basic parser configuration. This configuration class can
    49  * A very basic parser configuration. This configuration class can
    50  * be used as a base class for custom parser configurations. The
    50  * be used as a base class for custom parser configurations. The
    51  * basic parser configuration creates the symbol table (if not
    51  * basic parser configuration creates the symbol table (if not
   154 
   154 
   155     /** Locale. */
   155     /** Locale. */
   156     protected Locale fLocale;
   156     protected Locale fLocale;
   157 
   157 
   158     /** Components. */
   158     /** Components. */
   159     protected ArrayList fComponents;
   159     protected List<XMLComponent> fComponents;
   160 
   160 
   161     // handlers
   161     // handlers
   162 
   162 
   163     /** The document handler. */
   163     /** The document handler. */
   164     protected XMLDocumentHandler fDocumentHandler;
   164     protected XMLDocumentHandler fDocumentHandler;
   200     protected BasicParserConfiguration(SymbolTable symbolTable,
   200     protected BasicParserConfiguration(SymbolTable symbolTable,
   201                                        XMLComponentManager parentSettings) {
   201                                        XMLComponentManager parentSettings) {
   202         super(parentSettings);
   202         super(parentSettings);
   203 
   203 
   204         // create a vector to hold all the components in use
   204         // create a vector to hold all the components in use
   205         fComponents = new ArrayList();
   205         fComponents = new ArrayList<>();
   206 
   206 
   207         // create table for features and properties
   207         // create table for features and properties
   208         fFeatures = new HashMap();
   208         fFeatures = new HashMap<>();
   209         fProperties = new HashMap();
   209         fProperties = new HashMap<>();
   210 
   210 
   211         // add default recognized features
   211         // add default recognized features
   212         final String[] recognizedFeatures = {
   212         final String[] recognizedFeatures = {
   213                 PARSER_SETTINGS,
   213                 PARSER_SETTINGS,
   214             VALIDATION,
   214             VALIDATION,
   440      */
   440      */
   441     public void setFeature(String featureId, boolean state)
   441     public void setFeature(String featureId, boolean state)
   442         throws XMLConfigurationException {
   442         throws XMLConfigurationException {
   443 
   443 
   444         // forward to every component
   444         // forward to every component
   445         int count = fComponents.size();
   445         for (XMLComponent c : fComponents) {
   446         for (int i = 0; i < count; i++) {
       
   447             XMLComponent c = (XMLComponent) fComponents.get(i);
       
   448             c.setFeature(featureId, state);
   446             c.setFeature(featureId, state);
   449         }
   447         }
   450         // save state if noone "objects"
   448         // save state if noone "objects"
   451         super.setFeature(featureId, state);
   449         super.setFeature(featureId, state);
   452 
   450 
   460      */
   458      */
   461     public void setProperty(String propertyId, Object value)
   459     public void setProperty(String propertyId, Object value)
   462         throws XMLConfigurationException {
   460         throws XMLConfigurationException {
   463 
   461 
   464         // forward to every component
   462         // forward to every component
   465         int count = fComponents.size();
   463         for (XMLComponent c : fComponents) {
   466         for (int i = 0; i < count; i++) {
       
   467             XMLComponent c = (XMLComponent) fComponents.get(i);
       
   468             c.setProperty(propertyId, value);
   464             c.setProperty(propertyId, value);
   469         }
   465         }
   470 
   466 
   471         // store value if noone "objects"
   467         // store value if noone "objects"
   472         super.setProperty(propertyId, value);
   468         super.setProperty(propertyId, value);
   496 
   492 
   497     /**
   493     /**
   498      * reset all components before parsing and namespace context
   494      * reset all components before parsing and namespace context
   499      */
   495      */
   500     protected void reset() throws XNIException {
   496     protected void reset() throws XNIException {
   501 
       
   502         // reset every component
   497         // reset every component
   503         int count = fComponents.size();
   498         for (XMLComponent c : fComponents) {
   504         for (int i = 0; i < count; i++) {
       
   505             XMLComponent c = (XMLComponent) fComponents.get(i);
       
   506             c.reset(this);
   499             c.reset(this);
   507         }
   500         }
   508 
       
   509     } // reset()
   501     } // reset()
   510 
   502 
   511     /**
   503     /**
   512      * Check a property. If the property is known and supported, this method
   504      * Check a property. If the property is known and supported, this method
   513      * simply returns. Otherwise, the appropriate exception is thrown.
   505      * simply returns. Otherwise, the appropriate exception is thrown.