/** * Returns a set of keys in this property list where * the key and its corresponding value are strings, * including distinct keys in the default property list if a key * of the same name has not already been found from the main * properties list. Properties whose key or value is not * of type <tt>String</tt> are omitted. * <p> * The returned set is not backed by the <tt>Properties</tt> object. * Changes to this <tt>Properties</tt> are not reflected in the set, * or vice versa. * * @return a set of keys in this property list where * the key and its corresponding value are strings, * including the keys in the default property list. * @see java.util.Properties#defaults * @since 1.6 */ public Set<String> stringPropertyNames() { Hashtable<String, String> h = new Hashtable<>(); enumerateStringProperties(h); return h.keySet(); }
/** * Returns a set of keys in this property list where * the key and its corresponding value are strings, * including distinct keys in the default property list if a key * of the same name has not already been found from the main * properties list. Properties whose key or value is not * of type <tt>String</tt> are omitted. * <p> * The returned set is not backed by the <tt>Properties</tt> object. * Changes to this <tt>Properties</tt> are not reflected in the set, * or vice versa. * * @return a set of keys in this property list where * the key and its corresponding value are strings, * including the keys in the default property list. * @see java.util.Properties#defaults * @since 1.6 */ public Set<String> stringPropertyNames() { Hashtable<String, String> h = new Hashtable<>(); enumerateStringProperties(h); return h.keySet(); }
/** * Enumerates all key/value pairs in the specified hashtable * and omits the property if the key or value is not a string. * @param h the hashtable */ 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); } } }
/** * Returns a set of keys in this property list where * the key and its corresponding value are strings, * including distinct keys in the default property list if a key * of the same name has not already been found from the main * properties list. Properties whose key or value is not * of type <tt>String</tt> are omitted. * <p> * The returned set is not backed by the <tt>Properties</tt> object. * Changes to this <tt>Properties</tt> are not reflected in the set, * or vice versa. * * @return a set of keys in this property list where * the key and its corresponding value are strings, * including the keys in the default property list. * @see java.util.Properties#defaults * @since 1.6 */ public Set<String> stringPropertyNames() { Hashtable<String, String> h= new Hashtable<String, String>(); enumerateStringProperties(h); return h.keySet(); }
/** * Enumerates all key/value pairs in the specified hashtable * and omits the property if the key or value is not a string. * @param h the hashtable */ 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); } } }
/** * Enumerates all key/value pairs in the specified hashtable * and omits the property if the key or value is not a string. * @param h the hashtable */ 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); } } }