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 a 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 a 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 a 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 a 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 a 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 an 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 an 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:
- Integer or default
-
getDouble
Gets a double at a location. This will either return a 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 a Double.- Parameters:
path
- path to node (dot notation)- Returns:
- Double or null
-
getDouble
Gets a double at a location. This will either return a 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 a 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 a 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 a 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 Doubles
-
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 Booleans
-
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 vectors
-
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 vectors
-
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 vectors
-
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 aYAMLNode
.- Parameters:
path
- path to node (dot notation)def
- default value or null for an empty list as default- Returns:
- list of nodes
-
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)
-