Package com.sun.javatest.util
Class Properties
- java.lang.Object
-
- java.util.Dictionary<K,V>
-
- java.util.Hashtable
-
- com.sun.javatest.util.Properties
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map
public class Properties extends java.util.Hashtable
TheProperties
class represents a persistent set of properties. TheProperties
can be saved to a stream or loaded from a stream. Each key and its corresponding value in the property list is a string.A property list can contain another property list as its "defaults"; this second property list is searched if the property key is not found in the original property list.
Modified from JDK java.util.Properties to use Reader/Writer as well as InputStream/OutputStream, to fix locale/codepage problems.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Properties
defaults
A property list that contains default values for any keys not found in this property list.
-
Constructor Summary
Constructors Constructor Description Properties()
Creates an empty property list with no default values.Properties(Properties defaults)
Creates an empty property list with the specified defaults.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getProperty(java.lang.String key)
Searches for the property with the specified key in this property list.java.lang.String
getProperty(java.lang.String key, java.lang.String defaultValue)
Searches for the property with the specified key in this property list.void
list(java.io.PrintWriter out)
Prints this property list out to the specified output stream.void
load(java.io.Reader in)
Reads a property list from an input stream.java.util.Enumeration
propertyNames()
Returns an enumeration of all the keys in this property list, including the keys in the default property list.void
save(java.io.Writer out, java.lang.String header)
Stores this property list to the specified output stream.-
Methods inherited from class java.util.Hashtable
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, values
-
-
-
-
Field Detail
-
defaults
protected Properties defaults
A property list that contains default values for any keys not found in this property list.- Since:
- JDK1.0
-
-
Constructor Detail
-
Properties
public Properties()
Creates an empty property list with no default values.- Since:
- JDK1.0
-
Properties
public Properties(Properties defaults)
Creates an empty property list with the specified defaults.- Parameters:
defaults
- the defaults.- Since:
- JDK1.0
-
-
Method Detail
-
load
public void load(java.io.Reader in) throws java.io.IOException
Reads a property list from an input stream.- Parameters:
in
- the input stream.- Throws:
java.io.IOException
- if an error occurred when reading from the input stream.
-
save
public void save(java.io.Writer out, java.lang.String header) throws java.io.IOException
Stores this property list to the specified output stream. The string header is printed as a comment at the beginning of the stream.- Parameters:
out
- an output stream.header
- a description of the property list.- Throws:
java.io.IOException
- Since:
- JDK1.0
-
getProperty
public java.lang.String getProperty(java.lang.String key)
Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returnsnull
if the property is not found.- Parameters:
key
- the property key.- Returns:
- the value in this property list with the specified key value.
- Since:
- JDK1.0
- See Also:
defaults
-
getProperty
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns the default value argument if the property is not found.- Parameters:
key
- the hashtable key.defaultValue
- a default value.- Returns:
- the value in this property list with the specified key value.
- Since:
- JDK1.0
- See Also:
defaults
-
propertyNames
public java.util.Enumeration propertyNames()
Returns an enumeration of all the keys in this property list, including the keys in the default property list.- Returns:
- an enumeration of all the keys in this property list, including the keys in the default property list.
- Since:
- JDK1.0
- See Also:
Enumeration
,defaults
-
list
public void list(java.io.PrintWriter out)
Prints this property list out to the specified output stream. This method is useful for debugging.- Parameters:
out
- an output stream.- Since:
- JDK1.1
-
-