Class StringHelper


  • public class StringHelper
    extends Object
    Author:
    pvandermaesen
    • Constructor Detail

      • StringHelper

        public StringHelper()
    • Method Detail

      • addSufixToFileName

        public static String addSufixToFileName​(String fileName,
                                                String sufix)
      • arrayToString

        public static String arrayToString​(Object[] array)
      • asBase64

        public static String asBase64​(byte[] bytes)
        generate a base 64 string.
        Returns:
        a unique id.
      • asBase32

        public static String asBase32​(int value)
        generate a base 32 string with a int
        Returns:
        a unique id.
      • asBase32

        public static String asBase32​(byte value)
        generate a base 32 string with a int
        Returns:
        a unique id.
      • asBase32

        public static String asBase32​(byte[] bytes)
        generate a base 32 string.
        Returns:
        a unique id.
      • asBase64

        public static String asBase64​(int value)
        generate a base 64 string with a int
        Returns:
        a unique id.
      • asBase64

        public static String asBase64​(long value)
        generate a base 64 string with a long
        Returns:
        a unique id.
      • changeFileExtension

        public static String changeFileExtension​(String inFileName,
                                                 String newExt)
        change the file extension of the path
        Parameters:
        inFileName - a path or a url to a file.
        newExt - the new extension of the file.
        Returns:
        the same path with the new extension.
      • collectionToString

        public static String collectionToString​(String... values)
      • collectionToString

        public static String collectionToString​(Collection<?> col)
      • collectionToText

        public static String collectionToText​(Collection<?> col)
        convert a collection to text. Each item of the collection will be a line if the text.
        Parameters:
        col -
        Returns:
      • collectionToTextarea

        public static String collectionToTextarea​(Collection<?> col)
        convert a collection to text. Each item of the collection will be a line if the text.
        Parameters:
        col -
        Returns:
      • colorToHexString

        public static String colorToHexString​(Color color)
      • colorToHexStringNotNull

        public static String colorToHexStringNotNull​(Color color)
      • mergeString

        public static String mergeString​(String sep,
                                         String... parts)
        merge string with 'sep' between
        Parameters:
        sep -
        part -
        Returns:
      • convertString

        public static String convertString​(String pattern1,
                                           String pattern2,
                                           String text)
        convert a string to another string if math pattern1 and convert to pattern2. pattern is a String with one '*' for any characters. sample : /*, /test/*, /view/fr --> /test/view/fr
        Parameters:
        pattern1 - a pattern with one '*'
        pattern2 - a pattern with one '*'
        text -
        Returns:
      • countChar

        public static int countChar​(String str,
                                    char c)
      • CR2BR

        public static String CR2BR​(String text)
        replace CR with
        Parameters:
        text - a simple text
        Returns:
        XHTML code
      • createASCIIString

        public static String createASCIIString​(String text)
      • removeSpecialChars

        public static String removeSpecialChars​(char c)
      • doubleQutotes

        public static String doubleQutotes​(String text)
      • removeSpecialChars

        public static String removeSpecialChars​(String text)
      • createFileName

        public static String createFileName​(String fileName)
        convert a file name with space, accent and other bad character to a acceptable name. sample: "l'éléphant rose.odt" -> "l_elephant_rose.odt"
        Parameters:
        fileName - a bad file name
        Returns:
        a correct file name
      • createI18NURL

        public static String createI18NURL​(String value)
      • trim

        public static String trim​(String text,
                                  char trimChar)
        replace trimChar at the start and the end of text string. sample : --test-, - >>> test
        Parameters:
        text -
        trimChar -
        Returns:
      • trimInternal

        public static String trimInternal​(String str)
        replace all space repeatition with one space
      • noRepeatChar

        public static String noRepeatChar​(String text,
                                          char chr)
      • CRtoSpace

        public static String CRtoSpace​(String text)
        replace CR with a space
        Parameters:
        text - a simple text
        Returns:
        one line text
      • cutEndXHTML

        public static String cutEndXHTML​(String str,
                                         int cut)
        cut the end of a xhtml code. sample: "aaa´coucou", 5 = "aaa´c"
        Parameters:
        str - the string
        cut - the end charaster must be removed.
        Returns:
        a trunced XHTML String
      • decodeBase64

        public static byte[] decodeBase64​(String data)
                                   throws IOException
        generate a base 64 string.
        Returns:
        a unique id.
        Throws:
        IOException
      • decodeNoChar

        public static String decodeNoChar​(String data,
                                          String noChars)
        insert char from a Sting (encoded with encodeNoChar)
        Parameters:
        data - string to be encoded
        noChars - list of vorbiden char
        Returns:
      • encodeCDATA

        public static String encodeCDATA​(String value)
        encode a string to a CDATA sequence.
        Parameters:
        value -
        Returns:
      • encodeNoChar

        public static String encodeNoChar​(String data,
                                          String noChars)
        remove char from a Sting
        Parameters:
        data - string to be encoded
        noChars - list of vorbiden char
        Returns:
      • encryptPassword

        public static String encryptPassword​(String plaintext)
      • encryptPasswordSHA256

        public static String encryptPasswordSHA256​(String plaintext)
      • escapeWordChar

        public static String escapeWordChar​(String text)
      • expandSystemProperties

        public static String expandSystemProperties​(String str)
      • firstLetterLower

        public static String firstLetterLower​(String string)
      • firstLetterUpper

        public static String firstLetterUpper​(String string)
      • frameTokenCaseUnsensitive

        public static String frameTokenCaseUnsensitive​(String str,
                                                       String token,
                                                       String prefix,
                                                       String sufix)
        split a String, if there are no character between two token this method place a empty String ( != String.split )
        Parameters:
        str - a standard str
        token - a token ( not pattern !!! )
        Returns:
        a array of String without the token
      • getDateRandomId

        public static String getDateRandomId()
        return a ID contruct on with the current date : sample : 20101223-4687
        Returns:
      • getDateRandomIdWithCheck

        public static String getDateRandomIdWithCheck()
        return a ID contruct on with the current date : sample : 20101223-4687
        Returns:
      • getDigitMod9

        public static int getDigitMod9​(String value)
      • extractNumber

        public static Integer extractNumber​(String text)
        extract only number of a alpha numeric string
        Parameters:
        text -
        Returns:
        23 from "23px", null from "animal".
      • extractLong

        public static Long extractLong​(String text)
        extract only number of a alpha numeric string
        Parameters:
        text -
        Returns:
        23 from "23px", null from "animal".
      • extractNumberAsString

        public static String extractNumberAsString​(String text)
        extract only number of a alpha numeric string
        Parameters:
        text -
        Returns:
        23 from "23px", null from "animal".
      • replaceFileExtension

        public static String replaceFileExtension​(String file,
                                                  String ext)
      • getFileExtension

        public static String getFileExtension​(String inFileName)
        retreive the file extension.
        Parameters:
        inFileName - a file name
        Returns:
        a file extension without dot ( pdf, zip, ... )
      • getFileNameFromPath

        public static String getFileNameFromPath​(String path)
        retreive the file extension.
        Parameters:
        inFileName - a file name
        Returns:
        a file name
      • removeDuplicateToken

        public static String removeDuplicateToken​(String text,
                                                  String token)
      • getLanguageFromFileName

        public static String getLanguageFromFileName​(String filename)
      • getDirNameFromPath

        public static String getDirNameFromPath​(String path)
      • getFileNameWithoutExtension

        public static String getFileNameWithoutExtension​(String inFileName)
        retreive the file extension.
        Parameters:
        inFileName - a file name
        Returns:
        a file extension without dot ( pdf, zip, ... )
      • getFileSize

        public static final String getFileSize​(String filePath)
        return a formated size in a String.
        Parameters:
        filePath - a path to a file
        Returns:
        a string represent a size (sample : 45KB)
      • getFirstNotNull

        public static String getFirstNotNull​(String value1,
                                             String value2)
      • getPropertieskey

        public static String getPropertieskey​(String key)
      • getRandomId

        public static String getRandomId()
      • getShortRandomId

        public static String getShortRandomId()
        return a short id (length 10 chars).
        Returns:
      • encodeAsStructuredCommunicationMod97

        public static String encodeAsStructuredCommunicationMod97​(String code)
        transform a string of number (length 10) to a structured communication, last number is the mod 97 of the first number
        Parameters:
        code - a string of length 10 with only number
        Returns:
        a string on length 12 with the the last number is the mod 97
      • getRandomIdBase10

        public static String getRandomIdBase10()
        generate a id in a String.
        Returns:
        a unique id.
      • getLargeRandomIdBase64

        public static String getLargeRandomIdBase64()
        generate a id in a String.
        Returns:
        a unique id.
      • getRandomIdBase64

        public static String getRandomIdBase64()
        generate a id in a String.
        Returns:
        a unique id.
      • getRandomString

        public static String getRandomString​(int lenght)
      • getRandomString

        public static String getRandomString​(int lenght,
                                             String acceptedChars)
      • htmlSize

        public static int htmlSize​(String str)
        retreive the size of a String with html code. sample: "aaa´" = 4.
        Parameters:
        str - the string
        Returns:
        the size of the String;
      • isCharset

        public static boolean isCharset​(byte[] b,
                                        String inCharset)
      • isDigit

        public static boolean isDigit​(char c)
      • isLetter

        public static boolean isLetter​(char c)
      • isLikeNumber

        public static boolean isLikeNumber​(String str)
        check if string contains somthing similar to digital number
        Parameters:
        str -
        Returns:
      • isDigit

        public static boolean isDigit​(String str)
        check if stirng contains only digital number
        Parameters:
        str -
        Returns:
      • isAlpha

        public static boolean isAlpha​(String str)
        check if stirng contains only digital number
        Parameters:
        str -
        Returns:
      • isFloat

        public static boolean isFloat​(String str)
      • isHTMLText

        public static boolean isHTMLText​(String text)
      • isHTML

        public static final boolean isHTML​(String fileName)
        return true if the filename in a html image).
        Parameters:
        fileName - file name with extension
        Returns:
        true if file name is a image
      • isHTMLStatic

        public static final boolean isHTMLStatic​(String fileName)
      • isProperties

        public static final boolean isProperties​(String fileName)
      • isImage

        public static final boolean isImage​(String fileName)
        return true if the filename in a image for wcms (sp. : tif or psd in not a image).
        Parameters:
        fileName - file name with extension
        Returns:
        true if file name is a image
      • isEditable

        public static final boolean isEditable​(String fileName)
        return true if the filename in a image for wcms (sp. : tif or psd in not a image).
        Parameters:
        fileName - file name with extension
        Returns:
        true if file name is a image
      • isJpeg

        public static final boolean isJpeg​(String fileName)
        return true if the filename in a image for wcms (sp. : tif or psd in not a image).
        Parameters:
        fileName - file name with extension
        Returns:
        true if file name is a image
      • isExcelFile

        public static final boolean isExcelFile​(String fileName)
        return true if the filename in a image for wcms (sp. : tif or psd in not a image).
        Parameters:
        fileName - file name with extension
        Returns:
        true if file name is a image
      • isImageExtension

        public static final boolean isImageExtension​(String fileExtension)
        return true if the file extension is an image for wcms (sp. : tif or psd is not an image).
        Parameters:
        fileExtension - file extension
        Returns:
        true if file name is a image
        See Also:
        getFileExtension(String)
      • isEditableExtension

        public static final boolean isEditableExtension​(String fileExtension)
      • isJpgExtension

        public static final boolean isJpgExtension​(String fileExtension)
        return true if the file extension is an image for wcms (sp. : tif or psd is not an image).
        Parameters:
        fileExtension - file extension
        Returns:
        true if file name is a image
        See Also:
        getFileExtension(String)
      • isDoc

        public static final boolean isDoc​(String fileName)
        return true if the filename in a document (sp. : word, libreoffice...).
        Parameters:
        fileName - file name with extension
        Returns:
        true if file name is a image
      • isPDF

        public static final boolean isPDF​(String fileName)
        return true if the filename in a PDF file.
        Parameters:
        fileName - file name with extension
        Returns:
        true if file name is a image
      • isMail

        public static boolean isMail​(String email)
      • isMailURL

        public static boolean isMailURL​(String url)
      • isPasswordMath

        public static final boolean isPasswordMath​(String pwdData,
                                                   String userInput,
                                                   boolean crypted)
      • isPhoneNumber

        public static boolean isPhoneNumber​(String phone)
      • isSound

        public static final boolean isSound​(String fileName)
        return true if the filename in a sound file image.
        Parameters:
        fileName - file name with extension
        Returns:
        true if file name is a sound
      • isTrue

        public static boolean isTrue​(Object inBool)
      • isTrue

        public static boolean isTrue​(Object inBool,
                                     boolean defaultValue)
      • isTrue

        public static boolean isTrue​(String bool,
                                     boolean defaultValue)
      • isURL

        public static boolean isURL​(String url)
      • isURLFile

        public static final boolean isURLFile​(String fileName)
        return true if the filename in a url file).
        Parameters:
        fileName - file name with extension
        Returns:
        true if file name is a url file
      • isVideo

        public static final boolean isVideo​(String fileName)
        return true if the filename in a video file image).
        Parameters:
        fileName - file name with extension
        Returns:
        true if file name is a video
      • matchStarPattern

        public static boolean matchStarPattern​(String str,
                                               String pattern)
        Test if a string match with a pattern using stars (*).
        assert matchStarPattern("eeA", "ee*");
        assert !matchStarPattern("eeA", "ee");
        assert matchStarPattern("Aee", "*ee");
        assert !matchStarPattern("Aee", "ee");
        assert matchStarPattern("eAe", "e*e");
        assert !matchStarPattern("eAe", "ee");
        assert matchStarPattern("ee", "ee");
        Parameters:
        str -
        pattern -
        Returns:
      • matchQuestionPattern

        public static boolean matchQuestionPattern​(String str,
                                                   String pattern)
        Test if a string match with a pattern using '?'.
        Parameters:
        str -
        pattern -
        Returns:
      • matchSimplePattern

        public static boolean matchSimplePattern​(String str,
                                                 String pattern,
                                                 boolean ignoreCase)
        Test if a string match with a pattern using '?' and '*'.
        Parameters:
        str -
        pattern -
        Returns:
      • neverEmpty

        public static String neverEmpty​(String inStr,
                                        String replaceWith)
        transform a string empty to a other string
        Parameters:
        inStr - a string can be null
        replaceWith - replace with this if null.
        Returns:
        never null ( empty string if input is null)
      • neverNull

        public static String neverNull​(Object inStr)
        transform a string null in a empty String.
        Parameters:
        inStr - a string can be null
        Returns:
        never null ( empty string if input is null)
      • neverNull

        public static String neverNull​(Object inStr,
                                       String replaceWith)
        transform a string null in a empty String.
        Parameters:
        inStr - a string can be null
        replaceWith - replace with this if null.
        Returns:
        never null ( empty string if input is null)
      • neverNullOrEmpty

        public static String neverNullOrEmpty​(Object inStr,
                                              String replaceWith)
      • parseInputLocalDate

        public static LocalDate parseInputLocalDate​(String inDate)
      • parseInputLocalTime

        public static LocalTime parseInputLocalTime​(String inTime)
      • parseInt

        public static int parseInt​(String value,
                                   int defaultValue)
        null save parse int.
        Parameters:
        value - a string with a int inside
        defaultValue - the value if string value is null
        Returns:
      • smartParseDate

        public static Date smartParseDate​(String inDate)
      • smartParseTime

        public static LocalTime smartParseTime​(String inTime)
      • smartParseDate

        public static Date smartParseDate​(String inDate,
                                          String lang)
      • smartParseDateTime

        public static Date smartParseDateTime​(String inDate)
      • readLines

        public static String[] readLines​(String text)
      • createComparableString

        public static String createComparableString​(String text)
      • removeAccents

        public static String removeAccents​(String textWithAccent)
      • removeCR

        public static String removeCR​(String text)
        remove CR from a String
        Parameters:
        text - a simple String
        Returns:
        a string without CR.
      • removeFirstChar

        public static final String removeFirstChar​(String txt,
                                                   char c)
      • removeRepeatedChar

        public static String removeRepeatedChar​(String str)
      • removeRepeatedChar

        public static String removeRepeatedChar​(String str,
                                                char c)
        remove repeated char inside string. sample : "javlo--love" "-" = "javlo-love".
        Parameters:
        str -
        c -
        Returns:
      • removeSequence

        public static final String removeSequence​(String text,
                                                  String prefix,
                                                  String sufix)
        remove sequence from a string. sample : removeSequence ("slkqfj #dlskj# sdljf", "#", "#") -> slkqfj sdljf.
        Parameters:
        text - a simple text
        prefix - the prefix for identify the sequence
        sufix - the sufix for identify the sequence
        Returns:
      • removeTag

        public static String removeTag​(String text)
        remove tag. sample: link -> link
        Parameters:
        text - XHTML Code
        Returns:
        simple text
      • renderDate

        public static String renderDate​(Date date)
      • renderSortableDate

        public static String renderSortableDate​(Date date)
        Parameters:
        date -
        Returns:
      • renderDateAsRFC822String

        public static String renderDateAsRFC822String​(Date date)
      • renderDateAsRFC822String

        public static String renderDateAsRFC822String​(LocalDateTime date)
      • renderDateAsRFC822String

        public static String renderDateAsRFC822String​(ZonedDateTime date)
      • renderDateAsRFC822String

        public static String renderDateAsRFC822String​(LocalDate date)
      • renderDateWithDefaultValue

        public static String renderDateWithDefaultValue​(Date date,
                                                        String defaultValue)
      • renderTimeInSecond

        public static final String renderTimeInSecond​(long time)
      • renderDouble

        public static String renderDouble​(double value,
                                          int precision)
      • renderDouble

        public static String renderDouble​(double value,
                                          Locale locale)
      • renderDouble

        public static String renderDouble​(double value,
                                          int precision,
                                          char sep)
      • renderDoubleAsPercentage

        public static String renderDoubleAsPercentage​(double value)
      • renderFileTime

        public static String renderFileTime​(Date date)
      • renderLightDate

        public static String renderLightDate​(Date date)
      • renderNumber

        public static String renderNumber​(int n,
                                          int size)
      • renderNumber

        public static String renderNumber​(long n,
                                          int size)
      • renderOnlyTime

        public static String renderOnlyTime​(Date date)
      • renderSecondFileTime

        public static String renderSecondFileTime​(Date date)
      • renderSize

        public static final String renderSize​(long size)
        return a formated size in a String.
        Parameters:
        filePath - a path to a file
        Returns:
        a string represent a size (sample : 45KB)
      • renderSortableTime

        public static String renderSortableTime​(Date date)
      • renderTime

        public static String renderTime​(Date date)
      • renderTimeShort

        public static String renderTimeShort​(Date date)
      • renderTimeOnlyShort

        public static String renderTimeOnlyShort​(Date date)
      • renderTimeOnly

        public static String renderTimeOnly​(Date date)
      • renderUserFriendlyDate

        public static String renderUserFriendlyDate​(Date date)
      • renderUserFriendlyDate

        public static String renderUserFriendlyDate​(Locale locale,
                                                    Date date)
      • renderUserFriendlyTime

        public static String renderUserFriendlyTime​(Date date)
      • safeParseLong

        public static Long safeParseLong​(String string,
                                         Long defaultValue)
      • safeParseDouble

        public static Double safeParseDouble​(String string,
                                             Double defaultValue)
      • searchStructuredEmail

        public static Collection<javax.mail.internet.InternetAddress> searchStructuredEmail​(String text)
        extract email from a free text
        Parameters:
        text - a free text
        Returns:
        a collection of email address
      • searchEmail

        public static Collection<String> searchEmail​(String text)
        extract email from a free text
        Parameters:
        text - a free text
        Returns:
        a collection of email address
      • searchLinks

        public static List<URL> searchLinks​(String text)
        extract external link from a free text
        Parameters:
        text - a free text, can be html
        Returns:
        a collection of URL
      • split

        public static String[] split​(String str,
                                     String token)
        split a String, if there are no character between two token this method place a empty String ( != String.split )
        Parameters:
        str - a standard str
        token - a token ( not pattern !!! )
        Returns:
        a array of String without the separator
      • splitStaySeparator

        public static String[] splitStaySeparator​(String str,
                                                  char token)
        split a String, if there are no character between two token this method place a empty String ( != String.split )
        Parameters:
        str - a standard str
        token - a token ( not pattern !!! )
        Returns:
        a array of String with the separator
      • splitStaySeparator

        public static String[] splitStaySeparator​(String str,
                                                  String token)
        split a String, if there are no character between two token this method place a empty String ( != String.split )
        Parameters:
        str - a standard str
        token - a token ( not pattern !!! )
        Returns:
        a array of String with the separator
      • stringInArray

        public static int stringInArray​(String[] array,
                                        String token)
      • stringToArray

        public static String[] stringToArray​(String str)
      • stringToArrayRemoveEmpty

        public static String[] stringToArrayRemoveEmpty​(String str)
      • stringToCollection

        public static List<String> stringToCollection​(String str)
      • stringToCollectionTrim

        public static List<String> stringToCollectionTrim​(String str)
      • stringToCollection

        public static List<String> stringToCollection​(String str,
                                                      String token,
                                                      boolean trim)
      • stringToFileName

        public static String stringToFileName​(String inStr)
      • stringWithoutSpecialChar

        public static String stringWithoutSpecialChar​(String inStr)
      • textToList

        public static String textToList​(GlobalContext globalContext,
                                        String text,
                                        String sep,
                                        String layout,
                                        boolean autoLink,
                                        String ulClass)
        Parameters:
        sep - separation between title and text. sample "1.2 great section" sep=" " -> "1.2" is title and "great section" is text.
        layout - the layout of the list : ("ul-ul", "ol-ol", "ul-ol", "ol-ul") the first element is the first level and the next is all the next level.
        Returns:
        a xhtml list.
      • toJSString

        public static String toJSString​(String inStr)
        transform a String to insert in a JavaScript.
        Parameters:
        inStr - a Simple String
        Returns:
        a String with replacement for insert into a javascript.
      • toMaxSize

        public static String toMaxSize​(String str,
                                       int size,
                                       String sufix)
        transform a String to a max size. sample: "Welcome in the new wave party" --> "Welcome in the..."
        Parameters:
        str - the string must be cut.
        size - the max size of the final string.
        sufix - the sufix of new String if cutted (sp. ... ).
        Returns:
      • toXMLAttribute

        public static String toXMLAttribute​(String value)
        transform a free value to a attribute xml value
        Parameters:
        value -
        Returns:
      • toHTMLAttribute

        public static String toHTMLAttribute​(String value)
        transform a free value to a attribute xml value
        Parameters:
        value -
        Returns:
      • trimAndNullify

        public static String trimAndNullify​(String str)
      • txt2htmlCR

        public static String txt2htmlCR​(String text)
        replace CR with
        and replace special char to html code
        Parameters:
        text - a simple text
        Returns:
        XHTML code
      • writeLines

        public static String writeLines​(String... text)
      • getPathType

        public static String getPathType​(String path,
                                         String prefix)
        return the type of a path (video, image...)
        Parameters:
        path -
        prefix -
        Returns:
      • isEmpty

        public static boolean isEmpty​(Object value)
      • isAllEmpty

        public static boolean isAllEmpty​(Object... values)
      • isOneEmpty

        public static boolean isOneEmpty​(Object... values)
      • extractItem

        public static List<String> extractItem​(String text,
                                               String prefix,
                                               String suffix)
        extract a subtext from a text.
        Parameters:
        text -
        prefix -
        suffix -
        Returns:
      • replaceBloc

        public static String replaceBloc​(String content,
                                         String newBloc,
                                         String prefix,
                                         String suffix,
                                         int insidePosition)
        replace a bloc, between two prefix and suffix and with char pos inside.
        Parameters:
        content -
        newBloc -
        prefix -
        suffix -
        insidePosition -
        Returns:
      • replaceItem

        public static String replaceItem​(String text,
                                         String newItem,
                                         String prefix,
                                         String suffix)
        replace text in larger text
        Parameters:
        text - the original text
        newItem - the new text part
        prefix - the prefix before the replacement
        suffix - the suffix afther the replacement
        Returns:
      • stringToCollectionRemoveEmpty

        public static Collection<? extends String> stringToCollectionRemoveEmpty​(String addRolesAsRaw)
      • sortText

        public static String sortText​(String text)
        sort line of a text
      • createKey

        public static String createKey​(int length,
                                       Set<String> keys)
        create a new unic key.
        Parameters:
        length - the length of the key.
        keys - set of keys allready exist
        Returns:
        null if all keys are in keys set
      • removeNumber

        public static String removeNumber​(String text)
      • trimSpaceAndUnderscore

        public static String trimSpaceAndUnderscore​(String inText)
      • trimLineReturn

        public static String trimLineReturn​(String string)
      • escapeString

        public static String escapeString​(String field,
                                          boolean escapeDoubleQuotes)
      • cleanPath

        public static String cleanPath​(String path)
        clean path, remove double "/" and replace "\" by "/"
        Parameters:
        path -
        Returns:
        "//web/path" >> "/web/path"
      • containsUppercase

        public static boolean containsUppercase​(String text)
        check if a text contains uppercase char. test > false, Test > true, TEST > true
        Parameters:
        text -
        Returns:
      • containsOne

        public static boolean containsOne​(String source,
                                          String... texts)
      • containsNoCase

        public static boolean containsNoCase​(String text,
                                             String token)
      • containsAny

        public static boolean containsAny​(String source,
                                          String... texts)
      • escapeProperty

        public static String escapeProperty​(String theString,
                                            boolean escapeSpace,
                                            boolean escapeUnicode)
        Method copied from the private method java.util.Properties#saveConvert(...)
        Parameters:
        theString -
        escapeSpace -
        escapeUnicode -
        Returns:
      • validUTF8

        public static boolean validUTF8​(byte[] input)
      • getNewToken

        public static String getNewToken()
      • escapeHTML

        public static String escapeHTML​(String html)
      • renderPrice

        public static String renderPrice​(double price,
                                         String currency)
      • getNumberAsAlphabetic

        public static String getNumberAsAlphabetic​(int number)
      • parseColor

        public static Color parseColor​(String color)
        parse error without fault, return null if color is unidentified.
        Parameters:
        color -
        Returns:
      • trimList

        public static List<String> trimList​(Collection<String> list)
        trim all items of the list.
        Parameters:
        list -
        Returns:
      • getItem

        public static String getItem​(String text,
                                     String sep,
                                     int i,
                                     String defaultValue)
        get the item from a string with separator. sample : text1,text2,text3 getItem(sample,",",1) = text1
        Parameters:
        text -
        sep -
        i -
        defaultValue - default value if item not found
        Returns:
      • getPixelValue

        public static Integer getPixelValue​(String pxSize)
        transform a string with size in pixel in integer.
        Parameters:
        pxSize - a size in px (sp. '12px').
        Returns:
        null if bad param (sp. 12%, tralala, null) and the value in pixel if corrent param (12px, 0px, 23 px).
      • hex

        public static String hex​(byte[] array)
      • getCRC32

        public static long getCRC32​(String text)
      • rangeMatches

        public static boolean rangeMatches​(String range,
                                           Integer value)
        Test if the value is included in the range.
        Parameters:
        range - Range values are like -25,25-30,31-35,35+
        value - the integer to test
        Returns:
        true is the value is in the range false otherwise
      • listContainsItem

        public static boolean listContainsItem​(String list,
                                               String sep,
                                               String item)
      • getColNum

        public static int getColNum​(String colName)
      • getColName

        public static String getColName​(int colIndex)
      • timedTokenGenerate

        public static String timedTokenGenerate​(String data,
                                                long timeInMillis)
      • timedTokenValidate

        public static boolean timedTokenValidate​(String tokenData,
                                                 String orignalData,
                                                 int validityRangeInMinutes,
                                                 long timeInMillis)
      • onlyAlphaNumeric

        public static String onlyAlphaNumeric​(String data,
                                              boolean stopOnBadChar)
      • toLatin

        public static String toLatin​(String text)
        convert to latin alphabet
        Parameters:
        text -
        Returns:
      • removeQuote

        public static String removeQuote​(String text)
        remote " on the start and the end of text, if quote was found.
        Parameters:
        text -
        Returns:
      • normalizePhoneNumber

        public static String normalizePhoneNumber​(String phone,
                                                  String countryPrefix)
        format number to number like : +32486123456
        Parameters:
        phone -
        countryPrefix -
        Returns:
      • compare

        public static boolean compare​(String str1,
                                      String str2)
      • propertiesToString

        public static String propertiesToString​(Properties p)
      • extractHost

        public static String extractHost​(String inUrl)
      • extractHostAndProtocol

        public static String extractHostAndProtocol​(String inUrl)
      • parseInt

        public static Integer parseInt​(String txt)
        parse txt, if is'nt integer return 0
        Parameters:
        txt -
        Returns:
      • parseInt

        public static Integer parseInt​(String txt,
                                       Integer defaultValue)
        parse int, if txt is'nt integer return default value.
        Parameters:
        txt -
        defaultValue -
        Returns:
      • setLineSeparator

        public static String setLineSeparator​(String text,
                                              int maxSize,
                                              String lineSeparator)
      • toJsonValue

        public static String toJsonValue​(String data)
      • camelToSnake

        public static String camelToSnake​(String camelStr)
      • snakeToCamel

        public static String snakeToCamel​(String str)
      • splitAddress

        public static String[] splitAddress​(String address)
      • indentScss

        public static String indentScss​(String scss)
      • indentText

        public static String indentText​(String text,
                                        char tokenOpen,
                                        char tokenClose,
                                        char escapeChar,
                                        String alignStr)
      • toArrayString

        public static String[] toArrayString​(Object[] objArray)
      • isContains

        public static boolean isContains​(String src,
                                         String token)
      • copyInClipbaord

        public static void copyInClipbaord​(String content)
      • escapeSpecialRegexChars

        public static String escapeSpecialRegexChars​(String str)