com.taggercat.el
Class ELUtils

java.lang.Object
  extended by com.taggercat.el.ELUtils

public class ELUtils
extends java.lang.Object

A collection of utility functions used by the EL Parser.


Field Summary
static int CAST_BIGDECIMAL
           
static int CAST_BIGINTEGER
           
static int CAST_BYTE
           
static int CAST_DOUBLE
           
static int CAST_FLOAT
           
static int CAST_INTEGER
           
static int CAST_LONG
           
static int CAST_SHORT
           
 
Method Summary
static void addStaticMethods(java.lang.Class staticClasss, java.util.Map<java.lang.String,java.lang.String> functionMap, java.util.List<java.lang.String> functionNames)
          Adds all public static methods declared in the specified class to the EL's function map.
static java.lang.Object getBeanProperty(java.lang.Object startingObject, java.lang.String scopedMethodName)
          Gets the bean property.
static java.lang.Integer getDateDiff(java.util.Calendar cal1, java.util.Calendar cal2, int datePart)
          Calculates the difference between two dates.
static int getDaysInMonth(int year, int month)
           
static java.lang.StringBuffer getMethodSignature(java.lang.String functionName, java.util.List functionArgs)
          Returns a method signature for the method name, and args
static void initConstants(java.util.Map<java.lang.String,java.lang.Integer> expConstants)
           
static java.lang.Object invokeStaticFunction(ELContext elContext, java.lang.String classname, java.lang.String functionName, java.util.List functionArgs)
           
static boolean matchLike(java.lang.String searchFieldValue, java.lang.String searchValue)
          String search with wild card support.
static java.lang.Boolean matchRegularExpression(java.lang.String input, java.lang.String regxString)
          Returns true if the input string is matched by the regular expression.
static java.lang.String toBeanGetterName(java.lang.String basicName)
          Converts the basic method name to a getter method name.
static java.util.Date toDate(java.lang.String dateStr)
          Parses a date string using the formatters initialized in the config class.
static java.lang.String unEscape(java.lang.String str)
          Unescape any \", \' \n \r sequences
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CAST_BIGDECIMAL

public static final int CAST_BIGDECIMAL
See Also:
Constant Field Values

CAST_BIGINTEGER

public static final int CAST_BIGINTEGER
See Also:
Constant Field Values

CAST_BYTE

public static final int CAST_BYTE
See Also:
Constant Field Values

CAST_DOUBLE

public static final int CAST_DOUBLE
See Also:
Constant Field Values

CAST_FLOAT

public static final int CAST_FLOAT
See Also:
Constant Field Values

CAST_INTEGER

public static final int CAST_INTEGER
See Also:
Constant Field Values

CAST_LONG

public static final int CAST_LONG
See Also:
Constant Field Values

CAST_SHORT

public static final int CAST_SHORT
See Also:
Constant Field Values
Method Detail

addStaticMethods

public static void addStaticMethods(java.lang.Class staticClasss,
                                    java.util.Map<java.lang.String,java.lang.String> functionMap,
                                    java.util.List<java.lang.String> functionNames)
Adds all public static methods declared in the specified class to the EL's function map.

Parameters:
staticClasss -
functionMap -

matchLike

public static boolean matchLike(java.lang.String searchFieldValue,
                                java.lang.String searchValue)
String search with wild card support. This supports both leading, and / or trailing wild card characters. Either * or % can be used as a wild card.

Parameters:
searchFieldValue - the value to search in
searchValue - the value to search for
Returns:
true if the search value is found in the search field value

matchRegularExpression

public static java.lang.Boolean matchRegularExpression(java.lang.String input,
                                                       java.lang.String regxString)
                                                throws java.lang.Exception
Returns true if the input string is matched by the regular expression.

Parameters:
input - the value to search in
regxString - the regular expression to match
Returns:
true if the search value is found in the search field value
Throws:
java.lang.Exception

unEscape

public static java.lang.String unEscape(java.lang.String str)
Unescape any \", \' \n \r sequences

Parameters:
str - the string to unescape
Returns:
the unescaped string

toDate

public static java.util.Date toDate(java.lang.String dateStr)
Parses a date string using the formatters initialized in the config class.

Parameters:
dateStr - the date string
Returns:
the Date value, null if the date string cannot be parsed by one of the formatters

initConstants

public static void initConstants(java.util.Map<java.lang.String,java.lang.Integer> expConstants)

getBeanProperty

public static java.lang.Object getBeanProperty(java.lang.Object startingObject,
                                               java.lang.String scopedMethodName)
                                        throws java.lang.IllegalArgumentException
Gets the bean property.

Parameters:
startingObject - the source, or starting object to execute the method on
scopedMethodName - the method name of the form = "customer.order.account.foo";
Returns:
the property returned from the last getter, eg. getFoo()
Throws:
java.lang.IllegalArgumentException

toBeanGetterName

public static java.lang.String toBeanGetterName(java.lang.String basicName)
Converts the basic method name to a getter method name.

Parameters:
basicName - the basic name
Returns:
the getter name

invokeStaticFunction

public static java.lang.Object invokeStaticFunction(ELContext elContext,
                                                    java.lang.String classname,
                                                    java.lang.String functionName,
                                                    java.util.List functionArgs)
                                             throws java.lang.ClassNotFoundException,
                                                    java.lang.IllegalArgumentException,
                                                    java.lang.IllegalAccessException,
                                                    java.lang.reflect.InvocationTargetException
Throws:
java.lang.ClassNotFoundException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

getMethodSignature

public static java.lang.StringBuffer getMethodSignature(java.lang.String functionName,
                                                        java.util.List functionArgs)
Returns a method signature for the method name, and args

Parameters:
functionName - the function name
functionArgs - the arg type
Returns:
the method signature for the method name, and args

getDateDiff

public static java.lang.Integer getDateDiff(java.util.Calendar cal1,
                                            java.util.Calendar cal2,
                                            int datePart)
Calculates the difference between two dates.

Parameters:
cal1 - the first calendar
cal2 - the second calendar
datePart - the date part to calculate the difference for
Returns:
the difference

getDaysInMonth

public static int getDaysInMonth(int year,
                                 int month)