Class JSTLFunctions


  • public class JSTLFunctions
    extends Object
    Utility functions that are exposed through a taglib.
    Author:
    Guus der Kinderen
    • Constructor Detail

      • JSTLFunctions

        public JSTLFunctions()
    • Method Detail

      • split

        public static String[] split​(String string,
                                     String regex)
        JSTL delegate for String.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 of String.split(String).
        Parameters:
        string - The string to split
        regex - 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 into application/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 a application/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)