Class TreeRoot<T extends YamlLine<T>>

  • Type Parameters:
    T - child nodes type
    All Implemented Interfaces:
    LineNumberAware
    Direct Known Subclasses:
    CmtTree, StructTree

    public abstract class TreeRoot<T extends YamlLine<T>>
    extends TreeNode<T>
    Base class for both comments and structure trees.
    Since:
    30.05.2021
    • Constructor Summary

      Constructors 
      Constructor Description
      TreeRoot​(java.util.List<T> nodes, int linesCnt)  
    • Constructor Detail

      • TreeRoot

        public TreeRoot​(java.util.List<T> nodes,
                        int linesCnt)
    • Method Detail

      • getYamlPath

        public java.lang.String getYamlPath()
        Description copied from class: TreeNode
        Note, for list items possible empty dash line is ignored (not a level in path).
        Specified by:
        getYamlPath in class TreeNode<T extends YamlLine<T>>
        Returns:
        null as tree root does not have any yaml path
      • getYamlPathElement

        public java.lang.String getYamlPathElement()
        Description copied from class: TreeNode
        Cases: - for property or object (or list) root: "name" - for list item: "[n]" (where n number from 0). Note that scalar value will be contained in the same node and for object item it would be "empty" wrapper containing object properties as children. - for comment only node: empty string (no identity)
        Specified by:
        getYamlPathElement in class TreeNode<T extends YamlLine<T>>
        Returns:
        null as tree root does not have any yaml path
      • getLineNum

        public int getLineNum()
        Returns:
        0 as tree root is not represented with any line number
      • getLinesCnt

        public int getLinesCnt()
        NOTE: numbers may be different for comments and structural parser as the later would ignore trailing comments.
        Returns:
        count of lines in yaml file (overall)
      • getTreeLeaves

        public java.util.List<T> getTreeLeaves()
        Specified by:
        getTreeLeaves in class TreeNode<T extends YamlLine<T>>
        Returns:
        all scalar properties and properties with list values (not looking inside list values!)
      • find

        public T find​(java.lang.String path)
        Description copied from class: TreeNode
        Search for yaml node by path. For list items path should include exact item number (e.g. list[1]), wildcard search not supported.

        IMPORTANT: path must NOT include node itself (node from where search started)

        Specified by:
        find in class TreeNode<T extends YamlLine<T>>
        Parameters:
        path - yaml path (with '/' as separator)
        Returns:
        found node or null