Class Preferences

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

public class Preferences extends Object
Container for shell preferences.
  • 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:
    • SHOW_LAST_RESULT_KEY

      public static final String SHOW_LAST_RESULT_KEY
      Preference key controlling whether the last result is shown.
      See Also:
    • SANITIZE_STACK_TRACE_KEY

      public static final String SANITIZE_STACK_TRACE_KEY
      Preference key controlling stack-trace sanitization.
      See Also:
    • EDITOR_KEY

      public static final String EDITOR_KEY
      Preference key storing the preferred editor command.
      See Also:
    • PARSER_FLAVOR_KEY

      public static final String PARSER_FLAVOR_KEY
      Preference key storing the parser flavor.
      See Also:
    • PARSER_RIGID

      public static final String PARSER_RIGID
      Parser flavor value selecting rigid parsing.
      See Also:
    • PARSER_RELAXED

      public static final String PARSER_RELAXED
      Parser flavor value selecting relaxed parsing.
      See Also:
  • 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