src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DeepNodeListImpl.java
author joehw
Wed, 18 Oct 2017 13:25:49 -0700
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
child 48409 5ab69533994b
permissions -rw-r--r--
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked Reviewed-by: lancea, rriggs, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
     3
 * @LastModified: Oct 2017
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one or more
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     7
 * contributor license agreements.  See the NOTICE file distributed with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     8
 * this work for additional information regarding copyright ownership.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     9
 * The ASF licenses this file to You under the Apache License, Version 2.0
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    10
 * (the "License"); you may not use this file except in compliance with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    11
 * the License.  You may obtain a copy of the License at
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 *      http://www.apache.org/licenses/LICENSE-2.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
package com.sun.org.apache.xerces.internal.dom;
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    23
import java.util.ArrayList;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    24
import java.util.List;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import org.w3c.dom.Node;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import org.w3c.dom.NodeList;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
 * This class implements the DOM's NodeList behavior for
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
 * Element.getElementsByTagName()
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
 * <P>
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
 * The DOM describes NodeList as follows:
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
 * <P>
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
 * 1) It may represent EITHER nodes scattered through a subtree (when
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 * returned by Element.getElementsByTagName), or just the immediate
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
 * children (when returned by Node.getChildNodes). The latter is easy,
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
 * but the former (which this class addresses) is more challenging.
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
 * <P>
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
 * 2) Its behavior is "live" -- that is, it always reflects the
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
 * current state of the document tree. To put it another way, the
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 * NodeLists obtained before and after a series of insertions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * deletions are effectively identical (as far as the user is
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 * concerned, the former has been dynamically updated as the changes
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 * have been made).
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 * <P>
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
 * 3) Its API accesses individual nodes via an integer index, with the
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
 * listed nodes numbered sequentially in the order that they were
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
 * found during a preorder depth-first left-to-right search of the tree.
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
 * (Of course in the case of getChildNodes, depth is not involved.) As
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
 * nodes are inserted or deleted in the tree, and hence the NodeList,
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
 * the numbering of nodes that follow them in the NodeList will
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
 * change.
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
 * <P>
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
 * It is rather painful to support the latter two in the
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
 * getElementsByTagName case. The current solution is for Nodes to
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
 * maintain a change count (eventually that may be a Digest instead),
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
 * which the NodeList tracks and uses to invalidate itself.
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
 * <P>
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
 * Unfortunately, this does _not_ respond efficiently in the case that
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
 * the dynamic behavior was supposed to address: scanning a tree while
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
 * it is being extended. That requires knowing which subtrees have
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
 * changed, which can become an arbitrarily complex problem.
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
 * <P>
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
 * We save some work by filling the vector only as we access the
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
 * item()s... but I suspect the same users who demanded index-based
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
 * access will also start by doing a getLength() to control their loop,
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
 * blowing this optimization out of the water.
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
 * <P>
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
 * NOTE: Level 2 of the DOM will probably _not_ use NodeList for its
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
 * extended search mechanisms, partly for the reasons just discussed.
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
 * @xerces.internal
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
 * @since  PR-DOM-Level-1-19980818.
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
public class DeepNodeListImpl
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    77
        implements NodeList {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
    // Data
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
    protected NodeImpl rootNode; // Where the search started
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
    protected String tagName;   // Or "*" to mean all-tags-acceptable
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    84
    protected int changes = 0;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    85
    protected List<Node> nodes;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
    protected String nsName;
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
    protected boolean enableNS = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
    // Constructors
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
    /** Constructor. */
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
    public DeepNodeListImpl(NodeImpl rootNode, String tagName) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
        this.rootNode = rootNode;
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    97
        this.tagName = tagName;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    98
        nodes = new ArrayList<>();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
    /** Constructor for Namespace support. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
    public DeepNodeListImpl(NodeImpl rootNode,
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   103
            String nsName, String tagName) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
        this(rootNode, tagName);
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   105
        this.nsName = (nsName != null && nsName.length() != 0) ? nsName : null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
        enableNS = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
    // NodeList methods
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
    /** Returns the length of the node list. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
    public int getLength() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
        // Preload all matching elements. (Stops when we run out of subtree!)
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
        item(java.lang.Integer.MAX_VALUE);
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
        return nodes.size();
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
    /** Returns the node at the specified index. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
    public Node item(int index) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
        Node thisNode;
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
        // Tree changed. Do it all from scratch!
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   125
        if (rootNode.changes() != changes) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   126
            nodes = new ArrayList<>();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
            changes = rootNode.changes();
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
        // In the cache
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   131
        final int currentSize = nodes.size();
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   132
        if (index < currentSize) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   133
            return nodes.get(index);
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   134
        } // Not yet seen
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
        else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
            // Pick up where we left off (Which may be the beginning)
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   138
            if (currentSize == 0) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   139
                thisNode = rootNode;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   140
            } else {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   141
                thisNode = (NodeImpl) (nodes.get(currentSize - 1));
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   142
            }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   144
            // Add nodes up to the one we're looking for
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   145
            while (thisNode != null && index >= nodes.size()) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   146
                thisNode = nextMatchingElementAfter(thisNode);
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   147
                if (thisNode != null) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   148
                    nodes.add(thisNode);
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   149
                }
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   150
            }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
            // Either what we want, or null (not avail.)
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   153
            return thisNode;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   154
        }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
    } // item(int):Node
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
    // Protected methods (might be overridden by an extending DOM)
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
     * Iterative tree-walker. When you have a Parent link, there's often no
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
     * need to resort to recursion. NOTE THAT only Element nodes are matched
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
     * since we're specifically supporting getElementsByTagName().
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
    protected Node nextMatchingElementAfter(Node current) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   169
        Node next;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   170
        while (current != null) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   171
            // Look down to first child.
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   172
            if (current.hasChildNodes()) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   173
                current = (current.getFirstChild());
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   174
            } // Look right to sibling (but not from root!)
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   175
            else if (current != rootNode && null != (next = current.getNextSibling())) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   176
                current = next;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   177
            } // Look up and right (but not past root!)
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   178
            else {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   179
                next = null;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   180
                for (; current != rootNode; // Stop when we return to starting point
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   181
                        current = current.getParentNode()) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   183
                    next = current.getNextSibling();
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   184
                    if (next != null) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   185
                        break;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   186
                    }
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   187
                }
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   188
                current = next;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   189
            }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
                        // Have we found an Element with the right tagName?
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   192
            // ("*" matches anything.)
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   193
            if (current != rootNode
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   194
                    && current != null
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   195
                    && current.getNodeType() == Node.ELEMENT_NODE) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   196
                if (!enableNS) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   197
                    if (tagName.equals("*")
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   198
                            || ((ElementImpl) current).getTagName().equals(tagName)) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   199
                        return current;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   200
                    }
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   201
                } else {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   202
                    // DOM2: Namespace logic.
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   203
                    if (tagName.equals("*")) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   204
                        if (nsName != null && nsName.equals("*")) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   205
                            return current;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   206
                        } else {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   207
                            ElementImpl el = (ElementImpl) current;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   208
                            if ((nsName == null
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   209
                                    && el.getNamespaceURI() == null)
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   210
                                    || (nsName != null
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   211
                                    && nsName.equals(el.getNamespaceURI()))) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
                                return current;
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
                            }
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   214
                        }
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   215
                    } else {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   216
                        ElementImpl el = (ElementImpl) current;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   217
                        if (el.getLocalName() != null
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   218
                                && el.getLocalName().equals(tagName)) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   219
                            if (nsName != null && nsName.equals("*")) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   220
                                return current;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   221
                            } else {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   222
                                if ((nsName == null
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   223
                                        && el.getNamespaceURI() == null)
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
                                        || (nsName != null
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   225
                                        && nsName.equals(el.getNamespaceURI()))) {
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   226
                                    return current;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
                                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
                            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
                        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
                    }
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   231
                }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   234
            // Otherwise continue walking the tree
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   235
        }
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   236
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   237
        // Fell out of tree-walk; no more instances found
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   238
        return null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
    } // nextMatchingElementAfter(int):Node
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
} // class DeepNodeListImpl