Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.javatest.tool
Class Preferences

    java.lang.Object
      com.sun.javatest.tool.Preferences

    public class Preferences

extends java.lang.Object

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
`static interface` | `Preferences.Observer` An observer interface for use by those that wishing to monitor changes to user preferences.
`static class` | `Preferences.Pane` An abstract class for a GUI panel that can be displayed to allow the user to edit some of the user preferences.

Method Summary
`static Preferences` | `access()` Access the single Preferences object.
`void` | `addObserver(java.lang.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(java.lang.String prefix, Preferences.Observer o)` Add an observer to be notified of changes to all preferences whose name begins with a given prefix.
`java.lang.String` | `getPreference(java.lang.String name)` Get a named preference value.
`java.lang.String` | `getPreference(java.lang.String name, java.lang.String defaultValue)` Get a named preference value, using a default if the named preference is not found.
`void` | `removeObserver(java.lang.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(java.lang.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(java.lang.String name, java.lang.String newValue)` Set the value of a named preference.
`void` | `showDialog(javax.swing.JFrame f, Preferences.Pane[] panes, javax.help.HelpBroker helpBroker)` Show a dialog to allow the user to edit the set of preferences.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### access

    public static Preferences access()

  Access the single Preferences object.

  Returns:
    the single Preferences object

### 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

    public java.lang.String getPreference(java.lang.String name)

  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:
    `setPreference(java.lang.String, java.lang.String)`

### getPreference

    public java.lang.String getPreference(java.lang.String name,
                                          java.lang.String defaultValue)

  Get a named preference value, using a default if the named preference is not found.

  Parameters:
    `name` - the name of the desired preference
    `defaultValue` - 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(java.lang.String, java.lang.String)`

### setPreference

    public void setPreference(java.lang.String name,
                              java.lang.String newValue)

  Set the value of a named preference. Any interested observers will be notified.

  Parameters:
    `name` - the name of the preference to be set
    `newValue` - the new value for the preference
  See Also:
    `getPreference(java.lang.String)`

### addObserver

    public void addObserver(java.lang.String prefix,
                            Preferences.Observer o)

  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 observed
    `o` - the observer to be added
  See Also:
    `removeObserver(java.lang.String, com.sun.javatest.tool.Preferences.Observer)`

### addObserver

    public void addObserver(java.lang.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. This allows an observer to monitor a single preference or a group of preferences.

  Parameters:
    `prefixes` - the prefix to determine which preferences will be observed
    `o` - the observer to be added
  See Also:
    `removeObserver(java.lang.String, com.sun.javatest.tool.Preferences.Observer)`

### removeObserver

    public void removeObserver(java.lang.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. 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 removed
    `o` - the observer to be removed
  See Also:
    `addObserver(java.lang.String, com.sun.javatest.tool.Preferences.Observer)`

### removeObserver

    public void removeObserver(java.lang.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. 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 removed
    `o` - the observer to be removed
  See Also:
    `addObserver(java.lang.String, com.sun.javatest.tool.Preferences.Observer)`

### showDialog

    public void showDialog(javax.swing.JFrame f,
                           Preferences.Pane[] panes,
                           javax.help.HelpBroker helpBroker)

  Show a dialog to allow the user to edit the set of preferences. A collection of editing panes must be provided that each provide the GUI to edit a subset of the preferences.

  Parameters:
    `f` - the parent frame for the dialog
    `panes` - the editing panes to be displayed in the dialog
    `helpBroker` - a help broker to be used to provide context sensitive help for the dialog

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.