Interface WSOptionsStorage


@API(type=NOT_EXTENDABLE, src=PUBLIC) public interface WSOptionsStorage
Support for the user to save and retrieve custom options in the Oxygen common preferences.
  • Method Details

    • setOptionsDoctypePrefix

      @Deprecated void setOptionsDoctypePrefix(String optionsDoctypePrefix)
      Deprecated.

      WARNING: THE USE OF THIS METHOD IS DISCOURAGED AND DEPRECATED

      All plugins initially share a common settings namespace. So that would mean that a plugin could read values set by other plugins or it could register to receive value changed events for certain option keys set by other plugins (which may sometimes be useful). But this also means that accidentally a plugin could also overwrite the value for a certain key if more than one plugin use the same key. So ideally your plugin's persisted keys would all be manually prefixed with some unique ID when they are defined. This would be the recommended way of doing things. If you still want to use the method:

      Using this method when working with the singleton access to the workspace "PluginWorkspaceProvider.getPluginWorkspace().getOptionsStorage()" will set it for all plugins. So a plugin will globally influence the global prefixes for keys loaded and saved also by other plugins. Which is never a good thing.

      But using this method on the WorkspaceAccessPluginExtension.applicationStarted will only set the prefix for your plugin. So as long as your plugin will keep using the "WSOptionsStorage" received on the applicationStarted callback you will not influence other plugins.

      Sets the options doctype prefix which is used to prefix options like a namespace.
      Parameters:
      optionsDoctypePrefix - The document type prefix used to build the options keys. This should not be null.
    • addOptionListener

      void addOptionListener(WSOptionListener listener)
      Adds an OptionListener to the current set of options. The listener is notified when the value of its associated option changes.
      Parameters:
      listener - The OptionListener to be added.
    • removeOptionListener

      void removeOptionListener(WSOptionListener listener)
      Removes an option listener from the current set of option listeners.
      Parameters:
      listener - The OptionListener to be removed.
    • getOption

      String getOption(String key, String defaultValue)
      Provides the value of the option associated with the specified key.
      Parameters:
      key - The key that uniquely identifies an option.
      defaultValue - The default value for the specified option.
      Returns:
      The value of the specified option or the default value if the option has not been set yet.
    • setOption

      void setOption(String key, String value)
      Modifies the value of an option. If the supplied value is null The option will be removed from storage.
      Parameters:
      key - The key of the option whose value is to be modified.
      value - The new value of the option. If null the option will be removed from the storage.
    • getSecretOption

      String getSecretOption(String key, String defaultValue)
      Provides the value of the option associated with the specified key.
      Parameters:
      key - The key that uniquely identifies an option.
      defaultValue - The default value for the specified option.
      Returns:
      The value of the specified option or the default value if the option has not been set yet.
      Since:
      27.1
    • setSecretOption

      void setSecretOption(String key, String value)
      Modifies the value of an option. If the supplied value is null The option will be removed from storage.
      Parameters:
      key - The key of the option whose value is to be modified.
      value - The new value of the option. If null the option will be removed from the storage.
      Since:
      27.1
    • setPersistentObjectOption

      void setPersistentObjectOption(String key, ExternalPersistentObject persistentObject)
      Set a persistent object.
      Parameters:
      key - The key.
      persistentObject - The persistent object.
      Since:
      22
    • getPersistentObjectOption

      ExternalPersistentObject getPersistentObjectOption(String key, ExternalPersistentObject defaultValue)
      Get a persistent object.
      Parameters:
      key - The key.
      defaultValue - Default value
      Returns:
      The external persistent object or the default provided value.
      Since:
      22
    • getStringArrayOption

      String[] getStringArrayOption(String key, String[] defaultValues)
      Provides the values set for the option identified by the given key.
      Parameters:
      key - The key that uniquely identifies the option.
      defaultValues - The default values for the specified option.
      Returns:
      the values set for the option identified by the given key or the default values if other values have not been set yet.
    • setStringArrayOption

      void setStringArrayOption(String key, String[] values)
      Modifies the values set for the option identified by the given key. If the provided value is null, the option will be removed from storage.
      Parameters:
      key - The key that uniquely identifies the option.
      values - The new values to set. If null, the option will be removed from the storage.