src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDocumentInfo.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) 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.
    19  * limitations under the License.
    19  * limitations under the License.
    20  */
    20  */
    21 
    21 
    22 package com.sun.org.apache.xerces.internal.impl.xs.traversers;
    22 package com.sun.org.apache.xerces.internal.impl.xs.traversers;
    23 
    23 
    24 import java.util.Stack;
       
    25 import java.util.Vector;
       
    26 
       
    27 import com.sun.org.apache.xerces.internal.impl.validation.ValidationState;
    24 import com.sun.org.apache.xerces.internal.impl.validation.ValidationState;
    28 import com.sun.org.apache.xerces.internal.impl.xs.SchemaNamespaceSupport;
    25 import com.sun.org.apache.xerces.internal.impl.xs.SchemaNamespaceSupport;
    29 import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols;
    26 import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols;
    30 import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaException;
    27 import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaException;
    31 import com.sun.org.apache.xerces.internal.impl.xs.util.XInt;
    28 import com.sun.org.apache.xerces.internal.impl.xs.util.XInt;
    32 import com.sun.org.apache.xerces.internal.util.SymbolTable;
    29 import com.sun.org.apache.xerces.internal.util.SymbolTable;
       
    30 import java.util.ArrayList;
       
    31 import java.util.List;
       
    32 import java.util.Stack;
       
    33 import org.w3c.dom.Attr;
    33 import org.w3c.dom.Element;
    34 import org.w3c.dom.Element;
       
    35 import org.w3c.dom.NamedNodeMap;
    34 import org.w3c.dom.Node;
    36 import org.w3c.dom.Node;
    35 import org.w3c.dom.Attr;
       
    36 import org.w3c.dom.NamedNodeMap;
       
    37 
    37 
    38 /**
    38 /**
    39  * Objects of this class hold all information pecular to a
    39  * Objects of this class hold all information pecular to a
    40  * particular XML Schema document.  This is needed because
    40  * particular XML Schema document.  This is needed because
    41  * namespace bindings and other settings on the <schema/> element
    41  * namespace bindings and other settings on the <schema/> element
    48 class XSDocumentInfo {
    48 class XSDocumentInfo {
    49 
    49 
    50     // Data
    50     // Data
    51     protected SchemaNamespaceSupport fNamespaceSupport;
    51     protected SchemaNamespaceSupport fNamespaceSupport;
    52     protected SchemaNamespaceSupport fNamespaceSupportRoot;
    52     protected SchemaNamespaceSupport fNamespaceSupportRoot;
    53     protected Stack SchemaNamespaceSupportStack = new Stack();
    53     protected Stack<SchemaNamespaceSupport> SchemaNamespaceSupportStack = new Stack<>();
    54 
    54 
    55     // schema's attributeFormDefault
    55     // schema's attributeFormDefault
    56     protected boolean fAreLocalAttributesQualified;
    56     protected boolean fAreLocalAttributesQualified;
    57 
    57 
    58     // elementFormDefault
    58     // elementFormDefault
    70 
    70 
    71     // the root of the schema Document tree itself
    71     // the root of the schema Document tree itself
    72     protected Element fSchemaElement;
    72     protected Element fSchemaElement;
    73 
    73 
    74     // all namespaces that this document can refer to
    74     // all namespaces that this document can refer to
    75     Vector fImportedNS = new Vector();
    75     List<String> fImportedNS = new ArrayList<>();
    76 
    76 
    77     protected ValidationState fValidationContext = new ValidationState();
    77     protected ValidationState fValidationContext = new ValidationState();
    78 
    78 
    79     SymbolTable fSymbolTable = null;
    79     SymbolTable fSymbolTable = null;
    80 
    80 
   186 
   186 
   187         fValidationContext.setNamespaceSupport(fNamespaceSupport);
   187         fValidationContext.setNamespaceSupport(fNamespaceSupport);
   188     }
   188     }
   189 
   189 
   190     void restoreNSSupport() {
   190     void restoreNSSupport() {
   191         fNamespaceSupport = (SchemaNamespaceSupport)SchemaNamespaceSupportStack.pop();
   191         fNamespaceSupport = SchemaNamespaceSupportStack.pop();
   192         fValidationContext.setNamespaceSupport(fNamespaceSupport);
   192         fValidationContext.setNamespaceSupport(fNamespaceSupport);
   193     }
   193     }
   194 
   194 
   195     // some Object methods
   195     // some Object methods
   196     public String toString() {
   196     public String toString() {
   197         return fTargetNamespace == null?"no targetNamspace":"targetNamespace is " + fTargetNamespace;
   197         return fTargetNamespace == null?"no targetNamspace":"targetNamespace is " + fTargetNamespace;
   198     }
   198     }
   199 
   199 
   200     public void addAllowedNS(String namespace) {
   200     public void addAllowedNS(String namespace) {
   201         fImportedNS.addElement(namespace == null ? "" : namespace);
   201         fImportedNS.add(namespace == null ? "" : namespace);
   202     }
   202     }
   203 
   203 
   204     public boolean isAllowedNS(String namespace) {
   204     public boolean isAllowedNS(String namespace) {
   205         return fImportedNS.contains(namespace == null ? "" : namespace);
   205         return fImportedNS.contains(namespace == null ? "" : namespace);
   206     }
   206     }
   207 
   207 
   208     // store whether we have reported an error about that this document
   208     // store whether we have reported an error about that this document
   209     // can't access components from the given namespace
   209     // can't access components from the given namespace
   210     private Vector fReportedTNS = null;
   210     private List<String> fReportedTNS = null;
   211     // check whether we need to report an error against the given uri.
   211     // check whether we need to report an error against the given uri.
   212     // if we have reported an error, then we don't need to report again;
   212     // if we have reported an error, then we don't need to report again;
   213     // otherwise we reported the error, and remember this fact.
   213     // otherwise we reported the error, and remember this fact.
   214     final boolean needReportTNSError(String uri) {
   214     final boolean needReportTNSError(String uri) {
   215         if (fReportedTNS == null)
   215         if (fReportedTNS == null)
   216             fReportedTNS = new Vector();
   216             fReportedTNS = new ArrayList<>();
   217         else if (fReportedTNS.contains(uri))
   217         else if (fReportedTNS.contains(uri))
   218             return false;
   218             return false;
   219         fReportedTNS.addElement(uri);
   219         fReportedTNS.add(uri);
   220         return true;
   220         return true;
   221     }
   221     }
   222 
   222 
   223     // return the attributes on the schema element itself:
   223     // return the attributes on the schema element itself:
   224     Object [] getSchemaAttrs () {
   224     Object [] getSchemaAttrs () {