Class Configuration
- java.lang.Object
-
- org.spdx.Configuration
-
public final class Configuration extends Object
The configuration class for the Spdx-Java-LibraryWhen a caller attempts to retrieve a configuration property, it will first be checked in the Java system properties (i.e. set via `-D` command line options to the JVM, or by programmatic calls to `System.setProperty()` in code), and will then fall back on a properties file in the classpath. That file must be called `/resources/spdx-java-library.properties`.
Please see the documentation for specifics on what configuration options Spdx-Java-Library supports, and how they impact the library's behavior.
- Author:
- Gary O'Neall
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConfigurationgetInstance()Retrieve the singleton instance of the Configuration classStringgetProperty(String propertyName)Retrieve the value of a configuration property by its nameStringgetProperty(String propertyName, String defaultValue)Retrieve the value of a configuration property by its name; return a default value if was not foundStringgetProperty(List<String> propertyNames, String defaultValue)Retrieve the value of the first found configuration property from a list of names; return a default value if none are found
-
-
-
Method Detail
-
getInstance
public static Configuration getInstance()
Retrieve the singleton instance of the Configuration class- Returns:
- The singleton instance of the Configuration class.
-
getProperty
public String getProperty(String propertyName)
Retrieve the value of a configuration property by its name- Parameters:
propertyName- The name of the configuration property to retrieve.- Returns:
- The value of the given property name, or null if it wasn't found.
-
getProperty
public String getProperty(String propertyName, String defaultValue)
Retrieve the value of a configuration property by its name; return a default value if was not found- Parameters:
propertyName- The name of the configuration property to retrieve.defaultValue- The default value to return, if the property isn't found.- Returns:
- The value of the given property name, or defaultValue if it wasn't found.
-
getProperty
public String getProperty(List<String> propertyNames, String defaultValue)
Retrieve the value of the first found configuration property from a list of names; return a default value if none are foundThis method checks each property name in the provided list in order. If a property name is not found, it moves on to the next one. If a property name is found, its value is returned. If none of the property names are found, the provided default value is returned.
- Parameters:
propertyNames- An ordered list of configuration property names to retrieve.defaultValue- The default value to return if none of the properties are found.- Returns:
- The value of the first found property name, or
defaultValueif none are found.
-
-