jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java
changeset 27747 3a271dc8b758
parent 25859 3317bb8137f4
equal deleted inserted replaced
27736:8c9bd4be4a86 27747:3a271dc8b758
    57  * @since 1.6
    57  * @since 1.6
    58  * @see CanonicalizationMethod
    58  * @see CanonicalizationMethod
    59  */
    59  */
    60 public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
    60 public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
    61 
    61 
    62     private List<String> preList;
    62     private final List<String> prefixList;
    63 
    63 
    64     /**
    64     /**
    65      * Indicates the default namespace ("#default").
    65      * Indicates the default namespace ("#default").
    66      */
    66      */
    67     public static final String DEFAULT = "#default";
    67     public static final String DEFAULT = "#default";
    69     /**
    69     /**
    70      * Creates a <code>ExcC14NParameterSpec</code> with an empty prefix
    70      * Creates a <code>ExcC14NParameterSpec</code> with an empty prefix
    71      * list.
    71      * list.
    72      */
    72      */
    73     public ExcC14NParameterSpec() {
    73     public ExcC14NParameterSpec() {
    74         preList = Collections.emptyList();
    74         prefixList = Collections.emptyList();
    75     }
    75     }
    76 
    76 
    77     /**
    77     /**
    78      * Creates a <code>ExcC14NParameterSpec</code> with the specified list
    78      * Creates a <code>ExcC14NParameterSpec</code> with the specified list
    79      * of prefixes. The list is copied to protect against subsequent
    79      * of prefixes. The list is copied to protect against subsequent
    84      * @throws NullPointerException if <code>prefixList</code> is
    84      * @throws NullPointerException if <code>prefixList</code> is
    85      *    <code>null</code>
    85      *    <code>null</code>
    86      * @throws ClassCastException if any of the entries in the list are not
    86      * @throws ClassCastException if any of the entries in the list are not
    87      *    of type <code>String</code>
    87      *    of type <code>String</code>
    88      */
    88      */
    89     @SuppressWarnings("rawtypes")
    89     public ExcC14NParameterSpec(List<String> prefixList) {
    90     public ExcC14NParameterSpec(List prefixList) {
       
    91         if (prefixList == null) {
    90         if (prefixList == null) {
    92             throw new NullPointerException("prefixList cannot be null");
    91             throw new NullPointerException("prefixList cannot be null");
    93         }
    92         }
    94         List<?> copy = new ArrayList<>((List<?>)prefixList);
    93         List<String> tempList = Collections.checkedList(new ArrayList<>(),
    95         for (int i = 0, size = copy.size(); i < size; i++) {
    94                                                         String.class);
    96             if (!(copy.get(i) instanceof String)) {
    95         tempList.addAll(prefixList);
    97                 throw new ClassCastException("not a String");
    96         this.prefixList = Collections.unmodifiableList(tempList);
    98             }
       
    99         }
       
   100 
       
   101         @SuppressWarnings("unchecked")
       
   102         List<String> temp = (List<String>)copy;
       
   103 
       
   104         preList = Collections.unmodifiableList(temp);
       
   105     }
    97     }
   106 
    98 
   107     /**
    99     /**
   108      * Returns the inclusive namespace prefix list. Each entry in the list
   100      * Returns the inclusive namespace prefix list. Each entry in the list
   109      * is a <code>String</code> that represents a namespace prefix.
   101      * is a <code>String</code> that represents a namespace prefix.
   112      * java.util.Collections#unmodifiableList unmodifiable list}.
   104      * java.util.Collections#unmodifiableList unmodifiable list}.
   113      *
   105      *
   114      * @return the inclusive namespace prefix list (may be empty but never
   106      * @return the inclusive namespace prefix list (may be empty but never
   115      *    <code>null</code>)
   107      *    <code>null</code>)
   116      */
   108      */
   117     @SuppressWarnings("rawtypes")
   109     public List<String> getPrefixList() {
   118     public List getPrefixList() {
   110         return prefixList;
   119         return preList;
       
   120     }
   111     }
   121 }
   112 }