src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/JAXPNamespaceContextWrapper.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.
    20  */
    20  */
    21 
    21 
    22 package com.sun.org.apache.xerces.internal.util;
    22 package com.sun.org.apache.xerces.internal.util;
    23 
    23 
    24 
    24 
       
    25 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
    25 import java.util.Collections;
    26 import java.util.Collections;
    26 import java.util.Enumeration;
    27 import java.util.Enumeration;
    27 import java.util.List;
    28 import java.util.List;
    28 import java.util.TreeSet;
    29 import java.util.TreeSet;
    29 import java.util.Vector;
    30 import java.util.Vector;
    30 
       
    31 import javax.xml.XMLConstants;
    31 import javax.xml.XMLConstants;
    32 
       
    33 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
       
    34 
    32 
    35 /**
    33 /**
    36  * <p>A read-only XNI wrapper around a JAXP NamespaceContext.</p>
    34  * <p>A read-only XNI wrapper around a JAXP NamespaceContext.</p>
    37  *
    35  *
    38  * @author Michael Glavassevich, IBM
    36  * @author Michael Glavassevich, IBM
    40  */
    38  */
    41 public final class JAXPNamespaceContextWrapper implements NamespaceContext {
    39 public final class JAXPNamespaceContextWrapper implements NamespaceContext {
    42 
    40 
    43     private javax.xml.namespace.NamespaceContext fNamespaceContext;
    41     private javax.xml.namespace.NamespaceContext fNamespaceContext;
    44     private SymbolTable fSymbolTable;
    42     private SymbolTable fSymbolTable;
    45     private List fPrefixes;
    43     private List<String> fPrefixes;
    46     private final Vector fAllPrefixes = new Vector();
    44     private final Vector<String> fAllPrefixes = new Vector<>();
    47 
    45 
    48     private int[] fContext = new int[8];
    46     private int[] fContext = new int[8];
    49     private int fCurrentContext;
    47     private int fCurrentContext;
    50 
    48 
    51     public JAXPNamespaceContextWrapper(SymbolTable symbolTable) {
    49     public JAXPNamespaceContextWrapper(SymbolTable symbolTable) {
    66 
    64 
    67     public SymbolTable getSymbolTable() {
    65     public SymbolTable getSymbolTable() {
    68         return fSymbolTable;
    66         return fSymbolTable;
    69     }
    67     }
    70 
    68 
    71     public void setDeclaredPrefixes(List prefixes) {
    69     public void setDeclaredPrefixes(List<String> prefixes) {
    72         fPrefixes = prefixes;
    70         fPrefixes = prefixes;
    73     }
    71     }
    74 
    72 
    75     public List getDeclaredPrefixes() {
    73     public List<String> getDeclaredPrefixes() {
    76         return fPrefixes;
    74         return fPrefixes;
    77     }
    75     }
    78 
    76 
    79     /*
    77     /*
    80      * NamespaceContext methods
    78      * NamespaceContext methods
   102             return (fSymbolTable != null) ? fSymbolTable.addSymbol(prefix) : prefix.intern();
   100             return (fSymbolTable != null) ? fSymbolTable.addSymbol(prefix) : prefix.intern();
   103         }
   101         }
   104         return null;
   102         return null;
   105     }
   103     }
   106 
   104 
   107     public Enumeration getAllPrefixes() {
   105     public Enumeration<String> getAllPrefixes() {
   108         // There may be duplicate prefixes in the list so we
   106         // There may be duplicate prefixes in the list so we
   109         // first transfer them to a set to ensure uniqueness.
   107         // first transfer them to a set to ensure uniqueness.
   110         return Collections.enumeration(new TreeSet(fAllPrefixes));
   108         return Collections.enumeration(new TreeSet<String>(fAllPrefixes));
   111     }
   109     }
   112 
   110 
   113     public void pushContext() {
   111     public void pushContext() {
   114         // extend the array, if necessary
   112         // extend the array, if necessary
   115         if (fCurrentContext + 1 == fContext.length) {
   113         if (fCurrentContext + 1 == fContext.length) {
   135     public int getDeclaredPrefixCount() {
   133     public int getDeclaredPrefixCount() {
   136         return (fPrefixes != null) ? fPrefixes.size() : 0;
   134         return (fPrefixes != null) ? fPrefixes.size() : 0;
   137     }
   135     }
   138 
   136 
   139     public String getDeclaredPrefixAt(int index) {
   137     public String getDeclaredPrefixAt(int index) {
   140         return (String) fPrefixes.get(index);
   138         return fPrefixes.get(index);
   141     }
   139     }
   142 
   140 
   143     public void reset() {
   141     public void reset() {
   144         fCurrentContext = 0;
   142         fCurrentContext = 0;
   145         fContext[fCurrentContext] = 0;
   143         fContext[fCurrentContext] = 0;