AnsiCode
instances.
A StyleContext attached to a io.
takes precedence over global custom styles and predefined styles during tag resolution.
See ParserConfiguration for the full resolution order.
Instances are obtained via builder(), from(Map), or
from(StyleContext). NONE is a sentinel representing an empty context
with no registered styles.
This class is immutable and thread-safe. StyleContextBuilder is
not thread-safe; external synchronization is required if a builder instance
is shared across threads.
Example:
StyleContext ctx = StyleContext.builder()
.add("highlight", ColorCode.YELLOW)
.add("muted", StyleCode.DIM)
.build();
ParserConfiguration config = ParserConfiguration.builder()
.styleContext(ctx)
.build();
| Modifier and Type | Class and Description |
|---|---|
| public static class | StyleContext.
Builder for |
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| public static final StyleContext | NONE
A sentinel |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public static StyleContext. | |
| public boolean | equals(Object o)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public static StyleContext | |
| public static StyleContext | Returns: a newStyleContext containing the same stylesthe context to copy; must not be context)nullCreates a shallow copy of an existing |
| public static StyleContext | |
| public AnsiCode | |
| public int | |
| public String |
| localStyles | back to summary |
|---|---|
| private final Map<String, AnsiCode> localStyles | |
| NONE | back to summary |
|---|---|
| public static final StyleContext NONE A sentinel Passing this to | |
| StyleContext | back to summary |
|---|---|
| pack-priv StyleContext(StyleContext. | |
| StyleContext | back to summary |
|---|---|
| pack-priv StyleContext() | |
| builder | back to summary |
|---|---|
| public static StyleContext. 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.
| |
| from | back to summary |
|---|---|
| public static StyleContext from(Map<String, AnsiCode> codes) Creates a The provided map is copied; subsequent modifications to it do not affect the returned context.
| |
| from | back to summary |
|---|---|
| public static StyleContext from(StyleContext context) Creates a shallow copy of an existing The registered styles are copied; the returned context is independent of the source.
| |
| fromTheme | back to summary |
|---|---|
| public static StyleContext fromTheme(String theme) Creates a The registered styles are copied; the returned context is independent of the source.
| |
| get | back to summary |
|---|---|
| public AnsiCode get(String s) Returns the | |
| 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-
| |
StyleContext.
Multiple add calls accumulate; later registrations for the same
markup name overwrite earlier ones. All overloads ultimately store a single
AnsiCode per name — multi-code overloads wrap their arguments in a
CompositeColor.
This builder is not thread-safe.
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public StyleContext. | |
| public StyleContext. | Returns: this builderthe markup name; must not be style, AnsiCode... nullone or more ANSI codes to combine; must not be code)nullRegisters multiple |
| public StyleContext. | Returns: this builderthe markup name; must not be style, Collection<AnsiCode> nulla collection of ANSI codes to combine; must not be code)nullRegisters a collection of |
| public StyleContext. | |
| public StyleContext. | Returns: this builderthe context whose styles to merge; must not be context)nullMerges all styles from an existing |
| public StyleContext | Returns: a new, immutableStyleContextConstructs a new |
| localStyles | back to summary |
|---|---|
| private final Map<String, AnsiCode> localStyles | |
| NULL_STYLE_NAME | back to summary |
|---|---|
| private static final String NULL_STYLE_NAME | |
| StyleContextBuilder | back to summary |
|---|---|
| private StyleContextBuilder() | |
| add | back to summary |
|---|---|
| public StyleContext. Registers a single
| |
| add | back to summary |
|---|---|
| public StyleContext. Registers multiple
| |
| add | back to summary |
|---|---|
| public StyleContext. Registers a collection of
| |
| add | back to summary |
|---|---|
| public StyleContext. Bulk-registers all entries from the given map. Entries are added in iteration order; if the map contains a name already registered in this builder, the map's value overwrites the existing one.
| |
| add | back to summary |
|---|---|
| public StyleContext. Merges all styles from an existing If a name from
| |
| build | back to summary |
|---|---|
| public StyleContext build() Constructs a new
| |