src/share/classes/java/util/prefs/XmlSupport.java

Print this page
rev 4802 : 7117249: fix warnings in java.util.jar, .logging, .prefs, .zip
Reviewed-by: alanb, dholmes, forax, sherman, smarks
Contributed-by: London Java Community and Michael Barker <mikeb01@gmail.com>

@@ -104,21 +104,21 @@
         Element xmlRoot =  (Element)
         preferences.appendChild(doc.createElement("root"));
         xmlRoot.setAttribute("type", (p.isUserNode() ? "user" : "system"));
 
         // Get bottom-up list of nodes from p to root, excluding root
-        List ancestors = new ArrayList();
+        List<Preferences> ancestors = new ArrayList<>();
 
         for (Preferences kid = p, dad = kid.parent(); dad != null;
                                    kid = dad, dad = kid.parent()) {
             ancestors.add(kid);
         }
         Element e = xmlRoot;
         for (int i=ancestors.size()-1; i >= 0; i--) {
             e.appendChild(doc.createElement("map"));
             e = (Element) e.appendChild(doc.createElement("node"));
-            e.setAttribute("name", ((Preferences)ancestors.get(i)).name());
+            e.setAttribute("name", ancestors.get(i).name());
         }
         putPreferencesInXml(e, doc, p, subTree);
 
         writeDoc(doc, os);
     }

@@ -337,21 +337,21 @@
      * as the internal (undocumented) format for FileSystemPrefs.
      *
      * @throws IOException if writing to the specified output stream
      *         results in an <tt>IOException</tt>.
      */
-    static void exportMap(OutputStream os, Map map) throws IOException {
+    static void exportMap(OutputStream os, Map<String, String> map) throws IOException {
         Document doc = createPrefsDoc("map");
         Element xmlMap = doc.getDocumentElement( ) ;
         xmlMap.setAttribute("MAP_XML_VERSION", MAP_XML_VERSION);
 
-        for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) {
-            Map.Entry e = (Map.Entry) i.next();
+        for (Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext(); ) {
+            Map.Entry<String, String> e = i.next();
             Element xe = (Element)
                 xmlMap.appendChild(doc.createElement("entry"));
-            xe.setAttribute("key",   (String) e.getKey());
-            xe.setAttribute("value", (String) e.getValue());
+            xe.setAttribute("key",   e.getKey());
+            xe.setAttribute("value", e.getValue());
         }
 
         writeDoc(doc, os);
     }
 

@@ -366,11 +366,11 @@
      * @throws IOException if reading from the specified output stream
      *         results in an <tt>IOException</tt>.
      * @throws InvalidPreferencesFormatException Data on input stream does not
      *         constitute a valid XML document with the mandated document type.
      */
-    static void importMap(InputStream is, Map m)
+    static void importMap(InputStream is, Map<String, String> m)
         throws IOException, InvalidPreferencesFormatException
     {
         try {
             Document doc = loadPrefsDoc(is);
             Element xmlMap = doc.getDocumentElement();