java.lang.Object
i2p.susi.util.Config

public class Configextends Object
Static configuration manager. Warning: Not suitable for multiple applications or prefixes.
  • Field Details

    • properties

      private static Properties properties
      Defaults shipped with the webmail.
    • config

      private static Properties config
      Values the user has set.
    • configPrefix

      private static String configPrefix
      Prefix naming this component's properties.
  • Constructor Details

    • Config

      public Config()
      Creates an empty config.
  • Method Details

    • getProperty

      public static String getProperty(String name)
      Get a property by name, checking system properties first, then the config file, then the default properties.
      Parameters:
      name - the property name (prefix will be added if set)
      Returns:
      the property value, or null if not found
    • hasConfigFile

      public static boolean hasConfigFile()
      Don't bother showing a reload config button if this returns false.
      Returns:
      true if the config file exists
    • reloadConfiguration

      public static void reloadConfiguration()
      Reload the configuration from the properties resource and the susimail.config file in the config directory.
    • getProperties

      public static Properties getProperties()
      Returns the properties, sorted, WITHOUT the prefix.
      Returns:
      the sorted properties, with the config prefix stripped
    • saveConfiguration

      public static void saveConfiguration(Properties newProps) throws IOException
      Saves the properties. A property not in newProps will be removed but will not override the default in the resource.
      Parameters:
      newProps - non-null WITHOUT the prefix
      Throws:
      IOException - if the save fails
    • getProperty

      public static String getProperty(String name, String defaultValue)
      Get a property by name with a default value.
      Parameters:
      name - the property name
      defaultValue - the value to return if the property is not found
      Returns:
      the property value, or defaultValue if not found
    • getProperty

      public static int getProperty(String name, int defaultValue)
      Get a property as an integer with a default value.
      Parameters:
      name - the property name
      defaultValue - the value to return if the property is not found or not a valid integer
      Returns:
      the property value as an integer, or defaultValue
    • setPrefix

      public static void setPrefix(String prefix)
      Set the configuration key prefix. All property lookups will be prefixed with this string followed by a dot (if not already present). Static! Not for use by multiple applications!
      Parameters:
      prefix - the prefix to prepend to property names