Class ConfigSection

All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>

public class ConfigSection extends LinkedHashMap<String,Object>
Since:
26.04.2016
Author:
fromgate
See Also:
  • Constructor Details

    • ConfigSection

      public ConfigSection()
      Empty ConfigSection constructor
    • ConfigSection

      public ConfigSection(String key, Object value)
      Constructor of ConfigSection that contains initial key/value data
      Parameters:
      key -
      value -
    • ConfigSection

      public ConfigSection(LinkedHashMap<String,Object> map)
      Constructor of ConfigSection, based on values stored in map.
      Parameters:
      map -
  • Method Details

    • getAllMap

      public Map<String,Object> getAllMap()
      Get root section as LinkedHashMap
      Returns:
    • getAll

      public ConfigSection getAll()
      Get new instance of config section
      Returns:
    • get

      public Object get(String key)
      Get object by key. If section does not contain value, return null
    • get

      public <T> T get(String key, T defaultValue)
      Get object by key. If section does not contain value, return default value
      Parameters:
      key -
      defaultValue -
      Returns:
    • set

      public void set(String key, Object value)
      Store value into config section
      Parameters:
      key -
      value -
    • isSection

      public boolean isSection(String key)
      Check type of section element defined by key. Return true this element is ConfigSection
      Parameters:
      key -
      Returns:
    • getSection

      public ConfigSection getSection(String key)
      Get config section element defined by key
      Parameters:
      key -
      Returns:
    • getSections

      public ConfigSection getSections()
      Get all ConfigSections in root path. Example config: a1: b1: c1: c2: a2: b2: c3: c4: a3: true a4: "hello" a5: 100

      getSections() will return new ConfigSection, that contains sections a1 and a2 only.

      Returns:
    • getSections

      public ConfigSection getSections(String key)
      Get sections (and only sections) from provided path
      Parameters:
      key - - config section path, if null or empty root path will used.
      Returns:
    • getInt

      public int getInt(String key)
      Get int value of config section element
      Parameters:
      key - - key (inside) current section (default value equals to 0)
      Returns:
    • getInt

      public int getInt(String key, int defaultValue)
      Get int value of config section element
      Parameters:
      key - - key (inside) current section
      defaultValue - - default value that will returned if section element is not exists
      Returns:
    • isInt

      public boolean isInt(String key)
      Check type of section element defined by key. Return true this element is Integer
      Parameters:
      key -
      Returns:
    • getLong

      public long getLong(String key)
      Get long value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getLong

      public long getLong(String key, long defaultValue)
      Get long value of config section element
      Parameters:
      key - - key (inside) current section
      defaultValue - - default value that will returned if section element is not exists
      Returns:
    • isLong

      public boolean isLong(String key)
      Check type of section element defined by key. Return true this element is Long
      Parameters:
      key -
      Returns:
    • getDouble

      public double getDouble(String key)
      Get double value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getDouble

      public double getDouble(String key, double defaultValue)
      Get double value of config section element
      Parameters:
      key - - key (inside) current section
      defaultValue - - default value that will returned if section element is not exists
      Returns:
    • isDouble

      public boolean isDouble(String key)
      Check type of section element defined by key. Return true this element is Double
      Parameters:
      key -
      Returns:
    • getString

      public String getString(String key)
      Get String value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getString

      public String getString(String key, String defaultValue)
      Get String value of config section element
      Parameters:
      key - - key (inside) current section
      defaultValue - - default value that will returned if section element is not exists
      Returns:
    • isString

      public boolean isString(String key)
      Check type of section element defined by key. Return true this element is String
      Parameters:
      key -
      Returns:
    • getBoolean

      public boolean getBoolean(String key)
      Get boolean value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getBoolean

      public boolean getBoolean(String key, boolean defaultValue)
      Get boolean value of config section element
      Parameters:
      key - - key (inside) current section
      defaultValue - - default value that will returned if section element is not exists
      Returns:
    • isBoolean

      public boolean isBoolean(String key)
      Check type of section element defined by key. Return true this element is Integer
      Parameters:
      key -
      Returns:
    • getList

      public List getList(String key)
      Get List value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getList

      public List getList(String key, List defaultList)
      Get List value of config section element
      Parameters:
      key - - key (inside) current section
      defaultList - - default value that will returned if section element is not exists
      Returns:
    • isList

      public boolean isList(String key)
      Check type of section element defined by key. Return true this element is List
      Parameters:
      key -
      Returns:
    • getStringList

      public List<String> getStringList(String key)
      Get String List value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getIntegerList

      public List<Integer> getIntegerList(String key)
      Get Integer List value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getBooleanList

      public List<Boolean> getBooleanList(String key)
      Get Boolean List value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getDoubleList

      public List<Double> getDoubleList(String key)
      Get Double List value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getFloatList

      public List<Float> getFloatList(String key)
      Get Float List value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getLongList

      public List<Long> getLongList(String key)
      Get Long List value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getByteList

      public List<Byte> getByteList(String key)
      Get Byte List value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getCharacterList

      public List<Character> getCharacterList(String key)
      Get Character List value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getShortList

      public List<Short> getShortList(String key)
      Get Short List value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • getMapList

      public List<Map> getMapList(String key)
      Get Map List value of config section element
      Parameters:
      key - - key (inside) current section
      Returns:
    • exists

      public boolean exists(String key, boolean ignoreCase)
      Check existence of config section element
      Parameters:
      key -
      ignoreCase -
      Returns:
    • exists

      public boolean exists(String key)
      Check existence of config section element
      Parameters:
      key -
      Returns:
    • remove

      public void remove(String key)
      Remove config section element
      Parameters:
      key -
    • getKeys

      public Set<String> getKeys(boolean child)
      Get all keys
      Parameters:
      child - - true = include child keys
      Returns:
    • getKeys

      public Set<String> getKeys()
      Get all keys
      Returns: