提交 75ee28e4 编写于 作者: S smarks

7118546: fix warnings in javax.xml.crypto, javax.script

Reviewed-by: mullan
上级 322c6102
......@@ -36,6 +36,8 @@ package javax.script;
*/
public class ScriptException extends Exception {
private static final long serialVersionUID = 8265071037049225001L;
private String fileName;
private int lineNumber;
private int columnNumber;
......
......@@ -52,5 +52,6 @@ public interface NodeSetData extends Data {
* @return an <code>Iterator</code> over the nodes in this
* <code>NodeSetData</code> in document order
*/
@SuppressWarnings("rawtypes")
Iterator iterator();
}
......@@ -47,13 +47,13 @@ import org.w3c.dom.Element;
*/
public class DOMCryptoContext implements XMLCryptoContext {
private HashMap nsMap = new HashMap();
private HashMap idMap = new HashMap();
private HashMap objMap = new HashMap();
private HashMap<String,String> nsMap = new HashMap<>();
private HashMap<String,Element> idMap = new HashMap<>();
private HashMap<Object,Object> objMap = new HashMap<>();
private String baseURI;
private KeySelector ks;
private URIDereferencer dereferencer;
private HashMap propMap = new HashMap();
private HashMap<String,Object> propMap = new HashMap<>();
private String defaultPrefix;
/**
......@@ -73,7 +73,7 @@ public class DOMCryptoContext implements XMLCryptoContext {
if (namespaceURI == null) {
throw new NullPointerException("namespaceURI cannot be null");
}
String prefix = (String) nsMap.get(namespaceURI);
String prefix = nsMap.get(namespaceURI);
return (prefix != null ? prefix : defaultPrefix);
}
......@@ -87,7 +87,7 @@ public class DOMCryptoContext implements XMLCryptoContext {
if (namespaceURI == null) {
throw new NullPointerException("namespaceURI is null");
}
return (String) nsMap.put(namespaceURI, prefix);
return nsMap.put(namespaceURI, prefix);
}
public String getDefaultNamespacePrefix() {
......@@ -170,7 +170,7 @@ public class DOMCryptoContext implements XMLCryptoContext {
if (idValue == null) {
throw new NullPointerException("idValue is null");
}
return (Element) idMap.get(idValue);
return idMap.get(idValue);
}
/**
......@@ -219,6 +219,7 @@ public class DOMCryptoContext implements XMLCryptoContext {
*
* @return a read-only iterator over the set of mappings
*/
@SuppressWarnings("rawtypes")
public Iterator iterator() {
return Collections.unmodifiableMap(idMap).entrySet().iterator();
}
......
......@@ -86,5 +86,6 @@ public interface Manifest extends XMLStructure {
*
* @return an unmodifiable list of one or more <code>Reference</code>s
*/
@SuppressWarnings("rawtypes")
List getReferences();
}
......@@ -85,6 +85,7 @@ public interface Reference extends URIReference, XMLStructure {
* @return an unmodifiable list of <code>Transform</code>s
* (may be empty but never <code>null</code>)
*/
@SuppressWarnings("rawtypes")
List getTransforms();
/**
......
......@@ -87,5 +87,6 @@ public interface SignatureProperties extends XMLStructure {
* @return an unmodifiable list of one or more
* <code>SignatureProperty</code>s
*/
@SuppressWarnings("rawtypes")
List getProperties();
}
......@@ -91,5 +91,6 @@ public interface SignatureProperty extends XMLStructure {
*
* @return an unmodifiable list of one or more <code>XMLStructure</code>s
*/
@SuppressWarnings("rawtypes")
List getContent();
}
......@@ -80,6 +80,7 @@ public interface SignedInfo extends XMLStructure {
*
* @return an unmodifiable list of one or more {@link Reference}s
*/
@SuppressWarnings("rawtypes")
List getReferences();
/**
......
......@@ -157,9 +157,9 @@ public abstract class TransformService implements Transform {
if (mechanismType.equals("DOM")) {
dom = true;
}
List services = GetInstance.getServices("TransformService", algorithm);
for (Iterator t = services.iterator(); t.hasNext(); ) {
Service s = (Service)t.next();
List<Service> services = GetInstance.getServices("TransformService", algorithm);
for (Iterator<Service> t = services.iterator(); t.hasNext(); ) {
Service s = t.next();
String value = s.getAttribute("MechanismType");
if ((value == null && dom) ||
(value != null && value.equals(mechanismType))) {
......@@ -277,7 +277,7 @@ public abstract class TransformService implements Transform {
+ " mechanism not available");
}
private static class MechanismMapEntry implements Map.Entry {
private static class MechanismMapEntry implements Map.Entry<String,String> {
private final String mechanism;
private final String algorithm;
private final String key;
......@@ -290,19 +290,19 @@ public abstract class TransformService implements Transform {
if (!(o instanceof Map.Entry)) {
return false;
}
Map.Entry e = (Map.Entry) o;
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
return (getKey()==null ?
e.getKey()==null : getKey().equals(e.getKey())) &&
(getValue()==null ?
e.getValue()==null : getValue().equals(e.getValue()));
}
public Object getKey() {
public String getKey() {
return key;
}
public Object getValue() {
public String getValue() {
return mechanism;
}
public Object setValue(Object value) {
public String setValue(String value) {
throw new UnsupportedOperationException();
}
public int hashCode() {
......
......@@ -100,6 +100,7 @@ public interface XMLObject extends XMLStructure {
* @return an unmodifiable list of <code>XMLStructure</code>s (may be empty
* but never <code>null</code>)
*/
@SuppressWarnings("rawtypes")
List getContent();
/**
......
......@@ -136,6 +136,7 @@ public interface XMLSignature extends XMLStructure {
* @return an unmodifiable list of <code>XMLObject</code>s (may be empty
* but never <code>null</code>)
*/
@SuppressWarnings("rawtypes")
List getObjects();
/**
......
......@@ -365,6 +365,7 @@ public abstract class XMLSignatureFactory {
* @throws ClassCastException if any of the <code>objects</code> are not of
* type <code>XMLObject</code>
*/
@SuppressWarnings("rawtypes")
public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki,
List objects, String id, String signatureValueId);
......@@ -398,6 +399,7 @@ public abstract class XMLSignatureFactory {
* compliant
* @throws NullPointerException if <code>dm</code> is <code>null</code>
*/
@SuppressWarnings("rawtypes")
public abstract Reference newReference(String uri, DigestMethod dm,
List transforms, String type, String id);
......@@ -428,6 +430,7 @@ public abstract class XMLSignatureFactory {
* @throws NullPointerException if <code>dm</code> or
* <code>digestValue</code> is <code>null</code>
*/
@SuppressWarnings("rawtypes")
public abstract Reference newReference(String uri, DigestMethod dm,
List transforms, String type, String id, byte[] digestValue);
......@@ -470,6 +473,7 @@ public abstract class XMLSignatureFactory {
* <code>appliedTransforms</code> or <code>result</code> is
* <code>null</code>
*/
@SuppressWarnings("rawtypes")
public abstract Reference newReference(String uri, DigestMethod dm,
List appliedTransforms, Data result, List transforms, String type,
String id);
......@@ -489,6 +493,7 @@ public abstract class XMLSignatureFactory {
* @throws NullPointerException if any of the parameters
* are <code>null</code>
*/
@SuppressWarnings("rawtypes")
public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm, List references);
......@@ -507,6 +512,7 @@ public abstract class XMLSignatureFactory {
* @throws NullPointerException if <code>cm</code>, <code>sm</code>, or
* <code>references</code> are <code>null</code>
*/
@SuppressWarnings("rawtypes")
public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm, List references, String id);
......@@ -524,6 +530,7 @@ public abstract class XMLSignatureFactory {
* @throws ClassCastException if <code>content</code> contains any
* entries that are not of type {@link XMLStructure}
*/
@SuppressWarnings("rawtypes")
public abstract XMLObject newXMLObject(List content, String id,
String mimeType, String encoding);
......@@ -540,6 +547,7 @@ public abstract class XMLSignatureFactory {
* @throws ClassCastException if <code>references</code> contains any
* entries that are not of type {@link Reference}
*/
@SuppressWarnings("rawtypes")
public abstract Manifest newManifest(List references);
/**
......@@ -556,6 +564,7 @@ public abstract class XMLSignatureFactory {
* @throws ClassCastException if <code>references</code> contains any
* entries that are not of type {@link Reference}
*/
@SuppressWarnings("rawtypes")
public abstract Manifest newManifest(List references, String id);
/**
......@@ -574,6 +583,7 @@ public abstract class XMLSignatureFactory {
* @throws ClassCastException if <code>content</code> contains any
* entries that are not of type {@link XMLStructure}
*/
@SuppressWarnings("rawtypes")
public abstract SignatureProperty newSignatureProperty
(List content, String target, String id);
......@@ -592,6 +602,7 @@ public abstract class XMLSignatureFactory {
* @throws ClassCastException if <code>properties</code> contains any
* entries that are not of type {@link SignatureProperty}
*/
@SuppressWarnings("rawtypes")
public abstract SignatureProperties newSignatureProperties
(List properties, String id);
......
......@@ -94,6 +94,7 @@ public interface KeyInfo extends XMLStructure {
* in this <code>KeyInfo</code>. Never returns <code>null</code> or an
* empty list.
*/
@SuppressWarnings("rawtypes")
List getContent();
/**
......
......@@ -305,6 +305,7 @@ public abstract class KeyInfoFactory {
* @throws ClassCastException if <code>content</code> contains any entries
* that are not of type {@link XMLStructure}
*/
@SuppressWarnings("rawtypes")
public abstract KeyInfo newKeyInfo(List content);
/**
......@@ -324,6 +325,7 @@ public abstract class KeyInfoFactory {
* @throws ClassCastException if <code>content</code> contains any entries
* that are not of type {@link XMLStructure}
*/
@SuppressWarnings("rawtypes")
public abstract KeyInfo newKeyInfo(List content, String id);
/**
......@@ -385,6 +387,7 @@ public abstract class KeyInfoFactory {
* @throws ClassCastException if <code>other</code> contains any
* entries that are not of type {@link XMLStructure}
*/
@SuppressWarnings("rawtypes")
public abstract PGPData newPGPData(byte[] keyId, byte[] keyPacket,
List other);
......@@ -408,6 +411,7 @@ public abstract class KeyInfoFactory {
* @throws ClassCastException if <code>other</code> contains any
* entries that are not of type {@link XMLStructure}
*/
@SuppressWarnings("rawtypes")
public abstract PGPData newPGPData(byte[] keyPacket, List other);
/**
......@@ -439,6 +443,7 @@ public abstract class KeyInfoFactory {
* @throws ClassCastException if <code>transforms</code> contains any
* entries that are not of type {@link Transform}
*/
@SuppressWarnings("rawtypes")
public abstract RetrievalMethod newRetrievalMethod(String uri, String type,
List transforms);
......@@ -464,6 +469,7 @@ public abstract class KeyInfoFactory {
* @throws ClassCastException if <code>content</code> contains any entries
* that are not of one of the valid types mentioned above
*/
@SuppressWarnings("rawtypes")
public abstract X509Data newX509Data(List content);
/**
......
......@@ -112,5 +112,6 @@ public interface PGPData extends XMLStructure {
* @return an unmodifiable list of <code>XMLStructure</code>s (may be
* empty, but never <code>null</code>)
*/
@SuppressWarnings("rawtypes")
List getExternalElements();
}
......@@ -80,6 +80,7 @@ public interface RetrievalMethod extends URIReference, XMLStructure {
* @return an unmodifiable list of <code>Transform</code> objects (may be
* empty but never <code>null</code>).
*/
@SuppressWarnings("rawtypes")
List getTransforms();
/**
......
......@@ -109,5 +109,6 @@ public interface X509Data extends XMLStructure {
* @return an unmodifiable list of the content in this <code>X509Data</code>
* (never <code>null</code> or empty)
*/
@SuppressWarnings("rawtypes")
List getContent();
}
......@@ -59,7 +59,7 @@ import java.util.List;
*/
public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
private List preList;
private List<String> preList;
/**
* Indicates the default namespace ("#default").
......@@ -71,7 +71,7 @@ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
* list.
*/
public ExcC14NParameterSpec() {
preList = Collections.EMPTY_LIST;
preList = Collections.emptyList();
}
/**
......@@ -86,17 +86,22 @@ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
* @throws ClassCastException if any of the entries in the list are not
* of type <code>String</code>
*/
@SuppressWarnings("rawtypes")
public ExcC14NParameterSpec(List prefixList) {
if (prefixList == null) {
throw new NullPointerException("prefixList cannot be null");
}
this.preList = new ArrayList(prefixList);
for (int i = 0, size = preList.size(); i < size; i++) {
if (!(preList.get(i) instanceof String)) {
List<?> copy = new ArrayList<>((List<?>)prefixList);
for (int i = 0, size = copy.size(); i < size; i++) {
if (!(copy.get(i) instanceof String)) {
throw new ClassCastException("not a String");
}
}
preList = Collections.unmodifiableList(preList);
@SuppressWarnings("unchecked")
List<String> temp = (List<String>)copy;
preList = Collections.unmodifiableList(temp);
}
/**
......@@ -109,6 +114,7 @@ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
* @return the inclusive namespace prefix list (may be empty but never
* <code>null</code>)
*/
@SuppressWarnings("rawtypes")
public List getPrefixList() {
return preList;
}
......
......@@ -46,7 +46,7 @@ import javax.xml.crypto.dsig.Transform;
*/
public final class XPathFilter2ParameterSpec implements TransformParameterSpec {
private final List xPathList;
private final List<XPathType> xPathList;
/**
* Creates an <code>XPathFilter2ParameterSpec</code>.
......@@ -59,11 +59,12 @@ public final class XPathFilter2ParameterSpec implements TransformParameterSpec {
* @throws NullPointerException if <code>xPathList</code> is
* <code>null</code>
*/
@SuppressWarnings("rawtypes")
public XPathFilter2ParameterSpec(List xPathList) {
if (xPathList == null) {
throw new NullPointerException("xPathList cannot be null");
}
List xPathListCopy = new ArrayList(xPathList);
List<?> xPathListCopy = new ArrayList<>((List<?>)xPathList);
if (xPathListCopy.isEmpty()) {
throw new IllegalArgumentException("xPathList cannot be empty");
}
......@@ -74,7 +75,11 @@ public final class XPathFilter2ParameterSpec implements TransformParameterSpec {
("xPathList["+i+"] is not a valid type");
}
}
this.xPathList = Collections.unmodifiableList(xPathListCopy);
@SuppressWarnings("unchecked")
List<XPathType> temp = (List<XPathType>)xPathListCopy;
this.xPathList = Collections.unmodifiableList(temp);
}
/**
......@@ -86,6 +91,7 @@ public final class XPathFilter2ParameterSpec implements TransformParameterSpec {
* @return a <code>List</code> of <code>XPathType</code> objects
* (never <code>null</code> or empty)
*/
@SuppressWarnings("rawtypes")
public List getXPathList() {
return xPathList;
}
......
......@@ -52,7 +52,7 @@ import java.util.Map.Entry;
public final class XPathFilterParameterSpec implements TransformParameterSpec {
private String xPath;
private Map nsMap;
private Map<String,String> nsMap;
/**
* Creates an <code>XPathFilterParameterSpec</code> with the specified
......@@ -66,7 +66,7 @@ public final class XPathFilterParameterSpec implements TransformParameterSpec {
throw new NullPointerException();
}
this.xPath = xPath;
this.nsMap = Collections.EMPTY_MAP;
this.nsMap = Collections.emptyMap();
}
/**
......@@ -83,21 +83,26 @@ public final class XPathFilterParameterSpec implements TransformParameterSpec {
* @throws ClassCastException if any of the map's keys or entries are not
* of type <code>String</code>
*/
@SuppressWarnings("rawtypes")
public XPathFilterParameterSpec(String xPath, Map namespaceMap) {
if (xPath == null || namespaceMap == null) {
throw new NullPointerException();
}
this.xPath = xPath;
nsMap = new HashMap(namespaceMap);
Iterator entries = nsMap.entrySet().iterator();
Map<?,?> copy = new HashMap<>((Map<?,?>)namespaceMap);
Iterator<? extends Map.Entry<?,?>> entries = copy.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry me = (Map.Entry) entries.next();
Map.Entry<?,?> me = entries.next();
if (!(me.getKey() instanceof String) ||
!(me.getValue() instanceof String)) {
throw new ClassCastException("not a String");
}
}
nsMap = Collections.unmodifiableMap(nsMap);
@SuppressWarnings("unchecked")
Map<String,String> temp = (Map<String,String>)copy;
nsMap = Collections.unmodifiableMap(temp);
}
/**
......@@ -120,6 +125,7 @@ public final class XPathFilterParameterSpec implements TransformParameterSpec {
* @return a <code>Map</code> of namespace prefixes to namespace URIs (may
* be empty, but never <code>null</code>)
*/
@SuppressWarnings("rawtypes")
public Map getNamespaceMap() {
return nsMap;
}
......
......@@ -106,7 +106,7 @@ public class XPathType {
private final String expression;
private final Filter filter;
private Map nsMap;
private Map<String,String> nsMap;
/**
* Creates an <code>XPathType</code> instance with the specified XPath
......@@ -127,7 +127,7 @@ public class XPathType {
}
this.expression = expression;
this.filter = filter;
this.nsMap = Collections.EMPTY_MAP;
this.nsMap = Collections.emptyMap();
}
/**
......@@ -147,21 +147,26 @@ public class XPathType {
* @throws ClassCastException if any of the map's keys or entries are
* not of type <code>String</code>
*/
@SuppressWarnings("rawtypes")
public XPathType(String expression, Filter filter, Map namespaceMap) {
this(expression, filter);
if (namespaceMap == null) {
throw new NullPointerException("namespaceMap cannot be null");
}
nsMap = new HashMap(namespaceMap);
Iterator entries = nsMap.entrySet().iterator();
Map<?,?> copy = new HashMap<>((Map<?,?>)namespaceMap);
Iterator<? extends Map.Entry<?,?>> entries = copy.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry me = (Map.Entry) entries.next();
Map.Entry<?,?> me = entries.next();
if (!(me.getKey() instanceof String) ||
!(me.getValue() instanceof String)) {
throw new ClassCastException("not a String");
}
}
nsMap = Collections.unmodifiableMap(nsMap);
@SuppressWarnings("unchecked")
Map<String,String> temp = (Map<String,String>)copy;
nsMap = Collections.unmodifiableMap(temp);
}
/**
......@@ -193,6 +198,7 @@ public class XPathType {
* @return a <code>Map</code> of namespace prefixes to namespace URIs
* (may be empty, but never <code>null</code>)
*/
@SuppressWarnings("rawtypes")
public Map getNamespaceMap() {
return nsMap;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册