Class SectionNode

java.lang.Object
ch.njol.skript.config.Node
ch.njol.skript.config.SectionNode
All Implemented Interfaces:
Iterable<Node>

public class SectionNode extends Node implements Iterable<Node>
  • Constructor Details

  • Method Details

    • size

      public int size()
      Returns:
      Total amount of nodes (including void nodes) in this section.
    • add

      public void add(Node n)
      Adds the given node at the end of this section.
      Parameters:
      n -
    • insert

      public void insert(Node n, int index)
      Inserts the given node into this section at the specified position.
      Parameters:
      n -
      index - between 0 and size(), inclusive
    • remove

      public void remove(Node n)
      Removes the given node from this section.
      Parameters:
      n -
    • remove

      @Nullable public @Nullable Node remove(String key)
      Removes an entry with the given key.
      Parameters:
      key -
      Returns:
      The removed node, or null if the key didn't match any node.
    • iterator

      public Iterator<Node> iterator()
      Iterator over all non-void nodes of this section.
      Specified by:
      iterator in interface Iterable<Node>
    • get

      @Nullable public @Nullable Node get(@Nullable @Nullable String key)
      Gets a subnode (EntryNode or SectionNode) with the specified name.
      Parameters:
      key -
      Returns:
      The node with the given name
    • getValue

      @Nullable public @Nullable String getValue(String key)
    • get

      public String get(String name, String def)
      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

      public void set(String key, String value)
    • set

      public void set(String key, @Nullable @Nullable Node node)
    • 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

      public void convertToEntries(int levels, String separator)
      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

      public void save(PrintWriter w)
      Overrides:
      save in class Node
    • validate

      public boolean validate(SectionValidator validator)
    • setValues

      public boolean setValues(SectionNode other, String... excluded)
      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

      public boolean compareValues(SectionNode other, String... excluded)
      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.