org.elasticsearch.common.settings
Interface Settings

All Known Implementing Classes:
ImmutableSettings

public interface Settings

Immutable settings allowing to control the configuration.

Using ImmutableSettings.settingsBuilder() in order to create a builder which in turn can create an immutable implementation of settings.

See Also:
ImmutableSettings

Nested Class Summary
static interface Settings.Builder
          A settings builder interface.
 
Method Summary
 String get(String setting)
          Returns the setting value associated with the setting key.
 String get(String setting, String defaultValue)
          Returns the setting value associated with the setting key.
 String[] getAsArray(String settingPrefix)
          The values associated with a setting prefix as an array.
 String[] getAsArray(String settingPrefix, String[] defaultArray)
          The values associated with a setting prefix as an array.
 Boolean getAsBoolean(String setting, Boolean defaultValue)
          Returns the setting value (as boolean) associated with the setting key.
 ByteSizeValue getAsBytesSize(String setting, ByteSizeValue defaultValue)
          Returns the setting value (as size) associated with the setting key.
<T> Class<? extends T>
getAsClass(String setting, Class<? extends T> defaultClazz)
          Returns the setting value (as a class) associated with the setting key.
<T> Class<? extends T>
getAsClass(String setting, Class<? extends T> defaultClazz, String prefixPackage, String suffixClassName)
          Returns the setting value (as a class) associated with the setting key.
 Double getAsDouble(String setting, Double defaultValue)
          Returns the setting value (as double) associated with the setting key.
 Float getAsFloat(String setting, Float defaultValue)
          Returns the setting value (as float) associated with the setting key.
 Integer getAsInt(String setting, Integer defaultValue)
          Returns the setting value (as int) associated with the setting key.
 Long getAsLong(String setting, Long defaultValue)
          Returns the setting value (as long) associated with the setting key.
 com.google.common.collect.ImmutableMap<String,String> getAsMap()
          The settings as a Map.
 SizeValue getAsSize(String setting, SizeValue defaultValue)
          Returns the setting value (as size) associated with the setting key.
 TimeValue getAsTime(String setting, TimeValue defaultValue)
          Returns the setting value (as time) associated with the setting key.
 Version getAsVersion(String setting, Version defaultVersion)
          Retruns a parsed version.
 Settings getByPrefix(String prefix)
          A settings that are filtered (and key is removed) with the specified prefix.
 ClassLoader getClassLoader()
          The class loader associated with this settings, or Classes.getDefaultClassLoader() if not set.
 ClassLoader getClassLoaderIfSet()
          The class loader associated with this settings, but only if explicitly set, otherwise null.
 Settings getComponentSettings(Class component)
          Component settings for a specific component.
 Settings getComponentSettings(String prefix, Class component)
          Component settings for a specific component.
 Map<String,Settings> getGroups(String settingPrefix)
          Returns group settings for the given setting prefix.
 

Method Detail

getComponentSettings

Settings getComponentSettings(Class component)
Component settings for a specific component. Returns all the settings for the given class, where the FQN of the class is used, without the org.elasticsearch prefix. If there is no org.elasticsearch prefix, then the prefix used is the first part of the package name (org / com / ...)


getComponentSettings

Settings getComponentSettings(String prefix,
                              Class component)
Component settings for a specific component. Returns all the settings for the given class, where the FQN of the class is used, without provided prefix.


getByPrefix

Settings getByPrefix(String prefix)
A settings that are filtered (and key is removed) with the specified prefix.


getClassLoader

ClassLoader getClassLoader()
The class loader associated with this settings, or Classes.getDefaultClassLoader() if not set.


getClassLoaderIfSet

@Nullable
ClassLoader getClassLoaderIfSet()
The class loader associated with this settings, but only if explicitly set, otherwise null.


getAsMap

com.google.common.collect.ImmutableMap<String,String> getAsMap()
The settings as a Map.


get

String get(String setting)
Returns the setting value associated with the setting key.

Parameters:
setting - The setting key
Returns:
The setting value, null if it does not exists.

get

String get(String setting,
           String defaultValue)
Returns the setting value associated with the setting key. If it does not exists, returns the default value provided.

Parameters:
setting - The setting key
defaultValue - The value to return if no value is associated with the setting
Returns:
The setting value, or the default value if no value exists

getGroups

Map<String,Settings> getGroups(String settingPrefix)
                               throws SettingsException
Returns group settings for the given setting prefix.

Throws:
SettingsException

getAsFloat

Float getAsFloat(String setting,
                 Float defaultValue)
                 throws SettingsException
Returns the setting value (as float) associated with the setting key. If it does not exists, returns the default value provided.

Parameters:
setting - The setting key
defaultValue - The value to return if no value is associated with the setting
Returns:
The (float) value, or the default value if no value exists.
Throws:
SettingsException - Failure to parse the setting

getAsDouble

Double getAsDouble(String setting,
                   Double defaultValue)
                   throws SettingsException
Returns the setting value (as double) associated with the setting key. If it does not exists, returns the default value provided.

Parameters:
setting - The setting key
defaultValue - The value to return if no value is associated with the setting
Returns:
The (double) value, or the default value if no value exists.
Throws:
SettingsException - Failure to parse the setting

getAsInt

Integer getAsInt(String setting,
                 Integer defaultValue)
                 throws SettingsException
Returns the setting value (as int) associated with the setting key. If it does not exists, returns the default value provided.

Parameters:
setting - The setting key
defaultValue - The value to return if no value is associated with the setting
Returns:
The (int) value, or the default value if no value exists.
Throws:
SettingsException - Failure to parse the setting

getAsLong

Long getAsLong(String setting,
               Long defaultValue)
               throws SettingsException
Returns the setting value (as long) associated with the setting key. If it does not exists, returns the default value provided.

Parameters:
setting - The setting key
defaultValue - The value to return if no value is associated with the setting
Returns:
The (long) value, or the default value if no value exists.
Throws:
SettingsException - Failure to parse the setting

getAsBoolean

Boolean getAsBoolean(String setting,
                     Boolean defaultValue)
                     throws SettingsException
Returns the setting value (as boolean) associated with the setting key. If it does not exists, returns the default value provided.

Parameters:
setting - The setting key
defaultValue - The value to return if no value is associated with the setting
Returns:
The (boolean) value, or the default value if no value exists.
Throws:
SettingsException - Failure to parse the setting

getAsTime

TimeValue getAsTime(String setting,
                    TimeValue defaultValue)
                    throws SettingsException
Returns the setting value (as time) associated with the setting key. If it does not exists, returns the default value provided.

Parameters:
setting - The setting key
defaultValue - The value to return if no value is associated with the setting
Returns:
The (time) value, or the default value if no value exists.
Throws:
SettingsException - Failure to parse the setting
See Also:
TimeValue.parseTimeValue(String, org.elasticsearch.common.unit.TimeValue)

getAsBytesSize

ByteSizeValue getAsBytesSize(String setting,
                             ByteSizeValue defaultValue)
                             throws SettingsException
Returns the setting value (as size) associated with the setting key. If it does not exists, returns the default value provided.

Parameters:
setting - The setting key
defaultValue - The value to return if no value is associated with the setting
Returns:
The (size) value, or the default value if no value exists.
Throws:
SettingsException - Failure to parse the setting
See Also:
ByteSizeValue.parseBytesSizeValue(String, org.elasticsearch.common.unit.ByteSizeValue)

getAsSize

SizeValue getAsSize(String setting,
                    SizeValue defaultValue)
                    throws SettingsException
Returns the setting value (as size) associated with the setting key. If it does not exists, returns the default value provided.

Parameters:
setting - The setting key
defaultValue - The value to return if no value is associated with the setting
Returns:
The (size) value, or the default value if no value exists.
Throws:
SettingsException - Failure to parse the setting
See Also:
ByteSizeValue.parseBytesSizeValue(String, org.elasticsearch.common.unit.ByteSizeValue)

getAsClass

<T> Class<? extends T> getAsClass(String setting,
                                  Class<? extends T> defaultClazz)
                              throws NoClassSettingsException
Returns the setting value (as a class) associated with the setting key. If it does not exists, returns the default class provided.

Type Parameters:
T - The type of the class
Parameters:
setting - The setting key
defaultClazz - The class to return if no value is associated with the setting
Returns:
The class setting value, or the default class provided is no value exists
Throws:
NoClassSettingsException - Failure to load a class

getAsClass

<T> Class<? extends T> getAsClass(String setting,
                                  Class<? extends T> defaultClazz,
                                  String prefixPackage,
                                  String suffixClassName)
                              throws NoClassSettingsException
Returns the setting value (as a class) associated with the setting key. If the value itself fails to represent a loadable class, the value will be appended to the prefixPackage and suffixed with the suffixClassName and it will try to be loaded with it.

Type Parameters:
T - The type of the class
Parameters:
setting - The setting key
defaultClazz - The class to return if no value is associated with the setting
prefixPackage - The prefix package to prefix the value with if failing to load the class as is
suffixClassName - The suffix class name to prefix the value with if failing to load the class as is
Returns:
The class represented by the setting value, or the default class provided if no value exists
Throws:
NoClassSettingsException - Failure to load the class

getAsArray

String[] getAsArray(String settingPrefix,
                    String[] defaultArray)
                    throws SettingsException
The values associated with a setting prefix as an array. The settings array is in the format of: settingPrefix.[index].

It will also automatically load a comma separated list under the settingPrefix and merge with the numbered format.

Parameters:
settingPrefix - The setting prefix to load the array by
Returns:
The setting array values
Throws:
SettingsException

getAsArray

String[] getAsArray(String settingPrefix)
                    throws SettingsException
The values associated with a setting prefix as an array. The settings array is in the format of: settingPrefix.[index].

It will also automatically load a comma separated list under the settingPrefix and merge with the numbered format.

Parameters:
settingPrefix - The setting prefix to load the array by
Returns:
The setting array values
Throws:
SettingsException

getAsVersion

Version getAsVersion(String setting,
                     Version defaultVersion)
                     throws SettingsException
Retruns a parsed version.

Throws:
SettingsException


Copyright © 2009-2012. All Rights Reserved.