Class 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 postfix
      static java.lang.String COLOR_PREFIX
      Color tag prefix
      static java.awt.Color GRAY_COLOR
      Gray color
      private static java.lang.String GRAY_COLOR_STRING  
    • 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)  
      private static java.lang.String toStringInternal​(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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
      • GRAY_COLOR_STRING

        private static final java.lang.String GRAY_COLOR_STRING
    • Constructor Detail

      • RichTextStringUtils

        public RichTextStringUtils()
    • 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 - text
        color - color
      • startColor

        public static void startColor​(java.lang.StringBuilder text,
                                      java.awt.Color color)
        Set given color to the given text.
        Parameters:
        text - text
        color - 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 - text
        color - 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 - text
        color - 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 - text
        color - color
      • wrapInColor

        public static void wrapInColor​(java.lang.StringBuffer text,
                                       java.awt.Color color)
        Set given color to the given text.
        Parameters:
        text - text
        color - 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 - text
        index - index
        Returns:
        cut text
      • toString

        public static java.lang.String toString​(java.awt.Color color)
        Parameters:
        color - color
        Returns:
        color representation
      • toStringInternal

        private static java.lang.String toStringInternal​(java.awt.Color color)