org.omnifaces.el.functions
Class Strings

java.lang.Object
  extended by org.omnifaces.el.functions.Strings

public final class Strings
extends java.lang.Object

Collection of EL functions for string manipulation.

Author:
Bauke Scholtz

Method Summary
static java.lang.String abbreviate(java.lang.String text, int size)
          Abbreviate the given text on the given size limit with ellipsis.
static java.lang.String capitalize(java.lang.String string)
          Capitalize the given string, i.e.
static java.lang.String concat(java.lang.Object left, java.lang.Object right)
          Concatenate the string representation of the given objects.
static java.lang.String encodeURL(java.lang.String string)
          URL-encode the given string using UTF-8.
static java.lang.String escapeJS(java.lang.String string)
          Escapes the given string according the JavaScript code rules.
static java.lang.String format1(java.lang.String pattern, java.lang.Object param1)
          Format the given string with 1 parameter.
static java.lang.String format2(java.lang.String pattern, java.lang.Object param1, java.lang.Object param2)
           
static java.lang.String format3(java.lang.String pattern, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3)
           
static java.lang.String format4(java.lang.String pattern, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3, java.lang.Object param4)
           
static java.lang.String format5(java.lang.String pattern, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3, java.lang.Object param4, java.lang.Object param5)
           
static java.lang.String prettyURL(java.lang.String string)
          URL-prettify the given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

abbreviate

public static java.lang.String abbreviate(java.lang.String text,
                                          int size)
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

public static java.lang.String concat(java.lang.Object left,
                                      java.lang.Object right)
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 is null, otherwise the new EL 2.2 #{bean.string1.concat(bean.string2)} can just be used.

Parameters:
left - The left hand.
right - The right hand.
Returns:
The concatenated strings.

capitalize

public static java.lang.String capitalize(java.lang.String string)
Capitalize the given string, i.e. uppercase the first character.

Parameters:
string - The string to be capitalized.
Returns:
The capitalized string.
Since:
1.1

prettyURL

public static java.lang.String prettyURL(java.lang.String string)
URL-prettify the given string. It performs the following tasks: This is useful when populating links with dynamic paths obtained from user controlled variables, such as blog titles.

Parameters:
string - The string to be prettified.
Returns:
The prettified string.

encodeURL

public static java.lang.String encodeURL(java.lang.String string)
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:
java.lang.UnsupportedOperationException - When this platform does not support UTF-8.

escapeJS

public static java.lang.String escapeJS(java.lang.String string)
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.

format1

public static java.lang.String format1(java.lang.String pattern,
                                       java.lang.Object param1)
Format the given string with 1 parameter. The locale is obtained by Faces.getLocale(). Design notice: There are five formatX() methods, each taking 1 to 5 format parameters because EL functions does not support varargs methods nor overloaded function names.

Parameters:
pattern - The format pattern.
param1 - The first parameter.
Returns:
The formatted string.
See Also:
MessageFormat

format2

public static java.lang.String format2(java.lang.String pattern,
                                       java.lang.Object param1,
                                       java.lang.Object param2)
See Also:
format1(String, Object)

format3

public static java.lang.String format3(java.lang.String pattern,
                                       java.lang.Object param1,
                                       java.lang.Object param2,
                                       java.lang.Object param3)
See Also:
format1(String, Object)

format4

public static java.lang.String format4(java.lang.String pattern,
                                       java.lang.Object param1,
                                       java.lang.Object param2,
                                       java.lang.Object param3,
                                       java.lang.Object param4)
See Also:
format1(String, Object)

format5

public static java.lang.String format5(java.lang.String pattern,
                                       java.lang.Object param1,
                                       java.lang.Object param2,
                                       java.lang.Object param3,
                                       java.lang.Object param4,
                                       java.lang.Object param5)
See Also:
format1(String, Object)