Package org.jivesoftware.admin
Class JSTLFunctions
- java.lang.Object
-
- org.jivesoftware.admin.JSTLFunctions
-
public class JSTLFunctions extends Object
Utility functions that are exposed through a taglib.- Author:
- Guus der Kinderen
-
-
Constructor Summary
Constructors Constructor Description JSTLFunctions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
byteFormat(long bytes)
A formatter for formatting byte sizes.static String
escapeHTMLTags(String string)
This method takes a string which may contain HTML tags (ie, <b>, <table>, etc) and converts the '<' and '>' characters to their HTML escape sequences.static String
replaceAll(String string, String regex, String replacement)
JSTL delegate forString.replaceAll(String, String)
.static String[]
split(String string, String regex)
JSTL delegate forString.split(String)
.static String
urlDecode(String string)
Decodes aapplication/x-www-form-urlencoded
string using the UTF-8 encoding scheme.static String
urlEncode(String string)
Translates a string intoapplication/x-www-form-urlencoded
format using a specific encoding scheme.
-
-
-
Method Detail
-
replaceAll
public static String replaceAll(String string, String regex, String replacement)
JSTL delegate forString.replaceAll(String, String)
. The first argument is the value on which the replacement has to occur. The other arguments are passed toString.replaceAll(String, String)
directly.- Parameters:
string
- The string to searchregex
- the regular expression to which this string is to be matchedreplacement
- the string to be substituted for each match- Returns:
- the updated string
- See Also:
String.replaceAll(String, String)
-
split
public static String[] split(String string, String regex)
JSTL delegate forString.split(String)
. The first argument is the value on which the replacement has to occur. The other argument is used as the argument for the invocation ofString.split(String)
.- Parameters:
string
- The string to splitregex
- the delimiting regular expression- Returns:
- the the array of strings computed by splitting this string around matches of the given regular expression
- See Also:
String.split(String)
-
byteFormat
public static String byteFormat(long bytes)
A formatter for formatting byte sizes. For example, formatting 12345 byes results in "12.1 K" and 1234567 results in "1.18 MB".- Parameters:
bytes
- the number of bytes- Returns:
- the number of bytes in terms of KB, MB, etc.
- See Also:
ByteFormat
-
urlEncode
public static String urlEncode(String string)
Translates a string intoapplication/x-www-form-urlencoded
format using a specific encoding scheme. This method uses the UTF-8 encoding scheme to obtain the bytes for unsafe characters.- Parameters:
string
- the URL to encode- Returns:
- the encoded URL
- See Also:
URLEncoder
-
urlDecode
public static String urlDecode(String string)
Decodes aapplication/x-www-form-urlencoded
string using the UTF-8 encoding scheme. The encoding is used to determine what characters are represented by any consecutive sequences of the form "%xy
".- Parameters:
string
- the String to encode- Returns:
- the encoded string
- See Also:
URLDecoder
-
escapeHTMLTags
public static String escapeHTMLTags(String string)
This method takes a string which may contain HTML tags (ie, <b>, <table>, etc) and converts the '<' and '>' characters to their HTML escape sequences. It will also replace LF with <br>.- Parameters:
string
- the String to escape- Returns:
- the escaped string
- See Also:
StringUtils.escapeHTMLTags(String)
-
-