Class FileFormatSchemaVerification

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

public class FileFormatSchemaVerification extends Object
This class is used to verify that files match a particular FileFormatSchema.
Since:
Alpha v.0.1
Version:
Alpha v.0.3
Author:
Logan Ferree (Tadukoo)
  • Constructor Details

    • FileFormatSchemaVerification

      private FileFormatSchemaVerification()
      Not allowed to make a FileFormatSchemaVerification instance
  • Method Details

    • verifyFileFormat

      public static boolean verifyFileFormat(com.github.tadukoo.util.logger.EasyLogger logger, FileFormat format, FileFormatSchema schema, String filepath)
      Checks if the file located at the given file path matches the given FileFormatSchema or not.
      Parameters:
      logger - The EasyLogger to log any messages
      format - The FileFormat to use for checking against
      schema - The FileFormatSchema to use for checking against
      filepath - The path to the file to be checked
      Returns:
      If the file matches the formatting or not
    • verifyFileFormat

      public static boolean verifyFileFormat(com.github.tadukoo.util.logger.EasyLogger logger, FileFormat format, FileFormatSchema schema, String filepath, Node headNode)
      Checks if the given Nodes (given via the head Node) located (or to be located) at the given file path matches the given FileFormatSchema or not.
      This version allows for checking Nodes before they're saved.
      Parameters:
      logger - The EasyLogger to log any messages
      format - The FileFormat to use for checking against
      schema - The FileFormatSchema to use for checking against
      filepath - The path to the file to be checked
      headNode - The head Node of those to be checked
      Returns:
      If the file (/Nodes) matches the formatting or not
    • getFormatNodesMap

      private static Map<String,FormatNode> getFormatNodesMap(FileFormatSchema schema)
      Creates a Map out of the FormatNodes present in the given FileFormatSchema.
      Parameters:
      schema - The FileFormatSchema to grab the FormatNodes off of
      Returns:
      A mapping of FormatNode names to the FormatNodes themselves
    • verifyNode

      private static boolean verifyNode(com.github.tadukoo.util.logger.EasyLogger logger, Map<String,FormatNode> formatNodes, Node node, List<String> nodeNames, String filepath)
      Checks if the given Node (and any children and siblings down the line) matches the proper formatting passed in or not.
      Parameters:
      logger - The EasyLogger to log any messages
      formatNodes - The FormatNodes as a Map of their names to them
      node - The Node to be tested
      nodeNames - The allowed names for this particular Node's format
      filepath - The path to the file (used in some formatting)
      Returns:
      If the Node matches the formatting appropriately or not