src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
child 47477 115ed64c7822
equal deleted inserted replaced
47358:d07d5f7cab35 47359:e1a6c0168741
     1 /*
     1 /*
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
       
     3  * @LastModified: Oct 2017
     3  */
     4  */
     4 /*
     5 /*
     5  * Licensed to the Apache Software Foundation (ASF) under one or more
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     6  * contributor license agreements.  See the NOTICE file distributed with
     7  * contributor license agreements.  See the NOTICE file distributed with
     7  * this work for additional information regarding copyright ownership.
     8  * this work for additional information regarding copyright ownership.
    17  * See the License for the specific language governing permissions and
    18  * See the License for the specific language governing permissions and
    18  * limitations under the License.
    19  * limitations under the License.
    19  */
    20  */
    20 
    21 
    21 package com.sun.org.apache.xerces.internal.parsers;
    22 package com.sun.org.apache.xerces.internal.parsers;
    22 
       
    23 import java.util.Locale;
       
    24 import java.util.Stack;
       
    25 
    23 
    26 import com.sun.org.apache.xerces.internal.dom.AttrImpl;
    24 import com.sun.org.apache.xerces.internal.dom.AttrImpl;
    27 import com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl;
    25 import com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl;
    28 import com.sun.org.apache.xerces.internal.dom.DOMErrorImpl;
    26 import com.sun.org.apache.xerces.internal.dom.DOMErrorImpl;
    29 import com.sun.org.apache.xerces.internal.dom.DOMMessageFormatter;
    27 import com.sun.org.apache.xerces.internal.dom.DOMMessageFormatter;
    42 import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl;
    40 import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl;
    43 import com.sun.org.apache.xerces.internal.dom.TextImpl;
    41 import com.sun.org.apache.xerces.internal.dom.TextImpl;
    44 import com.sun.org.apache.xerces.internal.impl.Constants;
    42 import com.sun.org.apache.xerces.internal.impl.Constants;
    45 import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
    43 import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
    46 import com.sun.org.apache.xerces.internal.util.DOMErrorHandlerWrapper;
    44 import com.sun.org.apache.xerces.internal.util.DOMErrorHandlerWrapper;
       
    45 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
    47 import com.sun.org.apache.xerces.internal.xni.Augmentations;
    46 import com.sun.org.apache.xerces.internal.xni.Augmentations;
    48 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
    47 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
    49 import com.sun.org.apache.xerces.internal.xni.QName;
    48 import com.sun.org.apache.xerces.internal.xni.QName;
    50 import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
    49 import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
    51 import com.sun.org.apache.xerces.internal.xni.XMLLocator;
    50 import com.sun.org.apache.xerces.internal.xni.XMLLocator;
    54 import com.sun.org.apache.xerces.internal.xni.XNIException;
    53 import com.sun.org.apache.xerces.internal.xni.XNIException;
    55 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
    54 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
    56 import com.sun.org.apache.xerces.internal.xs.AttributePSVI;
    55 import com.sun.org.apache.xerces.internal.xs.AttributePSVI;
    57 import com.sun.org.apache.xerces.internal.xs.ElementPSVI;
    56 import com.sun.org.apache.xerces.internal.xs.ElementPSVI;
    58 import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
    57 import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
    59 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
    58 import java.util.Locale;
       
    59 import java.util.Stack;
    60 import org.w3c.dom.Attr;
    60 import org.w3c.dom.Attr;
    61 import org.w3c.dom.CDATASection;
    61 import org.w3c.dom.CDATASection;
    62 import org.w3c.dom.Comment;
    62 import org.w3c.dom.Comment;
    63 import org.w3c.dom.DOMError;
    63 import org.w3c.dom.DOMError;
    64 import org.w3c.dom.Document;
    64 import org.w3c.dom.Document;
   261     protected boolean fFilterReject = false;
   261     protected boolean fFilterReject = false;
   262 
   262 
   263     // data
   263     // data
   264 
   264 
   265     /** Base uri stack*/
   265     /** Base uri stack*/
   266     protected final Stack fBaseURIStack = new Stack ();
   266     protected final Stack<String> fBaseURIStack = new Stack<>();
   267 
   267 
   268     /** LSParserFilter: tracks the element depth within a rejected subtree. */
   268     /** LSParserFilter: tracks the element depth within a rejected subtree. */
   269     protected int fRejectedElementDepth = 0;
   269     protected int fRejectedElementDepth = 0;
   270 
   270 
   271     /** LSParserFilter: store depth of skipped elements */
   271     /** LSParserFilter: store depth of skipped elements */
   272     protected Stack fSkippedElemStack = null;
   272     protected Stack<Boolean> fSkippedElemStack = null;
   273 
   273 
   274     /** LSParserFilter: true if inside entity reference */
   274     /** LSParserFilter: true if inside entity reference */
   275     protected boolean fInEntityRef = false;
   275     protected boolean fInEntityRef = false;
   276 
   276 
   277     /** Attribute QName. */
   277     /** Attribute QName. */
   343 
   343 
   344         if (!documentClassName.equals(DEFAULT_DOCUMENT_CLASS_NAME) &&
   344         if (!documentClassName.equals(DEFAULT_DOCUMENT_CLASS_NAME) &&
   345             !documentClassName.equals(PSVI_DOCUMENT_CLASS_NAME)) {
   345             !documentClassName.equals(PSVI_DOCUMENT_CLASS_NAME)) {
   346             // verify that this class exists and is of the right type
   346             // verify that this class exists and is of the right type
   347             try {
   347             try {
   348                 Class _class = ObjectFactory.findProviderClass (documentClassName, true);
   348                 Class<?> _class = ObjectFactory.findProviderClass (documentClassName, true);
   349                 //if (!_class.isAssignableFrom(Document.class)) {
   349                 //if (!_class.isAssignableFrom(Document.class)) {
   350                 if (!Document.class.isAssignableFrom (_class)) {
   350                 if (!Document.class.isAssignableFrom (_class)) {
   351                     throw new IllegalArgumentException (
   351                     throw new IllegalArgumentException (
   352                         DOMMessageFormatter.formatMessage(
   352                         DOMMessageFormatter.formatMessage(
   353                         DOMMessageFormatter.DOM_DOMAIN,
   353                         DOMMessageFormatter.DOM_DOMAIN,
   786                 fDocumentImpl.setDocumentURI (locator.getExpandedSystemId ());
   786                 fDocumentImpl.setDocumentURI (locator.getExpandedSystemId ());
   787             }
   787             }
   788             else {
   788             else {
   789                 // use specified document class
   789                 // use specified document class
   790                 try {
   790                 try {
   791                     Class documentClass = ObjectFactory.findProviderClass (fDocumentClassName, true);
   791                     Class<?> documentClass = ObjectFactory.findProviderClass (fDocumentClassName, true);
   792                     fDocument = (Document)documentClass.getConstructor().newInstance();
   792                     fDocument = (Document)documentClass.getConstructor().newInstance();
   793 
   793 
   794                     // if subclass of our own class that's cool too
   794                     // if subclass of our own class that's cool too
   795                     Class defaultDocClass =
   795                     Class<?> defaultDocClass =
   796                     ObjectFactory.findProviderClass (CORE_DOCUMENT_CLASS_NAME, true);
   796                     ObjectFactory.findProviderClass (CORE_DOCUMENT_CLASS_NAME, true);
   797                     if (defaultDocClass.isAssignableFrom (documentClass)) {
   797                     if (defaultDocClass.isAssignableFrom (documentClass)) {
   798                         fDocumentImpl = (CoreDocumentImpl)fDocument;
   798                         fDocumentImpl = (CoreDocumentImpl)fDocument;
   799 
   799 
   800                         Class psviDocClass = ObjectFactory.findProviderClass (PSVI_DOCUMENT_CLASS_NAME, true);
   800                         Class<?> psviDocClass = ObjectFactory.findProviderClass (PSVI_DOCUMENT_CLASS_NAME, true);
   801                         if (psviDocClass.isAssignableFrom (documentClass)) {
   801                         if (psviDocClass.isAssignableFrom (documentClass)) {
   802                             fStorePSVI = true;
   802                             fStorePSVI = true;
   803                         }
   803                         }
   804 
   804 
   805                         // REVISIT: when DOM Level 3 is REC rely on
   805                         // REVISIT: when DOM Level 3 is REC rely on