Interface Settings


public interface Settings
A collection of settings and the operations on them. There are two levels of settings:
  • Application settings, returned by App.getSettings(): global settings, the defaults for new comparisons, and the page and printer settings used for printing.
  • Comparison settings, returned by HistoryEntry.getSettings(): the settings of a single comparison, which start as a copy of the application defaults.

Settings are identified by the keys of the com.deltopia.io.SettingKey enum, loaded with Java.type():


 const Comparison = Java.type('com.deltawalker.script.Comparison');
 const SettingKey = Java.type('com.deltopia.io.SettingKey');

 const settings = comp.getSettings();
 settings.set(SettingKey.D_COMP_METHOD, [
     Comparison.Method.SIZE,
     Comparison.Method.DATE_MODIFIED
 ]);
 await comp.compare();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the Filters for comparisons of the specified Comparison.Type.
    get(com.deltopia.io.SettingKey key)
    Returns the current value of the setting with the specified key.
    Returns the PageSettings used for printing, such as the page orientation, margins, header and footer.
    Returns the PrinterSettings used for printing, such as the printer, number of copies and page range.
    void
    load(String path)
    Imports all settings - application settings, defaults for new comparisons, and the settings of the comparisons stored in the file - from a file previously written by save(String).
    void
    save(String path)
    Exports all settings - application settings, defaults for new comparisons, and the settings of all existing comparisons - to a file.
    void
    set(com.deltopia.io.SettingKey key, Object value)
    Sets the setting with the specified key to the specified value.
  • Method Details

    • filters

      Filters filters(Comparison.Type type)
      Returns the Filters for comparisons of the specified Comparison.Type. On the settings of a comparison, returns the filters of that comparison. On the application settings, returns the default filters used for new comparisons of that type.

      Only folder and text comparisons use filters.

      
       const filters = comp.getSettings().filters(Comparison.Type.FOLDER);
       
      Parameters:
      type - the type of comparison whose filters to return. Ignored, and can be null, on the settings of a comparison; cannot be null on the application settings.
      Returns:
      the Filters for the specified Comparison.Type
      Throws:
      NullPointerException - if type is null and this is the application settings object
      Since:
      2.0
    • get

      Object get(com.deltopia.io.SettingKey key)
      Returns the current value of the setting with the specified key. Only settings whose value is a boolean or a number can be read; the value is returned as a JavaScript boolean or number.
      
       const followLinks = App.getSettings().get(SettingKey.C_FOLLOW_SYMLINKS);
       
      Parameters:
      key - the key of the setting to read
      Returns:
      the value of the setting
      Throws:
      NullPointerException - if key is null
      IllegalArgumentException - if the value of the setting is neither a boolean nor a number
      Since:
      2.0
    • getPage

      Returns the PageSettings used for printing, such as the page orientation, margins, header and footer.

      Page settings are application-level settings: call getPage() on App.getSettings(), not on the settings of a comparison.

      Returns:
      the application's PageSettings
      Throws:
      UnsupportedOperationException - if called on the settings of a comparison
      Since:
      2.0
    • getPrinter

      Returns the PrinterSettings used for printing, such as the printer, number of copies and page range.

      Printer settings are application-level settings: call getPrinter() on App.getSettings(), not on the settings of a comparison.

      Returns:
      the application's PrinterSettings
      Throws:
      UnsupportedOperationException - if called on the settings of a comparison
      Since:
      2.0
    • load

      void load(String path) throws FileNotFoundException, IOException
      Imports all settings - application settings, defaults for new comparisons, and the settings of the comparisons stored in the file - from a file previously written by save(String).
      Parameters:
      path - the full path of a DeltaWalker settings file; cannot be null
      Throws:
      FileNotFoundException - declared for compatibility
      IOException - declared for compatibility
      NullPointerException - if path is null
      Since:
      2.0
    • save

      void save(String path) throws IOException
      Exports all settings - application settings, defaults for new comparisons, and the settings of all existing comparisons - to a file.
      Parameters:
      path - the full path of the file to write; cannot be null or empty
      Throws:
      IOException - if the file cannot be written
      NullPointerException - if path is null
      IllegalArgumentException - if path is an empty string
      Since:
      2.0
    • set

      void set(com.deltopia.io.SettingKey key, Object value)
      Sets the setting with the specified key to the specified value. The value must match the type of the setting: a boolean, a number or a string. SettingKey.D_COMP_METHOD takes a Comparison.Method or an array of them.

      Setting a value does not start a comparison or a re-comparison; the new value is used the next time the comparison runs.

      
       comp.getSettings().set(SettingKey.D_COMP_METHOD, Comparison.Method.AS_TEXT);
       
      Parameters:
      key - the key of the setting to set; cannot be null
      value - the new value; cannot be null or empty
      Throws:
      NullPointerException - if key or value is null
      IllegalArgumentException - if value is empty, does not match the type of the setting, or is a number out of range for it
      Since:
      2.0