Class AttributedString

java.lang.Object
org.jline.utils.AttributedCharSequence
org.jline.utils.AttributedString
All Implemented Interfaces:
CharSequence

public class AttributedString extends AttributedCharSequence
An immutable character sequence with ANSI style attributes.

The AttributedString class represents a character sequence where each character has associated style attributes (colors, bold, underline, etc.). It extends AttributedCharSequence and provides an immutable implementation, making it safe to use in concurrent contexts.

Key features of this class include:

  • Immutability - Once created, instances cannot be modified
  • Memory efficiency - Substrings are created without any memory copy
  • Rich styling - Support for foreground/background colors and text attributes
  • Concatenation - Multiple AttributedStrings can be joined together
  • Pattern matching - Regular expressions can be applied to find and extract parts

This class is commonly used for displaying styled text in terminal applications, such as prompts, menus, and highlighted output. For building AttributedStrings dynamically, use AttributedStringBuilder.

See Also: