Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.owasp.dependencycheck.utils
Class Settings

    java.lang.Object
      org.owasp.dependencycheck.utils.Settings

    public final class Settings

extends Object

A simple settings container that wraps the dependencycheck.properties file.

Author:
  Jeremy Long (jeremy.long@owasp.org)

Nested Class Summary
`static class` | `Settings.KEYS` The collection of keys used within the properties file.

Method Summary
`static boolean` | `getBoolean(String key)` Returns a boolean value from the properties file.
`static File` | `getFile(String key)` Returns a value from the properties file as a File object.
`static int` | `getInt(String key)` Returns an int value from the properties file.
`static int` | `getInt(String key, int defaultValue)` Returns an int value from the properties file.
`static long` | `getLong(String key)` Returns a long value from the properties file.
`static String` | `getString(String key)` Returns a value from the properties file.
`static String` | `getString(String key, String defaultValue)` Returns a value from the properties file.
`static File` | `getTempDirectory()` Returns the temporary directory.
`static void` | `mergeProperties(File filePath)` Merges a new properties file into the current properties.
`static void` | `mergeProperties(InputStream stream)` Merges a new properties file into the current properties.
`static void` | `mergeProperties(String filePath)` Merges a new properties file into the current properties.
`static void` | `removeProperty(String key)` Removes a property from the local properties collection.
`static void` | `setBoolean(String key, boolean value)` Sets a property value.
`static void` | `setString(String key, String value)` Sets a property value.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### setString

    public static void setString(String key,
                                 String value)

  Sets a property value.

  Parameters:
    `key` - the key for the property
    `value` - the value for the property

### setBoolean

    public static void setBoolean(String key,
                                  boolean value)

  Sets a property value.

  Parameters:
    `key` - the key for the property
    `value` - the value for the property

### mergeProperties

    public static void mergeProperties(File filePath)
                                throws FileNotFoundException,
                                       IOException

  Merges a new properties file into the current properties. This method allows for the loading of a user provided properties file.
  Note: even if using this method - system properties will be loaded before properties loaded from files.

  Parameters:
    `filePath` - the path to the properties file to merge.
  Throws:
    `FileNotFoundException` - is thrown when the filePath points to a non-existent file
    `IOException` - is thrown when there is an exception loading/merging the properties

### mergeProperties

    public static void mergeProperties(String filePath)
                                throws FileNotFoundException,
                                       IOException

  Merges a new properties file into the current properties. This method allows for the loading of a user provided properties file.
  Note: even if using this method - system properties will be loaded before properties loaded from files.

  Parameters:
    `filePath` - the path to the properties file to merge.
  Throws:
    `FileNotFoundException` - is thrown when the filePath points to a non-existent file
    `IOException` - is thrown when there is an exception loading/merging the properties

### mergeProperties

    public static void mergeProperties(InputStream stream)
                                throws IOException

  Merges a new properties file into the current properties. This method allows for the loading of a user provided properties file.
  Note: even if using this method - system properties will be loaded before properties loaded from files.

  Parameters:
    `stream` - an Input Stream pointing at a properties file to merge
  Throws:
    `IOException` - is thrown when there is an exception loading/merging the properties

### getFile

    public static File getFile(String key)

  Returns a value from the properties file as a File object. If the value was specified as a system property or passed in via the -Dprop=value argument - this method will return the value from the system properties before the values in the contained configuration file. This method will also replace a leading "[JAR]\" sequence with the path to the folder containing the JAR file containing this class.

  Parameters:
    `key` - the key to lookup within the properties file
  Returns:
    the property from the properties file converted to a File object

### getString

    public static String getString(String key,
                                   String defaultValue)

  Returns a value from the properties file. If the value was specified as a system property or passed in via the -Dprop=value argument - this method will return the value from the system properties before the values in the contained configuration file.

  Parameters:
    `key` - the key to lookup within the properties file
    `defaultValue` - the default value for the requested property
  Returns:
    the property from the properties file

### getTempDirectory

    public static File getTempDirectory()

  Returns the temporary directory.

  Returns:
    the temporary directory

### getString

    public static String getString(String key)

  Returns a value from the properties file. If the value was specified as a system property or passed in via the -Dprop=value argument - this method will return the value from the system properties before the values in the contained configuration file.

  Parameters:
    `key` - the key to lookup within the properties file
  Returns:
    the property from the properties file

### removeProperty

    public static void removeProperty(String key)

  Removes a property from the local properties collection. This is mainly used in test cases.

  Parameters:
    `key` - the property key to remove

### getInt

    public static int getInt(String key)
                      throws InvalidSettingException

  Returns an int value from the properties file. If the value was specified as a system property or passed in via the -Dprop=value argument - this method will return the value from the system properties before the values in the contained configuration file.

  Parameters:
    `key` - the key to lookup within the properties file
  Returns:
    the property from the properties file
  Throws:
    `InvalidSettingException` - is thrown if there is an error retrieving the setting

### getInt

    public static int getInt(String key,
                             int defaultValue)

  Returns an int value from the properties file. If the value was specified as a system property or passed in via the -Dprop=value argument - this method will return the value from the system properties before the values in the contained configuration file.

  Parameters:
    `key` - the key to lookup within the properties file
    `defaultValue` - the default value to return
  Returns:
    the property from the properties file or the defaultValue if the property does not exist or cannot be converted to an integer

### getLong

    public static long getLong(String key)
                        throws InvalidSettingException

  Returns a long value from the properties file. If the value was specified as a system property or passed in via the -Dprop=value argument - this method will return the value from the system properties before the values in the contained configuration file.

  Parameters:
    `key` - the key to lookup within the properties file
  Returns:
    the property from the properties file
  Throws:
    `InvalidSettingException` - is thrown if there is an error retrieving the setting

### getBoolean

    public static boolean getBoolean(String key)
                              throws InvalidSettingException

  Returns a boolean value from the properties file. If the value was specified as a system property or passed in via the `-Dprop=value` argument this method will return the value from the system properties before the values in the contained configuration file.

  Parameters:
    `key` - the key to lookup within the properties file
  Returns:
    the property from the properties file
  Throws:
    `InvalidSettingException` - is thrown if there is an error retrieving the setting

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012-2013 OWASP. All Rights Reserved.