< prev index next >

src/com/sun/javatest/util/PropertyArray.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg

@@ -225,11 +225,11 @@
      * @param data an array of sequential name value properties
      * @param key the name of the entry to be removed
      * @return an array that does not contain the named property
      */
     public static String[] remove(String[] data, String key) {
-        Vector vec = copyOutOf(data);
+        Vector<String> vec = copyOutOf(data);
         int lower = 0;
         int upper = vec.size() - 2;
         int mid = 0;
         String old = null;
 

@@ -237,31 +237,31 @@
             // no data yet
             return data;
         }
 
         // goes at the end
-        String last = (String)vec.elementAt(upper);
+        String last = vec.elementAt(upper);
         int cmp = key.compareTo(last);
         if (cmp > 0) {
             return data;
         }
 
         while (lower <= upper) {
             // in next line, take care to ensure that mid is always even
             mid = lower + ((upper - lower) / 4) * 2;
-            String e = (String)(vec.elementAt(mid));
+            String e = (vec.elementAt(mid));
             cmp = key.compareTo(e);
             if (cmp < 0) {
                 upper = mid - 2;
             }
             else if (cmp > 0) {
                 lower = mid + 2;
             }
             else {
                 // strings equal, zap key and value
                 vec.removeElementAt(mid);
-                old = (String)(vec.elementAt(mid));
+                old = vec.elementAt(mid);
                 vec.removeElementAt(mid);
                 break;
             }
         }
 

@@ -371,19 +371,19 @@
     /**
      * Enumerate the properties in an array.
      * @param props an array of sequential name value properties
      * @return an enumeration of the properties in the array
      */
-    public static Enumeration enumerate(final String[] props) {
-        return new Enumeration() {
+    public static Enumeration<String> enumerate(final String[] props) {
+        return new Enumeration<String>() {
             int pos = 0;
 
             public boolean hasMoreElements() {
                 return (props != null && pos < props.length);
             }
 
-            public Object nextElement() {
+            public String nextElement() {
                 if (props == null || pos >= props.length) {
                    return null;
                 }
                 else {
                    String current = props[pos];
< prev index next >