Class FormatNode

java.lang.Object
com.github.tadukoo.parsing.fileformat.FormatNode

public class FormatNode extends Object
Represents all the information about how a Node should be formatted for a FileFormat.
Since:
Alpha v.0.1
Version:
Alpha v.0.3
Author:
Logan Ferree (Tadukoo)
  • Field Details

    • NULL_NODE

      public static final String NULL_NODE
      The text used to signify a null (e.g. as an allowed Node for parent/child/sibling)
      See Also:
    • name

      private final String name
      The name of the Node - used to distinguish in parent/child/sibling requirements
    • titleRegex

      private final String titleRegex
      The regex used to ensure the title is of the correct format
    • dataRegex

      private final String dataRegex
      The regex used to ensure the data is of the correct format
    • level

      private final int level
      The required level of the Node
    • parentNames

      private final List<String> parentNames
      Names of allowed parents of the Node
    • childNames

      private final List<String> childNames
      Names of allowed children of the Node
    • prevSiblingNames

      private final List<String> prevSiblingNames
      Names of allowed previous siblings of the Node
    • nextSiblingNames

      private final List<String> nextSiblingNames
      Names of allowed next siblings of the Node
  • Constructor Details

    • FormatNode

      private FormatNode(String name, String titleRegex, String dataRegex, int level, List<String> parentNames, List<String> childNames, List<String> prevSiblingNames, List<String> nextSiblingNames)
      Constructs a FormatNode with the given data.
      Parameters:
      name - The name of the Node
      titleRegex - The regex to ensure the title is of the correct format
      dataRegex - The regex to ensure the data is of the correct format
      level - The required level of the Node
      parentNames - The names of allowed parent Nodes to this one
      childNames - The names of allowed child Nodes to this one
      prevSiblingNames - The names of allowed previous sibling Nodes to this one
      nextSiblingNames - The names of allowed next sibling Nodes to this one
  • Method Details

    • builder

      public static FormatNode.FormatNodeBuilder builder()
      Constructs a FormatNode.FormatNodeBuilder to be used to construct a FormatNode.
      Returns:
      A new FormatNodeBuilder
    • getName

      public String getName()
      Returns:
      The name for the Node
    • getTitleRegex

      public String getTitleRegex()
      Returns:
      The regex to use in ensuring the title is formatted correctly
    • getDataRegex

      public String getDataRegex()
      Returns:
      The regex to use in ensuring the data is formatted correctly
    • getNodeRegex

      public String getNodeRegex()
      Returns:
      The title regex and data regex combined, separated by a colon
    • getLevel

      public int getLevel()
      Returns:
      The required level of the Node
    • getParentNames

      public List<String> getParentNames()
      Returns:
      The allowed names for parent Nodes of this one
    • getChildNames

      public List<String> getChildNames()
      Returns:
      The allowed names for child Nodes of this one
    • getPrevSiblingNames

      public List<String> getPrevSiblingNames()
      Returns:
      The allowed names for previous sibling Nodes of this one
    • getNextSiblingNames

      public List<String> getNextSiblingNames()
      Returns:
      The allowed names for next sibling Nodes of this one
    • toString

      public String toString()
      Convert this FormatNode into Nodes to be converted into text to be stored and later loaded if needed.
      Overrides:
      toString in class Object
      Returns:
      The String representation of this FormatNode