io.github.kusoroadeolu.clique.parser.MarkupParser .
Instances are obtained via builder(). The DEFAULT constant provides
a pre-built configuration with the following values:
','falsefalseStyleContext#NONEStyle resolution order. When the parser encounters a markup tag, styles are resolved in the following order, with earlier entries taking precedence:
ParserConfigurationBuilder#styleContext(StyleContext)
or ParserConfigurationBuilder#addStyle(String, AnsiCode) on this configuration.Clique.registerStyle().This class is immutable and thread-safe. ParserConfigurationBuilder is
not thread-safe; external synchronization is required if a builder instance
is shared across threads.
Example:
ParserConfiguration config = ParserConfiguration.builder()
.enableAutoReset()
.delimiter(' ')
.addStyle("highlight", ColorCode.YELLOW)
.build();
| Modifier and Type | Class and Description |
|---|---|
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| public static final ParserConfiguration | DEFAULT
A default |
| private final String | |
| private final boolean | |
| private final boolean | |
| private final StyleContext |
| Access | Constructor and Description |
|---|---|
| private | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static ParserConfiguration. | Returns: a newParserConfigurationBuilderReturns a new builder for constructing a |
| public boolean | equals(Object o)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public String | Returns: the delimiter string; nevernullReturns the delimiter used to separate style names within a markup tag. |
| public boolean | Returns: true if auto-reset is enabled; false otherwiseReturns whether auto-reset is enabled. |
| public boolean | Returns: true if strict parsing is enabled; false otherwiseReturns whether strict parsing is enabled. |
| public StyleContext | Returns: the style context; nevernullReturns the local |
| public int | |
| public String |
| DEFAULT | back to summary |
|---|---|
| public static final ParserConfiguration DEFAULT A default | |
| delimiter | back to summary |
|---|---|
| private final String delimiter | |
| enableAutoReset | back to summary |
|---|---|
| private final boolean enableAutoReset | |
| enableStrictParsing | back to summary |
|---|---|
| private final boolean enableStrictParsing | |
| styleContext | back to summary |
|---|---|
| private final StyleContext styleContext | |
| ParserConfiguration | back to summary |
|---|---|
| private ParserConfiguration() | |
| ParserConfiguration | back to summary |
|---|---|
| private ParserConfiguration(ParserConfiguration. | |
| builder | back to summary |
|---|---|
| public static ParserConfiguration. Returns a new builder for constructing a | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| getDelimiter | back to summary |
|---|---|
| public String getDelimiter() Returns the delimiter used to separate style names within a markup tag. Defaults to
| |
| getEnableAutoReset | back to summary |
|---|---|
| public boolean getEnableAutoReset() Returns whether auto-reset is enabled. When
| |
| getEnableStrictParsing | back to summary |
|---|---|
| public boolean getEnableStrictParsing() Returns whether strict parsing is enabled. When
| |
| getStyleContext | back to summary |
|---|---|
| public StyleContext getStyleContext() Returns the local Styles in this context are resolved before global custom styles and predefined
styles. Returns
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
ParserConfiguration.
Default values match those of ParserConfiguration#DEFAULT. Methods may
be called in any order; each returns this for chaining. Style registrations
via addStyle(String, AnsiCode) and styleContext(StyleContext) are
cumulative — both can be used together and their entries are merged into a single
StyleContext at build() time.
This builder is not thread-safe.
| Modifier and Type | Field and Description |
|---|---|
| private StyleContext | |
| private String | |
| private boolean | |
| private boolean | |
| private final StyleContext. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public ParserConfiguration. | Returns: this builderthe markup name to register (e.g. markup, AnsiCode "highlight")the code)AnsiCode to associate with the markup nameRegisters a single custom style in the local |
| public ParserConfiguration | Returns: a new, immutableParserConfigurationConstructs a new |
| public ParserConfiguration. | Returns: this builderthe character to use as a style delimiter delimiter)Sets the delimiter used to separate style names within a markup tag. |
| public ParserConfiguration. | Returns: this builderEnables auto-reset, causing an ANSI reset sequence to be injected automatically when a new tag is encountered, preventing style bleed between tags. |
| public ParserConfiguration. | Returns: this builderEnables strict parsing, causing the parser to throw
|
| public ParserConfiguration. | Returns: this builderthe context whose styles to add; must not be styleContext)nullMerges all styles from the given |
| context | back to summary |
|---|---|
| private StyleContext context | |
| delimiter | back to summary |
|---|---|
| private String delimiter | |
| enableAutoReset | back to summary |
|---|---|
| private boolean enableAutoReset | |
| enableStrictParsing | back to summary |
|---|---|
| private boolean enableStrictParsing | |
| styleContextBuilder | back to summary |
|---|---|
| private final StyleContext. | |
| ParserConfigurationBuilder | back to summary |
|---|---|
| public ParserConfigurationBuilder() | |
| addStyle | back to summary |
|---|---|
| public ParserConfiguration. Registers a single custom style in the local Local styles take precedence over global custom styles and predefined styles.
Multiple calls accumulate; styles registered here are merged with any
| |
| build | back to summary |
|---|---|
| public ParserConfiguration build() Constructs a new All styles registered via
| |
| delimiter | back to summary |
|---|---|
| public ParserConfiguration. Sets the delimiter used to separate style names within a markup tag. Defaults to
| |
| enableAutoReset | back to summary |
|---|---|
| public ParserConfiguration. Enables auto-reset, causing an ANSI reset sequence to be injected automatically when a new tag is encountered, preventing style bleed between tags.
| |
| enableStrictParsing | back to summary |
|---|---|
| public ParserConfiguration. Enables strict parsing, causing the parser to throw
Without this option, unrecognized styles are silently ignored and the tag is passed through as-is. Structurally malformed tags (e.g. unclosed brackets, nested tags) are always passed through regardless of this setting.
| |
| styleContext | back to summary |
|---|---|
| public ParserConfiguration. Merges all styles from the given Local styles take precedence over global custom styles and predefined styles.
Multiple calls accumulate; styles from each context are merged with any styles
added via
| |