Class FileFormatSchemaVerification
java.lang.Object
com.github.tadukoo.parsing.fileformat.FileFormatSchemaVerification
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 Summary
ModifierConstructorDescriptionprivate
Not allowed to make a FileFormatSchemaVerification instance -
Method Summary
Modifier and TypeMethodDescriptionprivate static Map<String,
FormatNode> getFormatNodesMap
(FileFormatSchema schema) Creates a Map out of theFormatNode
s present in the givenFileFormatSchema
.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 givenFileFormatSchema
or not.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 givenFileFormatSchema
or not.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.
-
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 givenFileFormatSchema
or not.- Parameters:
logger
- TheEasyLogger
to log any messagesformat
- The FileFormat to use for checking againstschema
- The FileFormatSchema to use for checking againstfilepath
- 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 givenFileFormatSchema
or not.
This version allows for checking Nodes before they're saved.- Parameters:
logger
- TheEasyLogger
to log any messagesformat
- The FileFormat to use for checking againstschema
- The FileFormatSchema to use for checking againstfilepath
- The path to the file to be checkedheadNode
- The head Node of those to be checked- Returns:
- If the file (/Nodes) matches the formatting or not
-
getFormatNodesMap
Creates a Map out of theFormatNode
s present in the givenFileFormatSchema
.- 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
- TheEasyLogger
to log any messagesformatNodes
- The FormatNodes as a Map of their names to themnode
- The Node to be testednodeNames
- The allowed names for this particular Node's formatfilepath
- The path to the file (used in some formatting)- Returns:
- If the Node matches the formatting appropriately or not
-