提交 f25fffb5 编写于 作者: A art

8022185: Fix Raw and unchecked warnings in classes belonging to java.awt.datatransfer

Reviewed-by: art, pchelko
Contributed-by: NSrikalyan Chandrashekar <srikalyan.chandrashekar@oracle.com>
上级 08d5fa6f
...@@ -101,7 +101,7 @@ import sun.awt.datatransfer.DataTransferer; ...@@ -101,7 +101,7 @@ import sun.awt.datatransfer.DataTransferer;
public class DataFlavor implements Externalizable, Cloneable { public class DataFlavor implements Externalizable, Cloneable {
private static final long serialVersionUID = 8367026044764648243L; private static final long serialVersionUID = 8367026044764648243L;
private static final Class ioInputStreamClass = java.io.InputStream.class; private static final Class<InputStream> ioInputStreamClass = InputStream.class;
/** /**
* Tries to load a class from: the bootstrap loader, the system loader, * Tries to load a class from: the bootstrap loader, the system loader,
...@@ -116,10 +116,10 @@ public class DataFlavor implements Externalizable, Cloneable { ...@@ -116,10 +116,10 @@ public class DataFlavor implements Externalizable, Cloneable {
ClassLoader fallback) ClassLoader fallback)
throws ClassNotFoundException throws ClassNotFoundException
{ {
ClassLoader systemClassLoader = (ClassLoader) ClassLoader systemClassLoader =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<ClassLoader>() {
public Object run() { public ClassLoader run() {
ClassLoader cl = Thread.currentThread(). ClassLoader cl = Thread.currentThread().
getContextClassLoader(); getContextClassLoader();
return (cl != null) return (cl != null)
...@@ -142,7 +142,7 @@ public class DataFlavor implements Externalizable, Cloneable { ...@@ -142,7 +142,7 @@ public class DataFlavor implements Externalizable, Cloneable {
/* /*
* private initializer * private initializer
*/ */
static private DataFlavor createConstant(Class rc, String prn) { static private DataFlavor createConstant(Class<?> rc, String prn) {
try { try {
return new DataFlavor(rc, prn); return new DataFlavor(rc, prn);
} catch (Exception e) { } catch (Exception e) {
...@@ -314,7 +314,7 @@ public class DataFlavor implements Externalizable, Cloneable { ...@@ -314,7 +314,7 @@ public class DataFlavor implements Externalizable, Cloneable {
* @exception NullPointerException if either <code>primaryType</code>, * @exception NullPointerException if either <code>primaryType</code>,
* <code>subType</code> or <code>representationClass</code> is null * <code>subType</code> or <code>representationClass</code> is null
*/ */
private DataFlavor(String primaryType, String subType, MimeTypeParameterList params, Class representationClass, String humanPresentableName) { private DataFlavor(String primaryType, String subType, MimeTypeParameterList params, Class<?> representationClass, String humanPresentableName) {
super(); super();
if (primaryType == null) { if (primaryType == null) {
throw new NullPointerException("primaryType"); throw new NullPointerException("primaryType");
...@@ -331,7 +331,7 @@ public class DataFlavor implements Externalizable, Cloneable { ...@@ -331,7 +331,7 @@ public class DataFlavor implements Externalizable, Cloneable {
params.set("class", representationClass.getName()); params.set("class", representationClass.getName());
if (humanPresentableName == null) { if (humanPresentableName == null) {
humanPresentableName = (String)params.get("humanPresentableName"); humanPresentableName = params.get("humanPresentableName");
if (humanPresentableName == null) if (humanPresentableName == null)
humanPresentableName = primaryType + "/" + subType; humanPresentableName = primaryType + "/" + subType;
...@@ -732,7 +732,7 @@ public class DataFlavor implements Externalizable, Cloneable { ...@@ -732,7 +732,7 @@ public class DataFlavor implements Externalizable, Cloneable {
return bestFlavor; return bestFlavor;
} }
private static Comparator textFlavorComparator; private static Comparator<DataFlavor> textFlavorComparator;
static class TextFlavorComparator static class TextFlavorComparator
extends DataTransferer.DataFlavorComparator { extends DataTransferer.DataFlavorComparator {
...@@ -1438,6 +1438,6 @@ public class DataFlavor implements Externalizable, Cloneable { ...@@ -1438,6 +1438,6 @@ public class DataFlavor implements Externalizable, Cloneable {
/** Java class of objects this DataFlavor represents **/ /** Java class of objects this DataFlavor represents **/
private Class representationClass; private Class<?> representationClass;
} // class DataFlavor } // class DataFlavor
...@@ -44,13 +44,13 @@ class MimeTypeParameterList implements Cloneable { ...@@ -44,13 +44,13 @@ class MimeTypeParameterList implements Cloneable {
* Default constructor. * Default constructor.
*/ */
public MimeTypeParameterList() { public MimeTypeParameterList() {
parameters = new Hashtable(); parameters = new Hashtable<>();
} }
public MimeTypeParameterList(String rawdata) public MimeTypeParameterList(String rawdata)
throws MimeTypeParseException throws MimeTypeParseException
{ {
parameters = new Hashtable(); parameters = new Hashtable<>();
// now parse rawdata // now parse rawdata
parse(rawdata); parse(rawdata);
...@@ -59,10 +59,10 @@ class MimeTypeParameterList implements Cloneable { ...@@ -59,10 +59,10 @@ class MimeTypeParameterList implements Cloneable {
public int hashCode() { public int hashCode() {
int code = Integer.MAX_VALUE/45; // "random" value for empty lists int code = Integer.MAX_VALUE/45; // "random" value for empty lists
String paramName = null; String paramName = null;
Enumeration enum_ = this.getNames(); Enumeration<String> enum_ = this.getNames();
while (enum_.hasMoreElements()) { while (enum_.hasMoreElements()) {
paramName = (String)enum_.nextElement(); paramName = enum_.nextElement();
code += paramName.hashCode(); code += paramName.hashCode();
code += this.get(paramName).hashCode(); code += this.get(paramName).hashCode();
} }
...@@ -87,14 +87,14 @@ class MimeTypeParameterList implements Cloneable { ...@@ -87,14 +87,14 @@ class MimeTypeParameterList implements Cloneable {
String name = null; String name = null;
String thisValue = null; String thisValue = null;
String thatValue = null; String thatValue = null;
Set entries = parameters.entrySet(); Set<Map.Entry<String, String>> entries = parameters.entrySet();
Iterator iterator = entries.iterator(); Iterator<Map.Entry<String, String>> iterator = entries.iterator();
Map.Entry entry = null; Map.Entry<String, String> entry = null;
while (iterator.hasNext()) { while (iterator.hasNext()) {
entry = (Map.Entry)iterator.next(); entry = iterator.next();
name = (String)entry.getKey(); name = entry.getKey();
thisValue = (String)entry.getValue(); thisValue = entry.getValue();
thatValue = (String)that.parameters.get(name); thatValue = that.parameters.get(name);
if ((thisValue == null) || (thatValue == null)) { if ((thisValue == null) || (thatValue == null)) {
// both null -> equal, only one null -> not equal // both null -> equal, only one null -> not equal
if (thisValue != thatValue) { if (thisValue != thatValue) {
...@@ -250,7 +250,7 @@ class MimeTypeParameterList implements Cloneable { ...@@ -250,7 +250,7 @@ class MimeTypeParameterList implements Cloneable {
* is no current association. * is no current association.
*/ */
public String get(String name) { public String get(String name) {
return (String)parameters.get(name.trim().toLowerCase()); return parameters.get(name.trim().toLowerCase());
} }
/** /**
...@@ -271,7 +271,7 @@ class MimeTypeParameterList implements Cloneable { ...@@ -271,7 +271,7 @@ class MimeTypeParameterList implements Cloneable {
/** /**
* Retrieve an enumeration of all the names in this list. * Retrieve an enumeration of all the names in this list.
*/ */
public Enumeration getNames() { public Enumeration<String> getNames() {
return parameters.keys(); return parameters.keys();
} }
...@@ -279,15 +279,15 @@ class MimeTypeParameterList implements Cloneable { ...@@ -279,15 +279,15 @@ class MimeTypeParameterList implements Cloneable {
// Heuristic: 8 characters per field // Heuristic: 8 characters per field
StringBuilder buffer = new StringBuilder(parameters.size() * 16); StringBuilder buffer = new StringBuilder(parameters.size() * 16);
Enumeration keys = parameters.keys(); Enumeration<String> keys = parameters.keys();
while(keys.hasMoreElements()) while(keys.hasMoreElements())
{ {
buffer.append("; "); buffer.append("; ");
String key = (String)keys.nextElement(); String key = keys.nextElement();
buffer.append(key); buffer.append(key);
buffer.append('='); buffer.append('=');
buffer.append(quote((String)parameters.get(key))); buffer.append(quote(parameters.get(key)));
} }
return buffer.toString(); return buffer.toString();
...@@ -307,7 +307,7 @@ class MimeTypeParameterList implements Cloneable { ...@@ -307,7 +307,7 @@ class MimeTypeParameterList implements Cloneable {
return newObj; return newObj;
} }
private Hashtable parameters; private Hashtable<String, String> parameters;
// below here be scary parsing related things // below here be scary parsing related things
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册