org.elasticsearch.common.settings
Class ImmutableSettings.Builder

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

public static class ImmutableSettings.Builder
extends Object
implements Settings.Builder

A builder allowing to put different settings and then build() an immutable settings implementation. Use ImmutableSettings.settingsBuilder() in order to construct it.


Field Summary
static Settings EMPTY_SETTINGS
           
 
Method Summary
 Settings build()
          Builds a Settings (underlying uses ImmutableSettings) based on everything set on this builder.
 ImmutableSettings.Builder classLoader(ClassLoader classLoader)
          Sets the class loader associated with the settings built.
 String get(String key)
          Returns a setting value based on the setting key.
 Map<String,String> internalMap()
           
 ImmutableSettings.Builder loadFromClasspath(String resourceName)
          Loads settings from classpath that represents them using the SettingsLoaderFactory.loaderFromSource(String).
 ImmutableSettings.Builder loadFromSource(String source)
          Loads settings from the actual string content that represents them using the SettingsLoaderFactory.loaderFromSource(String).
 ImmutableSettings.Builder loadFromStream(String resourceName, InputStream is)
          Loads settings from a stream that represents them using the SettingsLoaderFactory.loaderFromSource(String).
 ImmutableSettings.Builder loadFromUrl(URL url)
          Loads settings from a url that represents them using the SettingsLoaderFactory.loaderFromSource(String).
 ImmutableSettings.Builder put(Map<String,String> settings)
          Sets all the provided settings.
 ImmutableSettings.Builder put(Properties properties)
          Sets all the provided settings.
 ImmutableSettings.Builder put(Settings settings)
          Sets all the provided settings.
 ImmutableSettings.Builder put(String setting, boolean value)
          Sets the setting with the provided setting key and the boolean value.
 ImmutableSettings.Builder put(String key, Class clazz)
          Sets a setting with the provided setting key and class as value.
 ImmutableSettings.Builder put(String setting, double value)
          Sets the setting with the provided setting key and the double value.
 ImmutableSettings.Builder put(String setting, float value)
          Sets the setting with the provided setting key and the float value.
 ImmutableSettings.Builder put(String setting, int value)
          Sets the setting with the provided setting key and the int value.
 ImmutableSettings.Builder put(String setting, long value)
          Sets the setting with the provided setting key and the long value.
 ImmutableSettings.Builder put(String setting, long value, ByteSizeUnit sizeUnit)
          Sets the setting with the provided setting key and the size value.
 ImmutableSettings.Builder put(String setting, long value, TimeUnit timeUnit)
          Sets the setting with the provided setting key and the time value.
 ImmutableSettings.Builder put(String key, String value)
          Sets a setting with the provided setting key and value.
 ImmutableSettings.Builder put(String settingPrefix, String groupName, String[] settings, String[] values)
          Sets the setting group.
 ImmutableSettings.Builder put(String setting, Version version)
           
 ImmutableSettings.Builder putArray(String setting, String... values)
          Sets the setting with the provided setting key and an array of values.
 ImmutableSettings.Builder putProperties(String prefix, Properties properties)
          Puts all the properties with keys starting with the provided prefix.
 ImmutableSettings.Builder putProperties(String prefix, Properties properties, String[] ignorePrefixes)
          Puts all the properties with keys starting with the provided prefix.
 String remove(String key)
          Removes the provided setting from the internal map holding the current list of settings.
 ImmutableSettings.Builder replacePropertyPlaceholders()
          Runs across all the settings set on this builder and replaces ${...} elements in the each setting value according to the following logic:

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_SETTINGS

public static final Settings EMPTY_SETTINGS
Method Detail

internalMap

public Map<String,String> internalMap()

remove

public String remove(String key)
Removes the provided setting from the internal map holding the current list of settings.


get

public String get(String key)
Returns a setting value based on the setting key.


put

public ImmutableSettings.Builder put(String key,
                                     String value)
Sets a setting with the provided setting key and value.

Parameters:
key - The setting key
value - The setting value
Returns:
The builder

put

public ImmutableSettings.Builder put(String key,
                                     Class clazz)
Sets a setting with the provided setting key and class as value.

Parameters:
key - The setting key
clazz - The setting class value
Returns:
The builder

put

public ImmutableSettings.Builder put(String setting,
                                     boolean value)
Sets the setting with the provided setting key and the boolean value.

Parameters:
setting - The setting key
value - The boolean value
Returns:
The builder

put

public ImmutableSettings.Builder put(String setting,
                                     int value)
Sets the setting with the provided setting key and the int value.

Parameters:
setting - The setting key
value - The int value
Returns:
The builder

put

public ImmutableSettings.Builder put(String setting,
                                     Version version)

put

public ImmutableSettings.Builder put(String setting,
                                     long value)
Sets the setting with the provided setting key and the long value.

Parameters:
setting - The setting key
value - The long value
Returns:
The builder

put

public ImmutableSettings.Builder put(String setting,
                                     float value)
Sets the setting with the provided setting key and the float value.

Parameters:
setting - The setting key
value - The float value
Returns:
The builder

put

public ImmutableSettings.Builder put(String setting,
                                     double value)
Sets the setting with the provided setting key and the double value.

Parameters:
setting - The setting key
value - The double value
Returns:
The builder

put

public ImmutableSettings.Builder put(String setting,
                                     long value,
                                     TimeUnit timeUnit)
Sets the setting with the provided setting key and the time value.

Parameters:
setting - The setting key
value - The time value
Returns:
The builder

put

public ImmutableSettings.Builder put(String setting,
                                     long value,
                                     ByteSizeUnit sizeUnit)
Sets the setting with the provided setting key and the size value.

Parameters:
setting - The setting key
value - The size value
Returns:
The builder

putArray

public ImmutableSettings.Builder putArray(String setting,
                                          String... values)
Sets the setting with the provided setting key and an array of values.

Parameters:
setting - The setting key
values - The values
Returns:
The builder

put

public ImmutableSettings.Builder put(String settingPrefix,
                                     String groupName,
                                     String[] settings,
                                     String[] values)
                              throws SettingsException
Sets the setting group.

Throws:
SettingsException

put

public ImmutableSettings.Builder put(Settings settings)
Sets all the provided settings.


put

public ImmutableSettings.Builder put(Map<String,String> settings)
Sets all the provided settings.


put

public ImmutableSettings.Builder put(Properties properties)
Sets all the provided settings.


loadFromSource

public ImmutableSettings.Builder loadFromSource(String source)
Loads settings from the actual string content that represents them using the SettingsLoaderFactory.loaderFromSource(String).


loadFromUrl

public ImmutableSettings.Builder loadFromUrl(URL url)
                                      throws SettingsException
Loads settings from a url that represents them using the SettingsLoaderFactory.loaderFromSource(String).

Throws:
SettingsException

loadFromStream

public ImmutableSettings.Builder loadFromStream(String resourceName,
                                                InputStream is)
                                         throws SettingsException
Loads settings from a stream that represents them using the SettingsLoaderFactory.loaderFromSource(String).

Throws:
SettingsException

loadFromClasspath

public ImmutableSettings.Builder loadFromClasspath(String resourceName)
                                            throws SettingsException
Loads settings from classpath that represents them using the SettingsLoaderFactory.loaderFromSource(String).

Throws:
SettingsException

classLoader

public ImmutableSettings.Builder classLoader(ClassLoader classLoader)
Sets the class loader associated with the settings built.


putProperties

public ImmutableSettings.Builder putProperties(String prefix,
                                               Properties properties)
Puts all the properties with keys starting with the provided prefix.

Parameters:
prefix - The prefix to filter property key by
properties - The properties to put
Returns:
The builder

putProperties

public ImmutableSettings.Builder putProperties(String prefix,
                                               Properties properties,
                                               String[] ignorePrefixes)
Puts all the properties with keys starting with the provided prefix.

Parameters:
prefix - The prefix to filter property key by
properties - The properties to put
Returns:
The builder

replacePropertyPlaceholders

public ImmutableSettings.Builder replacePropertyPlaceholders()
Runs across all the settings set on this builder and replaces ${...} elements in the each setting value according to the following logic:

First, tries to resolve it against a System property (System.getProperty(String)), next, tries and resolve it against an environment variable (System.getenv(String)), and last, tries and replace it with another setting already set on this builder.


build

public Settings build()
Builds a Settings (underlying uses ImmutableSettings) based on everything set on this builder.

Specified by:
build in interface Settings.Builder


Copyright © 2009-2012. All Rights Reserved.