org.sonar.api.config
Class Settings

java.lang.Object
  extended by 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.

Replace the deprecated component org.apache.commons.configuration.Configuration

Since:
2.12

Field Summary
protected  PropertyDefinitions definitions
           
protected  Map<String,String> properties
           
 
Constructor Summary
Settings()
           
Settings(PropertyDefinitions definitions)
           
 
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)
           
 Date getDate(String key)
           
 Date getDateTime(String key)
           
 String getDefaultValue(String key)
           
 PropertyDefinitions getDefinitions()
           
 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
 

Field Detail

properties

protected Map<String,String> properties

definitions

protected PropertyDefinitions definitions
Constructor Detail

Settings

public Settings()

Settings

public Settings(PropertyDefinitions definitions)
Method Detail

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)

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 :


getStringArrayBySeparator

public final String[] getStringArrayBySeparator(String key,
                                                String separator)
Value is splitted and trimmed.


getKeysStartingWith

public List<String> getKeysStartingWith(String prefix)

appendProperty

public final Settings appendProperty(String key,
                                     String value)

setProperty

public final Settings setProperty(String key,
                                  String value)

setProperty

public final Settings setProperty(String key,
                                  Boolean value)

setProperty

public final Settings setProperty(String key,
                                  Integer value)

setProperty

public final Settings setProperty(String key,
                                  Long value)

setProperty

public final Settings setProperty(String key,
                                  Double value)

setProperty

public final Settings setProperty(String key,
                                  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,
                                  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.