java.lang.Object
org.omnifaces.el.functions.Strings
Collection of EL functions for string manipulation: o:abbreviate(), o:capitalize(), o:concat(),
o:prettyURL(), o:encodeURL(), o:encodeURI(), o:encodeBase64(),
o:escapeJS(), o:stripTags() and o:formatX().
Instead of o:formatX(), you can also use <o:outputFormat>.
- Author:
- Bauke Scholtz
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringabbreviate(String text, int size) Abbreviate the given text on the given size limit with ellipsis.static Stringcapitalize(String string) Capitalize the given string, i.e. uppercase the first character.static StringConcatenate the string representation of the given objects.static StringencodeBase64(String string) Base64-encode the given string.static StringURI-encode the given string using UTF-8.static StringURL-encode the given string using UTF-8.static StringEscapes the given string according the JavaScript code rules.static StringFormat the given string with 1 parameter usingMessageFormatAPI.static StringFormat the given string with 2 parameters usingMessageFormatAPI.static StringFormat the given string with 3 parameters usingMessageFormatAPI.static StringFormat the given string with 4 parameters usingMessageFormatAPI.static StringFormat the given string with 5 parameters usingMessageFormatAPI.static booleanReturns true if the given string matches the given pattern.static Stringparenthesize(Object object) Parenthesize the given object.static StringURL-prettify the given string.static StringreplaceAll(String value, String pattern, String replacement) Replace all matches of the given pattern on the given string with the given replacement.static StringRemove XML tags from a string and return only plain text.
-
Method Details
-
abbreviate
Abbreviate the given text on the given size limit with ellipsis.- Parameters:
text- The text to be abbreviated.size- The size limit of the text.- Returns:
- The abbreviated text, or the unmodified text if it is shorter than the size.
-
concat
Concatenate the string representation of the given objects. This is useful when you don't know beforehand if one of the both hands is a string or isnull, otherwise the EL#{bean.string1.concat(bean.string2)}can just be used.- Parameters:
left- The left hand.right- The right hand.- Returns:
- The concatenated strings.
-
capitalize
Capitalize the given string, i.e. uppercase the first character.- Parameters:
string- The string to be capitalized.- Returns:
- The capitalized string.
- Since:
- 1.1
-
parenthesize
Parenthesize the given object. This will only wrap the given object in parenthesis when it's not empty or zero.- Parameters:
object- The object to be parenthesized.- Returns:
- The parenthesized object.
- Since:
- 3.0
-
replaceAll
Replace all matches of the given pattern on the given string with the given replacement.- Parameters:
value- The string to be replaced.pattern- The regular expression pattern to be tested.replacement- The string to be substituted for each match.- Returns:
- True if the given string matches the given pattern.
- Since:
- 1.5
- See Also:
-
matches
Returns true if the given string matches the given pattern.- Parameters:
value- The string to be matched.pattern- The regular expression pattern to be tested.- Returns:
- True if the given string matches the given pattern.
- Since:
- 1.5
- See Also:
-
prettyURL
URL-prettify the given string. It performs the following tasks:- Lowercase the string.
- Remove combining diacritical marks.
- Replace non-alphanumeric characters by hyphens.
- Parameters:
string- The string to be prettified.- Returns:
- The prettified string.
-
encodeURL
URL-encode the given string using UTF-8. This is useful for cases where you can't use<f:param>.- Parameters:
string- The string to be URL-encoded.- Returns:
- The URL-encoded string.
- Throws:
UnsupportedOperationException- When this platform does not support UTF-8.
-
encodeURI
URI-encode the given string using UTF-8. This is useful for cases where you need to embed path parameters in URLs.- Parameters:
string- The string to be URI-encoded.- Returns:
- The URI-encoded string.
- Throws:
UnsupportedOperationException- When this platform does not support UTF-8.- Since:
- 3.5
-
encodeBase64
Base64-encode the given string. This is useful for cases where you need to create data URLs.- Parameters:
string- The string to be Base64-encoded.- Returns:
- The Base64-encoded string.
- Since:
- 3.8
-
escapeJS
Escapes the given string according the JavaScript code rules. This escapes among others the special characters, the whitespace, the quotes and the unicode characters. Useful whenever you want to use a Java string variable as a JavaScript string variable.- Parameters:
string- The string to be escaped according the JavaScript code rules.- Returns:
- The escaped string according the JavaScript code rules.
-
stripTags
Remove XML tags from a string and return only plain text.- Parameters:
string- The string with XML tags.- Returns:
- The string without XML tags.
- Since:
- 3.7
-
format1
Format the given string with 1 parameter usingMessageFormatAPI. The locale is obtained byFaces.getLocale(). Design notice: There are five formatX() methods, each taking 1 to 5 format parameters because EL functions do not support varargs methods nor overloaded function names.- Parameters:
pattern- The format pattern.param1- The first parameter.- Returns:
- The formatted string.
- See Also:
-
format2
Format the given string with 2 parameters usingMessageFormatAPI. The locale is obtained byFaces.getLocale(). Design notice: There are five formatX() methods, each taking 1 to 5 format parameters because EL functions do not support varargs methods nor overloaded function names.- Parameters:
pattern- The format pattern.param1- The first parameter.param2- The second parameter.- Returns:
- The formatted string.
- See Also:
-
format3
Format the given string with 3 parameters usingMessageFormatAPI. The locale is obtained byFaces.getLocale(). Design notice: There are five formatX() methods, each taking 1 to 5 format parameters because EL functions do not support varargs methods nor overloaded function names.- Parameters:
pattern- The format pattern.param1- The first parameter.param2- The second parameter.param3- The third parameter.- Returns:
- The formatted string.
- See Also:
-
format4
public static String format4(String pattern, Object param1, Object param2, Object param3, Object param4) Format the given string with 4 parameters usingMessageFormatAPI. The locale is obtained byFaces.getLocale(). Design notice: There are five formatX() methods, each taking 1 to 5 format parameters because EL functions do not support varargs methods nor overloaded function names.- Parameters:
pattern- The format pattern.param1- The first parameter.param2- The second parameter.param3- The third parameter.param4- The fourth parameter.- Returns:
- The formatted string.
- See Also:
-
format5
public static String format5(String pattern, Object param1, Object param2, Object param3, Object param4, Object param5) Format the given string with 5 parameters usingMessageFormatAPI. The locale is obtained byFaces.getLocale(). Design notice: There are five formatX() methods, each taking 1 to 5 format parameters because EL functions do not support varargs methods nor overloaded function names.- Parameters:
pattern- The format pattern.param1- The first parameter.param2- The second parameter.param3- The third parameter.param4- The fourth parameter.param5- The fifth parameter.- Returns:
- The formatted string.
- See Also:
-