Class Prefs

java.lang.Object
VASSAL.preferences.Prefs
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
GlobalPrefs

public class Prefs extends Object implements Closeable
A set of preferences. Each set of preferences is identified by a name, and different sets may share a common editor, which is responsible for writing the preferences to disk.
See also:
GlobalOptions - main nexus for preferences being added
  • Field Details

  • Constructor Details

  • Method Details

    • getEditor

      public PrefsEditor getEditor()
    • getFile

      public File getFile()
    • isDisableAutoWrite

      public boolean isDisableAutoWrite()
      Returns:
      false -> overridden by GlobalPrefs
    • setDisableAutoWrite

      public void setDisableAutoWrite(boolean b)
      Parameters:
      b - - no action taken -> overridden by GlobalPrefs
    • addOption

      public void addOption(Configurer o)
    • addOption

      public void addOption(String category, Configurer o)
    • addOption

      public void addOption(String category, Configurer o, String prompt)
      Add a configurable property to the preferences in the given category
      Parameters:
      category - the tab under which to add the Configurer's controls in the editor window. If null, do not add controls.
      prompt - If non-null and the value was not read from the preferences file on initialization (i.e. first-time setup), prompt the user for an initial value
    • setValue

      public void setValue(String option, Object value)
    • getOption

      public Configurer getOption(String s)
    • getValue

      public Object getValue(String key)
      Parameters:
      key - Pref Key
      Returns:
      the value of the preferences setting stored under key
    • getStoredValue

      public String getStoredValue(String key)
      Return the value of a given preference.
      Parameters:
      key - the name of the preference to retrieve
      Returns:
      the value of this option read from the Preferences file at startup, or null if no value is undefined
    • read

      protected void read()
    • save

      public void save() throws IOException
      Store this set of preferences
      Throws:
      IOException
    • write

      @Deprecated(since="2021-02-15", forRemoval=true) public void write() throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Save these preferences and write to disk.
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • getGlobalPrefs

      public static Prefs getGlobalPrefs()
      A global set of preferences that exists independent of any individual module.
      Returns:
      the global Prefs object
    • initSharedGlobalPrefs

      public static void initSharedGlobalPrefs()
      Initialize visible Global Preferences that are shared between the Module Manager and the Editor/Player.
    • sanitize

      public static String sanitize(String str)