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

Print this page
rev 4793 : 7117249: java.util warnings patches from LJC/Mike Barker

*** 104,124 **** 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(); 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()); } putPreferencesInXml(e, doc, p, subTree); writeDoc(doc, os); } --- 104,124 ---- 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<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", ancestors.get(i).name()); } putPreferencesInXml(e, doc, p, subTree); writeDoc(doc, os); }
*** 337,357 **** * 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 { 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(); Element xe = (Element) xmlMap.appendChild(doc.createElement("entry")); ! xe.setAttribute("key", (String) e.getKey()); ! xe.setAttribute("value", (String) e.getValue()); } writeDoc(doc, os); } --- 337,357 ---- * 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<String, String> map) throws IOException { Document doc = createPrefsDoc("map"); Element xmlMap = doc.getDocumentElement( ) ; xmlMap.setAttribute("MAP_XML_VERSION", MAP_XML_VERSION); ! 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", e.getKey()); ! xe.setAttribute("value", e.getValue()); } writeDoc(doc, os); }
*** 366,376 **** * @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) throws IOException, InvalidPreferencesFormatException { try { Document doc = loadPrefsDoc(is); Element xmlMap = doc.getDocumentElement(); --- 366,376 ---- * @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<String, String> m) throws IOException, InvalidPreferencesFormatException { try { Document doc = loadPrefsDoc(is); Element xmlMap = doc.getDocumentElement();