org.sonar.api.config
Class Settings
java.lang.Object
org.sonar.api.config.Settings
- All Implemented Interfaces:
- BatchComponent, ServerComponent
- Direct Known Subclasses:
- BatchSettings, ProjectSettings, ServerSettings
public class Settings
- extends Object
- implements BatchComponent, ServerComponent
Project Settings on batch side, Global Settings on server side. This component does not access to database, so
property changed via setter methods are not persisted.
This component replaces the deprecated org.apache.commons.configuration.Configuration
- Since:
- 2.12
Method Summary |
Settings |
addEnvironmentVariables()
|
Settings |
addProperties(Map<String,String> props)
|
Settings |
addProperties(Properties props)
|
Settings |
addSystemProperties()
|
Settings |
appendProperty(String key,
String value)
|
Settings |
clear()
|
static Settings |
createForComponent(Object component)
Create empty settings. |
boolean |
getBoolean(String key)
|
protected String |
getClearString(String key)
Does not decrypt value. |
Date |
getDate(String key)
|
Date |
getDateTime(String key)
|
String |
getDefaultValue(String key)
|
PropertyDefinitions |
getDefinitions()
|
Encryption |
getEncryption()
|
int |
getInt(String key)
|
List<String> |
getKeysStartingWith(String prefix)
|
long |
getLong(String key)
|
Map<String,String> |
getProperties()
|
String |
getString(String key)
|
String[] |
getStringArray(String key)
Value is splitted by comma and trimmed. |
String[] |
getStringArrayBySeparator(String key,
String separator)
Value is splitted and trimmed. |
boolean |
hasDefaultValue(String key)
|
boolean |
hasKey(String key)
|
Settings |
removeProperty(String key)
|
Settings |
setProperties(Map<String,String> props)
|
Settings |
setProperty(String key,
Boolean value)
|
Settings |
setProperty(String key,
Date date)
|
Settings |
setProperty(String key,
Date date,
boolean includeTime)
|
Settings |
setProperty(String key,
Double value)
|
Settings |
setProperty(String key,
Integer value)
|
Settings |
setProperty(String key,
Long value)
|
Settings |
setProperty(String key,
String value)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
properties
protected final Map<String,String> properties
definitions
protected final PropertyDefinitions definitions
Settings
public Settings()
Settings
public Settings(PropertyDefinitions definitions)
getEncryption
public final Encryption getEncryption()
getDefaultValue
public final String getDefaultValue(String key)
hasKey
public final boolean hasKey(String key)
hasDefaultValue
public final boolean hasDefaultValue(String key)
getString
public final String getString(String key)
getClearString
protected String getClearString(String key)
- Does not decrypt value.
getBoolean
public final boolean getBoolean(String key)
getInt
public final int getInt(String key)
getLong
public final long getLong(String key)
getDate
public final Date getDate(String key)
getDateTime
public final Date getDateTime(String key)
getStringArray
public final String[] getStringArray(String key)
- Value is splitted by comma and trimmed.
Examples :
- "one,two,three " -> ["one", "two", "three"]
- " one, two, three " -> ["one", "two", "three"]
- "one, , three" -> ["one", "", "three"]
getStringArrayBySeparator
public final String[] getStringArrayBySeparator(String key,
String separator)
- Value is splitted and trimmed.
getKeysStartingWith
public final List<String> getKeysStartingWith(String prefix)
appendProperty
public final Settings appendProperty(String key,
String value)
setProperty
public final Settings setProperty(String key,
@Nullable
String value)
setProperty
public final Settings setProperty(String key,
@Nullable
Boolean value)
setProperty
public final Settings setProperty(String key,
@Nullable
Integer value)
setProperty
public final Settings setProperty(String key,
@Nullable
Long value)
setProperty
public final Settings setProperty(String key,
@Nullable
Double value)
setProperty
public final Settings setProperty(String key,
@Nullable
Date date)
addProperties
public final Settings addProperties(Map<String,String> props)
addProperties
public final Settings addProperties(Properties props)
addSystemProperties
public final Settings addSystemProperties()
addEnvironmentVariables
public final Settings addEnvironmentVariables()
setProperties
public final Settings setProperties(Map<String,String> props)
setProperty
public final Settings setProperty(String key,
@Nullable
Date date,
boolean includeTime)
removeProperty
public final Settings removeProperty(String key)
clear
public final Settings clear()
getProperties
public final Map<String,String> getProperties()
- Returns:
- unmodifiable properties
getDefinitions
public final PropertyDefinitions getDefinitions()
createForComponent
public static Settings createForComponent(Object component)
- Create empty settings. Definition of available properties is loaded from the given annotated class.
This method is usually used by unit tests.
Copyright © 2009-2012 SonarSource. All Rights Reserved.