Class Functions


  • public final class Functions
    extends Object
    Methods exposed for EL usage.
    • Method Detail

      • array

        public static String[] array​(String... values)
        Create an array of String based on the strings given as parameters.
        Parameters:
        values - the strings to put in the array.
        Returns:
        the array of strings.
      • integer

        public static Integer integer​(String value)
        Transforms a String to an Integer. If the parameter is not a valid integer (in radix 10) then it returns null.
        Parameters:
        value - the String containing the integer representation to be parsed
        Returns:
        the integer represented by the string argument in the radix 10.
      • integerWithRadix

        public static Integer integerWithRadix​(String value,
                                               int radix)
        Transforms a String to an Integer. If the parameter is not a valid integer then it returns null.
        Parameters:
        value - the String containing the integer representation to be parsed
        radix - the radix to be used while parsing s.
        Returns:
        the integer represented by the string argument in the specified radix.
      • bool

        public static Boolean bool​(String value)
        Transforms a String to an Boolean. The rules for the transformation are the same as the ones described on Boolean.valueOf(String).
        Parameters:
        value - the String containing the boolean representation to be parsed
        Returns:
        the boolean represented by the string argument.
      • contains

        public static boolean contains​(Object object,
                                       Object value)
        Returns true if the object contains the value.
        Parameters:
        object - the object to be searched.
        value - the value to find.
        Returns:
        the length of the object, or 0 if length could not be determined.
      • indexOf

        public static int indexOf​(String value,
                                  String substring)
        Returns the index within a string of the first occurrence of a specified substring.
        Parameters:
        value - the string to be searched.
        substring - the value to search for within the string
        Returns:
        the index of the first instance of substring, or -1 if not found.
      • join

        public static String join​(String[] values,
                                  String separator)
        Joins an array of strings into a single string value, with a specified separator.
        Parameters:
        separator - the separator to place between joined elements.
        values - the array of strings to be joined. You can use the array() function to construct this argument.
        Returns:
        the string containing the joined strings.
      • keyMatch

        public static String keyMatch​(Object map,
                                      String pattern)
        Returns the first key found in a map that matches the specified regular expression pattern, or null if no such match is found.
        Parameters:
        map - the map whose keys are to be searched.
        pattern - a string containing the regular expression pattern to match.
        Returns:
        the first matching key, or null if no match found.
      • length

        public static int length​(Object value)
        Returns the number of items in a collection, or the number of characters in a string.
        Parameters:
        value - the object whose length is to be determined.
        Returns:
        the length of the object, or 0 if length could not be determined.
      • matches

        public static boolean matches​(String value,
                                      String pattern)
        Returns true if the string contains the specified regular expression pattern.
        Parameters:
        value - the string to be searched.
        pattern - a string containing the regular expression pattern to find.
        Returns:
        true if the string contains the specified regular expression pattern.
      • matchingGroups

        public static String[] matchingGroups​(String value,
                                              String pattern)
        Returns an array containing the matches of a regular expression pattern against a string, or null if no match is found. The first element of the array is the entire match, and each subsequent element correlates to any capture group specified within the regular expression.
        Parameters:
        value - the string to be searched.
        pattern - a string containing the regular expression pattern to match.
        Returns:
        an array of matches, or null if no match found.
      • split

        public static String[] split​(String value,
                                     String regex)
        Splits a string into an array of substrings around matches of the given regular expression.
        Parameters:
        value - the string to be split.
        regex - the regular expression to split substrings around.
        Returns:
        the resulting array of split substrings.
      • toJson

        public static Object toJson​(String value)
        Parse/Un-marshal the input String into a JSON structure.
        Parameters:
        value - The stringified-JSON.
        Returns:
        an un-marshalled JSON structure or null if anything went wrong during parsing.
      • toLowerCase

        public static String toLowerCase​(String value)
        Converts all of the characters in a string to lower case.
        Parameters:
        value - the string whose characters are to be converted.
        Returns:
        the string with characters converted to lower case.
      • toString

        public static String toString​(Object value)
        Returns the string value of an arbitrary object.
        Parameters:
        value - the object whose string value is to be returned.
        Returns:
        the string value of the object.
      • toUpperCase

        public static String toUpperCase​(String value)
        Converts all of the characters in a string to upper case.
        Parameters:
        value - the string whose characters are to be converted.
        Returns:
        the string with characters converted to upper case.
      • trim

        public static String trim​(String value)
        Returns a copy of a string with leading and trailing whitespace omitted.
        Parameters:
        value - the string whose white space is to be omitted.
        Returns:
        the string with leading and trailing white space omitted.
      • urlEncode

        public static String urlEncode​(String value)
        Returns the URL encoding of the provided string.
        Parameters:
        value - the string to be URL encoded, which may be null.
        Returns:
        the URL encoding of the provided string, or null if string was null.
      • urlDecode

        public static String urlDecode​(String value)
        Returns the URL decoding of the provided string.
        Parameters:
        value - the string to be URL decoded, which may be null.
        Returns:
        the URL decoding of the provided string, or null if string was null.
      • encodeBase64

        public static String encodeBase64​(String value)
        Encode the given String input into Base 64.
        Parameters:
        value - the string to be Base64 encoded, which may be null.
        Returns:
        the Base64 encoding of the provided string, or null if string was null.
      • decodeBase64

        public static String decodeBase64​(String value)
        Decode the given Base64 String input.
        Parameters:
        value - the string to be Base64 decoded, which may be null.
        Returns:
        the decoding of the provided string, or null if string was null or if the input was not a Base64 valid input.
      • encodeBase64url

        public static String encodeBase64url​(String value)
        Encode the given String input into Base64url.
        Parameters:
        value - the string to be Base64url encoded, which may be null.
        Returns:
        the Base64url encoding of the provided string, or null if string was null.
      • decodeBase64url

        public static String decodeBase64url​(String value)
        Decode the given Base64url String input.
        Parameters:
        value - the string to be Base64url decoded, which may be null.
        Returns:
        the decoding of the provided string, or null if string was null or if the input was not a Base64url valid input.
      • read

        public static String read​(String filename)
        Returns the content of the given file as a plain String.
        Parameters:
        filename - file to be read
        Returns:
        the file content as a String or null if here was an error (missing file, ...)
      • readWithCharset

        public static String readWithCharset​(String filename,
                                             Charset charset)
        Returns the content of the given file as a plain String using a specific Charset.
        Parameters:
        filename - The file to read.
        charset - The Charset to use to read that file.
        Returns:
        The file contente as a String or null if an error occurred.
      • readProperties

        public static Properties readProperties​(String filename)
        Returns the content of the given file as a Properties.
        Parameters:
        filename - file to be read
        Returns:
        the file content as Properties or null if here was an error (missing file, ...)
      • pathToUrl

        public static String pathToUrl​(String path)
        Returns the String representation of the URL denoting the given path.
        Parameters:
        path - the path to build the URL from.
        Returns:
        the String representation of the URL denoting the given path.
      • fileToUrl

        public static String fileToUrl​(File file)
        Returns the String representation of the URL denoting the given file.
        Parameters:
        file - the file to build the URL from.
        Returns:
        the String representation of the URL denoting the given file.