@ThreadSafe public class ConfigSection extends Object
Modifier | Constructor and Description |
---|---|
protected |
ConfigSection()
Instantiated by subclasses only
|
protected |
ConfigSection(ConfigSection parent,
com.google.gson.JsonObject obj)
Creates a config section for the parent section
|
Modifier and Type | Method and Description |
---|---|
<V> List<V> |
addList(String tag,
Class<V> type)
Adds an empty list into the tag
|
static <V> ConfigSection |
addToList(Collection<V> list)
Gets a config section with the elements defined in the specified collection
|
com.google.gson.JsonObject |
asJsonObject()
As JSON form
|
boolean |
contains(String tag)
Checks to see if the section contains the tag
|
Set<Map.Entry<String,com.google.gson.JsonElement>> |
entries()
Obtains the set of the topmost key-value entries
|
BigDecimal |
getBigDecimal(String tag)
Gets a BigDecimal at the specified tag
|
BigDecimal |
getBigDecimal(String tag,
BigDecimal def)
Gets a BigDecimal at the specified tag, defaulting to the fallback if not found
|
BigInteger |
getBigInteger(String tag)
Gets the BigInteger at the tag
|
BigInteger |
getBigInteger(String tag,
BigInteger def)
Gets a BigInteger from the section, defaulting the the fallback if not found
|
boolean |
getBoolean(String tag)
Gets a boolean from the config with the given tag
|
boolean |
getBoolean(String tag,
boolean def)
Gets a boolean from the config with the given tag, defaulting to the fallback if the tag is not found
|
byte |
getByte(String tag)
Gets a character from the config with the given tag
|
byte |
getByte(String tag,
byte def)
Gets a byte from the config with the given tag, defaulting to the fallback if the tag is not found
|
char |
getChar(String tag)
Gets a character from the config with the given tag
|
char |
getChar(String tag,
char def)
Gets a character from the config with the given tag, or defaults to the fallback if the tag is not found
|
ConfigSection |
getConfigSection(String tag)
Gets a sub section which has the current section as a parent
|
double |
getDouble(String tag)
Gets a double from the config with the given tag
|
double |
getDouble(String tag,
double def)
Gets a double from the config with the given tag, or defaults to the fallback if the tag is not found
|
float |
getFloat(String tag)
Gets an float from the config with the given tag
|
float |
getFloat(String tag,
float def)
Gets a float from the config with the given tag, or defaults to the fallback if the tag is not found
|
int |
getInt(String tag)
Gets an integer from the config with the given tag
|
int |
getInt(String tag,
int def)
Gets an integer from the config with the given tag, or defaults to the fallback if the tag is not found
|
<V> List<V> |
getList(String tag,
Class<V> type)
Gets the list at the tag
|
<V> V |
getObject(String tag,
Class<V> clazz)
Gets the Object at the specified tag
|
String |
getString(String tag) |
String |
getString(String tag,
String def)
Gets the string at the specified tag, defaulting to the specified default if not found
|
Set<String> |
keys()
Returns all of the topmost keys.
|
ConfigSection |
parentSection()
The section parent
|
void |
remove(String tag)
Removes the tag from the configuration
|
Config |
rootSection()
The JSON root from the parent
|
void |
save()
Saves the parent data
|
void |
setBigDecimal(String tag,
BigDecimal bd)
Sets the
BigDecimal the specified tag |
void |
setBigInteger(String s,
BigInteger bi)
Sets the
BigInteger the specified tag |
void |
setBoolean(String tag,
boolean b)
Sets the boolean the specified tag
|
void |
setByte(String tag,
byte b)
Sets the byte the specified tag
|
void |
setChar(String tag,
char c)
Sets a character at the tag to the specified character
|
void |
setDouble(String tag,
double d)
Sets a double at the tag to a specified double
|
void |
setFloat(String tag,
float f)
Sets the float at the tag to a specified float
|
void |
setInt(String tag,
int in)
Sets the value at the tag to a specified integer
|
void |
setObject(String tag,
Object object)
Sets the object at the specified tag
|
void |
setString(String tag,
String s)
Sets the string the specified tag
|
Collection<com.google.gson.JsonElement> |
values()
Returns the topmost values
|
protected ConfigSection()
protected ConfigSection(ConfigSection parent, com.google.gson.JsonObject obj)
parent
- the section to be sub-sectioned underobj
- the section handler, used to store valuespublic static <V> ConfigSection addToList(Collection<V> list)
V
- the type in the collectionlist
- the collection of objects to serialize to a config sectionpublic int getInt(String tag, int def)
tag
- the tag to find the value fromdef
- the default value if no tag is foundpublic int getInt(String tag)
Gives 0
if the value could not be found
tag
- the tag to find the value frompublic void setInt(String tag, int in)
tag
- the tag to set the valuein
- the integer value to set the tagpublic double getDouble(String tag, double def)
tag
- the tag to find the value fromdef
- the default value if no tag is foundpublic double getDouble(String tag)
Gives 0.0D
if the value could not be found
tag
- the tag to find the value frompublic void setDouble(String tag, double d)
tag
- the tag to set the valued
- the double to set to the tagpublic float getFloat(String tag, float def)
tag
- the tag to find the value fromdef
- the default value if no tag is foundpublic float getFloat(String tag)
Gives 0.0F if the value could not be found
tag
- the tag to find the value frompublic void setFloat(String tag, float f)
tag
- the tag to set the valuef
- the float to set the tag topublic char getChar(String tag, char def)
tag
- the tag to find the value fromdef
- the default value if no tag is found