org.elasticsearch.common.settings
Class ImmutableSettings

java.lang.Object
  extended by org.elasticsearch.common.settings.ImmutableSettings
All Implemented Interfaces:
Settings

@ThreadSafe
@Immutable
public class ImmutableSettings
extends java.lang.Object
implements Settings

An immutable implementation of Settings.


Nested Class Summary
static class ImmutableSettings.Builder
          A builder allowing to put different settings and then ImmutableSettings.Builder.build() an immutable settings implementation.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.String get(java.lang.String setting)
          Returns the setting value associated with the setting key.
 java.lang.String get(java.lang.String setting, java.lang.String defaultValue)
          Returns the setting value associated with the setting key.
 java.lang.String[] getAsArray(java.lang.String settingPrefix)
          The values associated with a setting prefix as an array.
 java.lang.String[] getAsArray(java.lang.String settingPrefix, java.lang.String[] defaultArray)
          The values associated with a setting prefix as an array.
 java.lang.Boolean getAsBoolean(java.lang.String setting, java.lang.Boolean defaultValue)
          Returns the setting value (as boolean) associated with the setting key.
 ByteSizeValue getAsBytesSize(java.lang.String setting, ByteSizeValue defaultValue)
          Returns the setting value (as size) associated with the setting key.
<T> java.lang.Class<? extends T>
getAsClass(java.lang.String setting, java.lang.Class<? extends T> defaultClazz)
          Returns the setting value (as a class) associated with the setting key.
<T> java.lang.Class<? extends T>
getAsClass(java.lang.String setting, java.lang.Class<? extends T> defaultClazz, java.lang.String prefixPackage, java.lang.String suffixClassName)
          Returns the setting value (as a class) associated with the setting key.
 java.lang.Double getAsDouble(java.lang.String setting, java.lang.Double defaultValue)
          Returns the setting value (as double) associated with the setting key.
 java.lang.Float getAsFloat(java.lang.String setting, java.lang.Float defaultValue)
          Returns the setting value (as float) associated with the setting key.
 java.lang.Integer getAsInt(java.lang.String setting, java.lang.Integer defaultValue)
          Returns the setting value (as int) associated with the setting key.
 java.lang.Long getAsLong(java.lang.String setting, java.lang.Long defaultValue)
          Returns the setting value (as long) associated with the setting key.
 java.util.Map<java.lang.String,java.lang.String> getAsMap()
          The settings as a Map.
 SizeValue getAsSize(java.lang.String setting, SizeValue defaultValue)
          Returns the setting value (as size) associated with the setting key.
 TimeValue getAsTime(java.lang.String setting, TimeValue defaultValue)
          Returns the setting value (as time) associated with the setting key.
 Settings getByPrefix(java.lang.String prefix)
          A settings that are filtered (and key is removed) with the specified prefix.
 java.lang.ClassLoader getClassLoader()
          The class loader associated with this settings.
 Settings getComponentSettings(java.lang.Class component)
          Component settings for a specific component.
 Settings getComponentSettings(java.lang.String prefix, java.lang.Class component)
          Component settings for a specific component.
 Settings getGlobalSettings()
          The global settings if these settings are group settings.
 java.util.Map<java.lang.String,Settings> getGroups(java.lang.String settingPrefix)
          Returns group settings for the given setting prefix.
 int hashCode()
           
static Settings readSettingsFromStream(StreamInput in)
           
static Settings readSettingsFromStream(StreamInput in, Settings globalSettings)
           
static ImmutableSettings.Builder settingsBuilder()
          Returns a builder to be used in order to build settings.
static void writeSettingsToStream(Settings settings, StreamOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getGlobalSettings

public Settings getGlobalSettings()
Description copied from interface: Settings
The global settings if these settings are group settings.

Specified by:
getGlobalSettings in interface Settings

getClassLoader

public java.lang.ClassLoader getClassLoader()
Description copied from interface: Settings
The class loader associated with this settings.

Specified by:
getClassLoader in interface Settings

getAsMap

public java.util.Map<java.lang.String,java.lang.String> getAsMap()
Description copied from interface: Settings
The settings as a Map.

Specified by:
getAsMap in interface Settings

getComponentSettings

public Settings getComponentSettings(java.lang.Class component)
Description copied from interface: Settings
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.

Specified by:
getComponentSettings in interface Settings

getComponentSettings

public Settings getComponentSettings(java.lang.String prefix,
                                     java.lang.Class component)
Description copied from interface: Settings
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.

Specified by:
getComponentSettings in interface Settings

getByPrefix

public Settings getByPrefix(java.lang.String prefix)
Description copied from interface: Settings
A settings that are filtered (and key is removed) with the specified prefix.

Specified by:
getByPrefix in interface Settings

get

public java.lang.String get(java.lang.String setting)
Description copied from interface: Settings
Returns the setting value associated with the setting key.

Specified by:
get in interface Settings
Parameters:
setting - The setting key
Returns:
The setting value, null if it does not exists.

get

public java.lang.String get(java.lang.String setting,
                            java.lang.String defaultValue)
Description copied from interface: Settings
Returns the setting value associated with the setting key. If it does not exists, returns the default value provided.

Specified by:
get in interface Settings
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

getAsFloat

public java.lang.Float getAsFloat(java.lang.String setting,
                                  java.lang.Float defaultValue)
Description copied from interface: Settings
Returns the setting value (as float) associated with the setting key. If it does not exists, returns the default value provided.

Specified by:
getAsFloat in interface Settings
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.

getAsDouble

public java.lang.Double getAsDouble(java.lang.String setting,
                                    java.lang.Double defaultValue)
Description copied from interface: Settings
Returns the setting value (as double) associated with the setting key. If it does not exists, returns the default value provided.

Specified by:
getAsDouble in interface Settings
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.

getAsInt

public java.lang.Integer getAsInt(java.lang.String setting,
                                  java.lang.Integer defaultValue)
Description copied from interface: Settings
Returns the setting value (as int) associated with the setting key. If it does not exists, returns the default value provided.

Specified by:
getAsInt in interface Settings
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.

getAsLong

public java.lang.Long getAsLong(java.lang.String setting,
                                java.lang.Long defaultValue)
Description copied from interface: Settings
Returns the setting value (as long) associated with the setting key. If it does not exists, returns the default value provided.

Specified by:
getAsLong in interface Settings
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.

getAsBoolean

public java.lang.Boolean getAsBoolean(java.lang.String setting,
                                      java.lang.Boolean defaultValue)
Description copied from interface: Settings
Returns the setting value (as boolean) associated with the setting key. If it does not exists, returns the default value provided.

Specified by:
getAsBoolean in interface Settings
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.

getAsTime

public TimeValue getAsTime(java.lang.String setting,
                           TimeValue defaultValue)
Description copied from interface: Settings
Returns the setting value (as time) associated with the setting key. If it does not exists, returns the default value provided.

Specified by:
getAsTime in interface Settings
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.
See Also:
TimeValue.parseTimeValue(String, org.elasticsearch.common.unit.TimeValue)

getAsBytesSize

public ByteSizeValue getAsBytesSize(java.lang.String setting,
                                    ByteSizeValue defaultValue)
                             throws SettingsException
Description copied from interface: Settings
Returns the setting value (as size) associated with the setting key. If it does not exists, returns the default value provided.

Specified by:
getAsBytesSize in interface Settings
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

public SizeValue getAsSize(java.lang.String setting,
                           SizeValue defaultValue)
                    throws SettingsException
Description copied from interface: Settings
Returns the setting value (as size) associated with the setting key. If it does not exists, returns the default value provided.

Specified by:
getAsSize in interface Settings
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

public <T> java.lang.Class<? extends T> getAsClass(java.lang.String setting,
                                                   java.lang.Class<? extends T> defaultClazz)
                                        throws NoClassSettingsException
Description copied from interface: Settings
Returns the setting value (as a class) associated with the setting key. If it does not exists, returns the default class provided.

Specified by:
getAsClass in interface Settings
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

public <T> java.lang.Class<? extends T> getAsClass(java.lang.String setting,
                                                   java.lang.Class<? extends T> defaultClazz,
                                                   java.lang.String prefixPackage,
                                                   java.lang.String suffixClassName)
                                        throws NoClassSettingsException
Description copied from interface: Settings
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.

Specified by:
getAsClass in interface Settings
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

public java.lang.String[] getAsArray(java.lang.String settingPrefix)
                              throws SettingsException
Description copied from interface: Settings
The values associated with a setting prefix as an array. The settings array is in the format of: settingPrefix.[index].

Specified by:
getAsArray in interface Settings
Parameters:
settingPrefix - The setting prefix to load the array by
Returns:
The setting array values
Throws:
SettingsException

getAsArray

public java.lang.String[] getAsArray(java.lang.String settingPrefix,
                                     java.lang.String[] defaultArray)
                              throws SettingsException
Description copied from interface: Settings
The values associated with a setting prefix as an array. The settings array is in the format of: settingPrefix.[index].

Specified by:
getAsArray in interface Settings
Parameters:
settingPrefix - The setting prefix to load the array by
Returns:
The setting array values
Throws:
SettingsException

getGroups

public java.util.Map<java.lang.String,Settings> getGroups(java.lang.String settingPrefix)
                                                   throws SettingsException
Description copied from interface: Settings
Returns group settings for the given setting prefix.

Specified by:
getGroups in interface Settings
Throws:
SettingsException

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

readSettingsFromStream

public static Settings readSettingsFromStream(StreamInput in)
                                       throws java.io.IOException
Throws:
java.io.IOException

readSettingsFromStream

public static Settings readSettingsFromStream(StreamInput in,
                                              Settings globalSettings)
                                       throws java.io.IOException
Throws:
java.io.IOException

writeSettingsToStream

public static void writeSettingsToStream(Settings settings,
                                         StreamOutput out)
                                  throws java.io.IOException
Throws:
java.io.IOException

settingsBuilder

public static ImmutableSettings.Builder settingsBuilder()
Returns a builder to be used in order to build settings.