Class Text


  • public class Text
    extends java.lang.Object
    A set of utilities to use when dealing with text.
    • Constructor Summary

      Constructors 
      Constructor Description
      Text()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String escapeJagex​(java.lang.String str)
      Escapes a string for widgets, replacing < and > with their escaped counterparts
      static java.util.List<java.lang.String> fromCSV​(java.lang.String input)
      Splits comma separated values to list of strings
      static boolean matchesSearchTerms​(java.lang.Iterable<java.lang.String> searchTerms, java.util.Collection<java.lang.String> keywords)
      Checks if all the search terms in the given list matches at least one keyword.
      static java.lang.String removeFormattingTags​(java.lang.String str)
      Remove tags from the given string, except for <lt> and <gt>
      static java.lang.String removeTags​(java.lang.String str)
      Removes all tags from the given string.
      static java.lang.String sanitize​(java.lang.String name)
      Cleans the ironman status icon from playername string if present and corrects spaces.
      static java.lang.String sanitizeMultilineText​(java.lang.String str)
      In addition to removing all tags, replaces all <br> delimited text with spaces and all multiple continuous spaces with single space
      static java.lang.String standardize​(java.lang.String str)
      In addition to removing all tags, replaces nbsp with space, trims string and lowercases it
      static java.lang.String titleCase​(java.lang.Enum o)
      If passed in enum doesn't implement its own toString, converts enum name format from THIS_FORMAT to This Format.
      static java.lang.String toCSV​(java.util.Collection<java.lang.String> input)
      Joins collection of strings as comma separated values
      static java.lang.String toJagexName​(java.lang.String str)
      Convert a string into Jagex username format Remove all non-ascii characters, replace nbsp with space, replace _- with spaces, and trim
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 java.util.List<java.lang.String> fromCSV​(java.lang.String input)
        Splits comma separated values to list of strings
        Parameters:
        input - input
        Returns:
        list of values
      • toCSV

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

        public static java.lang.String removeTags​(java.lang.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 java.lang.String removeFormattingTags​(java.lang.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 java.lang.String standardize​(java.lang.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 java.lang.String toJagexName​(java.lang.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 java.lang.String sanitizeMultilineText​(java.lang.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 java.lang.String escapeJagex​(java.lang.String str)
        Escapes a string for widgets, replacing < and > with their escaped counterparts
      • sanitize

        public static java.lang.String sanitize​(java.lang.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 java.lang.String titleCase​(java.lang.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​(java.lang.Iterable<java.lang.String> searchTerms,
                                                 java.util.Collection<java.lang.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.