Package org.forgerock.openig.el
Class Functions
- java.lang.Object
-
- org.forgerock.openig.el.Functions
-
public final class Functions extends Object
Methods exposed for EL usage.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String[]array(String... values)Create an array of String based on the strings given as parameters.static Booleanbool(String value)static booleancontains(Object object, Object value)Returnstrueif the object contains the value.static StringdecodeBase64(String value)Decode the given Base64 String input.static StringencodeBase64(String value)Encode the given String input into Base 64.static StringfileToUrl(File file)Returns the String representation of the URL denoting the given file.static intindexOf(String value, String substring)Returns the index within a string of the first occurrence of a specified substring.static Integerinteger(String value)static IntegerintegerWithRadix(String value, int radix)static Stringjoin(String[] values, String separator)Joins an array of strings into a single string value, with a specified separator.static StringkeyMatch(Object map, String pattern)Returns the first key found in a map that matches the specified regular expression pattern, ornullif no such match is found.static intlength(Object value)Returns the number of items in a collection, or the number of characters in a string.static booleanmatches(String value, String pattern)Returnstrueif the string contains the specified regular expression pattern.static String[]matchingGroups(String value, String pattern)Returns an array containing the matches of a regular expression pattern against a string, ornullif no match is found.static StringpathToUrl(String path)Returns the String representation of the URL denoting the given path.static Stringread(String filename)Returns the content of the given file as a plain String.static PropertiesreadProperties(String filename)Returns the content of the given file as aProperties.static String[]split(String value, String regex)Splits a string into an array of substrings around matches of the given regular expression.static StringtoLowerCase(String value)Converts all of the characters in a string to lower case.static StringtoString(Object value)Returns the string value of an arbitrary object.static StringtoUpperCase(String value)Converts all of the characters in a string to upper case.static Stringtrim(String value)Returns a copy of a string with leading and trailing whitespace omitted.static StringurlDecode(String value)Returns the URL decoding of the provided string.static StringurlEncode(String value)Returns the URL encoding of the provided string.
-
-
-
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 aStringto anInteger. If the parameter is not a valid integer (in radix 10) then it returns null.- Parameters:
value- theStringcontaining 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)
- Parameters:
value- theStringcontaining the integer representation to be parsedradix- the radix to be used while parsings.- Returns:
- the integer represented by the string argument in the specified radix.
-
bool
public static Boolean bool(String value)
Transforms aStringto anBoolean. The rules for the transformation are the same as the ones described onBoolean.valueOf(String).- Parameters:
value- theStringcontaining the boolean representation to be parsed- Returns:
- the boolean represented by the string argument.
-
contains
public static boolean contains(Object object, Object value)
Returnstrueif the object contains the value.- Parameters:
object- the object to be searched.value- the value to find.- Returns:
- the length of the object, or
0if 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
-1if 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, ornullif 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
nullif 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
0if length could not be determined.
-
matches
public static boolean matches(String value, String pattern)
Returnstrueif 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:
trueif 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, ornullif 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
nullif 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.
-
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 benull.- Returns:
- the URL encoding of the provided string, or
nullifstringwasnull.
-
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 benull.- Returns:
- the URL decoding of the provided string, or
nullifstringwasnull.
-
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 benull.- Returns:
- the Base64 encoding of the provided string, or
nullifstringwasnull.
-
decodeBase64
public static String decodeBase64(String value)
Decode the given Base64 String input.- Parameters:
value- the string to be Base64 decoded, which may benull.- Returns:
- the decoding of the provided string, or
nullifstringwasnullor if the input was not a Base64 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, ...)
-
readProperties
public static Properties readProperties(String filename)
Returns the content of the given file as aProperties.- Parameters:
filename- file to be read- Returns:
- the file content as
Propertiesor 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.
-
-