public final class Strings extends Object
Collection of EL functions for string manipulation: of:abbreviate()
, of:capitalize()
, of:concat()
,
of:prettyURL()
, of:encodeURL()
, of:escapeJS()
and of:formatX()
.
Instead of of:formatX()
, you can also use <o:outputFormat>
.
Modifier and Type | Method and Description |
---|---|
static String |
abbreviate(String text,
int size)
Abbreviate the given text on the given size limit with ellipsis.
|
static String |
capitalize(String string)
Capitalize the given string, i.e.
|
static String |
concat(Object left,
Object right)
Concatenate the string representation of the given objects.
|
static String |
encodeURI(String string)
URI-encode the given string using UTF-8.
|
static String |
encodeURL(String string)
URL-encode the given string using UTF-8.
|
static String |
escapeJS(String string)
Escapes the given string according the JavaScript code rules.
|
static String |
format1(String pattern,
Object param1)
Format the given string with 1 parameter using
MessageFormat API. |
static String |
format2(String pattern,
Object param1,
Object param2)
Format the given string with 2 parameters using
MessageFormat API. |
static String |
format3(String pattern,
Object param1,
Object param2,
Object param3)
Format the given string with 3 parameters using
MessageFormat API. |
static String |
format4(String pattern,
Object param1,
Object param2,
Object param3,
Object param4)
Format the given string with 4 parameters using
MessageFormat API. |
static String |
format5(String pattern,
Object param1,
Object param2,
Object param3,
Object param4,
Object param5)
Format the given string with 5 parameters using
MessageFormat API. |
static boolean |
matches(String value,
String pattern)
Returns true if the given string matches the given pattern.
|
static String |
parenthesize(Object object)
Parenthesize the given object.
|
static String |
prettyURL(String string)
URL-prettify the given string.
|
static String |
replaceAll(String value,
String pattern,
String replacement)
Replace all matches of the given pattern on the given string with the given replacement.
|
public static String abbreviate(String text, int size)
text
- The text to be abbreviated.size
- The size limit of the text.public static String concat(Object left, Object right)
null
, otherwise the new EL 2.2
#{bean.string1.concat(bean.string2)}
can just be used.left
- The left hand.right
- The right hand.public static String capitalize(String string)
string
- The string to be capitalized.public static String parenthesize(Object object)
object
- The object to be parenthesized.public static String replaceAll(String value, String pattern, String replacement)
value
- The string to be replaced.pattern
- The regular expression pattern to be tested.replacement
- The string to be substituted for each match.String.replaceAll(String, String)
public static boolean matches(String value, String pattern)
value
- The string to be matched.pattern
- The regular expression pattern to be tested.String.matches(String)
public static String prettyURL(String string)
string
- The string to be prettified.public static String encodeURL(String string)
<f:param>
.string
- The string to be URL-encoded.UnsupportedOperationException
- When this platform does not support UTF-8.public static String encodeURI(String string)
string
- The string to be URI-encoded.UnsupportedOperationException
- When this platform does not support UTF-8.public static String escapeJS(String string)
string
- The string to be escaped according the JavaScript code rules.public static String format1(String pattern, Object param1)
MessageFormat
API. The locale is obtained by
Faces.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.pattern
- The format pattern.param1
- The first parameter.MessageFormat
public static String format2(String pattern, Object param1, Object param2)
MessageFormat
API. The locale is obtained by
Faces.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.pattern
- The format pattern.param1
- The first parameter.param2
- The second parameter.format1(String, Object)
public static String format3(String pattern, Object param1, Object param2, Object param3)
MessageFormat
API. The locale is obtained by
Faces.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.pattern
- The format pattern.param1
- The first parameter.param2
- The second parameter.param3
- The third parameter.format1(String, Object)
public static String format4(String pattern, Object param1, Object param2, Object param3, Object param4)
MessageFormat
API. The locale is obtained by
Faces.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.pattern
- The format pattern.param1
- The first parameter.param2
- The second parameter.param3
- The third parameter.param4
- The fourth parameter.format1(String, Object)
public static String format5(String pattern, Object param1, Object param2, Object param3, Object param4, Object param5)
MessageFormat
API. The locale is obtained by
Faces.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.pattern
- The format pattern.param1
- The first parameter.param2
- The second parameter.param3
- The third parameter.param4
- The fourth parameter.param5
- The fifth parameter.format1(String, Object)
Copyright © 2012–2020 OmniFaces. All rights reserved.