Package: org.codehaus.groovy.tools.shell.util

## [Java] Class Preferences

- org.codehaus.groovy.tools.shell.util.Preferences

-     public class Preferences
      extends Object

  Container for shell preferences.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static String` | `EDITOR_KEY` | Preference key storing the preferred editor command.
    `static String` | `PARSER_FLAVOR_KEY` | Preference key storing the parser flavor.
    `static String` | `PARSER_RELAXED` | Parser flavor value selecting relaxed parsing.
    `static String` | `PARSER_RIGID` | Parser flavor value selecting rigid parsing.
    `static String` | `SANITIZE_STACK_TRACE_KEY` | Preference key controlling stack-trace sanitization.
    `static String` | `SHOW_LAST_RESULT_KEY` | Preference key controlling whether the last result is shown.
    `static String` | `VERBOSITY_KEY` | Preference key storing the selected verbosity level.
    `static Verbosity` | `verbosity` | Current shell verbosity preference.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static void` | `addChangeListener(PreferenceChangeListener listener)` Registers a listener for preference changes.
    `` | `public static void` | `clear()` Clears all stored shell preferences.
    `` | `public static String` | `get(String name, String defaultValue)` Returns a preference value with a fallback.
    `` | `public static String` | `get(String name)` Returns a preference value or `null` when absent.
    `` | `public static String` | `getEditor()` Returns the configured editor command.
    `` | `public static String` | `getParserFlavor()` Returns the configured parser flavor.
    `` | `public static boolean` | `getSanitizeStackTrace()` Returns whether stack traces should be sanitized before display.
    `` | `public static boolean` | `getShowLastResult()` Returns whether the shell should display the last evaluation result.
    `` | `public static String[]` | `keys()` Returns all stored preference keys.
    `` | `public static void` | `put(String name, String value)` Stores a preference value.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### public static final String EDITOR_KEY

      Preference key storing the preferred editor command.

    - #### public static final String PARSER_FLAVOR_KEY

      Preference key storing the parser flavor.

    - #### public static final String PARSER_RELAXED

      Parser flavor value selecting relaxed parsing.

    - #### public static final String PARSER_RIGID

      Parser flavor value selecting rigid parsing.

    - #### public static final String SANITIZE_STACK_TRACE_KEY

      Preference key controlling stack-trace sanitization.

    - #### public static final String SHOW_LAST_RESULT_KEY

      Preference key controlling whether the last result is shown.

    - #### public static final String VERBOSITY_KEY

      Preference key storing the selected verbosity level.

    - #### public static Verbosity verbosity

      Current shell verbosity preference.

  - ### Method Detail

    - #### public static void addChangeListener(PreferenceChangeListener listener)

      Registers a listener for preference changes.

      Parameters:
        `listener` - the listener to register

    - #### public static void clear()

      Clears all stored shell preferences.

      throws:
        BackingStoreException if the backing store cannot be updated

    - #### public static String get(String name, String defaultValue)

      Returns a preference value with a fallback.

      Parameters:
        `name` - the preference key
        `defaultValue` - the fallback value to return when the key is absent
      Returns:
        the stored or fallback value

    - #### public static String get(String name)

      Returns a preference value or `null` when absent.

      Parameters:
        `name` - the preference key
      Returns:
        the stored value, or `null` if absent

    - #### public static String getEditor()

      Returns the configured editor command.

      Returns:
        the configured editor command, or the `EDITOR` environment variable if none is stored

    - #### public static String getParserFlavor()

      Returns the configured parser flavor.

      Returns:
        the parser flavor name

    - #### public static boolean getSanitizeStackTrace()

      Returns whether stack traces should be sanitized before display.

      Returns:
        `true` if stack traces should be sanitized

    - #### public static boolean getShowLastResult()

      Returns whether the shell should display the last evaluation result.

      Returns:
        `true` if the last result should be shown

    - #### public static String[] keys()

      Returns all stored preference keys.

      throws:
        BackingStoreException if the backing store cannot be queried
      Returns:
        the stored preference keys

    - #### public static void put(String name, String value)

      Stores a preference value.

      Parameters:
        `name` - the preference key
        `value` - the value to store