Top Description Fields Constructors Methods
jdk.internal.org.jline.utils

public Class StyleResolver

extends Object
Class Inheritance
Imports
java.util.Locale, java.util.function.Function

Resolves named (or source-referenced) AttributedStyle.
Since
3.6

Field Summary

Modifier and TypeField and Description
private final Function<String, String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private AttributedStyle

Returns:

the new style
apply
(AttributedStyle
the style to apply to
style
,
final String
the specification
spec
)

Apply style specification.

private AttributedStyle
applyAnsi(final AttributedStyle style, final String spec)

private AttributedStyle

Returns:

The new style
applyColor
(final AttributedStyle
The style to apply to
style
,
final String
Color specification: <color-mode>:<color-name>
spec
)

Apply color styles specification.

private AttributedStyle

Returns:

the new style
applyNamed
(final AttributedStyle
the style to apply to
style
,
final String
the named style
name
)

Apply default named styles.

private AttributedStyle

Returns:

the new style
applyReference
(final AttributedStyle
the style to apply to
style
,
final String
the specification
spec
)

Apply source-referenced named style.

private static Integer

Returns:

color code, or null if unable to determine.
color
(String
the name of the color
name
)

Returns the color identifier for the given name.

private static Integer

Returns:

color code, or null if unable to determine.
colorRgb
(String
the name of the color
name
)

Returns the RGB color for the given name.

public AttributedStyle

Returns:

the style
resolve
(final String
the specification
spec
)

Resolve the given style specification.

public AttributedStyle

Returns:

the style
resolve
(final String
the specification
spec
,
final String
the default specifiaction
defaultSpec
)

Resolve the given style specification.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

sourceback to summary
private final Function<String, String> source

Constructor Detail

StyleResolverback to summary
public StyleResolver(final Function<String, String> source)

Method Detail

applyback to summary
private AttributedStyle apply(AttributedStyle style, final String spec)

Apply style specification.

Parameters
style:AttributedStyle

the style to apply to

spec:String

the specification

Returns:AttributedStyle

the new style

applyAnsiback to summary
private AttributedStyle applyAnsi(final AttributedStyle style, final String spec)
applyColorback to summary
private AttributedStyle applyColor(final AttributedStyle style, final String spec)

Apply color styles specification.

Parameters
style:AttributedStyle

The style to apply to

spec:String

Color specification: <color-mode>:<color-name>

Returns:AttributedStyle

The new style

applyNamedback to summary
private AttributedStyle applyNamed(final AttributedStyle style, final String name)

Apply default named styles.

Parameters
style:AttributedStyle

the style to apply to

name:String

the named style

Returns:AttributedStyle

the new style

applyReferenceback to summary
private AttributedStyle applyReference(final AttributedStyle style, final String spec)

Apply source-referenced named style.

Parameters
style:AttributedStyle

the style to apply to

spec:String

the specification

Returns:AttributedStyle

the new style

colorback to summary
private static Integer color(String name)

Returns the color identifier for the given name.

Bright color can be specified with: !<color> or bright-<color>.

Full xterm256 color can be specified with: ~<color>.

Parameters
name:String

the name of the color

Returns:Integer

color code, or null if unable to determine.

colorRgbback to summary
private static Integer colorRgb(String name)

Returns the RGB color for the given name.

Bright color can be specified with: !<color> or bright-<color>.

Full xterm256 color can be specified with: ~<color>. RGB colors can be specified with: x<rgb> or #<rgb> where rgb is a 24 bits hexadecimal color.

Parameters
name:String

the name of the color

Returns:Integer

color code, or null if unable to determine.

resolveback to summary
public AttributedStyle resolve(final String spec)

Resolve the given style specification.

If for some reason the specification is invalid, then AttributedStyle#DEFAULT will be used.

Parameters
spec:String

the specification

Returns:AttributedStyle

the style

resolveback to summary
public AttributedStyle resolve(final String spec, final String defaultSpec)

Resolve the given style specification.

If this resolves to AttributedStyle#DEFAULT then given default specification is used if non-null.

Parameters
spec:String

the specification

defaultSpec:String

the default specifiaction

Returns:AttributedStyle

the style