Package com.sk89q.util.yaml
Class YAMLNode
java.lang.Object
com.sk89q.util.yaml.YAMLNode
- Direct Known Subclasses:
YAMLProcessor
Represents a configuration node.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a new node to the given path.void
clear()
Clear all nodes.getBlockVector2List
(String path, List<BlockVector2> def) Gets a list of 2D vectors.getBoolean
(String path) Gets a boolean at a location.boolean
getBoolean
(String path, boolean def) Gets a boolean at a location.getBooleanList
(String path, List<Boolean> def) Gets a list of booleans.Gets a double at a location.double
Gets a double at a location.getDoubleList
(String path, List<Double> def) Gets a list of doubles.Gets an integer at a location.int
Gets an integer at a location.getIntList
(String path, List<Integer> def) Gets a list of integers.Get a list of keys at a location.Gets a list of objects at a location.getMap()
Return the underlying map.Get a configuration node at a path.getNodeList
(String path, List<YAMLNode> def) Gets a list of nodes.Get a list of nodes at a location.getProperty
(String path) Gets a property at a location.Gets a string at a location.Gets a string at a location.getStringList
(String path, List<String> def) Gets a list of strings.Gets a vector at a location.Gets a string at a location.getVector2
(String path) Gets a 2D vector at a location.getVector2List
(String path, List<Vector2> def) Gets a list of 2D vectors.getVectorList
(String path, List<Vector3> def) Gets a list of vectors.void
removeProperty
(String path) Remove the property at a location.void
setProperty
(String path, Object value) Set the property at a location.void
setWriteDefaults
(boolean writeDefaults) boolean
-
Field Details
-
root
-
-
Constructor Details
-
YAMLNode
-
-
Method Details
-
getMap
Return the underlying map.- Returns:
- the map
-
clear
public void clear()Clear all nodes. -
getProperty
Gets a property at a location. This will either return an Object or null, with null meaning that no configuration value exists at that location. This could potentially return a default value (not yet implemented) as defined by a plugin, if this is a plugin-tied configuration.- Parameters:
path
- path to node (dot notation)- Returns:
- object or null
-
setProperty
Set the property at a location. This will override existing configuration data to have it conform to key/value mappings.- Parameters:
path
- the pathvalue
- the new value
-
addNode
Adds a new node to the given path. The returned object is a reference to the new node. This method will replace an existing node at the same path. SeesetProperty
.- Parameters:
path
- the path- Returns:
- a node for the path
-
getString
Gets a string at a location. This will either return an String or null, with null meaning that no configuration value exists at that location. If the object at the particular location is not actually a string, it will be converted to its string representation.- Parameters:
path
- path to node (dot notation)- Returns:
- string or null
-
getVector
Gets a vector at a location. This will either return an Vector or a null. If the object at the particular location is not actually a string, it will be converted to its string representation.- Parameters:
path
- path to node (dot notation)- Returns:
- string or default
-
getVector2
Gets a 2D vector at a location. This will either return an Vector or a null. If the object at the particular location is not actually a string, it will be converted to its string representation.- Parameters:
path
- path to node (dot notation)- Returns:
- string or default
-
getVector
Gets a string at a location. This will either return an Vector or the default value. If the object at the particular location is not actually a string, it will be converted to its string representation.- Parameters:
path
- path to node (dot notation)def
- default value- Returns:
- string or default
-
getString
Gets a string at a location. This will either return an String or the default value. If the object at the particular location is not actually a string, it will be converted to its string representation.- Parameters:
path
- path to node (dot notation)def
- default value- Returns:
- string or default
-
getInt
Gets an integer at a location. This will either return an integer or null. If the object at the particular location is not actually a integer, the default value will be returned. However, other number types will be casted to an integer.- Parameters:
path
- path to node (dot notation)- Returns:
- integer or null
-
getInt
Gets an integer at a location. This will either return an integer or the default value. If the object at the particular location is not actually a integer, the default value will be returned. However, other number types will be casted to an integer.- Parameters:
path
- path to node (dot notation)def
- default value- Returns:
- int or default
-
getDouble
Gets a double at a location. This will either return an double or null. If the object at the particular location is not actually a double, the default value will be returned. However, other number types will be casted to an double.- Parameters:
path
- path to node (dot notation)- Returns:
- double or null
-
getDouble
Gets a double at a location. This will either return an double or the default value. If the object at the particular location is not actually a double, the default value will be returned. However, other number types will be casted to an double.- Parameters:
path
- path to node (dot notation)def
- default value- Returns:
- double or default
-
getBoolean
Gets a boolean at a location. This will either return an boolean or null. If the object at the particular location is not actually a boolean, the default value will be returned.- Parameters:
path
- path to node (dot notation)- Returns:
- boolean or null
-
getBoolean
Gets a boolean at a location. This will either return an boolean or the default value. If the object at the particular location is not actually a boolean, the default value will be returned.- Parameters:
path
- path to node (dot notation)def
- default value- Returns:
- boolean or default
-
getKeys
Get a list of keys at a location. If the map at the particular location does not exist or it is not a map, null will be returned.- Parameters:
path
- path to node (dot notation)- Returns:
- list of keys
-
getList
Gets a list of objects at a location. If the list is not defined, null will be returned. The node must be an actual list.- Parameters:
path
- path to node (dot notation)- Returns:
- boolean or default
-
getStringList
Gets a list of strings. Non-valid entries will not be in the list. There will be no null slots. If the list is not defined, the default will be returned. 'null' can be passed for the default and an empty list will be returned instead. If an item in the list is not a string, it will be converted to a string. The node must be an actual list and not just a string.- Parameters:
path
- path to node (dot notation)def
- default value or null for an empty list as default- Returns:
- list of strings
-
getIntList
Gets a list of integers. Non-valid entries will not be in the list. There will be no null slots. If the list is not defined, the default will be returned. 'null' can be passed for the default and an empty list will be returned instead. The node must be an actual list and not just an integer.- Parameters:
path
- path to node (dot notation)def
- default value or null for an empty list as default- Returns:
- list of integers
-
getDoubleList
Gets a list of doubles. Non-valid entries will not be in the list. There will be no null slots. If the list is not defined, the default will be returned. 'null' can be passed for the default and an empty list will be returned instead. The node must be an actual list and cannot be just a double.- Parameters:
path
- path to node (dot notation)def
- default value or null for an empty list as default- Returns:
- list of integers
-
getBooleanList
Gets a list of booleans. Non-valid entries will not be in the list. There will be no null slots. If the list is not defined, the default will be returned. 'null' can be passed for the default and an empty list will be returned instead. The node must be an actual list and cannot be just a boolean,- Parameters:
path
- path to node (dot notation)def
- default value or null for an empty list as default- Returns:
- list of integers
-
getVectorList
Gets a list of vectors. Non-valid entries will not be in the list. There will be no null slots. If the list is not defined, the default will be returned. 'null' can be passed for the default and an empty list will be returned instead. The node must be an actual node and cannot be just a vector,- Parameters:
path
- path to node (dot notation)def
- default value or null for an empty list as default- Returns:
- list of integers
-
getVector2List
Gets a list of 2D vectors. Non-valid entries will not be in the list. There will be no null slots. If the list is not defined, the default will be returned. 'null' can be passed for the default and an empty list will be returned instead. The node must be an actual node and cannot be just a vector,- Parameters:
path
- path to node (dot notation)def
- default value or null for an empty list as default- Returns:
- list of integers
-
getBlockVector2List
Gets a list of 2D vectors. Non-valid entries will not be in the list. There will be no null slots. If the list is not defined, the default will be returned. 'null' can be passed for the default and an empty list will be returned instead. The node must be an actual node and cannot be just a vector,- Parameters:
path
- path to node (dot notation)def
- default value or null for an empty list as default- Returns:
- list of integers
-
getNodeList
Gets a list of nodes. Non-valid entries will not be in the list. There will be no null slots. If the list is not defined, the default will be returned. 'null' can be passed for the default and an empty list will be returned instead. The node must be an actual node and cannot be just a boolean,- Parameters:
path
- path to node (dot notation)def
- default value or null for an empty list as default- Returns:
- list of integers
-
getNode
Get a configuration node at a path. If the node doesn't exist or the path does not lead to a node, null will be returned. A node has key/value mappings.- Parameters:
path
- the path- Returns:
- node or null
-
getNodes
Get a list of nodes at a location. If the map at the particular location does not exist or it is not a map, null will be returned.- Parameters:
path
- path to node (dot notation)- Returns:
- map of nodes
-
removeProperty
Remove the property at a location. This will override existing configuration data to have it conform to key/value mappings.- Parameters:
path
- a path
-
writeDefaults
public boolean writeDefaults() -
setWriteDefaults
public void setWriteDefaults(boolean writeDefaults)
-