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 Link icon

  • Constructor Details Link icon

    • ConfigMap Link icon

      public ConfigMap()
  • Method Details Link icon

    • get Link icon

      public abstract String get(String key, String def)
    • entrySet Link icon

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

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

      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 Link icon

      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 Link icon

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

      public int getInt(String key)
    • getLong Link icon

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

      public long getLong(String key)
    • getSokLong Link icon

      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 Link icon

      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 Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

      public BigDecimal getBigDecimal(String key, BigDecimal def)
    • sub Link icon

      public ConfigMap sub(String prefix)
      Creates a sub map by a key prefix
       prefixkey1=value1
       prefixkey2=value2
       ->
       map
       key1=value1
       key2=value2
      Parameters:
      prefix - the key prefix for extraction
      Returns:
      not null config map
    • subSok Link icon

      public ConfigMap subSok(String... prefixes)
      Creates a sub map by key prefixes
       prefixkey1=value1
       prefixkey2=value2
       ->
       config map
       key1=value1
       key2=value2
      Parameters:
      prefixes - key prefixes for extraction, the first one is the actual, the rest are deprecated prefixes
      Returns:
      not null config map
    • subIndexed Link icon

      public SortedMap<Integer,ConfigMap> subIndexed(String prefix)
      Creates a sorted map of maps by a key prefix
       prefix1.12=2
       prefix1.34=4
       prefix2.56=2
       prefix2.78=4
       ->
       sorted Map
       1={12=2,34=4}
       2={56=2,78=4}
      Parameters:
      prefix - the key prefix for extraction
      Returns:
      not null map
    • subSokIndexed Link icon

      public SortedMap<Integer,ConfigMap> subSokIndexed(String... prefixes)
      Creates a sorted map of maps by key prefixes
       prefix1.12=2
       prefix1.34=4
       prefix2.56=2
       prefix2.78=4
       ->
       sorted Map
       1={12=2,34=4}
       2={56=2,78=4}
      Parameters:
      prefixes - key prefixes for extraction, the first one is the actual, the rest are deprecated prefixes
      Returns:
      not null map
    • subKeyed Link icon

      public Map<String,ConfigMap> subKeyed(String prefix)
      Creates a map of maps by a key prefix
       prefixa.12=2
       prefixa.34=4
       prefixb.56=u
       prefixb.kk=4
       ->
       unsorted map
       a={12=2,34=4}
       b={56=u,kk=4}
      Parameters:
      prefix - the key prefix for extraction
      Returns:
      not null map
      See Also:
    • getConfig Link icon

      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 Link icon

      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 Link icon

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

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

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

      public String getDataString()
      Serializes the data to key=value string lines
      Returns:
      the string with pairs on lines