Class MiscFunctions
java.lang.Object
org.deltava.taglib.functions.MiscFunctions
A JSP Function Library to store miscellaneous functions.
- Since:
- 1.0
- Version:
- 11.0
- Author:
- Luke
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> boolean
contains
(Collection<T> c, T obj) A JSP-friendly function to check if an object exists within a Collection.static long
difference
(Temporal t1, Temporal t2) Displays the time difference between two date/times.static String
"Escape" a string by stripping out all inline HTML.static <T> T
first
(Collection<T> c) Returns the first object in a Collection.static String
Formats a Date into a String for use in a JSP Tag parameter.static <T> T
A JSP-friendly function to get an element from a List.static String
Performs a search and replace operation.static String
splice
(Collection<?> c, String delim) Concatenates a series of list elements into a String.static <T> Collection
<T> subset
(Collection<T> c, int size) Returns a subset of a Collection.static String
toHex
(long val) Converts a number to hexadecimal.static String
Converts a string to lower case.static String
toRGBA
(int c, float a) Generates a CSS color with alpha.static String
Converts a string to upper case.
-
Method Details
-
get
A JSP-friendly function to get an element from a List. Equivalent toList.get(int)
.- Parameters:
l
- the List containing the elementsidx
- the element position within the List- Returns:
- the element, or null if an invalid index is specified
-
first
Returns the first object in a Collection.- Parameters:
c
- the Collection- Returns:
- the first Object returned by the Collection's iterator.
-
subset
Returns a subset of a Collection.- Parameters:
c
- the Collectionsize
- the number of entries to return- Returns:
- a Collection with the specified number of entries, or less if c is smaller than size
-
contains
A JSP-friendly function to check if an object exists within a Collection.- Parameters:
c
- the Collectionobj
- the Object- Returns:
- TRUE if c is not null and c.contains(obj), otherwise FALSE
- See Also:
-
escape
-
replace
-
splice
Concatenates a series of list elements into a String.- Parameters:
c
- a Collection of objectsdelim
- the delimiter- Returns:
- a delimited String
-
toHex
Converts a number to hexadecimal.- Parameters:
val
- the number to convert- Returns:
- the converted number, with "0x" prepended to it
- See Also:
-
toLower
-
toUpper
-
toRGBA
Generates a CSS color with alpha.- Parameters:
c
- the RGB colora
- the alpha factor from 0 to 1- Returns:
- a CSS color with alpha
-
format
-
difference
-