Class TextHelper


  • public final class TextHelper
    extends java.lang.Object
    Helper class for transforming different texts
    • Constructor Summary

      Constructors 
      Constructor Description
      TextHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String formatMetricAmount​(double metricAmount)
      Removes insignificant figures in metric amount
      static java.lang.String formatMetricAmount​(java.lang.String metricAmount)
      Removes insignificant figures in metric amount
      static java.lang.String getLowerCase​(java.lang.String input)
      Uncapitalizes all the characters in the space separated words in the given string
      static java.lang.String getTitleCase​(java.lang.String input)
      Capitalizes the first character of all the space separated words in the given string
      static java.lang.String getUpperCase​(java.lang.String input)
      Capitalizes all the characters in the space separated words in the given string
      static boolean isEmpty​(java.lang.String input)
      Checks if String is null, empty and trimmed empty
      static java.lang.String obscureCardCode​(java.lang.String cardCode)
      Obscures the given card code, except for the last 4 characters.
      static java.lang.CharSequence removeTrailingWhiteLines​(java.lang.CharSequence text)
      Removes the trailing white lines from the text.
      static java.lang.String removeTrailingWhiteLinesAndSpaces​(java.lang.CharSequence text)
      Removes the trailing white lines and spaces from the text.
      static java.lang.String shorten​(int point)
      Shortens the point values using suffixes.
      static java.lang.String splitCardCode​(java.lang.String cardCode)
      Splits a given 16-character card code into 4 character groups with spaces.
      static java.lang.String stripHtmlTags​(java.lang.String string)
      Removes html tags
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TextHelper

        public TextHelper()
    • Method Detail

      • getTitleCase

        public static java.lang.String getTitleCase​(java.lang.String input)
        Capitalizes the first character of all the space separated words in the given string
        Parameters:
        input - text that will be modified
        Returns:
        the Capitalized string
      • getUpperCase

        public static java.lang.String getUpperCase​(java.lang.String input)
        Capitalizes all the characters in the space separated words in the given string
        Parameters:
        input - text that will be modified
        Returns:
        the Capitalized string
      • getLowerCase

        public static java.lang.String getLowerCase​(java.lang.String input)
        Uncapitalizes all the characters in the space separated words in the given string
        Parameters:
        input - text that will be modified
        Returns:
        the Capitalized string
      • isEmpty

        public static boolean isEmpty​(java.lang.String input)
        Checks if String is null, empty and trimmed empty
        Parameters:
        input - text that will be modified
        Returns:
        true if empty, else false
      • splitCardCode

        public static java.lang.String splitCardCode​(java.lang.String cardCode)
        Splits a given 16-character card code into 4 character groups with spaces. e.g. from "1234567812345678" to "1234 5678 1234 5678"
        Parameters:
        cardCode - 16-character card code
        Returns:
        modified text with space
      • obscureCardCode

        public static java.lang.String obscureCardCode​(java.lang.String cardCode)
        Obscures the given card code, except for the last 4 characters. e.g. from "1234567812345678" to "XXXXXXXXXXXX5678"
        Parameters:
        cardCode - 16-character card code
        Returns:
        obscured text
      • removeTrailingWhiteLines

        public static java.lang.CharSequence removeTrailingWhiteLines​(java.lang.CharSequence text)
        Removes the trailing white lines from the text.
        Parameters:
        text - text that will be modified
        Returns:
        the text without the trailing white lines.
      • removeTrailingWhiteLinesAndSpaces

        public static java.lang.String removeTrailingWhiteLinesAndSpaces​(java.lang.CharSequence text)
        Removes the trailing white lines and spaces from the text.
        Parameters:
        text - text that will be modified
        Returns:
        the text without the trailing white lines and spaces.
      • shorten

        public static java.lang.String shorten​(int point)
        Shortens the point values using suffixes.
        Parameters:
        point - number to shorten
        Returns:
        shortened number value in string
      • formatMetricAmount

        public static java.lang.String formatMetricAmount​(java.lang.String metricAmount)
        Removes insignificant figures in metric amount
        Parameters:
        metricAmount - metric amount value
        Returns:
        formatted metric amount
      • formatMetricAmount

        public static java.lang.String formatMetricAmount​(double metricAmount)
        Removes insignificant figures in metric amount
        Parameters:
        metricAmount - metric amount value
        Returns:
        formatted metric amount
      • stripHtmlTags

        public static java.lang.String stripHtmlTags​(java.lang.String string)
        Removes html tags
        Parameters:
        string - Text to be cleaned
        Returns:
        cleaned text