src/share/classes/java/util/Properties.java
Print this page
*** 822,832 ****
writeComments(bw, comments);
}
bw.write("#" + new Date().toString());
bw.newLine();
synchronized (this) {
! for (Enumeration e = keys(); e.hasMoreElements();) {
String key = (String)e.nextElement();
String val = (String)get(key);
key = saveConvert(key, true, escUnicode);
/* No need to escape embedded and trailing spaces for value, hence
* pass false to flag.
--- 822,832 ----
writeComments(bw, comments);
}
bw.write("#" + new Date().toString());
bw.newLine();
synchronized (this) {
! for (Enumeration<?> e = keys(); e.hasMoreElements();) {
String key = (String)e.nextElement();
String val = (String)get(key);
key = saveConvert(key, true, escUnicode);
/* No need to escape embedded and trailing spaces for value, hence
* pass false to flag.
*** 985,995 ****
* @see java.util.Enumeration
* @see java.util.Properties#defaults
* @see #stringPropertyNames
*/
public Enumeration<?> propertyNames() {
! Hashtable h = new Hashtable();
enumerate(h);
return h.keys();
}
/**
--- 985,995 ----
* @see java.util.Enumeration
* @see java.util.Properties#defaults
* @see #stringPropertyNames
*/
public Enumeration<?> propertyNames() {
! Hashtable<String,Object> h = new Hashtable<>();
enumerate(h);
return h.keys();
}
/**
*** 1024,1037 ****
* @throws ClassCastException if any key in this property list
* is not a string.
*/
public void list(PrintStream out) {
out.println("-- listing properties --");
! Hashtable h = new Hashtable();
enumerate(h);
! for (Enumeration e = h.keys() ; e.hasMoreElements() ;) {
! String key = (String)e.nextElement();
String val = (String)h.get(key);
if (val.length() > 40) {
val = val.substring(0, 37) + "...";
}
out.println(key + "=" + val);
--- 1024,1037 ----
* @throws ClassCastException if any key in this property list
* is not a string.
*/
public void list(PrintStream out) {
out.println("-- listing properties --");
! Hashtable<String,Object> h = new Hashtable<>();
enumerate(h);
! for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
! String key = e.nextElement();
String val = (String)h.get(key);
if (val.length() > 40) {
val = val.substring(0, 37) + "...";
}
out.println(key + "=" + val);
*** 1052,1065 ****
* method is duplicated in order to ensure that a non-1.1 compiler can
* compile this file.
*/
public void list(PrintWriter out) {
out.println("-- listing properties --");
! Hashtable h = new Hashtable();
enumerate(h);
! for (Enumeration e = h.keys() ; e.hasMoreElements() ;) {
! String key = (String)e.nextElement();
String val = (String)h.get(key);
if (val.length() > 40) {
val = val.substring(0, 37) + "...";
}
out.println(key + "=" + val);
--- 1052,1065 ----
* method is duplicated in order to ensure that a non-1.1 compiler can
* compile this file.
*/
public void list(PrintWriter out) {
out.println("-- listing properties --");
! Hashtable<String,Object> h = new Hashtable<>();
enumerate(h);
! for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
! String key = e.nextElement();
String val = (String)h.get(key);
if (val.length() > 40) {
val = val.substring(0, 37) + "...";
}
out.println(key + "=" + val);
*** 1070,1084 ****
* Enumerates all key/value pairs in the specified hashtable.
* @param h the hashtable
* @throws ClassCastException if any of the property keys
* is not of String type.
*/
! private synchronized void enumerate(Hashtable h) {
if (defaults != null) {
defaults.enumerate(h);
}
! for (Enumeration e = keys() ; e.hasMoreElements() ;) {
String key = (String)e.nextElement();
h.put(key, get(key));
}
}
--- 1070,1084 ----
* Enumerates all key/value pairs in the specified hashtable.
* @param h the hashtable
* @throws ClassCastException if any of the property keys
* is not of String type.
*/
! private synchronized void enumerate(Hashtable<String,Object> h) {
if (defaults != null) {
defaults.enumerate(h);
}
! for (Enumeration<?> e = keys() ; e.hasMoreElements() ;) {
String key = (String)e.nextElement();
h.put(key, get(key));
}
}
*** 1089,1099 ****
*/
private synchronized void enumerateStringProperties(Hashtable<String, String> h) {
if (defaults != null) {
defaults.enumerateStringProperties(h);
}
! for (Enumeration e = keys() ; e.hasMoreElements() ;) {
Object k = e.nextElement();
Object v = get(k);
if (k instanceof String && v instanceof String) {
h.put((String) k, (String) v);
}
--- 1089,1099 ----
*/
private synchronized void enumerateStringProperties(Hashtable<String, String> h) {
if (defaults != null) {
defaults.enumerateStringProperties(h);
}
! for (Enumeration<?> e = keys() ; e.hasMoreElements() ;) {
Object k = e.nextElement();
Object v = get(k);
if (k instanceof String && v instanceof String) {
h.put((String) k, (String) v);
}