org.teiid.query.function
Class FunctionMethods

java.lang.Object
  extended by org.teiid.query.function.FunctionMethods

public final class FunctionMethods
extends java.lang.Object

Static method hooks for most of the function library.


Field Summary
static java.lang.String SPACE_CHAR
           
 
Constructor Summary
FunctionMethods()
           
 
Method Summary
static java.lang.Object abs(java.math.BigDecimal x)
           
static java.lang.Object abs(java.math.BigInteger x)
           
static double abs(double x)
           
static float abs(float x)
           
static int abs(int x)
           
static long abs(long x)
           
static java.lang.Object acos(java.lang.Number number)
           
static java.lang.Integer ascii(java.lang.Character ch)
           
static java.lang.Integer ascii(java.lang.String ch)
           
static java.lang.Object asin(java.lang.Number number)
           
static java.lang.Object atan(java.lang.Number number)
           
static java.lang.Object atan2(java.lang.Number number1, java.lang.Number number2)
           
static java.lang.Object bitand(int x, int y)
           
static int bitnot(int x)
           
static java.lang.Object bitor(int x, int y)
           
static java.lang.Object bitxor(int x, int y)
           
static java.lang.Object ceiling(java.lang.Number x)
           
static java.lang.Object chr(int intValue)
           
static java.lang.Object coalesce(java.lang.Object value, java.lang.Object value1, java.lang.Object... other)
           
static java.lang.Object commandPayload(CommandContext context)
           
static java.lang.Object commandPayload(CommandContext context, java.lang.String param)
           
static java.lang.Object concat(java.lang.String str1, java.lang.String str2)
           
static java.lang.Object context(java.lang.Object context, java.lang.Object expression)
          This function should never actually be called - it is here solely so the xml context function can be resolved properly.
static java.lang.Object convert(java.lang.Object src, java.lang.String type)
           
static java.lang.Object cos(java.lang.Number number)
           
static java.lang.Object cot(java.lang.Number number)
           
static java.lang.Object currentDate()
           
static java.lang.Object currentTime()
           
static java.lang.Object currentTimestamp()
           
static java.lang.Object dayName(java.util.Date x)
           
static java.lang.Object dayOfMonth(java.util.Date x)
           
static java.lang.Object dayOfWeek(java.util.Date x)
           
static java.lang.Object dayOfYear(java.util.Date x)
           
static java.lang.Object degrees(java.lang.Number number)
           
static java.lang.Object divide(java.math.BigDecimal x, java.math.BigDecimal y)
           
static java.lang.Object divide(java.math.BigInteger x, java.math.BigInteger y)
           
static double divide(double x, double y)
           
static float divide(float x, float y)
           
static int divide(int x, int y)
           
static long divide(long x, long y)
           
static java.lang.Object env(CommandContext context, java.lang.String propertyName)
           
static java.lang.Object exp(java.lang.Number x)
           
static java.lang.Object floor(java.lang.Number x)
           
static java.lang.String format(java.util.Date date, java.lang.String format)
           
static java.lang.String format(java.lang.Number number, java.lang.String format)
           
static java.nio.charset.Charset getCharset(java.lang.String encoding)
           
static java.lang.Object hour(java.util.Date x)
           
static java.lang.Object ifnull(java.lang.Object value, java.lang.Object ifNullValue)
           
static java.lang.Object initCap(java.lang.String s)
           
static java.lang.Object insert(java.lang.String string1, java.lang.Integer start, java.lang.Integer length, java.lang.String str2)
           
static java.lang.Object left(java.lang.String string, java.lang.Integer count)
           
static java.lang.Object leftTrim(java.lang.String string)
           
static java.lang.Object length(java.lang.String str)
           
static java.lang.Object locate(java.lang.String sub, java.lang.String str)
           
static java.lang.Object locate(java.lang.String sub, java.lang.String str, java.lang.Integer start)
          TODO: The treatment of negative start indexes is inconsistent here.
static java.lang.Object log(java.lang.Number x)
           
static java.lang.Object log10(java.lang.Number x)
           
static java.lang.Object lookup(java.lang.Object codeTable, java.lang.Object returnElement, java.lang.Object keyElement, java.lang.Object keyValue)
          This function should never actually be called - it is here solely so the lookup function can be resolved properly.
static java.lang.Object lowerCase(java.lang.String str)
           
static java.lang.Object lpad(java.lang.String inputString, java.lang.Integer padLength)
           
static java.lang.Object lpad(java.lang.String inputString, java.lang.Integer padLength, java.lang.String padStr)
           
static java.lang.Object minus(java.math.BigDecimal x, java.math.BigDecimal y)
           
static java.lang.Object minus(java.math.BigInteger x, java.math.BigInteger y)
           
static double minus(double x, double y)
           
static float minus(float x, float y)
           
static int minus(int x, int y)
           
static long minus(long x, long y)
           
static java.lang.Object minute(java.util.Date x)
           
static java.lang.Object mod(java.math.BigDecimal x, java.math.BigDecimal y)
           
static java.lang.Object mod(java.math.BigInteger x, java.math.BigInteger y)
           
static double mod(double x, double y)
           
static float mod(float x, float y)
           
static int mod(int x, int y)
           
static long mod(long x, long y)
           
static java.lang.Object modifyTimeZone(CommandContext context, java.sql.Timestamp value, java.lang.String targetTimezoneString)
           
static java.lang.Object modifyTimeZone(java.sql.Timestamp value, java.lang.String originalTimezoneString, java.lang.String targetTimezoneString)
           
static java.lang.Object month(java.util.Date x)
           
static java.lang.Object monthName(java.util.Date x)
           
static java.lang.Object multiply(java.math.BigDecimal x, java.math.BigDecimal y)
           
static java.lang.Object multiply(java.math.BigInteger x, java.math.BigInteger y)
           
static double multiply(double x, double y)
           
static float multiply(float x, float y)
           
static int multiply(int x, int y)
           
static long multiply(long x, long y)
           
static java.lang.Object pad(java.lang.String str, java.lang.Integer padLength, java.lang.String padStr, boolean left)
           
static java.lang.Object parseBigDecimal(java.lang.String number, java.lang.String format)
           
static java.lang.Object parseBigInteger(java.lang.String number, java.lang.String format)
           
static java.lang.Object parseDouble(java.lang.String number, java.lang.String format)
           
static java.lang.Object parseFloat(java.lang.String number, java.lang.String format)
           
static java.lang.Object parseInteger(java.lang.String number, java.lang.String format)
           
static java.lang.Object parseLong(java.lang.String number, java.lang.String format)
           
static java.sql.Timestamp parseTimestamp(java.lang.String timestamp, java.lang.String format)
           
static java.lang.Object pi()
           
static java.lang.Object plus(java.math.BigDecimal x, java.math.BigDecimal y)
           
static java.lang.Object plus(java.math.BigInteger x, java.math.BigInteger y)
           
static double plus(double x, double y)
           
static float plus(float x, float y)
           
static int plus(int x, int y)
           
static long plus(long x, long y)
           
static java.math.BigDecimal power(java.math.BigDecimal x, int y)
           
static java.math.BigInteger power(java.math.BigInteger x, int y)
           
static double power(double x, double y)
           
static java.lang.Object quarter(java.util.Date date)
           
static java.lang.Object radians(java.lang.Number number)
           
static java.lang.Object rand(CommandContext context)
           
static java.lang.Object rand(CommandContext context, java.lang.Object seed)
           
static java.lang.Object repeat(java.lang.String str, java.lang.Integer count)
           
static java.lang.Object replace(java.lang.String string, java.lang.String subString, java.lang.String replaceString)
           
static java.lang.Object right(java.lang.String string, java.lang.Integer count)
           
static java.lang.Object rightTrim(java.lang.String string)
           
static java.math.BigDecimal round(java.math.BigDecimal bigDecimalNumber, int places)
           
static double round(double number, int places)
           
static float round(float number, int places)
           
static int round(int number, int places)
           
static java.lang.Object rowlimit(java.lang.Object expression)
          This pseudo-function should never actually be called - it is here solely so the xml rowlimit function can be resolved properly.
static java.lang.Object rowlimitexception(java.lang.Object expression)
          This pseudo-function should never actually be called - it is here solely so the xml rowlimitexception function can be resolved properly.
static java.lang.Object rpad(java.lang.String inputString, java.lang.Integer padLength)
           
static java.lang.Object rpad(java.lang.String inputString, java.lang.Integer padLength, java.lang.String padStr)
           
static java.lang.Object second(java.util.Date x)
           
static java.lang.Object sign(java.math.BigDecimal x)
           
static java.lang.Object sign(java.math.BigInteger x)
           
static java.lang.Object sign(double x)
           
static java.lang.Object sign(float x)
           
static java.lang.Object sign(int x)
           
static java.lang.Object sign(long x)
           
static java.lang.Object sin(java.lang.Number number)
           
static java.lang.Object sqrt(java.lang.Number x)
           
static java.lang.Object substring(java.lang.String string, java.lang.Integer start)
           
static java.lang.Object substring(java.lang.String string, java.lang.Integer startVal, java.lang.Integer lengthVal)
           
static java.lang.Object tan(java.lang.Number number)
           
static java.lang.Object timestampAdd(java.lang.String intervalType, java.lang.Integer count, java.sql.Timestamp timestamp)
           
static java.lang.Object timestampCreate(java.sql.Date date, java.sql.Time time)
          This method truncates (ignores) figures
static java.lang.Object timestampDiff(java.lang.String intervalType, java.sql.Timestamp ts1Obj, java.sql.Timestamp ts2Obj)
          This method truncates (ignores) figures
static java.sql.Blob toBytes(ClobType value, java.lang.String encoding)
           
static java.sql.Clob toChars(BlobType value, java.lang.String encoding)
           
static java.lang.Object translate(java.lang.String str, java.lang.String in, java.lang.String out)
           
static java.lang.Object upperCase(java.lang.String str)
           
static java.lang.Object user(CommandContext context)
           
static java.lang.Object week(java.util.Date x)
           
static java.lang.Object year(java.util.Date x)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPACE_CHAR

public static final java.lang.String SPACE_CHAR
See Also:
Constant Field Values
Constructor Detail

FunctionMethods

public FunctionMethods()
Method Detail

plus

public static int plus(int x,
                       int y)

plus

public static long plus(long x,
                        long y)

plus

public static float plus(float x,
                         float y)

plus

public static double plus(double x,
                          double y)

plus

public static java.lang.Object plus(java.math.BigInteger x,
                                    java.math.BigInteger y)

plus

public static java.lang.Object plus(java.math.BigDecimal x,
                                    java.math.BigDecimal y)

minus

public static int minus(int x,
                        int y)

minus

public static long minus(long x,
                         long y)

minus

public static float minus(float x,
                          float y)

minus

public static double minus(double x,
                           double y)

minus

public static java.lang.Object minus(java.math.BigInteger x,
                                     java.math.BigInteger y)

minus

public static java.lang.Object minus(java.math.BigDecimal x,
                                     java.math.BigDecimal y)

multiply

public static int multiply(int x,
                           int y)

multiply

public static long multiply(long x,
                            long y)

multiply

public static float multiply(float x,
                             float y)

multiply

public static double multiply(double x,
                              double y)

multiply

public static java.lang.Object multiply(java.math.BigInteger x,
                                        java.math.BigInteger y)

multiply

public static java.lang.Object multiply(java.math.BigDecimal x,
                                        java.math.BigDecimal y)

divide

public static int divide(int x,
                         int y)

divide

public static long divide(long x,
                          long y)

divide

public static float divide(float x,
                           float y)

divide

public static double divide(double x,
                            double y)

divide

public static java.lang.Object divide(java.math.BigInteger x,
                                      java.math.BigInteger y)

divide

public static java.lang.Object divide(java.math.BigDecimal x,
                                      java.math.BigDecimal y)

abs

public static int abs(int x)

abs

public static long abs(long x)

abs

public static float abs(float x)

abs

public static double abs(double x)

abs

public static java.lang.Object abs(java.math.BigInteger x)

abs

public static java.lang.Object abs(java.math.BigDecimal x)

ceiling

public static java.lang.Object ceiling(java.lang.Number x)

exp

public static java.lang.Object exp(java.lang.Number x)

floor

public static java.lang.Object floor(java.lang.Number x)

log

public static java.lang.Object log(java.lang.Number x)

log10

public static java.lang.Object log10(java.lang.Number x)

rand

public static java.lang.Object rand(CommandContext context,
                                    java.lang.Object seed)
                             throws FunctionExecutionException
Throws:
FunctionExecutionException

rand

public static java.lang.Object rand(CommandContext context)
                             throws FunctionExecutionException
Throws:
FunctionExecutionException

mod

public static int mod(int x,
                      int y)

mod

public static long mod(long x,
                       long y)

mod

public static float mod(float x,
                        float y)

mod

public static double mod(double x,
                         double y)

mod

public static java.lang.Object mod(java.math.BigInteger x,
                                   java.math.BigInteger y)

mod

public static java.lang.Object mod(java.math.BigDecimal x,
                                   java.math.BigDecimal y)

power

public static double power(double x,
                           double y)

power

public static java.math.BigInteger power(java.math.BigInteger x,
                                         int y)

power

public static java.math.BigDecimal power(java.math.BigDecimal x,
                                         int y)

round

public static int round(int number,
                        int places)

round

public static float round(float number,
                          int places)

round

public static double round(double number,
                           int places)

round

public static java.math.BigDecimal round(java.math.BigDecimal bigDecimalNumber,
                                         int places)

sign

public static java.lang.Object sign(int x)

sign

public static java.lang.Object sign(long x)

sign

public static java.lang.Object sign(float x)

sign

public static java.lang.Object sign(double x)

sign

public static java.lang.Object sign(java.math.BigInteger x)

sign

public static java.lang.Object sign(java.math.BigDecimal x)

sqrt

public static java.lang.Object sqrt(java.lang.Number x)

currentDate

public static java.lang.Object currentDate()

currentTime

public static java.lang.Object currentTime()

currentTimestamp

public static java.lang.Object currentTimestamp()

dayName

public static java.lang.Object dayName(java.util.Date x)

dayOfMonth

public static java.lang.Object dayOfMonth(java.util.Date x)

dayOfWeek

public static java.lang.Object dayOfWeek(java.util.Date x)

dayOfYear

public static java.lang.Object dayOfYear(java.util.Date x)

hour

public static java.lang.Object hour(java.util.Date x)

minute

public static java.lang.Object minute(java.util.Date x)

month

public static java.lang.Object month(java.util.Date x)

monthName

public static java.lang.Object monthName(java.util.Date x)

second

public static java.lang.Object second(java.util.Date x)

week

public static java.lang.Object week(java.util.Date x)

year

public static java.lang.Object year(java.util.Date x)

quarter

public static java.lang.Object quarter(java.util.Date date)
                                throws FunctionExecutionException
Throws:
FunctionExecutionException

timestampAdd

public static java.lang.Object timestampAdd(java.lang.String intervalType,
                                            java.lang.Integer count,
                                            java.sql.Timestamp timestamp)

timestampDiff

public static java.lang.Object timestampDiff(java.lang.String intervalType,
                                             java.sql.Timestamp ts1Obj,
                                             java.sql.Timestamp ts2Obj)
This method truncates (ignores) figures

Parameters:
interval -
timestamp1 -
timestamp2 -
Returns:
Throws:
FunctionExecutionException

timestampCreate

public static java.lang.Object timestampCreate(java.sql.Date date,
                                               java.sql.Time time)
This method truncates (ignores) figures

Parameters:
interval -
timestamp1 -
timestamp2 -
Returns:
Throws:
FunctionExecutionException

length

public static java.lang.Object length(java.lang.String str)

concat

public static java.lang.Object concat(java.lang.String str1,
                                      java.lang.String str2)

substring

public static java.lang.Object substring(java.lang.String string,
                                         java.lang.Integer startVal,
                                         java.lang.Integer lengthVal)

substring

public static java.lang.Object substring(java.lang.String string,
                                         java.lang.Integer start)

left

public static java.lang.Object left(java.lang.String string,
                                    java.lang.Integer count)
                             throws FunctionExecutionException
Throws:
FunctionExecutionException

right

public static java.lang.Object right(java.lang.String string,
                                     java.lang.Integer count)
                              throws FunctionExecutionException
Throws:
FunctionExecutionException

lowerCase

public static java.lang.Object lowerCase(java.lang.String str)

upperCase

public static java.lang.Object upperCase(java.lang.String str)

locate

public static java.lang.Object locate(java.lang.String sub,
                                      java.lang.String str)

locate

public static java.lang.Object locate(java.lang.String sub,
                                      java.lang.String str,
                                      java.lang.Integer start)
TODO: The treatment of negative start indexes is inconsistent here. We're treating the null value like Derby, but not throwing an exception if the value is less than 1 (less than 0 in DB2).


leftTrim

public static java.lang.Object leftTrim(java.lang.String string)

rightTrim

public static java.lang.Object rightTrim(java.lang.String string)

replace

public static java.lang.Object replace(java.lang.String string,
                                       java.lang.String subString,
                                       java.lang.String replaceString)

insert

public static java.lang.Object insert(java.lang.String string1,
                                      java.lang.Integer start,
                                      java.lang.Integer length,
                                      java.lang.String str2)
                               throws FunctionExecutionException
Throws:
FunctionExecutionException

repeat

public static java.lang.Object repeat(java.lang.String str,
                                      java.lang.Integer count)

ascii

public static java.lang.Integer ascii(java.lang.String ch)

ascii

public static java.lang.Integer ascii(java.lang.Character ch)

chr

public static java.lang.Object chr(int intValue)

initCap

public static java.lang.Object initCap(java.lang.String s)

lpad

public static java.lang.Object lpad(java.lang.String inputString,
                                    java.lang.Integer padLength,
                                    java.lang.String padStr)
                             throws FunctionExecutionException
Throws:
FunctionExecutionException

pad

public static java.lang.Object pad(java.lang.String str,
                                   java.lang.Integer padLength,
                                   java.lang.String padStr,
                                   boolean left)
                            throws FunctionExecutionException
Throws:
FunctionExecutionException

lpad

public static java.lang.Object lpad(java.lang.String inputString,
                                    java.lang.Integer padLength)
                             throws FunctionExecutionException
Throws:
FunctionExecutionException

rpad

public static java.lang.Object rpad(java.lang.String inputString,
                                    java.lang.Integer padLength,
                                    java.lang.String padStr)
                             throws FunctionExecutionException
Throws:
FunctionExecutionException

rpad

public static java.lang.Object rpad(java.lang.String inputString,
                                    java.lang.Integer padLength)
                             throws FunctionExecutionException
Throws:
FunctionExecutionException

translate

public static java.lang.Object translate(java.lang.String str,
                                         java.lang.String in,
                                         java.lang.String out)
                                  throws FunctionExecutionException
Throws:
FunctionExecutionException

convert

public static java.lang.Object convert(java.lang.Object src,
                                       java.lang.String type)
                                throws FunctionExecutionException
Throws:
FunctionExecutionException

context

public static java.lang.Object context(java.lang.Object context,
                                       java.lang.Object expression)
                                throws FunctionExecutionException
This function should never actually be called - it is here solely so the xml context function can be resolved properly. The actual function is implemented in the XML planner.

Parameters:
context - The context to apply the criteria in
expression - The expression on the left side of the criteria
Returns:
Same as expression
Throws:
FunctionExecutionException

rowlimit

public static java.lang.Object rowlimit(java.lang.Object expression)
                                 throws FunctionExecutionException
This pseudo-function should never actually be called - it is here solely so the xml rowlimit function can be resolved properly. The actual functionality is implemented in the XML planner/processor.

Parameters:
expression - The expression on the left side of the criteria, an xml node
Returns:
doesn't really return anything; this pseudo-function is used to control the number of rows returned from a mapping class.
Throws:
FunctionExecutionException

rowlimitexception

public static java.lang.Object rowlimitexception(java.lang.Object expression)
                                          throws FunctionExecutionException
This pseudo-function should never actually be called - it is here solely so the xml rowlimitexception function can be resolved properly. The actual functionality is implemented in the XML planner/processor.

Parameters:
expression - The expression on the left side of the criteria, an xml node
Returns:
doesn't really return anything; this pseudo-function is used to control the number of rows returned from a mapping class.
Throws:
FunctionExecutionException

lookup

public static java.lang.Object lookup(java.lang.Object codeTable,
                                      java.lang.Object returnElement,
                                      java.lang.Object keyElement,
                                      java.lang.Object keyValue)
This function should never actually be called - it is here solely so the lookup function can be resolved properly. The actual function is implemented in the ExpresionEvaluator

Parameters:
context - The context to apply the criteria in
expression - The expression on the left side of the criteria
Returns:
Same as expression

ifnull

public static java.lang.Object ifnull(java.lang.Object value,
                                      java.lang.Object ifNullValue)

coalesce

public static java.lang.Object coalesce(java.lang.Object value,
                                        java.lang.Object value1,
                                        java.lang.Object... other)

format

public static java.lang.String format(java.util.Date date,
                                      java.lang.String format)
                               throws FunctionExecutionException
Throws:
FunctionExecutionException

parseTimestamp

public static java.sql.Timestamp parseTimestamp(java.lang.String timestamp,
                                                java.lang.String format)
                                         throws FunctionExecutionException
Throws:
FunctionExecutionException

format

public static java.lang.String format(java.lang.Number number,
                                      java.lang.String format)
                               throws FunctionExecutionException
Throws:
FunctionExecutionException

parseInteger

public static java.lang.Object parseInteger(java.lang.String number,
                                            java.lang.String format)
                                     throws FunctionExecutionException
Throws:
FunctionExecutionException

parseLong

public static java.lang.Object parseLong(java.lang.String number,
                                         java.lang.String format)
                                  throws FunctionExecutionException
Throws:
FunctionExecutionException

parseDouble

public static java.lang.Object parseDouble(java.lang.String number,
                                           java.lang.String format)
                                    throws FunctionExecutionException
Throws:
FunctionExecutionException

parseFloat

public static java.lang.Object parseFloat(java.lang.String number,
                                          java.lang.String format)
                                   throws FunctionExecutionException
Throws:
FunctionExecutionException

parseBigInteger

public static java.lang.Object parseBigInteger(java.lang.String number,
                                               java.lang.String format)
                                        throws FunctionExecutionException
Throws:
FunctionExecutionException

parseBigDecimal

public static java.lang.Object parseBigDecimal(java.lang.String number,
                                               java.lang.String format)
                                        throws FunctionExecutionException
Throws:
FunctionExecutionException

acos

public static java.lang.Object acos(java.lang.Number number)

asin

public static java.lang.Object asin(java.lang.Number number)

atan

public static java.lang.Object atan(java.lang.Number number)

atan2

public static java.lang.Object atan2(java.lang.Number number1,
                                     java.lang.Number number2)

cos

public static java.lang.Object cos(java.lang.Number number)

cot

public static java.lang.Object cot(java.lang.Number number)

degrees

public static java.lang.Object degrees(java.lang.Number number)

pi

public static java.lang.Object pi()

radians

public static java.lang.Object radians(java.lang.Number number)

sin

public static java.lang.Object sin(java.lang.Number number)

tan

public static java.lang.Object tan(java.lang.Number number)

bitand

public static java.lang.Object bitand(int x,
                                      int y)

bitor

public static java.lang.Object bitor(int x,
                                     int y)

bitxor

public static java.lang.Object bitxor(int x,
                                      int y)

bitnot

public static int bitnot(int x)

user

public static java.lang.Object user(CommandContext context)

commandPayload

public static java.lang.Object commandPayload(CommandContext context)

commandPayload

public static java.lang.Object commandPayload(CommandContext context,
                                              java.lang.String param)
                                       throws ExpressionEvaluationException,
                                              FunctionExecutionException
Throws:
ExpressionEvaluationException
FunctionExecutionException

env

public static java.lang.Object env(CommandContext context,
                                   java.lang.String propertyName)

modifyTimeZone

public static java.lang.Object modifyTimeZone(java.sql.Timestamp value,
                                              java.lang.String originalTimezoneString,
                                              java.lang.String targetTimezoneString)

modifyTimeZone

public static java.lang.Object modifyTimeZone(CommandContext context,
                                              java.sql.Timestamp value,
                                              java.lang.String targetTimezoneString)

toChars

public static java.sql.Clob toChars(BlobType value,
                                    java.lang.String encoding)

toBytes

public static java.sql.Blob toBytes(ClobType value,
                                    java.lang.String encoding)
                             throws java.io.IOException
Throws:
java.io.IOException

getCharset

public static java.nio.charset.Charset getCharset(java.lang.String encoding)


Copyright © 2010. All Rights Reserved.