Class FormatNode.FormatNodeBuilder
java.lang.Object
com.github.tadukoo.parsing.fileformat.FormatNode.FormatNodeBuilder
- Enclosing class:
- FormatNode
Builder for constructing a
MUST specify the following:
FormatNode
object.
MUST specify the following:
- logger
- text OR
- name
- titleRegex OR titleFormat
- dataRegex OR dataFormat
- level
- parentNames - List with
FormatNode.NULL_NODE
- meaning no parent nodes allowed - childNames - List with
FormatNode.NULL_NODE
- meaning no child nodes allowed - prevSiblingNames - List with
FormatNode.NULL_NODE
- meaning no previous siblings allowed - nextSiblingNames - List with
FormatNode.NULL_NODE
- meaning no next siblings allowed
- Specifying text means you can't specify anything else
other than logger (which is required). You will get an IllegalArgumentException
if you try.
Specifying text will fill in the name, titleRegex, dataRegex, level, parentNames, childNames, prevSiblingNames, and nextSiblingNames based on the parsed text. - Specifying titleFormat will convert it into a titleRegex
- Specifying dataFormat will convert it into a dataRegex
- Since:
- Alpha v.0.1
- Version:
- Alpha v.0.3
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
Modifier and TypeFieldDescriptionNames of allowed child Nodesprivate String
The TFormatting to convert into a regex for the dataprivate String
The regex used to ensure the data is of the correct formatprivate int
The required level of the Nodeprivate com.github.tadukoo.util.logger.EasyLogger
TheEasyLogger
to use for logging initialization messagesprivate String
The name of the Node for identification purposesNames of allowed next sibling NodesNames of allowed parent NodesNames of allowed previous sibling Nodesprivate String
Text to use in parsing into a FormatNodeprivate String
The TFormatting to convert into a regex for the titleprivate String
The regex used to ensure the title is of the correct format -
Constructor Summary
ModifierConstructorDescriptionprivate
Not allowed to make FormatNodeBuilder outside of FormatNode -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a newFormatNode
with the specified parameters after checking for any errors.private void
Checks the builder for any errors in the data.Adds the given string to the list of allowed names for child Nodes.childNames
(List<String> childNames) Sets the allowed names for child Nodes.private void
Initializes the childNames list to an empty ArrayList if it's nullprivate void
Converts the text string into Nodes to be parsed into a FormatNodedataFormat
(String dataFormat) Sets the TFormatting to use for the data of the Node.Sets the regex to use for the data of the Node.level
(int level) Sets the level of the Node.logger
(com.github.tadukoo.util.logger.EasyLogger logger) Set theEasyLogger
to use for logging initialization messages.Creates a List of strings that only contains theFormatNode.NULL_NODE
string, to allow a null parent/child/sibling reference.Sets the name to use for the FormatNode.nextSiblingName
(String nextSiblingName) Adds the given string to the list of allowed names for next sibling Nodes.nextSiblingNames
(List<String> nextSiblingNames) Sets the allowed names for next sibling Nodes.private void
Initializes the nextSiblingNames list to an empty ArrayList if it's nullAdds null to the allowed names for child Nodes.Adds null to the allowed names for next sibling Nodes.Adds null to the allowed names for parent Nodes.Adds null to the allowed names for previous sibling Nodes.parentName
(String parentName) Adds the given string to the list of allowed names for parent Nodes.parentNames
(List<String> parentNames) Sets the allowed names for parent Nodes.private void
Initializes the parentNames list to an empty ArrayList if it's nullprevSiblingName
(String prevSiblingName) Adds the given string to the list of allowed names for previous sibling Nodes.prevSiblingNames
(List<String> prevSiblingNames) Sets the allowed names for previous sibling Nodes.private void
Initializes the prevSiblingNames list to an empty ArrayList if it's nullIf you specify text, you should only specify the Logger in addition to this.titleFormat
(String titleFormat) Sets the TFormatting to use for the title of the Node.titleRegex
(String titleRegex) Sets the regex to use for the title of the Node.
-
Field Details
-
logger
private com.github.tadukoo.util.logger.EasyLogger loggerTheEasyLogger
to use for logging initialization messages -
text
Text to use in parsing into a FormatNode -
name
The name of the Node for identification purposes -
titleRegex
The regex used to ensure the title is of the correct format -
titleFormat
The TFormatting to convert into a regex for the title -
dataRegex
The regex used to ensure the data is of the correct format -
dataFormat
The TFormatting to convert into a regex for the data -
level
private int levelThe required level of the Node -
parentNames
Names of allowed parent Nodes -
childNames
Names of allowed child Nodes -
prevSiblingNames
Names of allowed previous sibling Nodes -
nextSiblingNames
Names of allowed next sibling Nodes
-
-
Constructor Details
-
FormatNodeBuilder
private FormatNodeBuilder()Not allowed to make FormatNodeBuilder outside of FormatNode
-
-
Method Details
-
logger
Set theEasyLogger
to use for logging initialization messages.- Parameters:
logger
- TheEasyLogger
to use for logging messages- Returns:
- The FormatNodeBuilder, to continue in building
-
text
If you specify text, you should only specify the Logger in addition to this. Specifying anything else will cause an IllegalArgumentException, as the text is supposed to be the full formatting as a Tadukoo File Format format.- Parameters:
text
- The text to parse as a Tadukoo File Format format- Returns:
- The FormatNodeBuilder, to continue in building
-
name
Sets the name to use for the FormatNode.- Parameters:
name
- The name of the FormatNode- Returns:
- The FormatNodeBuilder, to continue in building
-
titleRegex
Sets the regex to use for the title of the Node.- Parameters:
titleRegex
- The regex to use for the title of the Node- Returns:
- The FormatNodeBuilder, to continue in building
-
titleFormat
Sets the TFormatting to use for the title of the Node. This will be converted to a regex when building.- Parameters:
titleFormat
- The TFormatting to use for the title of the Node- Returns:
- The FormatNodeBuilder, to continue in building
-
dataRegex
Sets the regex to use for the data of the Node.- Parameters:
dataRegex
- The regex to use for the data of the Node- Returns:
- The FormatNodeBuilder, to continue in building
-
dataFormat
Sets the TFormatting to use for the data of the Node. This will be converted to a regex when building.- Parameters:
dataFormat
- The TFormatting to use for the data of the Node- Returns:
- The FormatNodeBuilder, to continue in building
-
level
Sets the level of the Node.- Parameters:
level
- The required level of the Node- Returns:
- The FormatNodeBuilder, to continue in building
-
parentNamesCheck
private void parentNamesCheck()Initializes the parentNames list to an empty ArrayList if it's null -
parentNames
Sets the allowed names for parent Nodes.- Parameters:
parentNames
- Names allowed for parent Nodes- Returns:
- The FormatNodeBuilder, to continue in building
-
parentName
Adds the given string to the list of allowed names for parent Nodes.- Parameters:
parentName
- The name to add to the list of allowed parent Nodes- Returns:
- The FormatNodeBuilder, to continue in building
-
nullParentName
Adds null to the allowed names for parent Nodes.- Returns:
- The FormatNodeBuilder, to continue in building
-
childNamesCheck
private void childNamesCheck()Initializes the childNames list to an empty ArrayList if it's null -
childNames
Sets the allowed names for child Nodes.- Parameters:
childNames
- Names allowed for child Nodes- Returns:
- The FormatNodeBuilder, to continue in building
-
childName
Adds the given string to the list of allowed names for child Nodes.- Parameters:
childName
- The name to add to the list of allowed child Nodes- Returns:
- The FormatNodeBuilder, to continue in building
-
nullChildName
Adds null to the allowed names for child Nodes.- Returns:
- The FormatNodeBuilder, to continue in building
-
prevSiblingNamesCheck
private void prevSiblingNamesCheck()Initializes the prevSiblingNames list to an empty ArrayList if it's null -
prevSiblingNames
Sets the allowed names for previous sibling Nodes.- Parameters:
prevSiblingNames
- Names allowed for previous sibling Nodes- Returns:
- The FormatNodeBuilder, to continue in building
-
prevSiblingName
Adds the given string to the list of allowed names for previous sibling Nodes.- Parameters:
prevSiblingName
- The name to add to the list of allowed previous sibling Nodes- Returns:
- The FormatNodeBuilder, to continue in building
-
nullPrevSiblingName
Adds null to the allowed names for previous sibling Nodes.- Returns:
- The FormatNodeBuilder, to continue in building
-
nextSiblingNamesCheck
private void nextSiblingNamesCheck()Initializes the nextSiblingNames list to an empty ArrayList if it's null -
nextSiblingNames
Sets the allowed names for next sibling Nodes.- Parameters:
nextSiblingNames
- Names allowed for next sibling Nodes- Returns:
- The FormatNodeBuilder, to continue in building
-
nextSiblingName
Adds the given string to the list of allowed names for next sibling Nodes.- Parameters:
nextSiblingName
- The name to add to the list of allowed next sibling Nodes- Returns:
- The FormatNodeBuilder, to continue in building
-
nullNextSiblingName
Adds null to the allowed names for next sibling Nodes.- Returns:
- The FormatNodeBuilder, to continue in building
-
checkForErrors
private void checkForErrors()Checks the builder for any errors in the data. Throws an IllegalArgumentException with any issues. -
convertText
private void convertText()Converts the text string into Nodes to be parsed into a FormatNode -
makeNullAllowed
Creates a List of strings that only contains theFormatNode.NULL_NODE
string, to allow a null parent/child/sibling reference.- Returns:
- A List with the NULL_NODE string in it
-
build
Builds a newFormatNode
with the specified parameters after checking for any errors.- Returns:
- The newly built
FormatNode
-