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. |