Class ConfigMap

java.lang.Object
java.util.AbstractMap<String,String>
org.bgerp.app.cfg.ConfigMap
All Implemented Interfaces:
Map<String,String>
Direct Known Subclasses:
Preferences, SimpleConfigMap

public abstract class ConfigMap extends AbstractMap<String,String>
Key - value strings map.
  • Field Details

  • Constructor Details

    • ConfigMap

      public ConfigMap()
  • Method Details

    • get

      public abstract String get(String key, String def)
    • get

      public String get(Object key)
      Specified by:
      get in interface Map<String,String>
      Overrides:
      get in class AbstractMap<String,String>
    • getSok

      public String getSok(String def, boolean validate, String... keys) throws BGMessageException
      Retrieves by key value with support of old keys.
      Parameters:
      def - default value.
      validate - throw an exception on using old keys.
      keys - first key is the actual one, after - olds.
      Returns:
      Throws:
      BGMessageException
    • getSok

      public String getSok(String... keys)
      Retrieves by key value with support of old keys.
      Parameters:
      keys - first key is the actual one, after - olds.
      Returns:
    • getInt

      public int getInt(String key, int def)
    • getInt

      public int getInt(String key)
    • getLong

      public long getLong(String key, long def)
    • getLong

      public long getLong(String key)
    • getSokLong

      public long getSokLong(long def, boolean validate, String... keys) throws BGMessageException
      Retrieves by key value with support of old keys.
      Parameters:
      def - default value.
      validate - throw an exception on using old keys.
      keys - first key is the actual one, after - olds.
      Returns:
      Throws:
      BGMessageException
    • getSokLong

      public long getSokLong(long def, String... keys)
      Retrieves by key value with support of old keys.
      Parameters:
      def - default value.
      keys - first key is the actual one, after - olds.
      Returns:
      Throws:
      BGMessageException
    • getBoolean

      public final boolean getBoolean(String key)
      Retrieves by key a boolean value with default false.
      Parameters:
      key - the key.
      Returns:
      See Also:
    • getBoolean

      public final boolean getBoolean(String key, boolean defaultValue)
      Retrieves by key a boolean value.
      Parameters:
      key - the key.
      defaultValue - default value.
      Returns:
      See Also:
    • getSokBoolean

      public boolean getSokBoolean(boolean def, boolean validate, String... keys) throws BGMessageException
      Retrieves by key value with support of old keys.
      Parameters:
      def - default value.
      validate - throw an exception on using old keys.
      keys - first key is the actual one, after - olds.
      Returns:
      Throws:
      BGMessageException
    • getSokBoolean

      public boolean getSokBoolean(boolean def, String... keys)
      Retrieves by key value with support of old keys.
      Parameters:
      def - default value.
      keys - first key is the actual one, after - olds.
      Returns:
      Throws:
      BGMessageException
    • getBigDecimal

      public BigDecimal getBigDecimal(String key, BigDecimal def)
    • entrySet

      public abstract Set<Map.Entry<String,String>> entrySet()
      Specified by:
      entrySet in interface Map<String,String>
      Specified by:
      entrySet in class AbstractMap<String,String>
    • fingerprint

      @Deprecated public String fingerprint()
      Deprecated.
    • sub

      public ConfigMap sub(String... prefixes)
      Selects subset of parameters by key prefixes.
      Parameters:
      prefixes - key prefixes.
      Returns:
    • getDataString

      public String getDataString()
      Сериализация набора параметров в строку <ключ>=<значение> с переносами строк.
      Returns:
    • getDataString

      public String getDataString(String prefix)
      Сериализация набора параметров в строку <ключ>=<значение> с переносами строк. К каждой строке добавляется префикс.
      Parameters:
      prefix -
      Returns:
    • getDataString

      @Deprecated public static final String getDataString(ConfigMap config)
      Deprecated.
    • subSokIndexed

      public SortedMap<Integer,ConfigMap> subSokIndexed(String... prefixes)
      Creates a new sorted sub-map with integer keys. With support of old prefixes.
       prefix.1.12=2
       prefix.1.34=4
       prefix.2.56=2
       prefix.2.78=4
       ->
       sorted Map
       1={12=2,34=4}
       2={56=2,78=4}
      Parameters:
      prefixes - prefixes for extraction, the first one is the actual, the rest are deprecated prefixes.
      Returns:
      never null.
    • subIndexed

      public SortedMap<Integer,ConfigMap> subIndexed(String prefix)
      Creates a new sorted sub-map with integer keys.
       prefix.1.12=2
       prefix.1.34=4
       prefix.2.56=2
       prefix.2.78=4
       ->
       sorted Map
       1={12=2,34=4}
       2={56=2,78=4}
      Parameters:
      prefix - the prefix for extraction.
      Returns:
      never null.
    • subKeyed

      public Map<String,ConfigMap> subKeyed(String... prefixes)
      Creates a new unsorted sub-map with integer keys.
       prefix.a.12=2
       prefix.a.34=4
       prefix.b.56=2
       prefix.b.78=4
       ->
       unsorted map
       a={12=2,34=4}
       b={56=2,78=4}
      Parameters:
      prefixes - prefixes for extraction.
      Returns:
      never null.
      See Also:
    • parseObjectsNoOrder

      @Deprecated public Map<String,Map<String,String>> parseObjectsNoOrder(String prefix)
      Deprecated.
      Parameters:
      prefix -
      Returns:
    • getConfig

      public final <K extends Config> K getConfig(Class<K> clazz)
      Creates if needed and gets pre parsed and cached configuration. Cache key - the class object of the configuration.
      Parameters:
      clazz - the configuration class.
      Returns:
    • getConfig

      public final Object getConfig(String className)
      Same with getConfig(Class), but with string parameter for calling from scripts. The method is less recommended as getConfig(Class), which is checked by compiler.
      Parameters:
      className - the full class name.
      Returns:
    • removeConfig

      public <K extends Config> void removeConfig(Class<K> clazz)
      Removes config from cache.
      Type Parameters:
      K -
      Parameters:
      clazz -
    • clearConfigs

      protected void clearConfigs()
      Clears all the parsed configurations from configMap.
    • validateConfig

      public final <K extends Config> void validateConfig(Class<K> clazz) throws BGMessageException
      Creates a configuration for validation purposes only..
      Parameters:
      clazz -
      Throws:
      BGMessageException