Class Settings
java.lang.Object
org.elasticsearch.common.settings.Settings
- All Implemented Interfaces:
org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentFragment
public final class Settings
extends Object
implements org.elasticsearch.common.xcontent.ToXContentFragment
An immutable settings implementation.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A builder allowing to put different settings and thenSettings.Builder.build()
an immutable settings implementation.Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
-
Field Summary
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Method Summary
Modifier and TypeMethodDescriptionstatic Settings.Builder
builder()
Returns a builder to be used in order to build settings.boolean
Returns a new settings object that contains all setting of the current one filtered by the given settings key predicate.static Settings
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
Parsers the generated xcontent fromtoXContent(XContentBuilder, Params)
into a new Settings object.Returns the setting value associated with the setting key.Returns the setting value associated with the setting key.getAsBoolean(String setting, Boolean defaultValue)
Returns the setting value (as boolean) associated with the setting key.getAsBytesSize(String setting, ByteSizeValue defaultValue)
Returns the setting value (as size) associated with the setting key.getAsDouble(String setting, Double defaultValue)
Returns the setting value (as double) associated with the setting key.getAsFloat(String setting, Float defaultValue)
Returns the setting value (as float) associated with the setting key.Returns group settings for the given setting prefix.Returns the setting value (as int) associated with the setting key.The values associated with a setting key as an immutable list.The values associated with a setting key as an immutable list.The values associated with a setting key as an immutable list.Returns the setting value (as long) associated with the setting key.getAsMemory(String setting, String defaultValue)
Returns the setting value (as size) associated with the setting key.getAsSettings(String setting)
Returns the settings mapped to the given setting name.org.elasticsearch.core.TimeValue
Returns the setting value (as time) associated with the setting key.getAsVersion(String setting, Version defaultVersion)
Returns a parsed version.getByPrefix(String prefix)
A settings that are filtered (and key is removed) with the specified prefix.Returns group settings for the given setting prefix.Returns group settings for the given setting prefix.int
hashCode()
boolean
Returnstrue
iff the given key has a value in this settings objectboolean
isEmpty()
Returnstrue
if this settings object contains no settingskeySet()
Returns the fully qualified setting names contained in this settings object.names()
static Settings
int
size()
Returns the number of settings in this settings object.toDelimitedString(char delimiter)
Returns the settings as delimited string.toString()
org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
static void
writeSettingsToStream(Settings settings, StreamOutput out)
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
Field Details
-
EMPTY
-
FORMAT_PARAMS
-
-
Method Details
-
getByPrefix
A settings that are filtered (and key is removed) with the specified prefix. -
filter
Returns a new settings object that contains all setting of the current one filtered by the given settings key predicate. -
getAsSettings
Returns the settings mapped to the given setting name. -
get
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
Returns the setting value associated with the setting key. If it does not exists, returns the default value provided. -
getAsFloat
Returns the setting value (as float) associated with the setting key. If it does not exists, returns the default value provided. -
getAsDouble
Returns the setting value (as double) associated with the setting key. If it does not exists, returns the default value provided. -
getAsInt
Returns the setting value (as int) associated with the setting key. If it does not exists, returns the default value provided. -
getAsLong
Returns the setting value (as long) associated with the setting key. If it does not exists, returns the default value provided. -
hasValue
Returnstrue
iff the given key has a value in this settings object -
getAsBoolean
Returns the setting value (as boolean) associated with the setting key. If it does not exists, returns the default value provided. -
getAsTime
public org.elasticsearch.core.TimeValue getAsTime(String setting, org.elasticsearch.core.TimeValue defaultValue)Returns the setting value (as time) associated with the setting key. If it does not exists, returns the default value provided. -
getAsBytesSize
public ByteSizeValue getAsBytesSize(String setting, ByteSizeValue defaultValue) throws SettingsExceptionReturns the setting value (as size) associated with the setting key. If it does not exists, returns the default value provided.- Throws:
SettingsException
-
getAsMemory
Returns the setting value (as size) associated with the setting key. Provided values can either be absolute values (interpreted as a number of bytes), byte sizes (eg. 1mb) or percentage of the heap size (eg. 12%). If it does not exists, parses the default value provided.- Throws:
SettingsException
-
getAsList
The values associated with a setting key as an immutable list.It will also automatically load a comma separated list under the settingPrefix and merge with the numbered format.
- Parameters:
key
- The setting key to load the list by- Returns:
- The setting list values
- Throws:
SettingsException
-
getAsList
The values associated with a setting key as an immutable list.If commaDelimited is true, it will automatically load a comma separated list under the settingPrefix and merge with the numbered format.
- Parameters:
key
- The setting key to load the list by- Returns:
- The setting list values
- Throws:
SettingsException
-
getAsList
public List<String> getAsList(String key, List<String> defaultValue, Boolean commaDelimited) throws SettingsExceptionThe values associated with a setting key as an immutable list.It will also automatically load a comma separated list under the settingPrefix and merge with the numbered format.
- Parameters:
key
- The setting key to load the list bydefaultValue
- The default value to use if no value is specifiedcommaDelimited
- Whether to try to parse a string as a comma-delimited value- Returns:
- The setting list values
- Throws:
SettingsException
-
getGroups
Returns group settings for the given setting prefix.- Throws:
SettingsException
-
getGroups
public Map<String,Settings> getGroups(String settingPrefix, boolean ignoreNonGrouped) throws SettingsExceptionReturns group settings for the given setting prefix.- Throws:
SettingsException
-
getAsGroups
Returns group settings for the given setting prefix.- Throws:
SettingsException
-
getAsVersion
Returns a parsed version.- Throws:
SettingsException
-
names
- Returns:
- The direct keys of this settings
-
toDelimitedString
Returns the settings as delimited string. -
equals
-
hashCode
public int hashCode() -
readSettingsFromStream
- Throws:
IOException
-
writeSettingsToStream
- Throws:
IOException
-
builder
Returns a builder to be used in order to build settings. -
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Throws:
IOException
-
fromXContent
public static Settings fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOExceptionParsers the generated xcontent fromtoXContent(XContentBuilder, Params)
into a new Settings object. Note this method requires the parser to either be positioned on a null token or onXContentParser.Token.START_OBJECT
.- Throws:
IOException
-
isEmpty
public boolean isEmpty()Returnstrue
if this settings object contains no settings- Returns:
true
if this settings object contains no settings
-
size
public int size()Returns the number of settings in this settings object. -
keySet
Returns the fully qualified setting names contained in this settings object. -
toString
-