ModSQL
Class Function_String

java.lang.Object
  |
  +--ModSQL.AbstractFunction
        |
        +--ModSQL.Function_String
All Implemented Interfaces:
Function

final class Function_String
extends AbstractFunction

SQL function for string operations.

Function_String provides: LEFT, RIGHT, UPPER, LOWER, INITCAP, LENGTH, LPAD, RPAD, and SUBSTR.

Author:
chris.studholme@utoronto.ca

Field Summary
static int INITCAP
          Function is INITCAP().
static int LEFT
          Function is LEFT().
static int LENGTH
          Function is LENGTH().
static int LOWER
          Function is LOWER().
static int LPAD
          Function is LPAD().
private  int op
          Which function are we? One of the above constants.
static int RIGHT
          Function is RIGHT().
static int RPAD
          Function is RPAD().
static int SUBSTR
          Function is SUBSTR().
static int UPPER
          Function is UPPER().
 
Fields inherited from class ModSQL.AbstractFunction
all_constant, constant_non_null, evaluate_order, evaluate_order_array, out_of_order, parameter_constant, parameter_value, parameters, parameters_array
 
Fields inherited from interface ModSQL.Function
MATCH_BEGINS, MATCH_EQU, MATCH_GT, MATCH_GTE, MATCH_LT, MATCH_LTE, MATCH_NE
 
Constructor Summary
Function_String(int op)
          Constructor.
 
Method Summary
 Object evaluate(boolean aggregate)
          Evaluate parameters and compute function.
static Function forName(String name)
          Returns a new instance of this class if name is recognized.
 String functionName()
          Returns the name of this function for use by toString() method.
 int getMaxResultSize()
          Returns the maximum size of any String computed by this function.
 int getSQLType()
          Returns the SQL type of this function.
 void optimize()
          Prepare the function for use.
 
Methods inherited from class ModSQL.AbstractFunction
addParameter, convertToSQLType, evaluate, evaluateConstantParameters, evaluateOrder, evaluateParameters, evaluateParameters, getCompatableType, getObjectSQLType, getParameter, getParameterCount, isAggregate, isConstant, postfixParameters, prefixParameters, registerWith, reset, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

LEFT

public static final int LEFT
Function is LEFT().

RIGHT

public static final int RIGHT
Function is RIGHT().

UPPER

public static final int UPPER
Function is UPPER().

LOWER

public static final int LOWER
Function is LOWER().

INITCAP

public static final int INITCAP
Function is INITCAP().

LENGTH

public static final int LENGTH
Function is LENGTH().

LPAD

public static final int LPAD
Function is LPAD().

RPAD

public static final int RPAD
Function is RPAD().

SUBSTR

public static final int SUBSTR
Function is SUBSTR().

op

private int op
Which function are we? One of the above constants.
Constructor Detail

Function_String

public Function_String(int op)
Constructor.
Parameters:
op - function type
Method Detail

forName

public static Function forName(String name)
Returns a new instance of this class if name is recognized. The instance is initialized as needed to represent the desired function.
Parameters:
name - name of function to find
Returns:
instance of this class or null if name does not match

optimize

public void optimize()
              throws SQLException
Prepare the function for use.
Overrides:
optimize in class AbstractFunction
Throws:
SQLException - if the parameters are invalid

getSQLType

public int getSQLType()
               throws SQLException
Returns the SQL type of this function.
Returns:
SQL type of data to be returned

getMaxResultSize

public int getMaxResultSize()
                     throws SQLException
Returns the maximum size of any String computed by this function. If a maximum size cannot be determined or this function does not return a String (ie. LENGTH), -1 is returned.
Returns:
maximum size of String returned or -1 if unknown

functionName

public String functionName()
Returns the name of this function for use by toString() method.
Overrides:
functionName in class AbstractFunction
Returns:
name of function

evaluate

public Object evaluate(boolean aggregate)
                throws SQLException,
                       EndOfTable

Evaluate parameters and compute function.

Parameters:
aggregate - passed to parameters
Returns:
result object
Throws:
SQLException - if a database-access error occurs
EndOfTable - if thrown by a parameter