jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java
author joehw
Thu, 15 Dec 2016 13:57:04 -0800
changeset 42802 2a03abb03c06
parent 42394 285ea8081752
child 44800 bc291f6e8320
permissions -rw-r--r--
8170556: Warnings cleanup related to JDK-8167340 Reviewed-by: dfuchs, lancea, clanger
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     1
/*
42394
285ea8081752 8167340: XMLStreamReader.getElementText return corrupt content when size of element is > 8192
joehw
parents: 39080
diff changeset
     2
 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     4
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    10
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    15
 * accompanied this code).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    16
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    20
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    23
 * questions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    24
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    25
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    26
package com.sun.org.apache.xerces.internal.impl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    27
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    28
import com.sun.org.apache.xerces.internal.util.NamespaceContextWrapper;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    29
import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    30
import com.sun.org.apache.xerces.internal.util.SymbolTable;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    31
import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    32
import com.sun.org.apache.xerces.internal.util.XMLChar;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    33
import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    34
import com.sun.org.apache.xerces.internal.xni.XNIException;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    35
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    36
import com.sun.xml.internal.stream.Entity;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    37
import com.sun.xml.internal.stream.StaxErrorReporter;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    38
import com.sun.xml.internal.stream.XMLEntityStorage;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    39
import com.sun.xml.internal.stream.dtd.nonvalidating.DTDGrammar;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    40
import com.sun.xml.internal.stream.dtd.nonvalidating.XMLNotationDecl;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    41
import com.sun.xml.internal.stream.events.EntityDeclarationImpl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    42
import com.sun.xml.internal.stream.events.NotationDeclarationImpl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    43
import java.io.BufferedInputStream;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    44
import java.io.BufferedReader;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    45
import java.io.IOException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    46
import java.io.InputStream;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    47
import java.io.Reader;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    48
import java.util.ArrayList;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    49
import java.util.List;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    50
import java.util.Map;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    51
import javax.xml.XMLConstants;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    52
import javax.xml.namespace.NamespaceContext;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    53
import javax.xml.namespace.QName;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    54
import javax.xml.stream.Location;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    55
import javax.xml.stream.XMLInputFactory;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    56
import javax.xml.stream.XMLStreamConstants;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    57
import javax.xml.stream.XMLStreamException;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    58
import javax.xml.stream.events.EntityDeclaration;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    59
import javax.xml.stream.events.NotationDeclaration;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    60
import javax.xml.stream.events.XMLEvent;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    61
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    62
/**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    63
 * This class implements javax.xml.stream.XMLStreamReader. It makes use of
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    64
 * XML*Scanner classes to derive most of its functionality. If desired,
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    65
 * Application can reuse this instance by calling reset() and setInputSource().
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    66
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    67
 * @author Neeraj Bajaj Sun Microsystems,Inc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    68
 * @author K.Venugopal Sun Microsystems,Inc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    69
 * @author Sunitha Reddy Sun Microsystems,Inc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    70
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    71
public class XMLStreamReaderImpl implements javax.xml.stream.XMLStreamReader {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    72
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    73
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    74
     * Property identifier: entity manager.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    75
     */
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    76
    protected static final String ENTITY_MANAGER
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    77
            = Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    78
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    79
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    80
     * Property identifier: Error Reporter.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    81
     */
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    82
    protected static final String ERROR_REPORTER
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    83
            = Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    84
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    85
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    86
     * Property identifier: Symbol table.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    87
     */
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    88
    protected static final String SYMBOL_TABLE
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    89
            = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    90
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    91
    protected static final String READER_IN_DEFINED_STATE
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    92
            = Constants.READER_IN_DEFINED_STATE;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    93
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    94
    private SymbolTable fSymbolTable = new SymbolTable();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    95
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    96
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    97
     * Document scanner.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
    98
     */
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    99
    protected XMLDocumentScannerImpl fScanner = new XMLNSDocumentScannerImpl();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   100
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   101
    //make Global NamespaceContextWrapper object,  fScanner.getNamespaceContext()
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   102
    //is dynamic object and ita value changes as per the state of the parser.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   103
    protected NamespaceContextWrapper fNamespaceContextWrapper =
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   104
            new NamespaceContextWrapper((NamespaceSupport) fScanner.getNamespaceContext());
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   105
    protected XMLEntityManager fEntityManager = new XMLEntityManager();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   106
    protected StaxErrorReporter fErrorReporter = new StaxErrorReporter();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   107
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   108
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   109
     * Entity scanner, this alwasy works on last entity that was opened.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   110
     */
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   111
    protected XMLEntityScanner fEntityScanner = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   112
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   113
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   114
     * Input Source
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   115
     */
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   116
    protected XMLInputSource fInputSource = null;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   117
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   118
     * Store properties
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   119
     */
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   120
    protected PropertyManager fPropertyManager = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   121
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   122
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   123
     * current event type
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   124
     */
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   125
    private int fEventType;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   126
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   127
     * debug flag
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   128
     */
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   129
    static final boolean DEBUG = false;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   130
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   131
     * more to scan
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   132
     */
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   133
    private boolean fReuse = true;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   134
    private boolean fReaderInDefinedState = true;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   135
    private String fDTDDecl = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   136
    private String versionStr = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   137
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   138
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   139
     * @param inputStream
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   140
     * @param props
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   141
     * @throws XMLStreamException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   142
     */
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   143
    public XMLStreamReaderImpl(InputStream inputStream, PropertyManager props) throws XMLStreamException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   144
        init(props);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   145
        //publicId, systemid, baseSystemId, inputStream, enocding
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   146
        XMLInputSource inputSource = new XMLInputSource(null, null, null, inputStream, null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   147
        //pass the input source to document scanner impl.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   148
        setInputSource(inputSource);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   149
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   150
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   151
    public XMLDocumentScannerImpl getScanner() {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   152
        System.out.println("returning scanner");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   153
        return fScanner;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   154
    }
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   155
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   156
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   157
     * @param systemid
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   158
     * @param props
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   159
     * @throws XMLStreamException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   160
     */
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   161
    public XMLStreamReaderImpl(String systemid, PropertyManager props) throws XMLStreamException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   162
        init(props);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   163
        //publicId, systemid, baseSystemId, inputStream, enocding
39080
57563e513b11 8158204: accessExternalSchema property handling is inconsistent and differs from spec.
joehw
parents: 33349
diff changeset
   164
        XMLInputSource inputSource = new XMLInputSource(null, systemid, null, false);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   165
        //pass the input source to document scanner impl.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   166
        setInputSource(inputSource);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   167
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   168
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   169
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   170
     * @param inputStream
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   171
     * @param encoding
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   172
     * @param props
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   173
     * @throws XMLStreamException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   174
     */
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   175
    public XMLStreamReaderImpl(InputStream inputStream, String encoding, PropertyManager props)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   176
            throws XMLStreamException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   177
        init(props);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   178
        //publicId, systemid, baseSystemId, inputStream, enocding
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   179
        XMLInputSource inputSource = new XMLInputSource(null, null, null,
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   180
                new BufferedInputStream(inputStream), encoding);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   181
        //pass the input source to document scanner impl.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   182
        setInputSource(inputSource);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   183
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   184
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   185
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   186
     * @param reader
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   187
     * @param props
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   188
     * @throws XMLStreamException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   189
     */
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   190
    public XMLStreamReaderImpl(Reader reader, PropertyManager props)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   191
            throws XMLStreamException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   192
        init(props);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   193
        //publicId, systemid, baseSystemId, inputStream, enocding
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   194
        //xxx: Using buffered reader
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   195
        XMLInputSource inputSource = new XMLInputSource(null, null, null,
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   196
                new BufferedReader(reader), null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   197
        //pass the input source to document scanner impl.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   198
        setInputSource(inputSource);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   199
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   200
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   201
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   202
     * @param inputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   203
     * @param props
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   204
     * @throws XMLStreamException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   205
     */
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   206
    public XMLStreamReaderImpl(XMLInputSource inputSource, PropertyManager props)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   207
            throws XMLStreamException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   208
        init(props);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   209
        //pass the input source to document scanner impl.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   210
        setInputSource(inputSource);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   211
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   212
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   213
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   214
     * @param inputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   215
     * @throws XMLStreamException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   216
     */
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   217
    public final void setInputSource(XMLInputSource inputSource) throws XMLStreamException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   218
        //once setInputSource() is called this instance is busy parsing the inputsource supplied
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   219
        //this instances is free for reuse if parser has reached END_DOCUMENT state or application has
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   220
        //called close()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   221
        fReuse = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   222
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   223
        try {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   224
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   225
            fScanner.setInputSource(inputSource);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   226
            //XMLStreamReader should be in defined state
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   227
            if (fReaderInDefinedState) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   228
                fEventType = fScanner.next();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   229
                if (versionStr == null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   230
                    versionStr = getVersion();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   231
                }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   232
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   233
                if (fEventType == XMLStreamConstants.START_DOCUMENT && versionStr != null
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   234
                        && versionStr.equals("1.1")) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   235
                    switchToXML11Scanner();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   236
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   237
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   238
            }
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   239
        } catch (java.io.IOException ex) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   240
            throw new XMLStreamException(ex);
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   241
        } catch (XNIException ex) { //Issue 56 XNIException not caught
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   242
            throw new XMLStreamException(ex.getMessage(), getLocation(), ex.getException());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   243
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   244
    }//setInputSource
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   245
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   246
    final void init(PropertyManager propertyManager) throws XMLStreamException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   247
        fPropertyManager = propertyManager;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   248
        //set Stax internal properties -- Note that these instances are being created in XMLReaderImpl.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   249
        //1.SymbolTable
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   250
        //2.XMLMessageFormatter
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   251
        //3.XMLEntityManager
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   252
        //4. call reset()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   253
        //1.
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   254
        propertyManager.setProperty(SYMBOL_TABLE, fSymbolTable);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   255
        //2.
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   256
        propertyManager.setProperty(ERROR_REPORTER, fErrorReporter);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   257
        //3.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   258
        propertyManager.setProperty(ENTITY_MANAGER, fEntityManager);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   259
        //4.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   260
        reset();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   261
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   262
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   263
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   264
     * This function tells if this instances is available for reuse. One must
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   265
     * call reset() and setInputSource() to be able to reuse this instance.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   266
     */
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   267
    public boolean canReuse() {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   268
        if (DEBUG) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   269
            System.out.println("fReuse = " + fReuse);
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   270
            System.out.println("fEventType = " + getEventTypeString(fEventType));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   271
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   272
        //when parsing begins, fReuse is set to false
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   273
        //fReuse is set to 'true' when application calls close()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   274
        return fReuse;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   275
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   276
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   277
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   278
     * Resets this instance so that this instance is ready for reuse.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   279
     */
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   280
    public void reset() {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   281
        fReuse = true;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   282
        fEventType = 0;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   283
        //reset entity manager
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   284
        fEntityManager.reset(fPropertyManager);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   285
        //reset the scanner
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   286
        fScanner.reset(fPropertyManager);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   287
        //REVISIT:this is too ugly -- we are getting XMLEntityManager and XMLEntityReader from
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   288
        //property manager, it should be only XMLEntityManager
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   289
        fDTDDecl = null;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   290
        fEntityScanner = fEntityManager.getEntityScanner();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   291
        //default value for this property is true. However, this should be false
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   292
        //when using XMLEventReader, because XMLEventReader should not have defined state.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   293
        fReaderInDefinedState = ((Boolean) fPropertyManager.getProperty(READER_IN_DEFINED_STATE));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   294
        versionStr = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   295
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   296
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   297
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   298
     * Frees any resources associated with this Reader. This method does not
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   299
     * close the underlying input source.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   300
     *
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   301
     * @throws XMLStreamException if there are errors freeing associated
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   302
     * resources
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   303
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   304
    public void close() throws XMLStreamException {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   305
        //xxx: Check what this function is intended to do.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   306
        //reset();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   307
        fReuse = true;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   308
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   309
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   310
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   311
     * Returns the character encoding declared on the xml declaration Returns
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   312
     * null if none was declared
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   313
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   314
     * @return the encoding declared in the document or null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   315
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   316
    public String getCharacterEncodingScheme() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   317
        return fScanner.getCharacterEncodingScheme();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   318
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   319
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   320
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   321
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   322
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   323
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   324
    public int getColumnNumber() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   325
        return fEntityScanner.getColumnNumber();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   326
    }//getColumnNumber
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   327
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   328
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   329
     * Return input encoding if known or null if unknown.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   330
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   331
     * @return the encoding of this instance or null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   332
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   333
    public String getEncoding() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   334
        return fEntityScanner.getEncoding();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   335
    }//getEncoding
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   336
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   337
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   338
     * Returns the current value of the parse event as a string, this returns
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   339
     * the string value of a CHARACTERS event, returns the value of a COMMENT,
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   340
     * the replacement value for an ENTITY_REFERENCE, the string value of a
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   341
     * CDATA section, the string value for a SPACE event, or the String value of
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   342
     * the internal subset of the DTD. If an ENTITY_REFERENCE has been resolved,
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   343
     * any character data will be reported as CHARACTERS events.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   344
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   345
     * @return the current text or null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   346
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   347
    public int getEventType() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   348
        return fEventType;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   349
    }//getEventType
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   350
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   351
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   352
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   353
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   354
    public int getLineNumber() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   355
        return fEntityScanner.getLineNumber();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   356
    }//getLineNumber
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   357
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   358
    public String getLocalName() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   359
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   360
            //xxx check whats the value of fCurrentElement
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   361
            return fScanner.getElementQName().localpart;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   362
        } else if (fEventType == XMLEvent.ENTITY_REFERENCE) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   363
            return fScanner.getEntityName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   364
        }
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   365
        throw new IllegalStateException("Method getLocalName() cannot be called for "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   366
                + getEventTypeString(fEventType) + " event.");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   367
    }//getLocalName()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   368
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   369
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   370
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   371
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   372
    public String getNamespaceURI() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   373
        //doesn't take care of Attribute as separte event
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   374
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   375
            return fScanner.getElementQName().uri;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   376
        }
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   377
        return null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   378
    }//getNamespaceURI
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   379
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   380
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   381
     * Get the data section of a processing instruction
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   382
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   383
     * @return the data or null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   384
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   385
    public String getPIData() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   386
        if (fEventType == XMLEvent.PROCESSING_INSTRUCTION) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   387
            return fScanner.getPIData().toString();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   388
        } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   389
            throw new java.lang.IllegalStateException("Current state of the parser is " + getEventTypeString(fEventType)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   390
                    + " But Expected state is " + XMLEvent.PROCESSING_INSTRUCTION);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   391
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   392
    }//getPIData
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   393
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   394
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   395
     * Get the target of a processing instruction
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   396
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   397
     * @return the target or null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   398
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   399
    public String getPITarget() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   400
        if (fEventType == XMLEvent.PROCESSING_INSTRUCTION) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   401
            return fScanner.getPITarget();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   402
        } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   403
            throw new java.lang.IllegalStateException("Current state of the parser is " + getEventTypeString(fEventType)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   404
                    + " But Expected state is " + XMLEvent.PROCESSING_INSTRUCTION);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   405
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   406
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   407
    }//getPITarget
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   408
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   409
    /**
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   410
     * @return the prefix of the current event, or null if the event does not
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   411
     * have a prefix. For START_ELEMENT and END_ELEMENT, return
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   412
     * XMLConstants.DEFAULT_NS_PREFIX when no prefix is available.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   413
     */
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   414
    public String getPrefix() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   415
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   416
            String prefix = fScanner.getElementQName().prefix;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   417
            return prefix == null ? XMLConstants.DEFAULT_NS_PREFIX : prefix;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   418
        }
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   419
        return null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   420
    }//getPrefix()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   421
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   422
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   423
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   424
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   425
    public char[] getTextCharacters() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   426
        if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   427
                || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   428
            return fScanner.getCharacterData().ch;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   429
        } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   430
            throw new IllegalStateException("Current state = " + getEventTypeString(fEventType)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   431
                    + " is not among the states " + getEventTypeString(XMLEvent.CHARACTERS) + " , "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   432
                    + getEventTypeString(XMLEvent.COMMENT) + " , " + getEventTypeString(XMLEvent.CDATA)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   433
                    + " , " + getEventTypeString(XMLEvent.SPACE) + " valid for getTextCharacters() ");
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   434
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   435
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   436
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   437
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   438
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   439
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   440
    public int getTextLength() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   441
        if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   442
                || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   443
            return fScanner.getCharacterData().length;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   444
        } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   445
            throw new IllegalStateException("Current state = " + getEventTypeString(fEventType)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   446
                    + " is not among the states " + getEventTypeString(XMLEvent.CHARACTERS) + " , "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   447
                    + getEventTypeString(XMLEvent.COMMENT) + " , " + getEventTypeString(XMLEvent.CDATA)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   448
                    + " , " + getEventTypeString(XMLEvent.SPACE) + " valid for getTextLength() ");
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   449
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   450
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   451
    }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   452
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   453
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   454
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   455
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   456
    public int getTextStart() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   457
        if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   458
                || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   459
            return fScanner.getCharacterData().offset;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   460
        } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   461
            throw new IllegalStateException("Current state = " + getEventTypeString(fEventType)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   462
                    + " is not among the states " + getEventTypeString(XMLEvent.CHARACTERS) + " , "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   463
                    + getEventTypeString(XMLEvent.COMMENT) + " , " + getEventTypeString(XMLEvent.CDATA)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   464
                    + " , " + getEventTypeString(XMLEvent.SPACE) + " valid for getTextStart() ");
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   465
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   466
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   467
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   468
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   469
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   470
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   471
    public String getValue() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   472
        if (fEventType == XMLEvent.PROCESSING_INSTRUCTION) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   473
            return fScanner.getPIData().toString();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   474
        } else if (fEventType == XMLEvent.COMMENT) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   475
            return fScanner.getComment();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   476
        } else if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   477
            return fScanner.getElementQName().localpart;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   478
        } else if (fEventType == XMLEvent.CHARACTERS) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   479
            return fScanner.getCharacterData().toString();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   480
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   481
        return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   482
    }//getValue()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   483
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   484
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   485
     * Get the XML language version of the current document being parsed
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   486
     */
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   487
    public String getVersion() {
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   488
        //apply SAP's patch: the default version in the scanner was set to 1.0 because of DOM and SAX
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   489
        //so this patch is a workaround of the difference between StAX and DOM
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   490
        // SAPJVM: Return null if the XML version has not been declared (as specified in the JavaDoc).
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   491
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   492
        String version = fEntityScanner.getXMLVersion();
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   493
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   494
        return "1.0".equals(version) && !fEntityScanner.xmlVersionSetExplicitly ? null : version;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   495
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   496
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   497
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   498
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   499
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   500
    public boolean hasAttributes() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   501
        return fScanner.getAttributeIterator().getLength() > 0 ? true : false;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   502
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   503
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   504
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   505
     * this Funtion returns true if the current event has name
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   506
     */
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   507
    public boolean hasName() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   508
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   509
            return true;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   510
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   511
            return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   512
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   513
    }//hasName()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   514
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   515
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   516
     * @throws XMLStreamException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   517
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   518
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   519
    public boolean hasNext() throws XMLStreamException {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   520
        //the scanner returns -1 when it detects a broken stream
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   521
        if (fEventType == -1) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   522
            return false;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   523
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   524
        //we can check in scanners if the scanner state is not set to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   525
        //terminating, we still have more events.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   526
        return fEventType != XMLEvent.END_DOCUMENT;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   527
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   528
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   529
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   530
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   531
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   532
    public boolean hasValue() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   533
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   534
                || fEventType == XMLEvent.ENTITY_REFERENCE || fEventType == XMLEvent.PROCESSING_INSTRUCTION
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   535
                || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CHARACTERS) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   536
            return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   537
        } else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   538
            return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   539
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   540
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   541
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   542
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   543
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   544
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   545
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   546
    public boolean isEndElement() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   547
        return fEventType == XMLEvent.END_ELEMENT;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   548
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   549
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   550
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   551
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   552
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   553
    public boolean isStandalone() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   554
        return fScanner.isStandAlone();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   555
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   556
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   557
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   558
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   559
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   560
    public boolean isStartElement() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   561
        return fEventType == XMLEvent.START_ELEMENT;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   562
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   563
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   564
    /**
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   565
     * Returns true if the cursor points to a character data event that consists
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   566
     * of all whitespace Application calling this method needs to cache the
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   567
     * value and avoid calling this method again for the same event.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   568
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   569
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   570
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   571
    public boolean isWhiteSpace() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   572
        if (isCharacters() || (fEventType == XMLStreamConstants.CDATA)) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   573
            char[] ch = this.getTextCharacters();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   574
            final int start = this.getTextStart();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   575
            final int end = start + this.getTextLength();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   576
            for (int i = start; i < end; i++) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   577
                if (!XMLChar.isSpace(ch[i])) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   578
                    return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   579
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   580
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   581
            return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   582
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   583
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   584
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   585
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   586
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   587
     * @throws XMLStreamException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   588
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   589
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   590
    public int next() throws XMLStreamException {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   591
        if (!hasNext()) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   592
            if (fEventType != -1) {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   593
                throw new java.util.NoSuchElementException(
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   594
                        "END_DOCUMENT reached: no more elements on the stream.");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   595
            } else {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   596
                throw new XMLStreamException(
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   597
                        "Error processing input source. The input stream is not complete.");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   598
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   599
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   600
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   601
            fEventType = fScanner.next();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   602
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   603
            if (versionStr == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   604
                versionStr = getVersion();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   605
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   606
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   607
            if (fEventType == XMLStreamConstants.START_DOCUMENT
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   608
                    && versionStr != null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   609
                    && versionStr.equals("1.1")) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   610
                switchToXML11Scanner();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   611
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   612
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   613
            return fEventType;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   614
        } catch (IOException ex) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   615
            // if this error occured trying to resolve the external DTD subset
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   616
            // and IS_VALIDATING == false, then this is not an XML error
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   617
            if (fScanner.fScannerState == XMLDocumentScannerImpl.SCANNER_STATE_DTD_EXTERNAL) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   618
                Boolean isValidating = (Boolean) fPropertyManager.getProperty(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   619
                        XMLInputFactory.IS_VALIDATING);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   620
                if (isValidating != null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   621
                        && !isValidating.booleanValue()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   622
                    // ignore the error, set scanner to known state
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   623
                    fEventType = XMLEvent.DTD;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   624
                    fScanner.setScannerState(XMLDocumentScannerImpl.SCANNER_STATE_PROLOG);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   625
                    fScanner.setDriver(fScanner.fPrologDriver);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   626
                    if (fDTDDecl == null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   627
                            || fDTDDecl.length() == 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   628
                        fDTDDecl = "<!-- "
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   629
                                + "Exception scanning External DTD Subset.  "
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   630
                                + "True contents of DTD cannot be determined.  "
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   631
                                + "Processing will continue as XMLInputFactory.IS_VALIDATING == false."
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   632
                                + " -->";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   633
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   634
                    return XMLEvent.DTD;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   635
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   636
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   637
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   638
            // else real error
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   639
            throw new XMLStreamException(ex.getMessage(), getLocation(), ex);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   640
        } catch (XNIException ex) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   641
            throw new XMLStreamException(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   642
                    ex.getMessage(),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   643
                    getLocation(),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   644
                    ex.getException());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   645
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   646
    } //next()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   647
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   648
    private void switchToXML11Scanner() throws IOException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   649
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   650
        int oldEntityDepth = fScanner.fEntityDepth;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   651
        com.sun.org.apache.xerces.internal.xni.NamespaceContext oldNamespaceContext
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   652
                = fScanner.fNamespaceContext;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   653
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   654
        fScanner = new XML11NSDocumentScannerImpl();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   655
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   656
        //get the new scanner state to old scanner's previous state
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   657
        fScanner.reset(fPropertyManager);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   658
        fScanner.setPropertyManager(fPropertyManager);
42394
285ea8081752 8167340: XMLStreamReader.getElementText return corrupt content when size of element is > 8192
joehw
parents: 39080
diff changeset
   659
        fEntityScanner = fEntityManager.getEntityScanner();
285ea8081752 8167340: XMLStreamReader.getElementText return corrupt content when size of element is > 8192
joehw
parents: 39080
diff changeset
   660
        fEntityScanner.registerListener(fScanner);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   661
        fEntityManager.fCurrentEntity.mayReadChunks = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   662
        fScanner.setScannerState(XMLEvent.START_DOCUMENT);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   663
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   664
        fScanner.fEntityDepth = oldEntityDepth;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   665
        fScanner.fNamespaceContext = oldNamespaceContext;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   666
        fEventType = fScanner.next();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   667
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   668
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   669
    final static String getEventTypeString(int eventType) {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   670
        switch (eventType) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   671
            case XMLEvent.START_ELEMENT:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   672
                return "START_ELEMENT";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   673
            case XMLEvent.END_ELEMENT:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   674
                return "END_ELEMENT";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   675
            case XMLEvent.PROCESSING_INSTRUCTION:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   676
                return "PROCESSING_INSTRUCTION";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   677
            case XMLEvent.CHARACTERS:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   678
                return "CHARACTERS";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   679
            case XMLEvent.COMMENT:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   680
                return "COMMENT";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   681
            case XMLEvent.START_DOCUMENT:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   682
                return "START_DOCUMENT";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   683
            case XMLEvent.END_DOCUMENT:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   684
                return "END_DOCUMENT";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   685
            case XMLEvent.ENTITY_REFERENCE:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   686
                return "ENTITY_REFERENCE";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   687
            case XMLEvent.ATTRIBUTE:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   688
                return "ATTRIBUTE";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   689
            case XMLEvent.DTD:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   690
                return "DTD";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   691
            case XMLEvent.CDATA:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   692
                return "CDATA";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   693
            case XMLEvent.SPACE:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   694
                return "SPACE";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   695
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   696
        return "UNKNOWN_EVENT_TYPE, " + String.valueOf(eventType);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   697
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   698
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   699
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   700
     * Returns the count of attributes on this START_ELEMENT, this method is
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   701
     * only valid on a START_ELEMENT or ATTRIBUTE. This count excludes namespace
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   702
     * definitions. Attribute indices are zero-based.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   703
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   704
     * @return returns the number of attributes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   705
     * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   706
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   707
    public int getAttributeCount() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   708
        //xxx: recognize SAX properties namespace, namespace-prefix to get XML Namespace declarations
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   709
        //does length includes namespace declarations ?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   710
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   711
        //State should be either START_ELEMENT or ATTRIBUTE
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   712
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   713
            return fScanner.getAttributeIterator().getLength();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   714
        } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   715
            throw new java.lang.IllegalStateException("Current state is not among the states "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   716
                    + getEventTypeString(XMLEvent.START_ELEMENT) + " , "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   717
                    + getEventTypeString(XMLEvent.ATTRIBUTE)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   718
                    + "valid for getAttributeCount()");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   719
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   720
    }//getAttributeCount
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   721
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   722
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   723
     * Returns the localName of the attribute at the provided index
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   724
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   725
     * @param index the position of the attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   726
     * @return the localName of the attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   727
     * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   728
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   729
    public QName getAttributeName(int index) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   730
        //State should be either START_ELEMENT or ATTRIBUTE
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   731
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   732
            return convertXNIQNametoJavaxQName(fScanner.getAttributeIterator().getQualifiedName(index));
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   733
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   734
            throw new java.lang.IllegalStateException("Current state is not among the states "
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   735
                    + getEventTypeString(XMLEvent.START_ELEMENT) + " , "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   736
                    + getEventTypeString(XMLEvent.ATTRIBUTE)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   737
                    + "valid for getAttributeName()");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   738
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   739
    }//getAttributeName
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   740
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   741
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   742
     * @param index
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   743
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   744
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   745
    public String getAttributeLocalName(int index) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   746
        //State should be either START_ELEMENT or ATTRIBUTE
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   747
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   748
            return fScanner.getAttributeIterator().getLocalName(index);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   749
        } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   750
            throw new java.lang.IllegalStateException();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   751
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   752
    }//getAttributeName
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   753
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   754
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   755
     * Returns the namespace of the attribute at the provided index
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   756
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   757
     * @param index the position of the attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   758
     * @return the namespace URI (can be null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   759
     * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   760
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   761
    public String getAttributeNamespace(int index) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   762
        //State should be either START_ELEMENT or ATTRIBUTE
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   763
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   764
            return fScanner.getAttributeIterator().getURI(index);
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   765
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   766
            throw new java.lang.IllegalStateException("Current state is not among the states "
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   767
                    + getEventTypeString(XMLEvent.START_ELEMENT) + " , "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   768
                    + getEventTypeString(XMLEvent.ATTRIBUTE)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   769
                    + "valid for getAttributeNamespace()");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   770
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   771
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   772
    }//getAttributeNamespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   773
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   774
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   775
     * Returns the prefix of this attribute at the provided index
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   776
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   777
     * @param index the position of the attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   778
     * @return the prefix of the attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   779
     * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   780
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   781
    public String getAttributePrefix(int index) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   782
        //State should be either START_ELEMENT or ATTRIBUTE
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   783
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   784
            return fScanner.getAttributeIterator().getPrefix(index);
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   785
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   786
            throw new java.lang.IllegalStateException("Current state is not among the states "
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   787
                    + getEventTypeString(XMLEvent.START_ELEMENT) + " , "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   788
                    + getEventTypeString(XMLEvent.ATTRIBUTE)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   789
                    + "valid for getAttributePrefix()");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   790
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   791
    }//getAttributePrefix
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   792
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   793
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   794
     * Returns the qname of the attribute at the provided index
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   795
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   796
     * @param index the position of the attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   797
     * @return the QName of the attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   798
     * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   799
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   800
    public javax.xml.namespace.QName getAttributeQName(int index) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   801
        //State should be either START_ELEMENT or ATTRIBUTE
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   802
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   803
            // create new object at runtime..
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   804
            String localName = fScanner.getAttributeIterator().getLocalName(index);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   805
            String uri = fScanner.getAttributeIterator().getURI(index);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   806
            return new javax.xml.namespace.QName(uri, localName);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   807
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   808
            throw new java.lang.IllegalStateException("Current state is not among the states "
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   809
                    + getEventTypeString(XMLEvent.START_ELEMENT) + " , "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   810
                    + getEventTypeString(XMLEvent.ATTRIBUTE)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   811
                    + "valid for getAttributeQName()");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   812
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   813
    }//getAttributeQName
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   814
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   815
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   816
     * Returns the XML type of the attribute at the provided index
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   817
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   818
     * @param index the position of the attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   819
     * @return the XML type of the attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   820
     * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   821
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   822
    public String getAttributeType(int index) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   823
        //State should be either START_ELEMENT or ATTRIBUTE
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   824
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   825
            return fScanner.getAttributeIterator().getType(index);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   826
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   827
            throw new java.lang.IllegalStateException("Current state is not among the states "
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   828
                    + getEventTypeString(XMLEvent.START_ELEMENT) + " , "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   829
                    + getEventTypeString(XMLEvent.ATTRIBUTE)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   830
                    + "valid for getAttributeType()");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   831
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   832
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   833
    }//getAttributeType
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   834
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   835
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   836
     * Returns the value of the attribute at the index
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   837
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   838
     * @param index the position of the attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   839
     * @return the attribute value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   840
     * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   841
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   842
    public String getAttributeValue(int index) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   843
        //State should be either START_ELEMENT or ATTRIBUTE
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   844
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   845
            return fScanner.getAttributeIterator().getValue(index);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   846
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   847
            throw new java.lang.IllegalStateException("Current state is not among the states "
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   848
                    + getEventTypeString(XMLEvent.START_ELEMENT) + " , "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   849
                    + getEventTypeString(XMLEvent.ATTRIBUTE)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   850
                    + "valid for getAttributeValue()");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   851
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   852
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   853
    }//getAttributeValue
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   854
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   855
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   856
     * @param namespaceURI
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   857
     * @param localName
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   858
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   859
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   860
    public String getAttributeValue(String namespaceURI, String localName) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   861
        //State should be either START_ELEMENT or ATTRIBUTE
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   862
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   863
            XMLAttributesImpl attributes = fScanner.getAttributeIterator();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   864
            if (namespaceURI == null) { //sjsxp issue 70
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   865
                return attributes.getValue(attributes.getIndexByLocalName(localName));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   866
            } else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   867
                return fScanner.getAttributeIterator().getValue(
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   868
                        namespaceURI.length() == 0 ? null : namespaceURI, localName);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   869
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   870
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   871
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   872
            throw new java.lang.IllegalStateException("Current state is not among the states "
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   873
                    + getEventTypeString(XMLEvent.START_ELEMENT) + " , "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   874
                    + getEventTypeString(XMLEvent.ATTRIBUTE)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   875
                    + "valid for getAttributeValue()");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   876
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   877
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   878
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   879
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   880
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   881
     * Reads the content of a text-only element. Precondition: the current event
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   882
     * is START_ELEMENT. Postcondition: The current event is the corresponding
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   883
     * END_ELEMENT.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   884
     *
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   885
     * @throws XMLStreamException if the current event is not a START_ELEMENT or
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   886
     * if a non text element is encountered
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   887
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   888
    public String getElementText() throws XMLStreamException {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   889
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   890
        if (getEventType() != XMLStreamConstants.START_ELEMENT) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   891
            throw new XMLStreamException(
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   892
                    "parser must be on START_ELEMENT to read next text", getLocation());
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   893
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   894
        int eventType = next();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   895
        StringBuilder content = new StringBuilder();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   896
        while (eventType != XMLStreamConstants.END_ELEMENT) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   897
            if (eventType == XMLStreamConstants.CHARACTERS
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   898
                    || eventType == XMLStreamConstants.CDATA
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   899
                    || eventType == XMLStreamConstants.SPACE
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   900
                    || eventType == XMLStreamConstants.ENTITY_REFERENCE) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   901
                content.append(getText());
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   902
            } else if (eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   903
                    || eventType == XMLStreamConstants.COMMENT) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   904
                // skipping
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   905
            } else if (eventType == XMLStreamConstants.END_DOCUMENT) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   906
                throw new XMLStreamException(
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   907
                        "unexpected end of document when reading element text content");
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   908
            } else if (eventType == XMLStreamConstants.START_ELEMENT) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   909
                throw new XMLStreamException("elementGetText() function expects text "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   910
                        + "only elment but START_ELEMENT was encountered.", getLocation());
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   911
            } else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   912
                throw new XMLStreamException(
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   913
                        "Unexpected event type " + eventType, getLocation());
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   914
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   915
            eventType = next();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   916
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   917
        return content.toString();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   918
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   919
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   920
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   921
     * Return the current location of the processor. If the Location is unknown
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   922
     * the processor should return an implementation of Location that returns -1
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   923
     * for the location and null for the publicId and systemId. The location
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   924
     * information is only valid until next() is called.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   925
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   926
    public Location getLocation() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   927
        return new Location() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   928
            String _systemId = fEntityScanner.getExpandedSystemId();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   929
            String _publicId = fEntityScanner.getPublicId();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   930
            int _offset = fEntityScanner.getCharacterOffset();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   931
            int _columnNumber = fEntityScanner.getColumnNumber();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   932
            int _lineNumber = fEntityScanner.getLineNumber();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   933
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   934
            public String getLocationURI() {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   935
                return _systemId;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   936
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   937
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   938
            public int getCharacterOffset() {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   939
                return _offset;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   940
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   941
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   942
            public int getColumnNumber() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   943
                return _columnNumber;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   944
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   945
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   946
            public int getLineNumber() {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   947
                return _lineNumber;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   948
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   949
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   950
            public String getPublicId() {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   951
                return _publicId;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   952
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   953
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   954
            public String getSystemId() {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   955
                return _systemId;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   956
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   957
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   958
            public String toString() {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   959
                StringBuilder sbuffer = new StringBuilder();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   960
                sbuffer.append("Line number = " + getLineNumber());
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   961
                sbuffer.append("\n");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   962
                sbuffer.append("Column number = " + getColumnNumber());
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   963
                sbuffer.append("\n");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   964
                sbuffer.append("System Id = " + getSystemId());
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   965
                sbuffer.append("\n");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   966
                sbuffer.append("Public Id = " + getPublicId());
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   967
                sbuffer.append("\n");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   968
                sbuffer.append("Location Uri= " + getLocationURI());
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   969
                sbuffer.append("\n");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   970
                sbuffer.append("CharacterOffset = " + getCharacterOffset());
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   971
                sbuffer.append("\n");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   972
                return sbuffer.toString();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   973
            }
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   974
        };
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   975
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   976
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   977
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   978
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   979
     * Returns a QName for the current START_ELEMENT or END_ELEMENT event
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   980
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   981
     * @return the QName for the current START_ELEMENT or END_ELEMENT event
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   982
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   983
    public javax.xml.namespace.QName getName() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   984
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   985
            return convertXNIQNametoJavaxQName(fScanner.getElementQName());
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   986
        } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   987
            throw new java.lang.IllegalStateException("Illegal to call getName() "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   988
                    + "when event type is " + getEventTypeString(fEventType) + "."
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   989
                    + " Valid states are " + getEventTypeString(XMLEvent.START_ELEMENT) + ", "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   990
                    + getEventTypeString(XMLEvent.END_ELEMENT));
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   991
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   992
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   993
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   994
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   995
     * Returns a read only namespace context for the current position. The
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   996
     * context is transient and only valid until a call to next() changes the
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   997
     * state of the reader.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
   998
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   999
     * @return return a namespace context
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1000
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1001
    public NamespaceContext getNamespaceContext() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1002
        return fNamespaceContextWrapper;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1003
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1004
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1005
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1006
     * Returns the count of namespaces declared on this START_ELEMENT or
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1007
     * END_ELEMENT, this method is only valid on a START_ELEMENT, END_ELEMENT or
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1008
     * NAMESPACE. On an END_ELEMENT the count is of the namespaces that are
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1009
     * about to go out of scope. This is the equivalent of the information
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1010
     * reported by SAX callback for an end element event.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1011
     *
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1012
     * @return returns the number of namespace declarations on this specific
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1013
     * element
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1014
     * @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1015
     * or NAMESPACE
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1016
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1017
    public int getNamespaceCount() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1018
        //namespaceContext is dynamic object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1019
        //REVISIT: check if it specifies all conditions mentioned in the javadoc
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1020
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1021
                || fEventType == XMLEvent.NAMESPACE) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1022
            return fScanner.getNamespaceContext().getDeclaredPrefixCount();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1023
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1024
            throw new IllegalStateException("Current event state is " + getEventTypeString(fEventType)
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1025
                    + " is not among the states " + getEventTypeString(XMLEvent.START_ELEMENT)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1026
                    + ", " + getEventTypeString(XMLEvent.END_ELEMENT) + ", "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1027
                    + getEventTypeString(XMLEvent.NAMESPACE)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1028
                    + " valid for getNamespaceCount().");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1029
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1030
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1031
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1032
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1033
     * Returns the prefix for the namespace declared at the index. Returns null
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1034
     * if this is the default namespace declaration
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1035
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1036
     * @param index the position of the namespace declaration
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1037
     * @return returns the namespace prefix
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1038
     * @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1039
     * or NAMESPACE
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1040
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1041
    public String getNamespacePrefix(int index) {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1042
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1043
                || fEventType == XMLEvent.NAMESPACE) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1044
            //namespaceContext is dynamic object.
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1045
            String prefix = fScanner.getNamespaceContext().getDeclaredPrefixAt(index);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1046
            return prefix.equals("") ? null : prefix;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1047
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1048
            throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1049
                    + " is not among the states " + getEventTypeString(XMLEvent.START_ELEMENT)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1050
                    + ", " + getEventTypeString(XMLEvent.END_ELEMENT) + ", "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1051
                    + getEventTypeString(XMLEvent.NAMESPACE)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1052
                    + " valid for getNamespacePrefix().");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1053
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1054
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1055
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1056
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1057
     * Returns the uri for the namespace declared at the index.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1058
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1059
     * @param index the position of the namespace declaration
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1060
     * @return returns the namespace uri
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1061
     * @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1062
     * or NAMESPACE
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1063
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1064
    public String getNamespaceURI(int index) {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1065
        if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1066
                || fEventType == XMLEvent.NAMESPACE) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1067
            //namespaceContext is dynamic object.
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1068
            return fScanner.getNamespaceContext().getURI(fScanner.getNamespaceContext()
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1069
                    .getDeclaredPrefixAt(index));
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1070
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1071
            throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1072
                    + " is not among the states " + getEventTypeString(XMLEvent.START_ELEMENT)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1073
                    + ", " + getEventTypeString(XMLEvent.END_ELEMENT) + ", "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1074
                    + getEventTypeString(XMLEvent.NAMESPACE)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1075
                    + " valid for getNamespaceURI().");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1076
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1077
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1078
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1079
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1080
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1081
     * Get the value of a feature/property from the underlying implementation
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1082
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1083
     * @param name The name of the property, may not be null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1084
     * @return The value of the property
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1085
     * @throws IllegalArgumentException if name is null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1086
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1087
    public Object getProperty(java.lang.String name) throws java.lang.IllegalArgumentException {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1088
        if (name == null) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1089
            throw new java.lang.IllegalArgumentException();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1090
        }
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1091
        if (fPropertyManager != null) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1092
            if (name.equals(PropertyManager.STAX_NOTATIONS)) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1093
                return getNotationDecls();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1094
            } else if (name.equals(PropertyManager.STAX_ENTITIES)) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1095
                return getEntityDecls();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1096
            } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1097
                return fPropertyManager.getProperty(name);
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1098
            }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1099
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1100
        return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1101
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1102
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1103
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1104
     * Returns the current value of the parse event as a string, this returns
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1105
     * the string value of a CHARACTERS event, returns the value of a COMMENT,
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1106
     * the replacement value for an ENTITY_REFERENCE, or the String value of the
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1107
     * DTD
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1108
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1109
     * @return the current text or null
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1110
     * @throws java.lang.IllegalStateException if this state is not a valid text
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1111
     * state.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1112
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1113
    public String getText() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1114
        if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1115
                || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1116
            //this requires creation of new string
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1117
            //fEventType == XMLEvent.ENTITY_REFERENCE
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1118
            return fScanner.getCharacterData().toString();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1119
        } else if (fEventType == XMLEvent.ENTITY_REFERENCE) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1120
            String name = fScanner.getEntityName();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1121
            if (name != null) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1122
                if (fScanner.foundBuiltInRefs) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1123
                    return fScanner.getCharacterData().toString();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1124
                }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1125
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1126
                XMLEntityStorage entityStore = fEntityManager.getEntityStore();
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
  1127
                Entity en = entityStore.getEntity(name);
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1128
                if (en == null) {
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
  1129
                    return null;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1130
                }
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1131
                if (en.isExternal()) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1132
                    return ((Entity.ExternalEntity) en).entityLocation.getExpandedSystemId();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1133
                } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1134
                    return ((Entity.InternalEntity) en).text;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1135
                }
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1136
            } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1137
                return null;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1138
            }
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1139
        } else if (fEventType == XMLEvent.DTD) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1140
            if (fDTDDecl != null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1141
                return fDTDDecl;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1142
            }
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1143
            XMLStringBuffer tmpBuffer = fScanner.getDTDDecl();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1144
            fDTDDecl = tmpBuffer.toString();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1145
            return fDTDDecl;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1146
        } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1147
            throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1148
                    + " is not among the states" + getEventTypeString(XMLEvent.CHARACTERS) + ", "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1149
                    + getEventTypeString(XMLEvent.COMMENT) + ", "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1150
                    + getEventTypeString(XMLEvent.CDATA) + ", "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1151
                    + getEventTypeString(XMLEvent.SPACE) + ", "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1152
                    + getEventTypeString(XMLEvent.ENTITY_REFERENCE) + ", "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1153
                    + getEventTypeString(XMLEvent.DTD) + " valid for getText() ");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1154
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1155
    }//getText
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1156
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1157
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1158
     * Test if the current event is of the given type and if the namespace and
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1159
     * name match the current namespace and name of the current event. If the
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1160
     * namespaceURI is null it is not checked for equality, if the localName is
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1161
     * null it is not checked for equality.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1162
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1163
     * @param type the event type
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1164
     * @param namespaceURI the uri of the event, may be null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1165
     * @param localName the localName of the event, may be null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1166
     * @throws XMLStreamException if the required values are not matched.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1167
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1168
    public void require(int type, String namespaceURI, String localName) throws XMLStreamException {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1169
        if (type != fEventType) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1170
            throw new XMLStreamException("Event type " + getEventTypeString(type) + " specified did "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1171
                    + "not match with current parser event " + getEventTypeString(fEventType));
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1172
        }
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1173
        if (namespaceURI != null && !namespaceURI.equals(getNamespaceURI())) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1174
            throw new XMLStreamException("Namespace URI " + namespaceURI + " specified did not match "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1175
                    + "with current namespace URI");
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1176
        }
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1177
        if (localName != null && !localName.equals(getLocalName())) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1178
            throw new XMLStreamException("LocalName " + localName + " specified did not match with "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1179
                    + "current local name");
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1180
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1181
        return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1182
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1183
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1184
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1185
     * Gets the the text associated with a CHARACTERS, SPACE or CDATA event.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1186
     * Text starting a "sourceStart" is copied into "destination" starting at
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1187
     * "targetStart". Up to "length" characters are copied. The number of
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1188
     * characters actually copied is returned.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1189
     *
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1190
     * The "sourceStart" argument must be greater or equal to 0 and less than or
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1191
     * equal to the number of characters associated with the event. Usually, one
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1192
     * requests text starting at a "sourceStart" of 0. If the number of
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1193
     * characters actually copied is less than the "length", then there is no
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1194
     * more text. Otherwise, subsequent calls need to be made until all text has
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1195
     * been retrieved. For example:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1196
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1197
     * <code>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1198
     * int length = 1024;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1199
     * char[] myBuffer = new char[ length ];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1200
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1201
     * for ( int sourceStart = 0 ; ; sourceStart += length )
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1202
     * {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1203
     *    int nCopied = stream.getTextCharacters( sourceStart, myBuffer, 0, length );
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1204
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1205
     *   if (nCopied < length)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1206
     *       break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1207
     * }
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1208
     * </code> XMLStreamException may be thrown if there are any XML errors in
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1209
     * the underlying source. The "targetStart" argument must be greater than or
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1210
     * equal to 0 and less than the length of "target", Length must be greater
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1211
     * than 0 and "targetStart + length" must be less than or equal to length of
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1212
     * "target".
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1213
     *
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1214
     * @param sourceStart the index of the first character in the source array
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1215
     * to copy
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1216
     * @param target the destination array
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1217
     * @param targetStart the start offset in the target array
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1218
     * @param length the number of characters to copy
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1219
     * @return the number of characters actually copied
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1220
     * @throws XMLStreamException if the underlying XML source is not
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1221
     * well-formed
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1222
     * @throws IndexOutOfBoundsException if targetStart < 0 or > than the length
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1223
     * of target
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1224
     * @throws IndexOutOfBoundwhile(isCharacters()) ;sException if length < 0 or targetStart + length
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1225
     * > length of target
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1226
     * @throws UnsupportedOperationException if this method is not supported
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1227
     * @throws NullPointerException is if target is null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1228
     */
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1229
    public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1230
            throws XMLStreamException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1231
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1232
        if (target == null) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1233
            throw new NullPointerException("target char array can't be null");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1234
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1235
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1236
        if (targetStart < 0 || length < 0 || sourceStart < 0 || targetStart >= target.length
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1237
                || (targetStart + length) > target.length) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1238
            throw new IndexOutOfBoundsException();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1239
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1240
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1241
        //getTextStart() + sourceStart should not be greater than the lenght of number of characters
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1242
        //present
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1243
        int copiedLength = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1244
        //int presentDataLen = getTextLength() - (getTextStart()+sourceStart);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1245
        int available = getTextLength() - sourceStart;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1246
        if (available < 0) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1247
            throw new IndexOutOfBoundsException("sourceStart is greater than"
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1248
                    + "number of characters associated with this event");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1249
        }
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1250
        if (available < length) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1251
            copiedLength = available;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1252
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1253
            copiedLength = length;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1254
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1255
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1256
        System.arraycopy(getTextCharacters(), getTextStart() + sourceStart, target, targetStart, copiedLength);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1257
        return copiedLength;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1258
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1259
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1260
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1261
     * Return true if the current event has text, false otherwise The following
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1262
     * events have text: CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1263
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1264
    public boolean hasText() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1265
        if (DEBUG) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1266
            pr("XMLReaderImpl#EVENT TYPE = " + fEventType);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1267
        }
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1268
        if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1269
                || fEventType == XMLEvent.CDATA) {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 25868
diff changeset
  1270
            return fScanner.getCharacterData().length > 0;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1271
        } else if (fEventType == XMLEvent.ENTITY_REFERENCE) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1272
            String name = fScanner.getEntityName();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1273
            if (name != null) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1274
                if (fScanner.foundBuiltInRefs) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1275
                    return true;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1276
                }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1277
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1278
                XMLEntityStorage entityStore = fEntityManager.getEntityStore();
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
  1279
                Entity en = entityStore.getEntity(name);
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1280
                if (en == null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1281
                    return false;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1282
                }
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1283
                if (en.isExternal()) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1284
                    return ((Entity.ExternalEntity) en).entityLocation.getExpandedSystemId() != null;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1285
                } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1286
                    return ((Entity.InternalEntity) en).text != null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1287
                }
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1288
            } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1289
                return false;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1290
            }
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1291
        } else if (fEventType == XMLEvent.DTD) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1292
            return fScanner.fSeenDoctypeDecl;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1293
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1294
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1295
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1296
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1297
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1298
     * Returns a boolean which indicates if this attribute was created by
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1299
     * default
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1300
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1301
     * @param index the position of the attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1302
     * @return true if this is a default attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1303
     * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1304
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1305
    public boolean isAttributeSpecified(int index) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1306
        //check that current state should be either START_ELEMENT or ATTRIBUTE
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1307
        if ((fEventType == XMLEvent.START_ELEMENT) || (fEventType == XMLEvent.ATTRIBUTE)) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1308
            return fScanner.getAttributeIterator().isSpecified(index);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1309
        } else {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1310
            throw new IllegalStateException("Current state is not among the states "
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1311
                    + getEventTypeString(XMLEvent.START_ELEMENT) + " , "
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1312
                    + getEventTypeString(XMLEvent.ATTRIBUTE)
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1313
                    + "valid for isAttributeSpecified()");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1314
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1315
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1316
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1317
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1318
     * Returns true if the cursor points to a character data event
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1319
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1320
     * @return true if the cursor points to character data, false otherwise
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1321
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1322
    public boolean isCharacters() {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1323
        return fEventType == XMLEvent.CHARACTERS;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1324
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1325
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1326
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1327
     * Skips any insignificant events (COMMENT and PROCESSING_INSTRUCTION) until
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1328
     * a START_ELEMENT or END_ELEMENT is reached. If other than space characters
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1329
     * are encountered, an exception is thrown. This method should be used when
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1330
     * processing element-only content because the parser is not able to
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1331
     * recognize ignorable whitespace if then DTD is missing or not interpreted.
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1332
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1333
     * @return the event type of the element read
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1334
     * @throws XMLStreamException if the current event is not white space
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1335
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1336
    public int nextTag() throws XMLStreamException {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1337
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1338
        int eventType = next();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1339
        while ((eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace()) // skip whitespace
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1340
                || (eventType == XMLStreamConstants.CDATA && isWhiteSpace())
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1341
                // skip whitespace
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1342
                || eventType == XMLStreamConstants.SPACE
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1343
                || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1344
                || eventType == XMLStreamConstants.COMMENT) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1345
            eventType = next();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1346
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1347
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1348
        if (eventType != XMLStreamConstants.START_ELEMENT && eventType != XMLStreamConstants.END_ELEMENT) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1349
            throw new XMLStreamException(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1350
                    "found: " + getEventTypeString(eventType)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1351
                    + ", expected " + getEventTypeString(XMLStreamConstants.START_ELEMENT)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1352
                    + " or " + getEventTypeString(XMLStreamConstants.END_ELEMENT),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1353
                    getLocation());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1354
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1355
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1356
        return eventType;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1357
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1358
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1359
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1360
     * Checks if standalone was set in the document
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1361
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1362
     * @return true if standalone was set in the document, or false otherwise
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1363
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1364
    public boolean standaloneSet() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1365
        //xxx: it requires if the standalone was set in the document ? This is different that if the document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1366
        // is standalone
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1367
        return fScanner.standaloneSet();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1368
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1369
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1370
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1371
     * @param qname
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1372
     * @return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1373
     */
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1374
    public javax.xml.namespace.QName convertXNIQNametoJavaxQName(
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1375
            com.sun.org.apache.xerces.internal.xni.QName qname) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1376
        if (qname == null) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1377
            return null;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1378
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1379
        //xxx: prefix definition ?
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1380
        if (qname.prefix == null) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1381
            return new javax.xml.namespace.QName(qname.uri, qname.localpart);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1382
        } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1383
            return new javax.xml.namespace.QName(qname.uri, qname.localpart, qname.prefix);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1384
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1385
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1386
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1387
    /**
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1388
     * Return the uri for the given prefix. The uri returned depends on the
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1389
     * current state of the processor.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1390
     *
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1391
     * <p>
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1392
     * <strong>NOTE:</strong>The 'xml' prefix is bound as defined in
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1393
     * <a href="http://www.w3.org/TR/REC-xml-names/#ns-using">Namespaces in
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1394
     * XML</a>
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1395
     * specification to "http://www.w3.org/XML/1998/namespace".
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1396
     *
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1397
     * <p>
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1398
     * <strong>NOTE:</strong> The 'xmlns' prefix must be resolved to following
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1399
     * namespace
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1400
     * <a href="http://www.w3.org/2000/xmlns/">http://www.w3.org/2000/xmlns/</a>
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1401
     *
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1402
     * @return the uri bound to the given prefix or null if it is not bound
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1403
     * @param prefix The prefix to lookup, may not be null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1404
     * @throws IllegalStateException - if the prefix is null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1405
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1406
    public String getNamespaceURI(String prefix) {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1407
        if (prefix == null) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1408
            throw new java.lang.IllegalArgumentException("prefix cannot be null.");
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1409
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1410
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1411
        //first add the string to symbol table.. since internally identity comparisons are done.
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1412
        return fScanner.getNamespaceContext().getURI(fSymbolTable.addSymbol(prefix));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1413
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1414
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1415
    //xxx: this function is not being used.
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1416
    protected void setPropertyManager(PropertyManager propertyManager) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1417
        fPropertyManager = propertyManager;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1418
        //REVISIT: we were supplying hashmap ealier
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1419
        fScanner.setProperty("stax-properties", propertyManager);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1420
        fScanner.setPropertyManager(propertyManager);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1421
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1422
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1423
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1424
     * @return returns the reference to property manager.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1425
     */
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1426
    protected PropertyManager getPropertyManager() {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1427
        return fPropertyManager;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1428
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1429
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1430
    static void pr(String str) {
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1431
        System.out.println(str);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1432
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1433
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1434
    protected List<EntityDeclaration> getEntityDecls() {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1435
        if (fEventType == XMLStreamConstants.DTD) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1436
            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1437
            ArrayList<EntityDeclaration> list = null;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1438
            Map<String, Entity> entities = entityStore.getEntities();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1439
            if (entities.size() > 0) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1440
                EntityDeclarationImpl decl = null;
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1441
                list = new ArrayList<>(entities.size());
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1442
                for (Map.Entry<String, Entity> entry : entities.entrySet()) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1443
                    String key = entry.getKey();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1444
                    Entity en = entry.getValue();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1445
                    decl = new EntityDeclarationImpl();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1446
                    decl.setEntityName(key);
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1447
                    if (en.isExternal()) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1448
                        decl.setXMLResourceIdentifier(((Entity.ExternalEntity) en).entityLocation);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1449
                        decl.setNotationName(((Entity.ExternalEntity) en).notation);
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1450
                    } else {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1451
                        decl.setEntityReplacementText(((Entity.InternalEntity) en).text);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1452
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1453
                    list.add(decl);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1454
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1455
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1456
            return list;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1457
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1458
        return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1459
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1460
42802
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1461
    protected List<NotationDeclaration> getNotationDecls() {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1462
        if (fEventType == XMLStreamConstants.DTD) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1463
            if (fScanner.fDTDScanner == null) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1464
                return null;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1465
            }
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1466
            DTDGrammar grammar = ((XMLDTDScannerImpl) (fScanner.fDTDScanner)).getGrammar();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1467
            if (grammar == null) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1468
                return null;
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1469
            }
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1470
            List<XMLNotationDecl> notations = grammar.getNotationDecls();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1471
            ArrayList<NotationDeclaration> list = new ArrayList<>();
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1472
            for (XMLNotationDecl notation : notations) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1473
                if (notation != null) {
2a03abb03c06 8170556: Warnings cleanup related to JDK-8167340
joehw
parents: 42394
diff changeset
  1474
                    list.add(new NotationDeclarationImpl(notation));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1475
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1476
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1477
            return list;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1478
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1479
        return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1480
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1481
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1482
}//XMLReaderImpl