Package org.sonar.api.config
Class Settings
- java.lang.Object
-
- org.sonar.api.config.Settings
-
- Direct Known Subclasses:
MapSettings
@ServerSide @ComputeEngineSide @ScannerSide @SonarLintSide @Deprecated public abstract class Settings extends java.lang.Object
Deprecated.since 6.5 useConfiguration
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Settings(PropertyDefinitions definitions, Encryption encryption)
Deprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Settings
addProperties(java.util.Map<java.lang.String,java.lang.String> props)
Deprecated.Settings
addProperties(java.util.Properties props)
Deprecated.Settings
appendProperty(java.lang.String key, java.lang.String value)
Deprecated.protected abstract java.util.Optional<java.lang.String>
get(java.lang.String key)
Deprecated.boolean
getBoolean(java.lang.String key)
Deprecated.Effective value as boolean.java.util.Date
getDate(java.lang.String key)
Deprecated.Effective value asDate
, without time fields.java.util.Date
getDateTime(java.lang.String key)
Deprecated.Effective value asDate
, with time fields.java.lang.String
getDefaultValue(java.lang.String key)
Deprecated.java.util.Optional<PropertyDefinition>
getDefinition(java.lang.String key)
Deprecated.The definition related to the specified property.PropertyDefinitions
getDefinitions()
Deprecated.All the property definitions declared by core and plugins.java.lang.Double
getDouble(java.lang.String key)
Deprecated.Effective value asDouble
.Encryption
getEncryption()
Deprecated.java.lang.Float
getFloat(java.lang.String key)
Deprecated.Effective value asFloat
.int
getInt(java.lang.String key)
Deprecated.Effective value asint
.java.util.List<java.lang.String>
getKeysStartingWith(java.lang.String prefix)
Deprecated.long
getLong(java.lang.String key)
Deprecated.Effective value aslong
.abstract java.util.Map<java.lang.String,java.lang.String>
getProperties()
Deprecated.Immutable map of the properties that have non-default values.java.util.Optional<java.lang.String>
getRawString(java.lang.String key)
Deprecated.The value that overrides the default value.java.lang.String
getString(java.lang.String key)
Deprecated.The effective value of the specified property.java.lang.String[]
getStringArray(java.lang.String key)
Deprecated.Value is split by comma and trimmed.java.lang.String[]
getStringArrayBySeparator(java.lang.String key, java.lang.String separator)
Deprecated.Value is split and trimmed.java.lang.String[]
getStringLines(java.lang.String key)
Deprecated.Value is split by carriage returns.boolean
hasDefaultValue(java.lang.String key)
Deprecated.boolean
hasKey(java.lang.String key)
Deprecated.protected abstract void
remove(java.lang.String key)
Deprecated.Settings
removeProperty(java.lang.String key)
Deprecated.protected abstract void
set(java.lang.String key, java.lang.String value)
Deprecated.Add the settings with the specified key and value, both are trimmed and neither can be null.Settings
setProperty(java.lang.String key, java.lang.Boolean value)
Deprecated.Settings
setProperty(java.lang.String key, java.lang.Double value)
Deprecated.Settings
setProperty(java.lang.String key, java.lang.Float value)
Deprecated.Settings
setProperty(java.lang.String key, java.lang.Integer value)
Deprecated.Settings
setProperty(java.lang.String key, java.lang.Long value)
Deprecated.Settings
setProperty(java.lang.String key, java.lang.String value)
Deprecated.Change a property value in a restricted scope only, depending on execution context.Settings
setProperty(java.lang.String key, java.lang.String[] values)
Deprecated.Settings
setProperty(java.lang.String key, java.util.Date date)
Deprecated.Settings
setProperty(java.lang.String key, java.util.Date date, boolean includeTime)
Deprecated.
-
-
-
Constructor Detail
-
Settings
protected Settings(PropertyDefinitions definitions, Encryption encryption)
Deprecated.
-
-
Method Detail
-
get
protected abstract java.util.Optional<java.lang.String> get(java.lang.String key)
Deprecated.
-
set
protected abstract void set(java.lang.String key, java.lang.String value)
Deprecated.Add the settings with the specified key and value, both are trimmed and neither can be null.- Throws:
java.lang.NullPointerException
- ifkey
and/orvalue
isnull
.
-
remove
protected abstract void remove(java.lang.String key)
Deprecated.
-
getProperties
public abstract java.util.Map<java.lang.String,java.lang.String> getProperties()
Deprecated.Immutable map of the properties that have non-default values. The default values defined byPropertyDefinitions
are 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
public Encryption getEncryption()
Deprecated.
-
getRawString
public java.util.Optional<java.lang.String> getRawString(java.lang.String key)
Deprecated.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 PropertyDefinitions getDefinitions()
Deprecated.All the property definitions declared by core and plugins.
-
getDefinition
public java.util.Optional<PropertyDefinition> getDefinition(java.lang.String key)
Deprecated.The definition related to the specified property. It may be empty.- Since:
- 6.1
-
hasKey
public boolean hasKey(java.lang.String key)
Deprecated.- Returns:
true
if the property has a non-default value, elsefalse
.
-
getDefaultValue
@CheckForNull public java.lang.String getDefaultValue(java.lang.String key)
Deprecated.
-
hasDefaultValue
public boolean hasDefaultValue(java.lang.String key)
Deprecated.
-
getString
@CheckForNull public java.lang.String getString(java.lang.String key)
Deprecated.The effective value of the specified property. Can returnnull
if 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.
- Throws:
java.lang.IllegalStateException
- if value is encrypted but fails to be decrypted.
-
getBoolean
public boolean getBoolean(java.lang.String key)
Deprecated.Effective value as boolean. It isfalse
ifgetString(String)
does not return"true"
, even if it's not a boolean representation.- Returns:
true
if the effective value is"true"
, elsefalse
.
-
getInt
public int getInt(java.lang.String key)
Deprecated.Effective value asint
.- Returns:
- the value as
int
. If the property does not have value nor default value, then0
is returned. - Throws:
java.lang.NumberFormatException
- if value is not empty and is not a parsable integer
-
getLong
public long getLong(java.lang.String key)
Deprecated.Effective value aslong
.- Returns:
- the value as
long
. If the property does not have value nor default value, then0L
is returned. - Throws:
java.lang.NumberFormatException
- if value is not empty and is not a parsablelong
-
getDate
@CheckForNull public java.util.Date getDate(java.lang.String key)
Deprecated.Effective value asDate
, without time fields. Format isDateUtils.DATE_FORMAT
.- Returns:
- the value as a
Date
. If the property does not have value nor default value, thennull
is returned. - Throws:
java.lang.RuntimeException
- if value is not empty and is not in accordance withDateUtils.DATE_FORMAT
.
-
getDateTime
@CheckForNull public java.util.Date getDateTime(java.lang.String key)
Deprecated.Effective value asDate
, with time fields. Format isDateUtils.DATETIME_FORMAT
.- Returns:
- the value as a
Date
. If the property does not have value nor default value, thennull
is returned. - Throws:
java.lang.RuntimeException
- if value is not empty and is not in accordance withDateUtils.DATETIME_FORMAT
.
-
getFloat
@CheckForNull public java.lang.Float getFloat(java.lang.String key)
Deprecated.Effective value asFloat
.- Returns:
- the value as
Float
. If the property does not have value nor default value, thennull
is returned. - Throws:
java.lang.NumberFormatException
- if value is not empty and is not a parsable number
-
getDouble
@CheckForNull public java.lang.Double getDouble(java.lang.String key)
Deprecated.Effective value asDouble
.- Returns:
- the value as
Double
. If the property does not have value nor default value, thennull
is returned. - Throws:
java.lang.NumberFormatException
- if value is not empty and is not a parsable number
-
getStringArray
public java.lang.String[] getStringArray(java.lang.String key)
Deprecated.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"]
-
getStringLines
public java.lang.String[] getStringLines(java.lang.String key)
Deprecated.Value is split by carriage returns.- Returns:
- non-null array of lines. The line termination characters are excluded.
- Since:
- 3.2
-
getStringArrayBySeparator
public java.lang.String[] getStringArrayBySeparator(java.lang.String key, java.lang.String separator)
Deprecated.Value is split and trimmed.
-
appendProperty
public Settings appendProperty(java.lang.String key, @Nullable java.lang.String value)
Deprecated.
-
setProperty
public Settings setProperty(java.lang.String key, @Nullable java.lang.String[] values)
Deprecated.
-
setProperty
public Settings setProperty(java.lang.String key, @Nullable java.lang.String value)
Deprecated.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
value
isnull
-
setProperty
public Settings setProperty(java.lang.String key, @Nullable java.lang.Boolean value)
Deprecated.- See Also:
setProperty(String, String)
-
setProperty
public Settings setProperty(java.lang.String key, @Nullable java.lang.Integer value)
Deprecated.- See Also:
setProperty(String, String)
-
setProperty
public Settings setProperty(java.lang.String key, @Nullable java.lang.Long value)
Deprecated.- See Also:
setProperty(String, String)
-
setProperty
public Settings setProperty(java.lang.String key, @Nullable java.lang.Double value)
Deprecated.- See Also:
setProperty(String, String)
-
setProperty
public Settings setProperty(java.lang.String key, @Nullable java.lang.Float value)
Deprecated.- See Also:
setProperty(String, String)
-
setProperty
public Settings setProperty(java.lang.String key, @Nullable java.util.Date date)
Deprecated.- See Also:
setProperty(String, String)
-
addProperties
public Settings addProperties(java.util.Map<java.lang.String,java.lang.String> props)
Deprecated.
-
addProperties
public Settings addProperties(java.util.Properties props)
Deprecated.
-
setProperty
public Settings setProperty(java.lang.String key, @Nullable java.util.Date date, boolean includeTime)
Deprecated.- See Also:
setProperty(String, String)
-
removeProperty
public Settings removeProperty(java.lang.String key)
Deprecated.
-
getKeysStartingWith
public java.util.List<java.lang.String> getKeysStartingWith(java.lang.String prefix)
Deprecated.
-
-