Package com.sun.interview
Class Properties2
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,
Object>
The
Properties
class represents a persistent set of
properties. The Properties
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.
This class is similar to java.util.Properties, but has upgraded capabilities.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Properties2
A property list that contains default values for any keys not found in this property list. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty property list with no default values.Properties2
(Properties2 defaults) Creates an empty property list with the specified defaults. -
Method Summary
Modifier and TypeMethodDescriptiongetProperty
(String key) Searches for the property with the specified key in this property list.getProperty
(String key, String defaultValue) Searches for the property with the specified key in this property list.void
list
(PrintWriter out) Prints this property list out to the specified output stream.void
Reads a property list from an input stream.void
load
(Properties source) Returns an enumeration of all the keys in this property list, including the keys in the default property list.void
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 Details
-
defaults
A property list that contains default values for any keys not found in this property list.
-
-
Constructor Details
-
Properties2
public Properties2()Creates an empty property list with no default values. -
Properties2
Creates an empty property list with the specified defaults.- Parameters:
defaults
- the defaults.
-
-
Method Details
-
load
-
load
Reads a property list from an input stream.- Parameters:
in
- the input stream.- Throws:
IOException
- if an error occurred when reading from the input stream.
-
save
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.
-
getProperty
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.
- See Also:
-
getProperty
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.
- See Also:
-
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.
- See Also:
-
list
Prints this property list out to the specified output stream. This method is useful for debugging.- Parameters:
out
- an output stream.
-