Class Settings

org.elasticsearch.common.settings.Settings
All Implemented Interfaces:
org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentFragment

public final class Settings extends implements org.elasticsearch.common.xcontent.ToXContentFragment
An immutable settings implementation.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A builder allowing to put different settings and then Settings.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
    Modifier and Type
    Field
    Description
    static Settings
     
    static <>
     

    Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent

    EMPTY_PARAMS
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a builder to be used in order to build settings.
    boolean
     o)
     
    <> predicate)
    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 from toXContent(XContentBuilder, Params) into a new Settings object.
     setting)
    Returns the setting value associated with the setting key.
     setting,  defaultValue)
    Returns the setting value associated with the setting key.
     setting,  defaultValue)
    Returns the setting value (as boolean) associated with the setting key.
     setting, ByteSizeValue defaultValue)
    Returns the setting value (as size) associated with the setting key.
     setting,  defaultValue)
    Returns the setting value (as double) associated with the setting key.
     setting,  defaultValue)
    Returns the setting value (as float) associated with the setting key.
    <,​Settings>
    Returns group settings for the given setting prefix.
     setting,  defaultValue)
    Returns the setting value (as int) associated with the setting key.
    <>
     key)
    The values associated with a setting key as an immutable list.
    <>
     key, <> defaultValue)
    The values associated with a setting key as an immutable list.
    <>
     key, <> defaultValue,  commaDelimited)
    The values associated with a setting key as an immutable list.
     setting,  defaultValue)
    Returns the setting value (as long) associated with the setting key.
     setting,  defaultValue)
    Returns the setting value (as size) associated with the setting key.
     setting)
    Returns the settings mapped to the given setting name.
    org.elasticsearch.core.TimeValue
     setting, org.elasticsearch.core.TimeValue defaultValue)
    Returns the setting value (as time) associated with the setting key.
     setting, Version defaultVersion)
    Returns a parsed version.
     prefix)
    A settings that are filtered (and key is removed) with the specified prefix.
    <,​Settings>
     settingPrefix)
    Returns group settings for the given setting prefix.
    <,​Settings>
     settingPrefix, boolean ignoreNonGrouped)
    Returns group settings for the given setting prefix.
    int
     
    boolean
     key)
    Returns true iff the given key has a value in this settings object
    boolean
    Returns true if this settings object contains no settings
    <>
    Returns the fully qualified setting names contained in this settings object.
    <>
     
    static Settings
     
    int
    Returns the number of settings in this settings object.
    toDelimitedString​(char delimiter)
    Returns the settings as delimited string.
     
    org.elasticsearch.common.xcontent.XContentBuilder
    toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
     
    static void
     

    Methods inherited from class java.lang.

    , , , , , , ,

    Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment

    isFragment
  • Field Details

    • EMPTY

      public static final Settings EMPTY
    • FORMAT_PARAMS

      public static final <> FORMAT_PARAMS
  • Method Details

    • getByPrefix

      public  prefix)
      A settings that are filtered (and key is removed) with the specified prefix.
    • filter

      public <> predicate)
      Returns a new settings object that contains all setting of the current one filtered by the given settings key predicate.
    • getAsSettings

      public  setting)
      Returns the settings mapped to the given setting name.
    • get

      public  get( 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

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

      public  getAsFloat( setting,  defaultValue)
      Returns the setting value (as float) associated with the setting key. If it does not exists, returns the default value provided.
    • getAsDouble

      public  getAsDouble( setting,  defaultValue)
      Returns the setting value (as double) associated with the setting key. If it does not exists, returns the default value provided.
    • getAsInt

      public  getAsInt( setting,  defaultValue)
      Returns the setting value (as int) associated with the setting key. If it does not exists, returns the default value provided.
    • getAsLong

      public  getAsLong( setting,  defaultValue)
      Returns the setting value (as long) associated with the setting key. If it does not exists, returns the default value provided.
    • hasValue

      public boolean hasValue( key)
      Returns true iff the given key has a value in this settings object
    • getAsBoolean

      public  getAsBoolean( setting,  defaultValue)
      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( 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  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.
      Throws:
      SettingsException
    • getAsMemory

      public  setting,  defaultValue) throws SettingsException
      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

      public <> getAsList( key) throws SettingsException
      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

      public <> getAsList( key, <> defaultValue) throws SettingsException
      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 <> getAsList( key, <> defaultValue,  commaDelimited) throws SettingsException
      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
      defaultValue - The default value to use if no value is specified
      commaDelimited - Whether to try to parse a string as a comma-delimited value
      Returns:
      The setting list values
      Throws:
      SettingsException
    • getGroups

      public <,​ settingPrefix) throws SettingsException
      Returns group settings for the given setting prefix.
      Throws:
      SettingsException
    • getGroups

      public <,​ settingPrefix, boolean ignoreNonGrouped) throws SettingsException
      Returns group settings for the given setting prefix.
      Throws:
      SettingsException
    • getAsGroups

      public <,​Settings> getAsGroups() throws SettingsException
      Returns group settings for the given setting prefix.
      Throws:
      SettingsException
    • getAsVersion

      public  setting, Version defaultVersion) throws SettingsException
      Returns a parsed version.
      Throws:
      SettingsException
    • names

      public <> names()
      Returns:
      The direct keys of this settings
    • toDelimitedString

      public  toDelimitedString(char delimiter)
      Returns the settings as delimited string.
    • equals

      public boolean equals( o)
      Overrides:
       in class 
    • hashCode

      public int hashCode()
      Overrides:
       in class 
    • readSettingsFromStream

      public static Settings readSettingsFromStream(StreamInput in) throws
      Throws:
    • writeSettingsToStream

      public static void writeSettingsToStream(Settings settings, StreamOutput out) throws
      Throws:
    • builder

      public static Settings.Builder 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
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
    • fromXContent

      public static Settings fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws
      Parsers the generated xcontent from toXContent(XContentBuilder, Params) into a new Settings object. Note this method requires the parser to either be positioned on a null token or on XContentParser.Token.START_OBJECT.
      Throws:
    • isEmpty

      public boolean isEmpty()
      Returns true 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

      public <> keySet()
      Returns the fully qualified setting names contained in this settings object.
    • toString

      public  toString()
      Overrides:
       in class