Class Text


  • public class Text
    extends Object
    A set of utilities to use when dealing with text.
    • Field Detail

      • JAGEX_PRINTABLE_CHAR_MATCHER

        public static final com.google.common.base.CharMatcher JAGEX_PRINTABLE_CHAR_MATCHER
    • Constructor Detail

      • Text

        public Text()
    • Method Detail

      • fromCSV

        public static List<String> fromCSV​(String input)
        Splits comma separated values to list of strings
        Parameters:
        input - input
        Returns:
        list of values
      • toCSV

        public static String toCSV​(Collection<String> input)
        Joins collection of strings as comma separated values
        Parameters:
        input - collection
        Returns:
        comma separated value string
      • removeTags

        public static String removeTags​(String str)
        Removes all tags from the given string.
        Parameters:
        str - The string to remove tags from.
        Returns:
        The given string with all tags removed from it.
      • removeFormattingTags

        public static String removeFormattingTags​(String str)
        Remove tags from the given string, except for <lt> and <gt>
        Parameters:
        str - The string to remove formatting tags from.
        Returns:
        The given string with all formatting tags removed from it.
      • standardize

        public static String standardize​(String str)
        In addition to removing all tags, replaces nbsp with space, trims string and lowercases it
        Parameters:
        str - The string to standardize
        Returns:
        The given `str` that is standardized
      • toJagexName

        public static String toJagexName​(String str)
        Convert a string into Jagex username format Remove all non-ascii characters, replace nbsp with space, replace _- with spaces, and trim
        Parameters:
        str - The string to standardize
        Returns:
        The given `str` that is in Jagex name format
      • sanitizeMultilineText

        public static String sanitizeMultilineText​(String str)
        In addition to removing all tags, replaces all <br> delimited text with spaces and all multiple continuous spaces with single space
        Parameters:
        str - The string to sanitize
        Returns:
        sanitized string
      • escapeJagex

        public static String escapeJagex​(String str)
        Escapes a string for widgets, replacing < and > with their escaped counterparts
      • sanitize

        public static String sanitize​(String name)
        Cleans the ironman status icon from playername string if present and corrects spaces.
        Parameters:
        name - Playername to lookup.
        Returns:
        Cleaned playername.
      • titleCase

        public static String titleCase​(Enum o)
        If passed in enum doesn't implement its own toString, converts enum name format from THIS_FORMAT to This Format.
        Parameters:
        o - an enum
        Returns:
        the enum's name in title case, or if it overrides toString, the value returned by toString
      • matchesSearchTerms

        public static boolean matchesSearchTerms​(Iterable<String> searchTerms,
                                                 Collection<String> keywords)
        Checks if all the search terms in the given list matches at least one keyword.
        Returns:
        true if all search terms matches at least one keyword, or false if otherwise.