This patch adds generic types in IppUtilities.java, fixing nearly a hundred warnings.
2010-04-28 Andrew John Hughes <ahug...@redhat.com> * gnu/javax/print/ipp/IppUtilities.java: (INTEGER_CLASS_ARRAY): Use generic typing. (TEXT_CLASS_ARRAY): Likewise. (classesByName): Likewise. (instanceByClass): Likewise. (getClass(String)): Remove cast. Return generic type. (getSupportedAttrName(Class<? extends Attribute>)): Remove cast. Add generic type to parameter. (getSupportedCategory(Class<?> extends Attribute>)): Likewise. (getEnumAttribute(String,Object)): Add missing generic types on Class. (getIntegerAttribute(String,int)): Likewise and on Constructor. (getTextAttribute(String,byte,byte[])): Likewise. -- Andrew :) Free Java Software Engineer Red Hat, Inc. (http://www.redhat.com) Support Free Java! Contribute to GNU Classpath and the OpenJDK http://www.gnu.org/software/classpath http://openjdk.java.net PGP Key: 94EFD9D8 (http://subkeys.pgp.net) Fingerprint = F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8
Index: gnu/javax/print/ipp/IppUtilities.java =================================================================== RCS file: /sources/classpath/classpath/gnu/javax/print/ipp/IppUtilities.java,v retrieving revision 1.2 diff -u -u -r1.2 IppUtilities.java --- gnu/javax/print/ipp/IppUtilities.java 27 Apr 2010 21:34:03 -0000 1.2 +++ gnu/javax/print/ipp/IppUtilities.java 27 Apr 2010 23:25:08 -0000 @@ -147,14 +147,16 @@ { // These are reused in the reflection code to not instantiate an array everytime private static Object[] INTEGER_ATT_VALUE = new Object[1]; - private static Class[] INTEGER_CLASS_ARRAY = new Class[] {int.class}; + private static Class<?>[] INTEGER_CLASS_ARRAY = new Class[] {int.class}; private static Object[] TEXT_ATT_VALUE = new Object[2]; - private static Class[] TEXT_CLASS_ARRAY = new Class[] {String.class, Locale.class}; + private static Class<?>[] TEXT_CLASS_ARRAY = new Class[] {String.class, Locale.class}; // The map -> Attribute name to Attribute class - private static HashMap classesByName = new HashMap(); + private static HashMap<String,Class<? extends Attribute>> classesByName = + new HashMap<String,Class<? extends Attribute>>(); // The map -> StandardAttribute class to SupportedAttribute category name - private static HashMap instanceByClass = new HashMap(); + private static HashMap<Class<? extends Attribute>,SupportedValuesAttribute> instanceByClass = + new HashMap<Class<? extends Attribute>,SupportedValuesAttribute>(); /** * All the currently needed attributes @@ -312,9 +314,9 @@ * @param name the attribute name * @return The <code>Class</code> object. */ - public static Class getClass(String name) + public static Class<? extends Attribute> getClass(String name) { - return (Class) classesByName.get(name); + return classesByName.get(name); } /** @@ -324,9 +326,9 @@ * @param clazz the standard attribute category * @return The name of the supported attribute category. */ - public static String getSupportedAttrName(Class clazz) + public static String getSupportedAttrName(Class<? extends Attribute> clazz) { - return ((SupportedValuesAttribute) instanceByClass.get(clazz)).getName(); + return instanceByClass.get(clazz).getName(); } /** @@ -336,9 +338,9 @@ * @param clazz the standard attribute category * @return The supported attribute category. */ - public static Class getSupportedCategory(Class clazz) + public static Class<? extends Attribute> getSupportedCategory(Class<? extends Attribute> clazz) { - return ((SupportedValuesAttribute) instanceByClass.get(clazz)).getCategory(); + return instanceByClass.get(clazz).getCategory(); } /** @@ -387,7 +389,7 @@ */ public static Attribute getEnumAttribute(String name, Object value) { - Class attrClass = getClass(name); + Class<?> attrClass = getClass(name); // There might be unknown enums we have no mapped class for if (attrClass == null) @@ -439,7 +441,7 @@ */ public static Attribute getIntegerAttribute(String name, int value) { - Class attrClass = getClass(name); + Class<?> attrClass = getClass(name); // There might be unknown attributes we have no mapped class for if (attrClass == null) @@ -447,8 +449,8 @@ try { - INTEGER_ATT_VALUE[0] = new Integer(value); - Constructor c = attrClass.getDeclaredConstructor(INTEGER_CLASS_ARRAY); + INTEGER_ATT_VALUE[0] = Integer.valueOf(value); + Constructor<?> c = attrClass.getDeclaredConstructor(INTEGER_CLASS_ARRAY); return (Attribute) c.newInstance(INTEGER_ATT_VALUE); } catch (SecurityException e) @@ -514,7 +516,7 @@ TEXT_ATT_VALUE[1] = locale; } - Class attrClass = getClass(name); + Class<?> attrClass = getClass(name); // There might be unknown attributes we have no mapped class for if (attrClass == null) @@ -522,7 +524,7 @@ try { - Constructor c = attrClass.getDeclaredConstructor(TEXT_CLASS_ARRAY); + Constructor<?> c = attrClass.getDeclaredConstructor(TEXT_CLASS_ARRAY); return (Attribute) c.newInstance(TEXT_ATT_VALUE); } catch (SecurityException e)