public interface ICustomDefinedFunctions
The implementing class does not have to do any parameter type checking. Parameter type checking will be handled by the reporting engine.
Modifier and Type | Field and Description |
---|---|
static short |
BOOLEAN
the BOOLEAN data type
|
static short |
DATE
the DATE data type
|
static short |
NUMERIC
the NUMERIC data type
|
static short |
STRING
the STRING data type
|
static short |
TIME
the TIME data type
|
static short |
TIMESTAMP
the TIMESTAMP data type
|
Modifier and Type | Method and Description |
---|---|
java.lang.String[] |
getAllFunctionNames()
Returns the names of all functions.
|
int[] |
getParamTypes(java.lang.String functionName)
Gets the parameter types of the specified function.
|
int |
getReturnType(java.lang.String functionName)
Gets the return type of the specified function.
|
java.lang.Object |
getValue(java.lang.String functionName,
java.lang.Object[] args)
This is where you implement your function.
|
static final short NUMERIC
static final short STRING
static final short BOOLEAN
static final short DATE
static final short TIME
static final short TIMESTAMP
java.lang.String[] getAllFunctionNames()
For example, if the functions MAX and MIN are going to be defined by this class, the implementation of the getAllFunctionNames() should read:
public String[] getAllFunctionNames() {
return new String[] {"MAX", "MIN"};
}
int getReturnType(java.lang.String functionName)
For example, if the functions MAX and MIN both return a number, the implementation of the getReturnType() function might read:
public int getReturnType(String functionName) {
if (functionName.equals("MAX")) return NUMERIC;
}
else if (functionName.equals("MIN")) return NUMERIC;
return -1;
String
- functionName: name of the custom defined functionint[] getParamTypes(java.lang.String functionName)
For example, if the functions MAX and MIN both take in two arguments of type number, the implementation of the getParamTypes() function might read:
public int[] getParamTypes(String functionName) {
if (functionName.equals("MAX")) return new int[] {NUMERIC, NUMERIC};
}
else if (functionName.equals("MIN")) return new int[] {NUMERIC, NUMERIC};
return -1;
String
- functionName: name of the custom defined functionjava.lang.Object getValue(java.lang.String functionName, java.lang.Object[] args) throws java.lang.Exception
For example, if the functions MAX and MIN gets the maximum and minimum of the two input arguments, respectively, the implementation of the getReturnType() function might read:
public Object getValue(String functionName, Object[] args) {
if (functionName.equals("MAX") && (args[0] instanceof int) && (args[1] instanceof int) )
}return java.lang.Math.max((int) args[0], (int) args[1]);
else if (functionName.equals("MIN") && (args[0] instanceof int) && (args[1] instanceof int) )
return java.lang.Math.max((int) args[0], (int) args[1]);
return null;
String
- functionName: name of the custom defined functionObject
- [] args: arguments to the functionjava.lang.Exception