Package com.nomagic.text.rich
Class RichTextStringUtils
- java.lang.Object
-
- com.nomagic.text.rich.RichTextStringUtils
-
@OpenApiAll public class RichTextStringUtils extends java.lang.Object
Utility class to work with rich text.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
COLOR_POSTFIX
Color tag postfixstatic java.lang.String
COLOR_PREFIX
Color tag prefixstatic java.awt.Color
GRAY_COLOR
Gray color
-
Constructor Summary
Constructors Constructor Description RichTextStringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
closeColor(java.lang.String text)
Close color tag.static void
closeColor(java.lang.StringBuffer text)
Close color tag.static void
closeColor(java.lang.StringBuilder text)
Close color tag.static void
startColor(java.lang.StringBuffer text, java.awt.Color color)
Set given color to the given text.static void
startColor(java.lang.StringBuilder text, java.awt.Color color)
Set given color to the given text.static java.lang.String
startColor(java.lang.String text, java.awt.Color color)
Set given color to the given text.static java.lang.String
toString(java.awt.Color color)
static java.lang.String
trimText(java.lang.String text, int index)
Trim text up to the given index.static void
wrapInColor(java.lang.StringBuffer text, java.awt.Color color)
Set given color to the given text.static void
wrapInColor(java.lang.StringBuilder text, java.awt.Color color)
Set given color to the given text.static java.lang.String
wrapInColor(java.lang.String text, java.awt.Color color)
Set given color to the given text.
-
-
-
Field Detail
-
GRAY_COLOR
public static final java.awt.Color GRAY_COLOR
Gray color
-
COLOR_PREFIX
public static final java.lang.String COLOR_PREFIX
Color tag prefix- See Also:
- Constant Field Values
-
COLOR_POSTFIX
public static final java.lang.String COLOR_POSTFIX
Color tag postfix- See Also:
- Constant Field Values
-
-
Method Detail
-
closeColor
public static java.lang.String closeColor(java.lang.String text)
Close color tag.- Parameters:
text
- text
-
closeColor
public static void closeColor(java.lang.StringBuilder text)
Close color tag.- Parameters:
text
- text
-
closeColor
public static void closeColor(java.lang.StringBuffer text)
Close color tag.- Parameters:
text
- text
-
startColor
public static void startColor(java.lang.StringBuffer text, java.awt.Color color)
Set given color to the given text.- Parameters:
text
- textcolor
- color
-
startColor
public static void startColor(java.lang.StringBuilder text, java.awt.Color color)
Set given color to the given text.- Parameters:
text
- textcolor
- color
-
startColor
public static java.lang.String startColor(java.lang.String text, java.awt.Color color)
Set given color to the given text.- Parameters:
text
- textcolor
- color- Returns:
- text with given color
-
wrapInColor
public static java.lang.String wrapInColor(@CheckForNull java.lang.String text, java.awt.Color color)
Set given color to the given text.- Parameters:
text
- textcolor
- color- Returns:
- text with given color
-
wrapInColor
public static void wrapInColor(java.lang.StringBuilder text, java.awt.Color color)
Set given color to the given text.- Parameters:
text
- textcolor
- color
-
wrapInColor
public static void wrapInColor(java.lang.StringBuffer text, java.awt.Color color)
Set given color to the given text.- Parameters:
text
- textcolor
- color
-
trimText
public static java.lang.String trimText(java.lang.String text, int index)
Trim text up to the given index. Make sure that "color" tag is not cut.- Parameters:
text
- textindex
- index- Returns:
- cut text
-
toString
public static java.lang.String toString(java.awt.Color color)
- Parameters:
color
- color- Returns:
- color representation
-
-