Class Node

java.lang.Object
ch.njol.skript.config.Node
All Implemented Interfaces:
NodeNavigator, AnyNamed, AnyProvider, Iterable<Node>, Validated
Direct Known Subclasses:
EntryNode, SectionNode, SimpleNode, VoidNode

public abstract class Node extends Object implements AnyNamed, Validated, NodeNavigator
  • Field Details

    • key

      @Nullable protected @Nullable String key
    • comment

      protected String comment
    • lineNum

      protected final int lineNum
    • parent

      @Nullable protected @Nullable SectionNode parent
    • config

      protected Config config
  • Constructor Details

  • Method Details

    • getKey

      @Nullable public @Nullable String getKey()
      Key of this node. null for empty or invalid nodes, and the config's main node.
    • getConfig

      public final Config getConfig()
    • rename

      public void rename(String newname)
    • move

      public void move(SectionNode newParent)
    • splitLine

      public static NonNullPair<String,String> splitLine(String line)
      Splits a line into value and comment.

      Whitespace is preserved (whitespace in front of the comment is added to the value), and any ## in the value are replaced by a single #. The comment is returned with a leading #, except if there is no comment in which case it will be the empty string.

      Parameters:
      line - the line to split
      Returns:
      A pair (value, comment).
    • splitLine

      public static NonNullPair<String,String> splitLine(String line, AtomicBoolean inBlockComment)
      Splits a line into value and comment.

      Whitespace is preserved (whitespace in front of the comment is added to the value), and any ## not in quoted strings in the value are replaced by a single #. The comment is returned with a leading #, except if there is no comment in which case it will be the empty string.

      Parameters:
      line - the line to split
      inBlockComment - Whether we are currently inside a block comment
      Returns:
      A pair (value, comment).
    • getComment

      @Nullable protected @Nullable String getComment()
    • getIndentation

      protected String getIndentation()
    • save

      public final String save()
    • save

      public void save(PrintWriter w)
    • getParent

      @Nullable public @Nullable SectionNode getParent()
    • remove

      public void remove()
      Removes this node from its parent. Does nothing if this node does not have a parent node.
    • getLine

      public int getLine()
      Returns:
      Original line of this node at the time it was loaded. -1 if this node was created dynamically.
    • isVoid

      public boolean isVoid()
      Returns:
      Whether this node does not hold information (i.e. is empty or invalid)
    • toString

      public String toString()
      returns information about this node which looks like the following:
      node value #including comments (config.sk, line xyz)
      Overrides:
      toString in class Object
    • debug

      public boolean debug()
    • invalidate

      public void invalidate() throws UnsupportedOperationException
      Description copied from interface: Validated
      Mark a thing as no longer safe to use. This should (typically) not be used by external modifiers, but implementations may differ.
      Implementations that do not want to expose an invalidator hook may throw an UnsupportedOperationException, which is protected by the internal contract.
      Specified by:
      invalidate in interface Validated
      Throws:
      UnsupportedOperationException - If this is not something that can be externally invalidated.
    • valid

      public boolean valid()
      Description copied from interface: Validated
      Implementations ought to specify what 'valid' means locally (e.g. should a new copy be obtained?) when overriding this method.
      Specified by:
      valid in interface Validated
      Returns:
      Whether this is still valid
    • getPath

      @Nullable public @Nullable String getPath()
    • getCurrentNode

      @NotNull public @NotNull Node getCurrentNode()
      Description copied from interface: NodeNavigator
      Obtains the current node represented by this navigator. If this navigator is itself a node, it should return itself.
      Specified by:
      getCurrentNode in interface NodeNavigator
      Returns:
      The main node represented by this navigator
    • getPathSteps

      @NotNull public @NotNull String[] getPathSteps()
      Returns the node names in the path to this node from the config root. If this is not a section node, returns the path to its parent node.

      Getting the path of node z in the following example would return an array with w.x, y, z.

           w.x:
            y:
             z: true # this node
       

      Returns:
      The path to this node in the config file.
    • name

      @Nullable public @Nullable String name()
      Specified by:
      name in interface AnyNamed
      Returns:
      This thing's name
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object