Class KeyTree.Node

java.lang.Object
org.simpleyaml.configuration.comments.KeyTree.Node
All Implemented Interfaces:
Iterable<KeyTree.Node>
Direct Known Subclasses:
YamlKeyTree.YamlCommentNode
Enclosing class:
KeyTree

public class KeyTree.Node extends Object implements Iterable<KeyTree.Node>
  • Field Details

  • Method Details

    • getName

      public String getName()
    • getComment

      public String getComment()
    • setComment

      public void setComment(String comment)
    • getSideComment

      public String getSideComment()
    • setSideComment

      public void setSideComment(String sideComment)
    • getParent

      public KeyTree.Node getParent()
    • isRootNode

      public boolean isRootNode()
    • isFirstNode

      public boolean isFirstNode()
    • getIndentation

      public int getIndentation()
    • get

      protected KeyTree.Node get(String path, boolean add, boolean priority)
      Get a child from its path, or optionally add a new one if it is not created.
      Parameters:
      path - the path of children names to look for separated by KeyTree.options() ConfigurationOptions.pathSeparator()
      add - if a new node must be added if it does not exist
      priority - if true the priority index is used to allow specific repetitions on list values (manually added), otherwise all nodes are allowed (loaded)
      Returns:
      the child that has the provided path or null if not found and not added
    • get

      public KeyTree.Node get(String path)
      Get a child from its path. May contain repetitions with list elements when using names (values can be repeated on a list).
      Parameters:
      path - the path of names to look for separated by KeyTree.options() ConfigurationOptions.pathSeparator()
      Returns:
      the child that has the provided path or null if not found
    • getPriority

      public KeyTree.Node getPriority(String path)
      Get a child from its path. Repetitions on list values are only allowed to keys inserted with priority using add(String).
      Parameters:
      path - the path of names to look for separated by KeyTree.options() ConfigurationOptions.pathSeparator()
      Returns:
      the child that has the provided path or null if not found
    • getElement

      protected KeyTree.Node getElement(int i, boolean add)
      Get a child list element from its index, or optionally add a new one if it is not created.


      If i is negative then gets the child at index size() + i
      Example: node.get(-1) gets the last child of node

      Parameters:
      i - the index of the child
      add - if a new node must be added if it does not exist
      Returns:
      the child with index i or null if not found and not created
    • getElement

      public KeyTree.Node getElement(int i)
      Get a child list element from its index.


      If i is negative then gets the child element indexed by size() + i
      Example: node.get(-1) gets the last child element of the node list.

      Parameters:
      i - the index of the child element
      Returns:
      the child with index i or null if not found
    • get

      public KeyTree.Node get(int i)
      Get a child from its index.


      If i is negative then gets the child at index size() + i
      Example: node.get(-1) gets the last child of node

      Parameters:
      i - the index of the child
      Returns:
      the child with index i or null if not found
    • getFirst

      public KeyTree.Node getFirst()
    • getLast

      public KeyTree.Node getLast()
    • add

      public KeyTree.Node add(String key)
    • add

      public KeyTree.Node add(int indent, String key)
    • add

      protected KeyTree.Node add(String key, boolean priority)
    • add

      protected KeyTree.Node add(int indent, String key, boolean priority)
    • setPriority

      protected void setPriority(String key, KeyTree.Node child)
    • checkList

      protected void checkList()
    • getValue

      public Object getValue()
    • hasChildren

      public boolean hasChildren()
    • children

      public List<KeyTree.Node> children()
    • keys

      public Set<String> keys()
    • entries

      public Set<Map.Entry<String,KeyTree.Node>> entries()
    • size

      public int size()
    • isList

      public boolean isList()
    • isList

      public void isList(int listSize)
    • getListSize

      public Integer getListSize()
    • setElementIndex

      public void setElementIndex(int elementIndex)
    • getElementIndex

      public Integer getElementIndex()
    • getPath

      public String getPath()
    • getPathWithName

      public String getPathWithName()
    • clearNode

      protected void clearNode()
    • clearIf

      protected boolean clearIf(Predicate<KeyTree.Node> condition, boolean removeFromParent)
    • clearIf

      public boolean clearIf(Predicate<KeyTree.Node> condition)
    • clear

      public void clear()
    • iterator

      public Iterator<KeyTree.Node> iterator()
      Specified by:
      iterator in interface Iterable<KeyTree.Node>
    • toString

      public String toString()
      Overrides:
      toString in class Object