Package ch.njol.skript.config
Class SectionNode
java.lang.Object
ch.njol.skript.config.Node
ch.njol.skript.config.SectionNode
- All Implemented Interfaces:
NodeNavigator,AnyNamed,AnyProvider,Iterable<Node>,Validated
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInsertsnodeinto this section at the specified position.voidAdds the given node at the end of this section.booleancompareValues(SectionNode other, String... excluded) Compares the keys and values of this SectionNode and another.voidconvertToEntries(int levels) Converts all SimpleNodes in this section to EntryNodes.voidconvertToEntries(int levels, String separator) REMIND breaks saving - separator argument can be different from config.sepator@Nullable NodeGets a subnode (EntryNode or SectionNode) with the specified name.Gets an entry's value or the default value if it doesn't exist or is not an EntryNode.@Nullable NodeFetches a node at position inside the current node.@Nullable StringGets the raw value from the node at the given path.voidDeprecated, for removal: This API element is subject to removal in a future version.booleanisEmpty()booleanisValid()iterator()If this navigator represents a node with no children (e.g.voidRemoves the given node from this section.@Nullable NodeRemoves an entry with the given key.voidsave(PrintWriter w) voidvoidbooleansetValues(SectionNode other, String... excluded) Updates the values of this SectionNode based on the values of another SectionNode.intsize()booleanvalidate(SectionValidator validator) Methods inherited from class ch.njol.skript.config.Node
debug, equals, getComment, getConfig, getCurrentNode, getIndentation, getKey, getLine, getParent, getPath, getPathSteps, hashCode, invalidate, isVoid, move, name, remove, rename, save, splitLine, splitLine, toString, validMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.njol.skript.lang.util.common.AnyNamed
setName, supportsNameChangeMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface ch.njol.skript.config.NodeNavigator
getNodeAt
-
Constructor Details
-
SectionNode
-
-
Method Details
-
size
public int size()- Returns:
- Total amount of nodes (including void nodes) in this section.
-
add
Adds the given node at the end of this section.- Parameters:
n-
-
add
Insertsnodeinto this section at the specified position.- Parameters:
index- The index, between 0 andsize()(inclusive), at which to insert the nodenode- The node to insert
-
insert
Deprecated, for removal: This API element is subject to removal in a future version.Useadd(int, Node)instead. -
remove
Removes the given node from this section.- Parameters:
n-
-
remove
Removes an entry with the given key.- Parameters:
key-- Returns:
- The removed node, or null if the key didn't match any node.
-
iterator
Description copied from interface:NodeNavigatorIf this navigator represents a node with no children (e.g. an entry node) this iterator will be empty.- Specified by:
iteratorin interfaceIterable<Node>- Specified by:
iteratorin interfaceNodeNavigator- Returns:
- An iterator over all non-void nodes in this section.
-
fullIterator
- Returns:
- An iterator over all nodes in this section, including void nodes.
-
get
Gets a subnode (EntryNode or SectionNode) with the specified name.- Specified by:
getin interfaceNodeNavigator- Parameters:
key-- Returns:
- The node with the given name
-
getValue
Description copied from interface:NodeNavigatorGets the raw value from the node at the given path. If any part of the path is invalid, this will return null.- Specified by:
getValuein interfaceNodeNavigator- Parameters:
key- The node path from which to get the value- Returns:
- If such a node exists, its value, otherwise null
-
get
Gets an entry's value or the default value if it doesn't exist or is not an EntryNode.- Parameters:
name- The name of the node (case insensitive)def- The default value- Returns:
- The value of the entry node with the give node, or def if there's no entry with the given name.
-
set
-
set
-
isEmpty
public boolean isEmpty() -
convertToEntries
public void convertToEntries(int levels) Converts all SimpleNodes in this section to EntryNodes.- Parameters:
levels- Amount of levels to go down, e.g. 0 to only convert direct subnodes of this section or -1 for all subnodes including subnodes of subnodes etc.
-
convertToEntries
REMIND breaks saving - separator argument can be different from config.sepator- Parameters:
levels- Maximum depth of recursion, -1 for no limit.separator- Some separator, e.g. ":" or "=".
-
save
-
validate
-
isValid
public boolean isValid()- Returns:
- True if this section and all children are valid, i.e. they contain no invalid nodes.
-
setValues
Updates the values of this SectionNode based on the values of another SectionNode.- Parameters:
other- The other SectionNode.excluded- Keys to exclude from this update.- Returns:
- True if there are differences in the keys of this SectionNode and the other SectionNode.
-
compareValues
Compares the keys and values of this SectionNode and another.- Parameters:
other- The other SectionNode.excluded- Keys to exclude from this comparison.- Returns:
- True if there are no differences in the keys and their values of this SectionNode and the other SectionNode.
-
getNodeAt
Description copied from interface:NodeNavigatorFetches a node at position inside the current node. If any stage represents a node with no children (e.g. an entry node) the result will be null.
In the following example, the two entry nodes can be obtained from the root with"first", "one"and"first", "two", "three"(respectively).first: one: value two: three: value- Specified by:
getNodeAtin interfaceNodeNavigator- Parameters:
keys- The node steps to traverse- Returns:
- The node at the final step (or nothing)
-
add(int, Node)instead.