Package com.sun.javatest.tool
Class Preferences
java.lang.Object
com.sun.javatest.tool.Preferences
A class which provides a collection of user preferences,
and a GUI interface to edit them. Preferences are represented
as named string values.
For now, the data is stored in a standard Java properties file
in the user's home directory; eventually, it will be converted to
use the J2SE support for user preferences.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
An observer interface for use by those that wishing to monitor changes to user preferences. -
Method Summary
Modifier and TypeMethodDescriptionstatic Preferences
access()
Access the single Preferences object.void
addObserver
(String[] prefixes, Preferences.Observer o) Add an observer to be notified of changes to all preferences whose name begins with any of a set of given prefixes.void
addObserver
(String prefix, Preferences.Observer o) Add an observer to be notified of changes to all preferences whose name begins with a given prefix.getPreference
(String name) Get a named preference value.getPreference
(String name, String defaultValue) Get a named preference value, using a default if the named preference is not found.static File
void
removeObserver
(String[] prefixes, Preferences.Observer o) Remove an observer which was previously registered to be notified of changes to all preferences whose name begins with any of a set of prefixed.void
removeObserver
(String prefix, Preferences.Observer o) Remove an observer which was previously registered to be notified of changes to all preferences whose name begins with a given prefix.void
save()
Save the current set of user preferences.void
setPreference
(String name, String newValue) Set the value of a named preference.
-
Method Details
-
access
Access the single Preferences object.- Returns:
- the single Preferences object
-
getPrefsDir
-
save
public void save()Save the current set of user preferences. For now, the data is stored in a standard Java properties file in the user's home directory; eventually, it will be converted to use the J2SE support for user preferences. -
getPreference
Get a named preference value.- Parameters:
name
- the name of the desired preference- Returns:
- the value of the named preference, or null if no such preference found
- See Also:
-
getPreference
Get a named preference value, using a default if the named preference is not found.- Parameters:
name
- the name of the desired preferencedefaultValue
- the default value to be returned if no such preference is found- Returns:
- the value of the named preference, or the default value if no such preference found
- See Also:
-
setPreference
Set the value of a named preference. Any interested observers will be notified.- Parameters:
name
- the name of the preference to be setnewValue
- the new value for the preference- See Also:
-
addObserver
Add an observer to be notified of changes to all preferences whose name begins with a given prefix. This allows an observer to monitor a single preference or a group of preferences.- Parameters:
prefix
- the prefix to determine which preferences will be observedo
- the observer to be added- See Also:
-
addObserver
Add an observer to be notified of changes to all preferences whose name begins with any of a set of given prefixes. This allows an observer to monitor a single preference or a group of preferences.- Parameters:
prefixes
- the prefix to determine which preferences will be observedo
- the observer to be added- See Also:
-
removeObserver
Remove an observer which was previously registered to be notified of changes to all preferences whose name begins with a given prefix. The prefix must exactly match the prefix with which it was previously registered.- Parameters:
prefix
- the prefix to identify which instance of the observer to be removedo
- the observer to be removed- See Also:
-
removeObserver
Remove an observer which was previously registered to be notified of changes to all preferences whose name begins with any of a set of prefixed. Each prefix must exactly match one with which the observer was previously registered.- Parameters:
prefixes
- the prefix to identify which instances of the observer to be removedo
- the observer to be removed- See Also:
-