Package org.sonar.api.config.internal
Class Settings
java.lang.Object
org.sonar.api.config.Settings
org.sonar.api.config.internal.Settings
- Direct Known Subclasses:
MapSettings
public abstract class Settings
extends org.sonar.api.config.Settings
Implementation of the deprecated Settings interface
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSettings(org.sonar.api.config.PropertyDefinitions definitions, Encryption encryption) -
Method Summary
Modifier and TypeMethodDescriptionaddProperties(Map<String, String> props) addProperties(Properties props) appendProperty(String key, String value) booleangetBoolean(String key) Effective value as boolean.Effective value asDate, without time fields.getDateTime(String key) Effective value asDate, with time fields.getDefaultValue(String key) Optional<org.sonar.api.config.PropertyDefinition>getDefinition(String key) The definition related to the specified property.org.sonar.api.config.PropertyDefinitionsAll the property definitions declared by core and plugins.Effective value asDouble.Effective value asFloat.intEffective value asint.getKeysStartingWith(String prefix) longEffective value aslong.Immutable map of the properties that have non-default values.getRawString(String key) The value that overrides the default value.The effective value of the specified property.String[]getStringArray(String key) Value is split by comma and trimmed.String[]getStringArrayBySeparator(String key, String separator) Value is split and trimmed.String[]getStringLines(String key) Value is split by carriage returns.booleanhasDefaultValue(String key) booleanprotected abstract voidremoveProperty(String key) protected abstract voidAdd the settings with the specified key and value, both are trimmed and neither can be null.setProperty(String key, Boolean value) setProperty(String key, Double value) setProperty(String key, Float value) setProperty(String key, Integer value) setProperty(String key, Long value) setProperty(String key, String value) Change a property value in a restricted scope only, depending on execution context.setProperty(String key, String[] values) setProperty(String key, Date date) setProperty(String key, Date date, boolean includeTime)
-
Constructor Details
-
Settings
-
-
Method Details
-
get
-
set
Add the settings with the specified key and value, both are trimmed and neither can be null.- Throws:
NullPointerException- ifkeyand/orvalueisnull.
-
remove
-
getProperties
Immutable map of the properties that have non-default values. The default values defined byPropertyDefinitionsare ignored, so the returned values are not the effective values. Basically only the non-empty results ofgetRawString(String)are returned.Values are not decrypted if they are encrypted with a secret key.
-
getEncryption
-
getRawString
The value that overrides the default value. It may be encrypted with a secret key. UsegetString(String)to get the effective and decrypted value.- Since:
- 6.1
-
getDefinitions
public org.sonar.api.config.PropertyDefinitions getDefinitions()All the property definitions declared by core and plugins. -
getDefinition
The definition related to the specified property. It may be empty.- Since:
- 6.1
-
hasKey
- Specified by:
hasKeyin classorg.sonar.api.config.Settings- Returns:
trueif the property has a non-default value, elsefalse.
-
getDefaultValue
-
hasDefaultValue
-
getString
The effective value of the specified property. Can returnnullif the property is not set and has no defined default value.If the property is encrypted with a secret key, then the returned value is decrypted.
- Specified by:
getStringin classorg.sonar.api.config.Settings- Throws:
IllegalStateException- if value is encrypted but fails to be decrypted.
-
getBoolean
Effective value as boolean. It isfalseifgetString(String)does not return"true", even if it's not a boolean representation.- Specified by:
getBooleanin classorg.sonar.api.config.Settings- Returns:
trueif the effective value is"true", elsefalse.
-
getInt
Effective value asint.- Specified by:
getIntin classorg.sonar.api.config.Settings- Returns:
- the value as
int. If the property does not have value nor default value, then0is returned. - Throws:
NumberFormatException- if value is not empty and is not a parsable integer
-
getLong
Effective value aslong.- Specified by:
getLongin classorg.sonar.api.config.Settings- Returns:
- the value as
long. If the property does not have value nor default value, then0Lis returned. - Throws:
NumberFormatException- if value is not empty and is not a parsablelong
-
getDate
Effective value asDate, without time fields. Format isDateUtils.DATE_FORMAT.- Specified by:
getDatein classorg.sonar.api.config.Settings- Returns:
- the value as a
Date. If the property does not have value nor default value, thennullis returned. - Throws:
RuntimeException- if value is not empty and is not in accordance withDateUtils.DATE_FORMAT.
-
getDateTime
Effective value asDate, with time fields. Format isDateUtils.DATETIME_FORMAT.- Specified by:
getDateTimein classorg.sonar.api.config.Settings- Returns:
- the value as a
Date. If the property does not have value nor default value, thennullis returned. - Throws:
RuntimeException- if value is not empty and is not in accordance withDateUtils.DATETIME_FORMAT.
-
getFloat
Effective value asFloat.- Specified by:
getFloatin classorg.sonar.api.config.Settings- Returns:
- the value as
Float. If the property does not have value nor default value, thennullis returned. - Throws:
NumberFormatException- if value is not empty and is not a parsable number
-
getDouble
Effective value asDouble.- Specified by:
getDoublein classorg.sonar.api.config.Settings- Returns:
- the value as
Double. If the property does not have value nor default value, thennullis returned. - Throws:
NumberFormatException- if value is not empty and is not a parsable number
-
getStringArray
Value is split by comma and trimmed. Never returns null.
Examples :- "one,two,three " -> ["one", "two", "three"]
- " one, two, three " -> ["one", "two", "three"]
- "one, , three" -> ["one", "", "three"]
- Specified by:
getStringArrayin classorg.sonar.api.config.Settings
-
getStringLines
Value is split by carriage returns.- Specified by:
getStringLinesin classorg.sonar.api.config.Settings- Returns:
- non-null array of lines. The line termination characters are excluded.
- Since:
- 3.2
-
getStringArrayBySeparator
Value is split and trimmed.- Specified by:
getStringArrayBySeparatorin classorg.sonar.api.config.Settings
-
appendProperty
-
setProperty
-
setProperty
Change a property value in a restricted scope only, depending on execution context. New value is never persisted. New value is ephemeral and kept in memory only:- during current analysis in the case of scanner stack
- during processing of current HTTP request in the case of web server stack
- during execution of current task in the case of Compute Engine stack
valueisnull -
setProperty
- See Also:
-
setProperty
- See Also:
-
setProperty
- See Also:
-
setProperty
- See Also:
-
setProperty
- See Also:
-
setProperty
- See Also:
-
addProperties
-
addProperties
-
setProperty
- See Also:
-
removeProperty
-
getKeysStartingWith
- Specified by:
getKeysStartingWithin classorg.sonar.api.config.Settings
-