org.loom.tags.functions
Class Functions

java.lang.Object
  extended by org.loom.tags.functions.Functions

public class Functions
extends java.lang.Object

List of JSP functions included with Loom. For usage instructions, see loom-core.tld


Constructor Summary
Functions()
           
 
Method Summary
static boolean contains(java.lang.Object collection, java.lang.Object item)
          Return true if the collection/array contains the given item.
static java.lang.String json(java.lang.Object value)
          Serializes the provided argument as a JSON object
static java.lang.String jsonView(java.lang.Object value, java.lang.String viewClassName)
          Serializes the provided argument as a JSON object using the provided view (see Jackson JsonView)
static int random(int maxValue)
          Return a random number between 0 (inclusive) and the provided value (exclusive)
static java.lang.String truncate(java.lang.String str, int maxWidth)
          Abbreviates a String using ellipsis.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Functions

public Functions()
Method Detail

random

@Function(example="${l:random(10)}")
public static int random(int maxValue)
Return a random number between 0 (inclusive) and the provided value (exclusive)


contains

@Function(example="<c:if test=\"${l:contains(collection, element)}\">")
public static boolean contains(java.lang.Object collection,
                                        java.lang.Object item)
                        throws javax.servlet.jsp.JspTagException
Return true if the collection/array contains the given item. If the collection is null, returns false as the safe bet.

Throws:
javax.servlet.jsp.JspTagException

truncate

@Function(example="${l:truncate(veryLongStringVar, 8)}")
public static java.lang.String truncate(java.lang.String str,
                                                 int maxWidth)
Abbreviates a String using ellipsis. See StringUtils#abbreviate(String, int) for details.


json

@Function(example="${l:json(value)}")
public static java.lang.String json(java.lang.Object value)
                             throws java.io.IOException
Serializes the provided argument as a JSON object

Throws:
java.io.IOException

jsonView

@Function(example="${l:jsonView(value, \'com.acme.json.FullView\')}")
public static java.lang.String jsonView(java.lang.Object value,
                                                 java.lang.String viewClassName)
                                 throws java.io.IOException
Serializes the provided argument as a JSON object using the provided view (see Jackson JsonView)

Throws:
java.io.IOException