com.taggercat.el
Class ELInternalFunctions

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

public class ELInternalFunctions
extends java.lang.Object

This class represents the internal functions available to the EL.

Version:
$Revision: #4 $ $DateTime: 2008/11/21 06:01:11 $

Constructor Summary
ELInternalFunctions()
           
 
Method Summary
static java.lang.Object check(java.lang.Boolean condition, java.lang.Object iffalse)
          Returns true if the condition is true, otherwise, the iffalse value is returned.
static java.lang.Object choose(java.lang.Object... args)
          Returns the result of the first corresponding true condition This method is essentially a single line switch statement.
static java.lang.Boolean contains(java.lang.String string, java.lang.String find)
          Returns the index within the string of the first occurrence of the find argument.
static java.lang.Object convert(java.lang.Number number, java.lang.Integer typeId)
          Converts the number argument to the specified type.
static java.util.Date date()
          Returns the current system date.
static java.util.Date dateAdd(java.util.Date date, java.lang.Integer delta)
          Returns the delta number of days to the date.
static java.util.Date dateAdd(java.util.Date date, java.lang.Integer delta, java.lang.Integer partId)
          Adds the specified delta to the date where the delta type is specified with the partId.
static java.lang.Integer dateDiff(java.util.Date date1, java.util.Date date2)
          Returns the number of days between the date1 and date2 values.
static java.lang.Integer dateDiff(java.util.Date date1, java.util.Date date2, java.lang.Integer partId)
          Returns the difference between the date1 and date2 values.
static java.lang.Integer datePart(java.util.Date date, java.lang.Number partId)
          Returns the date part for the date.
static java.lang.Integer dayOfWeek(java.util.Date date)
          Returns the Calendar.DAY_OF_WEEK for the date.
static java.util.Date endOfDay()
          Returns the end of the current day.
static java.util.Date endOfDay(java.util.Date date)
          Returns the end of the given date.
static java.util.Date endOfDay(java.util.Date date, java.util.Calendar cal)
          Returns the end of the given date and calendar.
static java.util.Date endOfHour(java.util.Date date)
          Returns the the end of the hour of the current date ( and time )
static java.util.Date endOfHour(java.util.Date date, java.util.Calendar cal)
          Returns the the end of the hour of the current date ( and time ) and calendar
static java.util.Date endOfMonth()
          Returns the end of the month for the current system date
static java.util.Date endOfMonth(java.util.Date date)
          Returns the end of the month for the specified date
static java.util.Date endOfMonth(java.util.Date date, java.util.Calendar cal)
          Returns the end of the month for the specified date and calendar
static java.lang.Boolean endsWith(java.lang.String string, java.lang.String suffix)
          Returns true if the string ends with the specified suffix.
static java.util.Date getDate()
          Returns the current system date.
static java.lang.Object ifNull(java.lang.Object obj, java.lang.String nullReplacement)
          Returns the nullReplacement object if the first argument is null, otherwise the first argument is returned.
static java.lang.Object iif(java.lang.Boolean condition, java.lang.Object trueResult, java.lang.Object falseResult)
          Returns the trueResult if the condition expression is true, otherwise the falseResult.
static java.lang.Integer indexOf(java.lang.String searchFor, java.lang.String searchIn)
          Returns the index within this string of the first occurrence of the specified substring.
static java.lang.Boolean isEmpty(java.util.Collection collection)
          Returns true if the collection is null or empty.
static java.lang.Boolean isEmpty(java.util.Map map)
          Returns true if the map is empty.
static java.lang.Boolean isEmpty(java.lang.String string)
          Returns true of the string argument is null or empty.
static java.lang.String lower(java.lang.String string)
          Converts the string to lower case.
static java.lang.Double max(java.lang.Number a, java.lang.Number b)
          The max of the two Number values.
static java.lang.Double min(java.lang.Number a, java.lang.Number b)
          The min of the two Number values.
static java.util.Date noonOfDay(java.util.Date date, java.util.Calendar cal)
           
static java.util.Date now()
          Returns the current system date.
static java.lang.String quote(java.lang.String string)
          Wraps the string argument value in double quotes.
static java.lang.String replaceAll(java.lang.String string, java.lang.String regex, java.lang.String replacement)
          Replaces each substring of this string that matches the given regular expression with the given replacement.
static java.lang.String replaceFirst(java.lang.String string, java.lang.String regex, java.lang.String replacement)
          Replaces the first substring of this string that matches the given regular expression with the given replacement.
static java.lang.String singleQuote(java.lang.String string)
          Wraps the string argument in single quotes.
static java.util.Date startOfDay()
          Returns the start of the day for the current system date
static java.util.Date startOfDay(java.util.Date date)
          Returns the start of the day for the specified date
static java.util.Date startOfDay(java.util.Date date, java.util.Calendar cal)
          Returns the start of the day for the specified date and calendar
static java.util.Date startOfMonth()
          Returns the start of the month for the current system date
static java.util.Date startOfMonth(java.util.Date date)
          Returns the start of the month for the specified date
static java.util.Date startOfMonth(java.util.Date date, java.util.Calendar cal)
          Returns the start of the month for the specified date and calendar
static java.lang.Boolean startsWith(java.lang.String string, java.lang.String prefix)
          Returns true if the string argument is prefixed with the prefix value.
static java.lang.String subString(java.lang.String string, java.lang.Number beginIndex, java.lang.Number endIndex)
          Returns a new string that is a substring of this string.
static java.util.Date toDate(java.lang.String dateString)
          Parses the dateString to a date value.
static java.util.Date toDate(java.lang.String dateString, java.lang.String format)
          Parses the dateString to a date value using the specified format formatter.
static java.lang.String trim(java.lang.String string)
          Returns the string argument trimmed of white space characters.
static java.lang.String upper(java.lang.String string)
          Returns the string argument converted to upper case.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ELInternalFunctions

public ELInternalFunctions()
Method Detail

check

public static java.lang.Object check(java.lang.Boolean condition,
                                     java.lang.Object iffalse)
Returns true if the condition is true, otherwise, the iffalse value is returned. This function is equivalent to IIF( condition, true, theFalseValue)

Parameters:
condition - the boolean condition to check.
iffalse - the value to return if the condition is false
Returns:
true if the condition is true, otherwise, the false value

contains

public static java.lang.Boolean contains(java.lang.String string,
                                         java.lang.String find)
Returns the index within the string of the first occurrence of the find argument.

Parameters:
string - any string.
find - the string to find.
Returns:
the first index, otherwise -1

convert

public static java.lang.Object convert(java.lang.Number number,
                                       java.lang.Integer typeId)
                                throws ParseException
Converts the number argument to the specified type.

Parameters:
number - the number to convert
typeId - the type id to convert to, the supported types are defined with the following constants:
  • TYPE.BIGDECIMAL
  • TYPE.BIGINTEGER
  • TYPE.BYTE
  • TYPE.DOUBLE
  • TYPE.FLOAT
  • TYPE.INTEGER
  • TYPE.LONG
  • TYPE.SHORT
Returns:
the number argument to the specified type
Throws:
ParseException

date

public static java.util.Date date()
Returns the current system date.

Returns:
the current system date

dateAdd

public static java.util.Date dateAdd(java.util.Date date,
                                     java.lang.Integer delta)
Returns the delta number of days to the date.

Parameters:
date - the date to add the days to
delta - the number of days to add to the date
Returns:
the date with the delta number of days added to it

dateAdd

public static java.util.Date dateAdd(java.util.Date date,
                                     java.lang.Integer delta,
                                     java.lang.Integer partId)
Adds the specified delta to the date where the delta type is specified with the partId.

Parameters:
date - the date
delta - the delta
partId - the date part, the supported date parts are defined with the following constants:
  • DATE.DAY_OF_MONTH
  • DATE.DAY_OF_WEEK
  • DATE.DAY_OF_WEEK_IN_MONTH
  • DATE.DAY_OF_YEAR
  • DATE.HOUR
  • DATE.MINUTE
  • DATE.MONTH
  • DATE.YEAR
  • DATE.SECOND
  • DATE.WEEK_OF_YEAR
  • DATE.WEEK_OF_MONTH
Returns:
the new date

dateDiff

public static java.lang.Integer dateDiff(java.util.Date date1,
                                         java.util.Date date2)
Returns the number of days between the date1 and date2 values.

Parameters:
date1 - the first date
date2 - the second date
Returns:
the number of days between the two dates

dateDiff

public static java.lang.Integer dateDiff(java.util.Date date1,
                                         java.util.Date date2,
                                         java.lang.Integer partId)
Returns the difference between the date1 and date2 values.

Parameters:
date1 - the first date
date2 - the second date
partId - the date part, the supported date parts are defined with the following constants:
  • DATE.DAY_OF_MONTH
  • DATE.DAY_OF_WEEK
  • DATE.DAY_OF_WEEK_IN_MONTH
  • DATE.DAY_OF_YEAR
  • DATE.HOUR
  • DATE.MINUTE
  • DATE.MONTH
  • DATE.YEAR
  • DATE.SECOND
  • DATE.WEEK_OF_YEAR
  • DATE.WEEK_OF_MONTH
Returns:
the difference ( in the specified part id ) between the two dates.

datePart

public static java.lang.Integer datePart(java.util.Date date,
                                         java.lang.Number partId)
Returns the date part for the date.

Parameters:
date - the date
partId - the date part, the supported date parts are defined with the following constants:
  • DATE.DAY_OF_MONTH
  • DATE.DAY_OF_WEEK
  • DATE.DAY_OF_WEEK_IN_MONTH
  • DATE.DAY_OF_YEAR
  • DATE.HOUR
  • DATE.MINUTE
  • DATE.MONTH
  • DATE.YEAR
  • DATE.SECOND
  • DATE.WEEK_OF_YEAR
  • DATE.WEEK_OF_MONTH
Returns:
the specified part of the date

dayOfWeek

public static java.lang.Integer dayOfWeek(java.util.Date date)
Returns the Calendar.DAY_OF_WEEK for the date.

Parameters:
date - the reference date
Returns:
the Calendar.DAY_OF_WEEK for the date

endsWith

public static java.lang.Boolean endsWith(java.lang.String string,
                                         java.lang.String suffix)
Returns true if the string ends with the specified suffix.

Parameters:
string -
suffix -
Returns:
true if the string ends with the specified suffix

getDate

public static java.util.Date getDate()
Returns the current system date.

Returns:
the current system date

ifNull

public static java.lang.Object ifNull(java.lang.Object obj,
                                      java.lang.String nullReplacement)
Returns the nullReplacement object if the first argument is null, otherwise the first argument is returned.

Parameters:
obj - the object to check for null
nullReplacement - the value to return if null.
Returns:
the nullReplacement object if the first argument is null, otherwise the first argument

choose

public static java.lang.Object choose(java.lang.Object... args)
Returns the result of the first corresponding true condition This method is essentially a single line switch statement.

If a condition is true, then the following result expression is returned.

If none of the conditions evaluate to true, then the null is returned

Parameters:
args - a variable number of condition - result expressions
Returns:
the result for the first true statement

iif

public static java.lang.Object iif(java.lang.Boolean condition,
                                   java.lang.Object trueResult,
                                   java.lang.Object falseResult)
Returns the trueResult if the condition expression is true, otherwise the falseResult.

Parameters:
condition - the expression to test
trueResult - the true result
falseResult - the false result
Returns:
the trueResult if the condition expression is true, otherwise the falseResult

indexOf

public static java.lang.Integer indexOf(java.lang.String searchFor,
                                        java.lang.String searchIn)
Returns the index within this string of the first occurrence of the specified substring.

Parameters:
searchFor - the string to search for
searchIn - tje string to search in
Returns:
the index within this string of the first occurrence of the specified substring; otherwise -1.

isEmpty

public static java.lang.Boolean isEmpty(java.util.Collection collection)
Returns true if the collection is null or empty.

Parameters:
collection - the collection to check
Returns:
true if the collection is null or empty

isEmpty

public static java.lang.Boolean isEmpty(java.util.Map map)
Returns true if the map is empty.

Parameters:
map - the map object to check
Returns:
true if the map is null or empty

isEmpty

public static java.lang.Boolean isEmpty(java.lang.String string)
Returns true of the string argument is null or empty.

Parameters:
string - the string to check
Returns:
true of the String argument is null or empty

lower

public static java.lang.String lower(java.lang.String string)
Converts the string to lower case.

Parameters:
string - the string to convert
Returns:
the string converted to lower case

max

public static java.lang.Double max(java.lang.Number a,
                                   java.lang.Number b)
The max of the two Number values.

Parameters:
a - one of the numbers
b - the other number
Returns:
the max of the two values

min

public static java.lang.Double min(java.lang.Number a,
                                   java.lang.Number b)
The min of the two Number values.

Parameters:
a - one of the numbers
b - the other number
Returns:
the min of the two values

now

public static java.util.Date now()
Returns the current system date.

Returns:
the current system date

quote

public static java.lang.String quote(java.lang.String string)
Wraps the string argument value in double quotes.

Parameters:
string - the string to wrap
Returns:
the string value in double quotes

singleQuote

public static java.lang.String singleQuote(java.lang.String string)
Wraps the string argument in single quotes.

Parameters:
string - the arg to single quote
Returns:
The string argument is single quoted

startsWith

public static java.lang.Boolean startsWith(java.lang.String string,
                                           java.lang.String prefix)
Returns true if the string argument is prefixed with the prefix value.

Parameters:
string - the value to check
prefix - the prefix to check for
Returns:
true if the string argument is prefixed with the prefix value

replaceAll

public static java.lang.String replaceAll(java.lang.String string,
                                          java.lang.String regex,
                                          java.lang.String replacement)
Replaces each substring of this string that matches the given regular expression with the given replacement.

Parameters:
string - the string to replace the values in
regex - the regular expression to which this string is to be matched
replacement - the replacement string
Returns:
the resulting string

replaceFirst

public static java.lang.String replaceFirst(java.lang.String string,
                                            java.lang.String regex,
                                            java.lang.String replacement)
Replaces the first substring of this string that matches the given regular expression with the given replacement.

Parameters:
string - the string to replace the values in
regex - the regular expression to which this string is to be matched
replacement - the replacement string
Returns:
the resulting string

subString

public static java.lang.String subString(java.lang.String string,
                                         java.lang.Number beginIndex,
                                         java.lang.Number endIndex)
Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1.

Parameters:
string -
beginIndex -
endIndex -
Returns:
the substring

toDate

public static java.util.Date toDate(java.lang.String dateString)
                             throws ParseException
Parses the dateString to a date value.

Parameters:
dateString - the string to parse
Returns:
the date value
Throws:
ParseException

toDate

public static java.util.Date toDate(java.lang.String dateString,
                                    java.lang.String format)
                             throws ParseException
Parses the dateString to a date value using the specified format formatter.

Parameters:
dateString - the date string to parse
format - the format to use
Returns:
the date value
Throws:
ParseException

trim

public static java.lang.String trim(java.lang.String string)
Returns the string argument trimmed of white space characters.

Parameters:
string -
Returns:
the string argument trimmed of white space characters

upper

public static java.lang.String upper(java.lang.String string)
Returns the string argument converted to upper case.

Parameters:
string -
Returns:
the string argument converted to upper case

endOfDay

public static java.util.Date endOfDay()
Returns the end of the current day.

Returns:
the end of the current day

endOfDay

public static java.util.Date endOfDay(java.util.Date date)
Returns the end of the given date.

Parameters:
date - the reference date
Returns:
the end of the given date

endOfDay

public static java.util.Date endOfDay(java.util.Date date,
                                      java.util.Calendar cal)
Returns the end of the given date and calendar.

Parameters:
date - the reference date
Returns:
the end of the given date and calendar

endOfHour

public static java.util.Date endOfHour(java.util.Date date)
Returns the the end of the hour of the current date ( and time )

Parameters:
date - the reference date
Returns:
end of the hour of the current date ( and time )

endOfHour

public static java.util.Date endOfHour(java.util.Date date,
                                       java.util.Calendar cal)
Returns the the end of the hour of the current date ( and time ) and calendar

Parameters:
date - the reference date
cal - the reference calendar
Returns:
end of the hour of the current date ( and time ) and calendar

startOfMonth

public static java.util.Date startOfMonth()
Returns the start of the month for the current system date

Returns:
Start of the month for the current system date

startOfMonth

public static java.util.Date startOfMonth(java.util.Date date)
Returns the start of the month for the specified date

Parameters:
date - the reference date
Returns:
Start of the month for the specified date

startOfMonth

public static java.util.Date startOfMonth(java.util.Date date,
                                          java.util.Calendar cal)
Returns the start of the month for the specified date and calendar

Parameters:
date - the reference date
cal - the reference calendar
Returns:
the start of the month for the specified date and calendar

endOfMonth

public static java.util.Date endOfMonth()
Returns the end of the month for the current system date

Returns:
the end of the month for the current system date

endOfMonth

public static java.util.Date endOfMonth(java.util.Date date)
Returns the end of the month for the specified date

Returns:
the end of the month for the specified date

endOfMonth

public static java.util.Date endOfMonth(java.util.Date date,
                                        java.util.Calendar cal)
Returns the end of the month for the specified date and calendar

Parameters:
date - the reference date
cal - the reference calendar
Returns:
the end of the month for the specified date and calendar

startOfDay

public static java.util.Date startOfDay()
Returns the start of the day for the current system date

Returns:
the start of the day for the current system date

startOfDay

public static java.util.Date startOfDay(java.util.Date date)
Returns the start of the day for the specified date

Parameters:
date - the reference date
Returns:
the start of the day for the specified date

startOfDay

public static java.util.Date startOfDay(java.util.Date date,
                                        java.util.Calendar cal)
Returns the start of the day for the specified date and calendar

Parameters:
date - the reference date
cal - the reference calendar
Returns:
the start of the day for the specified date and calendar

noonOfDay

public static java.util.Date noonOfDay(java.util.Date date,
                                       java.util.Calendar cal)