src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/ChildIterator.java
author joehw
Wed, 18 Oct 2017 13:25:49 -0700
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
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
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
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
 *
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    13
 *      http://www.apache.org/licenses/LICENSE-2.0
6
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
 */
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    21
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
package com.sun.org.apache.xpath.internal.axes;
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
import com.sun.org.apache.xml.internal.dtm.DTM;
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import com.sun.org.apache.xml.internal.dtm.DTMFilter;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import com.sun.org.apache.xpath.internal.XPathContext;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
import com.sun.org.apache.xpath.internal.compiler.Compiler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
 * This class implements an optimized iterator for
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
 * "node()" patterns, that is, any children of the
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
 * context node.
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
 * @see com.sun.org.apache.xpath.internal.axes.LocPathIterator
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
 * @xsl.usage advanced
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
public class ChildIterator extends LocPathIterator
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
{
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
    static final long serialVersionUID = -6935428015142993583L;
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
   * Create a ChildIterator object.
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
   * @param compiler A reference to the Compiler that contains the op map.
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
   * @param opPos The position within the op map, which contains the
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
   * location path expression for this itterator.
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
   * @param analysis Analysis bits of the entire pattern.
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
   * @throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
  ChildIterator(Compiler compiler, int opPos, int analysis)
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
          throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
    super(compiler, opPos, analysis, false);
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
    // This iterator matches all kinds of nodes
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
    initNodeTest(DTMFilter.SHOW_ALL);
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
   * Return the first node out of the nodeset, if this expression is
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
   * a nodeset expression.  This is the default implementation for
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
   * nodesets.
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
   * <p>WARNING: Do not mutate this class from this function!</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
   * @param xctxt The XPath runtime context.
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
   * @return the first node out of the nodeset, or DTM.NULL.
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
  public int asNode(XPathContext xctxt)
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
    throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
    int current = xctxt.getCurrentNode();
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
    DTM dtm = xctxt.getDTM(current);
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
    return dtm.getFirstChild(current);
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
   *  Returns the next node in the set and advances the position of the
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
   * iterator in the set. After a NodeIterator is created, the first call
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
   * to nextNode() returns the first node in the set.
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
   * @return  The next <code>Node</code> in the set being iterated over, or
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
   *   <code>null</code> if there are no more members in that set.
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
  public int nextNode()
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
        if(m_foundLast)
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
                return DTM.NULL;
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
    int next;
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
    m_lastFetched = next = (DTM.NULL == m_lastFetched)
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
                           ? m_cdtm.getFirstChild(m_context)
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
                           : m_cdtm.getNextSibling(m_lastFetched);
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
    // m_lastFetched = next;
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
    if (DTM.NULL != next)
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
      m_pos++;
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
      return next;
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
    else
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
      m_foundLast = true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
      return DTM.NULL;
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
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
   * Returns the axis being iterated, if it is known.
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
   * types.
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
  public int getAxis()
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
    return com.sun.org.apache.xml.internal.dtm.Axis.CHILD;
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
}