java.lang.Object
atlantafx.base.util.BBCodeParser
A simple push parser for the BBCode markup.
As the content is parsed, methods of
BBCodeHandler are called.The parser doesn't impose restrictions on tag names or tag params. It's a handler implementation responsibility to differentiate supported tags from unsupported and so to for the tag params. This allows user to utilize arbitrary tags or params without changing the parser behaviour. The parser, however, verifies that each opening tag has the matching closing tag.
If parsing is failed due to invalid input an IllegalStateException
will be thrown.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBBCodeParser(String input, BBCodeHandler handler) Creates a new parser.BBCodeParser(String input, BBCodeHandler handler, @Nullable Set<String> tags) Creates a new parser. -
Method Summary
Modifier and TypeMethodDescriptionstatic javafx.scene.text.TextFlowcreateFormattedText(String input) static javafx.scene.layout.VBoxcreateLayout(String input) static <T extends javafx.scene.layout.Pane>
TcreateLayout(String input, T container) Parses the given string using BBCode markup and returns corresponding layout.protected voidhandleCharacters(int start, int length) protected booleanhandleEndTag(int start, int length) protected booleanhandleStartTag(int start, int length, boolean selfClose) voidparse()Starts input parsing.splitBySpace(String str, int start, int length) Splits input string by whitespace ignoring quoted text.
-
Field Details
-
RESERVED_TAGS
Reserved tag names. Note, this isn't the list of supported codes as theBBCodeHandleris responsible for implementation.
-
-
Constructor Details
-
BBCodeParser
Creates a new parser. -
BBCodeParser
Creates a new parser.- Parameters:
input- An input non-null string.handler- ABBCodeHandlerimplementation.tags- The list of processed tags, i.e. the tags that parser won't ignore.
-
-
Method Details
-
parse
public void parse()Starts input parsing. There's no way to stop the process until parsing is finished. -
createFormattedText
-
createLayout
-
createLayout
Parses the given string using BBCode markup and returns corresponding layout. This is a shorthand method for using the feature.- Parameters:
input- The BBCode markup string.container- The root container.- See Also:
-
handleStartTag
protected boolean handleStartTag(int start, int length, boolean selfClose) -
handleEndTag
protected boolean handleEndTag(int start, int length) -
handleCharacters
protected void handleCharacters(int start, int length) -
splitBySpace
-