Class TreeRoot<T extends YamlLine<T>>
- java.lang.Object
-
- ru.vyarus.yaml.updater.parse.common.model.TreeNode<T>
-
- ru.vyarus.yaml.updater.parse.common.model.TreeRoot<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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tfind(java.lang.String path)Search for yaml node by path.intgetLineNum()intgetLinesCnt()NOTE: numbers may be different for comments and structural parser as the later would ignore trailing comments.java.util.List<T>getTreeLeaves()java.lang.StringgetYamlPath()Note, for list items possible empty dash line is ignored (not a level in path).java.lang.StringgetYamlPathElement()Cases: - for property or object (or list) root: "name" - for list item: "[n]" (where n number from 0).-
Methods inherited from class ru.vyarus.yaml.updater.parse.common.model.TreeNode
add, addAll, getChildren, getRoot, getRootProperties, hasChildren, hasListValue, setRoot
-
-
-
-
Constructor Detail
-
TreeRoot
public TreeRoot(java.util.List<T> nodes, int linesCnt)
-
-
Method Detail
-
getYamlPath
public java.lang.String getYamlPath()
Description copied from class:TreeNodeNote, for list items possible empty dash line is ignored (not a level in path).- Specified by:
getYamlPathin classTreeNode<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:TreeNodeCases: - 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:
getYamlPathElementin classTreeNode<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:
getTreeLeavesin classTreeNode<T extends YamlLine<T>>- Returns:
- all scalar properties and properties with list values (not looking inside list values!)
-
-