java.lang.Object
net.i2p.i2pcontrol.servlets.configuration.ConfigurationManager

public class ConfigurationManagerextends Object
Manage the configuration of I2PControl.
  • Field Details

    • CONFIG_FILE

      private final String CONFIG_FILE
      Name of the config file.
      See Also:
    • WEBAPP_CONFIG_FILE

      private final String WEBAPP_CONFIG_FILE
      Name of the webapp default config file.
      See Also:
    • configLocation

      private final File configLocation
      Where the config file is read and written.
    • _log

      private final Log _log
      Logger for this class.
    • _changed

      private boolean _changed
      True since settings changed without a save.
    • stringConfigurations

      private final Map<String,String> stringConfigurations
      Settings whose value is a string.
    • booleanConfigurations

      private final Map<String,Boolean> booleanConfigurations
      Settings whose value is a boolean.
    • integerConfigurations

      private final Map<String,Integer> integerConfigurations
      Settings whose value is an integer.
  • Constructor Details

    • ConfigurationManager

      public ConfigurationManager(I2PAppContext ctx, File dir, boolean isPlugin)
      Chooses the config filename for the plugin or webapp case, then reads it.
      Parameters:
      ctx - the application context supplying the log manager
      dir - the directory the configuration file is read from
      isPlugin - true to read I2PControl.conf, false to read i2pcontrol.config
  • Method Details

    • getConfFile

      public File getConfFile()
      Report the file this manager reads its key=value settings from and writes them back to.
      Returns:
      the conf file
    • readConfFile

      public void readConfFile()
      Reads configuration from file, every line is parsed as key=value.
    • writeConfFile

      public void writeConfFile()
      Write configuration into default config file. As of 0.12, doesn't actually write unless something changed.
    • parseConfigStr

      private void parseConfigStr(Properties input)
      Try to parse the input as 'key=value', where value will (in order) be parsed as integer/boolean/string.
      Parameters:
      input - the properties to parse, each value tried as an integer, then a boolean, then a string
    • getConf

      public boolean getConf(String settingName, boolean defaultValue)
      Check if a specific boolean configuration exists.
      Parameters:
      settingName - The key for the configuration.
      defaultValue - If the configuration is not found, we use a default value.
      Returns:
      The value of a configuration: true if found, defaultValue if not found.
    • getConf

      public int getConf(String settingName, int defaultValue)
      Check if a specific boolean configuration exists.
      Parameters:
      settingName - The key for the configuration.
      defaultValue - If the configuration is not found, we use a default value.
      Returns:
      The value of a configuration: true if found, defaultValue if not found.
    • getConf

      public String getConf(String settingName, String defaultValue)
      Get a specific String configuration.
      Parameters:
      settingName - The key for the configuration.
      defaultValue - If the configuration is not found, we use a default value.
      Returns:
      The value of the configuration, or the defaultValue.
    • setConf

      public void setConf(String settingName, int nbr)
      Set a specific int setting
      Parameters:
      settingName - the setting name
      nbr - the integer value to store for the setting
    • setConf

      public void setConf(String settingName, String str)
      Set a specific string setting
      Parameters:
      settingName - the setting name
      str - the string value to store for the setting
    • setConf

      public void setConf(String settingName, boolean bool)
      Set a specific boolean setting
      Parameters:
      settingName - the setting name
      bool - the boolean value to store for the setting