|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bukkit.configuration.MemorySection
public class MemorySection
A type of ConfigurationSection
that is stored in memory.
Field Summary | |
---|---|
protected Map<String,Object> |
map
|
Constructor Summary | |
---|---|
protected |
MemorySection()
Creates an empty MemorySection for use as a root Configuration section. |
protected |
MemorySection(ConfigurationSection parent,
String path)
Creates an empty MemorySection with the specified parent and path. |
Method Summary | |
---|---|
void |
addDefault(String path,
Object value)
Sets the default value in the root at the given path as provided. |
boolean |
contains(String path)
Checks if this ConfigurationSection contains the given path. |
static String |
createPath(ConfigurationSection section,
String key)
Creates a full path to the given ConfigurationSection from its root Configuration . |
static String |
createPath(ConfigurationSection section,
String key,
ConfigurationSection relativeTo)
Creates a relative path to the given ConfigurationSection from the given relative section. |
ConfigurationSection |
createSection(String path)
Creates an empty ConfigurationSection at the specified path. |
ConfigurationSection |
createSection(String path,
Map<?,?> map)
Creates a ConfigurationSection at the specified path, with specified values. |
Object |
get(String path)
Gets the requested Object by path. |
Object |
get(String path,
Object def)
Gets the requested Object by path, returning a default value if not found. |
boolean |
getBoolean(String path)
Gets the requested boolean by path. |
boolean |
getBoolean(String path,
boolean def)
Gets the requested boolean by path, returning a default value if not found. |
List<Boolean> |
getBooleanList(String path)
Gets the requested List of Boolean by path. |
List<Byte> |
getByteList(String path)
Gets the requested List of Byte by path. |
List<Character> |
getCharacterList(String path)
Gets the requested List of Character by path. |
Color |
getColor(String path)
Gets the requested Color by path. |
Color |
getColor(String path,
Color def)
Gets the requested Color by path, returning a default value if not found. |
ConfigurationSection |
getConfigurationSection(String path)
Gets the requested ConfigurationSection by path. |
String |
getCurrentPath()
Gets the path of this ConfigurationSection from its root Configuration
For any Configuration themselves, this will return an empty string. |
protected Object |
getDefault(String path)
|
ConfigurationSection |
getDefaultSection()
Gets the equivalent ConfigurationSection from the default Configuration defined in ConfigurationSection.getRoot() . |
double |
getDouble(String path)
Gets the requested double by path. |
double |
getDouble(String path,
double def)
Gets the requested double by path, returning a default value if not found. |
List<Double> |
getDoubleList(String path)
Gets the requested List of Double by path. |
List<Float> |
getFloatList(String path)
Gets the requested List of Float by path. |
int |
getInt(String path)
Gets the requested int by path. |
int |
getInt(String path,
int def)
Gets the requested int by path, returning a default value if not found. |
List<Integer> |
getIntegerList(String path)
Gets the requested List of Integer by path. |
ItemStack |
getItemStack(String path)
Gets the requested ItemStack by path. |
ItemStack |
getItemStack(String path,
ItemStack def)
Gets the requested ItemStack by path, returning a default value if not found. |
Set<String> |
getKeys(boolean deep)
Gets a set containing all keys in this section. |
List<?> |
getList(String path)
Gets the requested List by path. |
List<?> |
getList(String path,
List<?> def)
Gets the requested List by path, returning a default value if not found. |
long |
getLong(String path)
Gets the requested long by path. |
long |
getLong(String path,
long def)
Gets the requested long by path, returning a default value if not found. |
List<Long> |
getLongList(String path)
Gets the requested List of Long by path. |
List<Map<?,?>> |
getMapList(String path)
Gets the requested List of Maps by path. |
String |
getName()
Gets the name of this individual ConfigurationSection , in the path. |
OfflinePlayer |
getOfflinePlayer(String path)
Gets the requested OfflinePlayer by path. |
OfflinePlayer |
getOfflinePlayer(String path,
OfflinePlayer def)
Gets the requested OfflinePlayer by path, returning a default value if not found. |
ConfigurationSection |
getParent()
Gets the parent ConfigurationSection that directly contains this
ConfigurationSection . |
Configuration |
getRoot()
Gets the root Configuration that contains this ConfigurationSection
For any Configuration themselves, this will return its own object. |
List<Short> |
getShortList(String path)
Gets the requested List of Short by path. |
String |
getString(String path)
Gets the requested String by path. |
String |
getString(String path,
String def)
Gets the requested String by path, returning a default value if not found. |
List<String> |
getStringList(String path)
Gets the requested List of String by path. |
Map<String,Object> |
getValues(boolean deep)
Gets a Map containing all keys and their values for this section. |
Vector |
getVector(String path)
Gets the requested Vector by path. |
Vector |
getVector(String path,
Vector def)
Gets the requested Vector by path, returning a default value if not found. |
boolean |
isBoolean(String path)
Checks if the specified path is a boolean. |
boolean |
isColor(String path)
Checks if the specified path is a Color. |
boolean |
isConfigurationSection(String path)
Checks if the specified path is a ConfigurationSection. |
boolean |
isDouble(String path)
Checks if the specified path is a double. |
boolean |
isInt(String path)
Checks if the specified path is an int. |
boolean |
isItemStack(String path)
Checks if the specified path is an ItemStack. |
boolean |
isList(String path)
Checks if the specified path is a List. |
boolean |
isLong(String path)
Checks if the specified path is a long. |
boolean |
isOfflinePlayer(String path)
Checks if the specified path is an OfflinePlayer. |
protected boolean |
isPrimitiveWrapper(Object input)
|
boolean |
isSet(String path)
Checks if this ConfigurationSection has a value set for the given path. |
boolean |
isString(String path)
Checks if the specified path is a String. |
boolean |
isVector(String path)
Checks if the specified path is a Vector. |
protected void |
mapChildrenKeys(Set<String> output,
ConfigurationSection section,
boolean deep)
|
protected void |
mapChildrenValues(Map<String,Object> output,
ConfigurationSection section,
boolean deep)
|
void |
set(String path,
Object value)
Sets the specified path to the given value. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final Map<String,Object> map
Constructor Detail |
---|
protected MemorySection()
Configuration
section.
Note that calling this without being yourself a Configuration
will throw an
exception!
IllegalStateException
- Thrown if this is not a Configuration
root.protected MemorySection(ConfigurationSection parent, String path)
parent
- Parent section that contains this own section.path
- Path that you may access this section from via the root Configuration
.
IllegalArgumentException
- Thrown is parent or path is null, or if parent contains no root Configuration.Method Detail |
---|
public Set<String> getKeys(boolean deep)
ConfigurationSection
ConfigurationSection
s (and their children, etc). These will be in a
valid path notation for you to use.
If deep is set to false, then this will contain only the keys of any direct children,
and not their own children.
getKeys
in interface ConfigurationSection
deep
- Whether or not to get a deep list, as opposed to a shallow list.
public Map<String,Object> getValues(boolean deep)
ConfigurationSection
ConfigurationSection
s (and their children, etc). These
keys will be in a valid path notation for you to use.
If deep is set to false, then this will contain only the keys and values of any
direct children, and not their own children.
getValues
in interface ConfigurationSection
deep
- Whether or not to get a deep list, as opposed to a shallow list.
public boolean contains(String path)
ConfigurationSection
ConfigurationSection
contains the given path.
If the value for the requested path does not exist but a default value has
been specified, this will return true.
contains
in interface ConfigurationSection
path
- Path to check for existence.
public boolean isSet(String path)
ConfigurationSection
ConfigurationSection
has a value set for the given path.
If the value for the requested path does not exist but a default value has
been specified, this will still return false.
isSet
in interface ConfigurationSection
path
- Path to check for existence.
public String getCurrentPath()
ConfigurationSection
ConfigurationSection
from its root Configuration
For any Configuration
themselves, this will return an empty string.
If the section is no longer contained within its root for any reason, such as
being replaced with a different value, this may return null.
To retrieve the single name of this section, that is, the final part of the path
returned by this method, you may use ConfigurationSection.getName()
.
getCurrentPath
in interface ConfigurationSection
public String getName()
ConfigurationSection
ConfigurationSection
, in the path.
This will always be the final part of ConfigurationSection.getCurrentPath()
, unless the
section is orphaned.
getName
in interface ConfigurationSection
public Configuration getRoot()
ConfigurationSection
Configuration
that contains this ConfigurationSection
For any Configuration
themselves, this will return its own object.
If the section is no longer contained within its root for any reason, such as
being replaced with a different value, this may return null.
getRoot
in interface ConfigurationSection
public ConfigurationSection getParent()
ConfigurationSection
ConfigurationSection
that directly contains this
ConfigurationSection
.
For any Configuration
themselves, this will return null.
If the section is no longer contained within its parent for any reason, such as
being replaced with a different value, this may return null.
getParent
in interface ConfigurationSection
public void addDefault(String path, Object value)
ConfigurationSection
Configuration
was provided as a default collection,
then a new MemoryConfiguration
will be created to hold the new default
value.
If value is null, the value will be removed from the default Configuration source.
If the value as returned by ConfigurationSection.getDefaultSection()
is null,
then this will create a new section at the path, replacing anything that
may have existed there previously.
addDefault
in interface ConfigurationSection
path
- Path of the value to set.value
- Value to set the default to.public ConfigurationSection getDefaultSection()
ConfigurationSection
ConfigurationSection
from the default Configuration
defined in ConfigurationSection.getRoot()
.
If the root contains no defaults, or the defaults doesn't contain a value
for this path, or the value at this path is not a ConfigurationSection
then
this will return null.
getDefaultSection
in interface ConfigurationSection
public void set(String path, Object value)
ConfigurationSection
Configuration
s or ConfigurationSection
s, please use
ConfigurationSection.createSection(java.lang.String)
for that.
set
in interface ConfigurationSection
path
- Path of the object to set.value
- New value to set the path to.public Object get(String path)
ConfigurationSection
get
in interface ConfigurationSection
path
- Path of the Object to get.
public Object get(String path, Object def)
ConfigurationSection
Configuration
.
get
in interface ConfigurationSection
path
- Path of the Object to get.def
- The default value to return if the path is not found.
public ConfigurationSection createSection(String path)
ConfigurationSection
ConfigurationSection
at the specified path.
Any value that was previously set at this path will be overwritten. If the
previous value was itself a ConfigurationSection
, it will be orphaned.
createSection
in interface ConfigurationSection
path
- Path to create the section at.
public ConfigurationSection createSection(String path, Map<?,?> map)
ConfigurationSection
ConfigurationSection
at the specified path, with specified values.
Any value that was previously set at this path will be overwritten. If the
previous value was itself a ConfigurationSection
, it will be orphaned.
createSection
in interface ConfigurationSection
path
- Path to create the section at.map
- The values to used.
public String getString(String path)
ConfigurationSection
getString
in interface ConfigurationSection
path
- Path of the String to get.
public String getString(String path, String def)
ConfigurationSection
Configuration
.
getString
in interface ConfigurationSection
path
- Path of the String to get.def
- The default value to return if the path is not found or is not a String.
public boolean isString(String path)
ConfigurationSection
isString
in interface ConfigurationSection
path
- Path of the String to check.
public int getInt(String path)
ConfigurationSection
getInt
in interface ConfigurationSection
path
- Path of the int to get.
public int getInt(String path, int def)
ConfigurationSection
Configuration
.
getInt
in interface ConfigurationSection
path
- Path of the int to get.def
- The default value to return if the path is not found or is not an int.
public boolean isInt(String path)
ConfigurationSection
isInt
in interface ConfigurationSection
path
- Path of the int to check.
public boolean getBoolean(String path)
ConfigurationSection
getBoolean
in interface ConfigurationSection
path
- Path of the boolean to get.
public boolean getBoolean(String path, boolean def)
ConfigurationSection
Configuration
.
getBoolean
in interface ConfigurationSection
path
- Path of the boolean to get.def
- The default value to return if the path is not found or is not a boolean.
public boolean isBoolean(String path)
ConfigurationSection
isBoolean
in interface ConfigurationSection
path
- Path of the boolean to check.
public double getDouble(String path)
ConfigurationSection
getDouble
in interface ConfigurationSection
path
- Path of the double to get.
public double getDouble(String path, double def)
ConfigurationSection
Configuration
.
getDouble
in interface ConfigurationSection
path
- Path of the double to get.def
- The default value to return if the path is not found or is not a double.
public boolean isDouble(String path)
ConfigurationSection
isDouble
in interface ConfigurationSection
path
- Path of the double to check.
public long getLong(String path)
ConfigurationSection
getLong
in interface ConfigurationSection
path
- Path of the long to get.
public long getLong(String path, long def)
ConfigurationSection
Configuration
.
getLong
in interface ConfigurationSection
path
- Path of the long to get.def
- The default value to return if the path is not found or is not a long.
public boolean isLong(String path)
ConfigurationSection
isLong
in interface ConfigurationSection
path
- Path of the long to check.
public List<?> getList(String path)
ConfigurationSection
getList
in interface ConfigurationSection
path
- Path of the List to get.
public List<?> getList(String path, List<?> def)
ConfigurationSection
Configuration
.
getList
in interface ConfigurationSection
path
- Path of the List to get.def
- The default value to return if the path is not found or is not a List.
public boolean isList(String path)
ConfigurationSection
isList
in interface ConfigurationSection
path
- Path of the List to check.
public List<String> getStringList(String path)
ConfigurationSection
getStringList
in interface ConfigurationSection
path
- Path of the List to get.
public List<Integer> getIntegerList(String path)
ConfigurationSection
getIntegerList
in interface ConfigurationSection
path
- Path of the List to get.
public List<Boolean> getBooleanList(String path)
ConfigurationSection
getBooleanList
in interface ConfigurationSection
path
- Path of the List to get.
public List<Double> getDoubleList(String path)
ConfigurationSection
getDoubleList
in interface ConfigurationSection
path
- Path of the List to get.
public List<Float> getFloatList(String path)
ConfigurationSection
getFloatList
in interface ConfigurationSection
path
- Path of the List to get.
public List<Long> getLongList(String path)
ConfigurationSection
getLongList
in interface ConfigurationSection
path
- Path of the List to get.
public List<Byte> getByteList(String path)
ConfigurationSection
getByteList
in interface ConfigurationSection
path
- Path of the List to get.
public List<Character> getCharacterList(String path)
ConfigurationSection
getCharacterList
in interface ConfigurationSection
path
- Path of the List to get.
public List<Short> getShortList(String path)
ConfigurationSection
getShortList
in interface ConfigurationSection
path
- Path of the List to get.
public List<Map<?,?>> getMapList(String path)
ConfigurationSection
getMapList
in interface ConfigurationSection
path
- Path of the List to get.
public Vector getVector(String path)
ConfigurationSection
getVector
in interface ConfigurationSection
path
- Path of the Vector to get.
public Vector getVector(String path, Vector def)
ConfigurationSection
Vector
by path, returning a default value if not found.
If the Vector does not exist then the specified default value will returned
regardless of if a default has been identified in the root Configuration
.
getVector
in interface ConfigurationSection
path
- Path of the Vector to get.def
- The default value to return if the path is not found or is not a Vector.
public boolean isVector(String path)
ConfigurationSection
isVector
in interface ConfigurationSection
path
- Path of the Vector to check.
public OfflinePlayer getOfflinePlayer(String path)
ConfigurationSection
getOfflinePlayer
in interface ConfigurationSection
path
- Path of the OfflinePlayer to get.
public OfflinePlayer getOfflinePlayer(String path, OfflinePlayer def)
ConfigurationSection
OfflinePlayer
by path, returning a default value if not found.
If the OfflinePlayer does not exist then the specified default value will returned
regardless of if a default has been identified in the root Configuration
.
getOfflinePlayer
in interface ConfigurationSection
path
- Path of the OfflinePlayer to get.def
- The default value to return if the path is not found or is not an OfflinePlayer.
public boolean isOfflinePlayer(String path)
ConfigurationSection
isOfflinePlayer
in interface ConfigurationSection
path
- Path of the OfflinePlayer to check.
public ItemStack getItemStack(String path)
ConfigurationSection
getItemStack
in interface ConfigurationSection
path
- Path of the ItemStack to get.
public ItemStack getItemStack(String path, ItemStack def)
ConfigurationSection
ItemStack
by path, returning a default value if not found.
If the ItemStack does not exist then the specified default value will returned
regardless of if a default has been identified in the root Configuration
.
getItemStack
in interface ConfigurationSection
path
- Path of the ItemStack to get.def
- The default value to return if the path is not found or is not an ItemStack.
public boolean isItemStack(String path)
ConfigurationSection
isItemStack
in interface ConfigurationSection
path
- Path of the ItemStack to check.
public Color getColor(String path)
ConfigurationSection
getColor
in interface ConfigurationSection
path
- Path of the Color to get.
public Color getColor(String path, Color def)
ConfigurationSection
Color
by path, returning a default value if not found.
If the Color does not exist then the specified default value will returned
regardless of if a default has been identified in the root Configuration
.
getColor
in interface ConfigurationSection
path
- Path of the Color to get.def
- The default value to return if the path is not found or is not an Color.
public boolean isColor(String path)
ConfigurationSection
isColor
in interface ConfigurationSection
path
- Path of the Color to check.
public ConfigurationSection getConfigurationSection(String path)
ConfigurationSection
getConfigurationSection
in interface ConfigurationSection
path
- Path of the ConfigurationSection to get.
public boolean isConfigurationSection(String path)
ConfigurationSection
isConfigurationSection
in interface ConfigurationSection
path
- Path of the ConfigurationSection to check.
protected boolean isPrimitiveWrapper(Object input)
protected Object getDefault(String path)
protected void mapChildrenKeys(Set<String> output, ConfigurationSection section, boolean deep)
protected void mapChildrenValues(Map<String,Object> output, ConfigurationSection section, boolean deep)
public static String createPath(ConfigurationSection section, String key)
ConfigurationSection
from its root Configuration
.
You may use this method for any given ConfigurationSection
, not only MemorySection
.
section
- Section to create a path for.key
- Name of the specified section.
public static String createPath(ConfigurationSection section, String key, ConfigurationSection relativeTo)
ConfigurationSection
from the given relative section.
You may use this method for any given ConfigurationSection
, not only MemorySection
.
section
- Section to create a path for.key
- Name of the specified section.relativeTo
- Section to create the path relative to.
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |