Package cn.nukkit.utils
Class ConfigSection
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,
Object>
- Since:
- 26.04.2016
- Author:
- fromgate
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
ConstructorDescriptionEmpty ConfigSection constructorConfigSection
(String key, Object value) Constructor of ConfigSection that contains initial key/value dataConstructor of ConfigSection, based on values stored in map. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check existence of config section elementboolean
Check existence of config section elementGet object by key.<T> T
Get object by key.getAll()
Get new instance of config sectionGet root section as LinkedHashMapboolean
getBoolean
(String key) Get boolean value of config section elementboolean
getBoolean
(String key, boolean defaultValue) Get boolean value of config section elementgetBooleanList
(String key) Get Boolean List value of config section elementgetByteList
(String key) Get Byte List value of config section elementgetCharacterList
(String key) Get Character List value of config section elementdouble
Get double value of config section elementdouble
Get double value of config section elementgetDoubleList
(String key) Get Double List value of config section elementgetFloatList
(String key) Get Float List value of config section elementint
Get int value of config section elementint
Get int value of config section elementgetIntegerList
(String key) Get Integer List value of config section elementgetKeys()
Get all keysgetKeys
(boolean child) Get all keysGet List value of config section elementGet List value of config section elementlong
Get long value of config section elementlong
Get long value of config section elementgetLongList
(String key) Get Long List value of config section elementgetMapList
(String key) Get Map List value of config section elementgetSection
(String key) Get config section element defined by keyGet all ConfigSections in root path.getSections
(String key) Get sections (and only sections) from provided pathgetShortList
(String key) Get Short List value of config section elementGet String value of config section elementGet String value of config section elementgetStringList
(String key) Get String List value of config section elementboolean
Check type of section element defined by key.boolean
Check type of section element defined by key.boolean
Check type of section element defined by key.boolean
Check type of section element defined by key.boolean
Check type of section element defined by key.boolean
Check type of section element defined by key.boolean
Check type of section element defined by key.void
Remove config section elementvoid
Store value into config sectionMethods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Constructor Details
-
ConfigSection
public ConfigSection()Empty ConfigSection constructor -
ConfigSection
Constructor of ConfigSection that contains initial key/value data- Parameters:
key
-value
-
-
ConfigSection
Constructor of ConfigSection, based on values stored in map.- Parameters:
map
-
-
-
Method Details
-
getAllMap
Get root section as LinkedHashMap- Returns:
-
getAll
Get new instance of config section- Returns:
-
get
Get object by key. If section does not contain value, return null -
get
Get object by key. If section does not contain value, return default value- Parameters:
key
-defaultValue
-- Returns:
-
set
Store value into config section- Parameters:
key
-value
-
-
isSection
Check type of section element defined by key. Return true this element is ConfigSection- Parameters:
key
-- Returns:
-
getSection
Get config section element defined by key- Parameters:
key
-- Returns:
-
getSections
Get all ConfigSections in root path. Example config: a1: b1: c1: c2: a2: b2: c3: c4: a3: true a4: "hello" a5: 100getSections() will return new ConfigSection, that contains sections a1 and a2 only.
- Returns:
-
getSections
Get sections (and only sections) from provided path- Parameters:
key
- - config section path, if null or empty root path will used.- Returns:
-
getInt
Get int value of config section element- Parameters:
key
- - key (inside) current section (default value equals to 0)- Returns:
-
getInt
Get int value of config section element- Parameters:
key
- - key (inside) current sectiondefaultValue
- - default value that will returned if section element is not exists- Returns:
-
isInt
Check type of section element defined by key. Return true this element is Integer- Parameters:
key
-- Returns:
-
getLong
Get long value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getLong
Get long value of config section element- Parameters:
key
- - key (inside) current sectiondefaultValue
- - default value that will returned if section element is not exists- Returns:
-
isLong
Check type of section element defined by key. Return true this element is Long- Parameters:
key
-- Returns:
-
getDouble
Get double value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getDouble
Get double value of config section element- Parameters:
key
- - key (inside) current sectiondefaultValue
- - default value that will returned if section element is not exists- Returns:
-
isDouble
Check type of section element defined by key. Return true this element is Double- Parameters:
key
-- Returns:
-
getString
Get String value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getString
Get String value of config section element- Parameters:
key
- - key (inside) current sectiondefaultValue
- - default value that will returned if section element is not exists- Returns:
-
isString
Check type of section element defined by key. Return true this element is String- Parameters:
key
-- Returns:
-
getBoolean
Get boolean value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getBoolean
Get boolean value of config section element- Parameters:
key
- - key (inside) current sectiondefaultValue
- - default value that will returned if section element is not exists- Returns:
-
isBoolean
Check type of section element defined by key. Return true this element is Integer- Parameters:
key
-- Returns:
-
getList
Get List value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getList
Get List value of config section element- Parameters:
key
- - key (inside) current sectiondefaultList
- - default value that will returned if section element is not exists- Returns:
-
isList
Check type of section element defined by key. Return true this element is List- Parameters:
key
-- Returns:
-
getStringList
Get String List value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getIntegerList
Get Integer List value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getBooleanList
Get Boolean List value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getDoubleList
Get Double List value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getFloatList
Get Float List value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getLongList
Get Long List value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getByteList
Get Byte List value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getCharacterList
Get Character List value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getShortList
Get Short List value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
getMapList
Get Map List value of config section element- Parameters:
key
- - key (inside) current section- Returns:
-
exists
Check existence of config section element- Parameters:
key
-ignoreCase
-- Returns:
-
exists
Check existence of config section element- Parameters:
key
-- Returns:
-
remove
Remove config section element- Parameters:
key
-
-
getKeys
Get all keys- Parameters:
child
- - true = include child keys- Returns:
-
getKeys
Get all keys- Returns:
-