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

# Class Preferences

java.lang.Object
org.codehaus.groovy.tools.shell.util.Preferences

public class Preferences extends Object
Container for shell preferences.

- ## Field Summary

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

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Preferences()`

- ## Method Summary

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

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### verbosity

    public static IO.Verbosity verbosity
    Current shell verbosity preference.

  - ### VERBOSITY_KEY

    public static final String VERBOSITY_KEY
    Preference key storing the selected verbosity level.
    See Also:
      - Constant Field Values

  - ### SHOW_LAST_RESULT_KEY

    public static final String SHOW_LAST_RESULT_KEY
    Preference key controlling whether the last result is shown.
    See Also:
      - Constant Field Values

  - ### SANITIZE_STACK_TRACE_KEY

    public static final String SANITIZE_STACK_TRACE_KEY
    Preference key controlling stack-trace sanitization.
    See Also:
      - Constant Field Values

  - ### EDITOR_KEY

    public static final String EDITOR_KEY
    Preference key storing the preferred editor command.
    See Also:
      - Constant Field Values

  - ### PARSER_FLAVOR_KEY

    public static final String PARSER_FLAVOR_KEY
    Preference key storing the parser flavor.
    See Also:
      - Constant Field Values

  - ### PARSER_RIGID

    public static final String PARSER_RIGID
    Parser flavor value selecting rigid parsing.
    See Also:
      - Constant Field Values

  - ### PARSER_RELAXED

    public static final String PARSER_RELAXED
    Parser flavor value selecting relaxed parsing.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### Preferences

    public Preferences()

- ## Method Details

  - ### getShowLastResult

    public static boolean getShowLastResult()
    Returns whether the shell should display the last evaluation result.
    Returns:
      `true` if the last result should be shown

  - ### getSanitizeStackTrace

    public static boolean getSanitizeStackTrace()
    Returns whether stack traces should be sanitized before display.
    Returns:
      `true` if stack traces should be sanitized

  - ### getEditor

    public static String getEditor()
    Returns the configured editor command.
    Returns:
      the configured editor command, or the `EDITOR` environment variable if none is stored

  - ### getParserFlavor

    public static String getParserFlavor()
    Returns the configured parser flavor.
    Returns:
      the parser flavor name

  - ### keys

    public static String[] keys() throws BackingStoreException
    Returns all stored preference keys.
    Returns:
      the stored preference keys
    Throws:
      `BackingStoreException` - if the backing store cannot be queried

  - ### get

    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

  - ### get

    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

  - ### put

    public static void put(String name, String value)
    Stores a preference value.
    Parameters:
      `name` - the preference key
      `value` - the value to store

  - ### clear

    public static void clear() throws BackingStoreException
    Clears all stored shell preferences.
    Throws:
      `BackingStoreException` - if the backing store cannot be updated

  - ### addChangeListener

    public static void addChangeListener(PreferenceChangeListener listener)
    Registers a listener for preference changes.
    Parameters:
      `listener` - the listener to register