src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/AxesWalker.java
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
child 48409 5ab69533994b
equal deleted inserted replaced
47358:d07d5f7cab35 47359:e1a6c0168741
     1 /*
     1 /*
     2  * reserved comment block
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT REMOVE OR ALTER!
     3  * @LastModified: Oct 2017
     4  */
     4  */
     5 /*
     5 /*
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     7  * contributor license agreements.  See the NOTICE file distributed with
     7  * contributor license agreements.  See the NOTICE file distributed with
     8  * this work for additional information regarding copyright ownership.
     8  * this work for additional information regarding copyright ownership.
    19  * limitations under the License.
    19  * limitations under the License.
    20  */
    20  */
    21 
    21 
    22 package com.sun.org.apache.xpath.internal.axes;
    22 package com.sun.org.apache.xpath.internal.axes;
    23 
    23 
    24 import java.util.Vector;
       
    25 
       
    26 import com.sun.org.apache.xalan.internal.res.XSLMessages;
    24 import com.sun.org.apache.xalan.internal.res.XSLMessages;
    27 import com.sun.org.apache.xml.internal.dtm.DTM;
    25 import com.sun.org.apache.xml.internal.dtm.DTM;
    28 import com.sun.org.apache.xml.internal.dtm.DTMAxisTraverser;
    26 import com.sun.org.apache.xml.internal.dtm.DTMAxisTraverser;
    29 import com.sun.org.apache.xml.internal.dtm.DTMIterator;
    27 import com.sun.org.apache.xml.internal.dtm.DTMIterator;
    30 import com.sun.org.apache.xpath.internal.Expression;
    28 import com.sun.org.apache.xpath.internal.Expression;
    31 import com.sun.org.apache.xpath.internal.ExpressionOwner;
    29 import com.sun.org.apache.xpath.internal.ExpressionOwner;
    32 import com.sun.org.apache.xpath.internal.XPathContext;
    30 import com.sun.org.apache.xpath.internal.XPathContext;
    33 import com.sun.org.apache.xpath.internal.XPathVisitor;
    31 import com.sun.org.apache.xpath.internal.XPathVisitor;
    34 import com.sun.org.apache.xpath.internal.compiler.Compiler;
    32 import com.sun.org.apache.xpath.internal.compiler.Compiler;
    35 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
    33 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
       
    34 import java.util.List;
    36 
    35 
    37 /**
    36 /**
    38  * Serves as common interface for axes Walkers, and stores common
    37  * Serves as common interface for axes Walkers, and stores common
    39  * state variables.
    38  * state variables.
    40  */
    39  */
   109    *                  corresponding clones in even vectors.
   108    *                  corresponding clones in even vectors.
   110    *
   109    *
   111    * @return non-null clone, which may be a new clone, or may be a clone
   110    * @return non-null clone, which may be a new clone, or may be a clone
   112    *         contained on the cloneList.
   111    *         contained on the cloneList.
   113    */
   112    */
   114   AxesWalker cloneDeep(WalkingIterator cloneOwner, Vector cloneList)
   113   AxesWalker cloneDeep(WalkingIterator cloneOwner, List<AxesWalker> cloneList)
   115      throws CloneNotSupportedException
   114      throws CloneNotSupportedException
   116   {
   115   {
   117     AxesWalker clone = findClone(this, cloneList);
   116     AxesWalker clone = findClone(this, cloneList);
   118     if(null != clone)
   117     if(null != clone)
   119       return clone;
   118       return clone;
   120     clone = (AxesWalker)this.clone();
   119     clone = (AxesWalker)this.clone();
   121     clone.setLocPathIterator(cloneOwner);
   120     clone.setLocPathIterator(cloneOwner);
   122     if(null != cloneList)
   121     if(null != cloneList)
   123     {
   122     {
   124       cloneList.addElement(this);
   123       cloneList.add(this);
   125       cloneList.addElement(clone);
   124       cloneList.add(clone);
   126     }
   125     }
   127 
   126 
   128     if(wi().m_lastUsedWalker == this)
   127     if(wi().m_lastUsedWalker == this)
   129       cloneOwner.m_lastUsedWalker = clone;
   128       cloneOwner.m_lastUsedWalker = clone;
   130 
   129 
   153    * @param cloneList vector of sources in odd elements, and the
   152    * @param cloneList vector of sources in odd elements, and the
   154    *                  corresponding clones in even vectors, may be null.
   153    *                  corresponding clones in even vectors, may be null.
   155    *
   154    *
   156    * @return A clone that corresponds to the key, or null if key not found.
   155    * @return A clone that corresponds to the key, or null if key not found.
   157    */
   156    */
   158   static AxesWalker findClone(AxesWalker key, Vector cloneList)
   157   static AxesWalker findClone(AxesWalker key, List<AxesWalker> cloneList)
   159   {
   158   {
   160     if(null != cloneList)
   159     if(null != cloneList)
   161     {
   160     {
   162       // First, look for clone on list.
   161       // First, look for clone on list.
   163       int n = cloneList.size();
   162       int n = cloneList.size();
   164       for (int i = 0; i < n; i+=2)
   163       for (int i = 0; i < n; i+=2)
   165       {
   164       {
   166         if(key == cloneList.elementAt(i))
   165         if(key == cloneList.get(i))
   167           return (AxesWalker)cloneList.elementAt(i+1);
   166           return cloneList.get(i+1);
   168       }
   167       }
   169     }
   168     }
   170     return null;
   169     return null;
   171   }
   170   }
   172 
   171