JExpression Class API Reference
The JExpression class contains API methods that let you create and invoke an expression, return the value of an expression, and check the return datatype.
The JExpression class contains the following API methods:
- •getBytes
- •getDouble
- •getInt
- •getLong
- •getResultDataType
- •getResultMetadata
- •getStringBuffer
- •invoke
- •isResultNull
getBytes
Returns the value of an expression result as a byte[] datatype. Gets the result of an expression that encypts data with the AES_ENCRYPT function.
Use the following syntax:
objectName.getBytes();
Use the following example Java code to get the result of an expression that encrypts the binary data using the AES_ENCRYPT function, where JExprEncryptData is a JExpression object:
byte[] newBytes = JExprEncryptData.getBytes();
getDouble
Returns the value of an expression result as a Double datatype.
Use the following syntax:
objectName.getDouble();
Use the following example Java code to get the result of an expression that returns a salary value as a double, where JExprSalary is a JExpression object:
double salary = JExprSalary.getDouble();
getInt
Returns the value of an expression result as an Integer datatype.
Use the following syntax:
objectName.getInt();
For example, use the following Java code to get the result of an expression that returns an employee ID number as an integer, where findEmpID is a JExpression object:
int empID = findEmpID.getInt();
getLong
Returns the value of an expression result as a Long datatype. Gets the result of an expression that uses a Date datatype.
Use the following syntax:
objectName.getLong();
Use the following example Java code to get the result of an expression that returns a Date value as a Long datatype, where JExprCurrentDate is a JExpression object:
long currDate = JExprCurrentDate.getLong();
getResultDataType
Returns the datatype of an expression result. Returns a value of EDataType.
Use the following syntax:
objectName.getResultDataType();
Use the following example Java code to invoke an expression and assign the datatype of the result to the variable dataType:
myObject.invoke(new Object[] { NAME,COMPANY }, ERowType INSERT);
EDataType dataType = myObject.getResultDataType();
getResultMetadata
Returns the metadata for an expression result. You can use getResultMetadata to get the precision, scale, and datatype of an expression result. You can assign the metadata of the return value from an expression to a JExprParamMetadata object. Use the getScale, getPrecision, and getDataType object methods to retrieve the result metadata.
Use the following syntax:
objectName.getResultMetadata();
Use the following example Java code to assign the scale, precision, and datatype of the return value of myObject to variables:
JExprParamMetadata myMetadata = myObject.getResultMetadata();
int scale = myMetadata.getScale();
int prec = myMetadata.getPrecision();
int datatype = myMetadata.getDataType();
getStringBuffer
Returns the value of an expression result as a String datatype.
Use the following syntax:
objectName.getStringBuffer();
Use the following example Java code to get the result of an expression that returns two concatenated strings, where JExprConcat is an JExpression object:
String result = JExprConcat.getStringBuffer();
invoke
Invokes an expression. Arguments for invoke include an object that defines the input parameters and the row type. You must instantiate a JExpression object before you can use the invoke method. For the row type, use ERowType.INSERT, ERowType.DELETE, and ERowType.UPDATE.
Use the following syntax:
objectName.invoke(
new Object[] { param1[, ... paramN ]},
rowType
);
The following table describes the arguments:
Argument | Datatype | Input/ Output | Description |
---|
objectName | JExpression | Input | JExpression object name. |
parameters | - | Input | Object array that contains the input values for the expression. |
For example, you create a function on the Functions code entry tab named address_lookup() that returns an JExpression object that represents the expression. Use the following code to invoke the expression that uses input ports NAME and COMPANY:
JExpression myObject = address_lookup();
myObject.invoke(new Object[] { NAME,COMPANY }, ERowType INSERT);
isResultNull
Checks the value of an expression result.
Use the following syntax:
objectName.isResultNull();
Use the following example Java code to invoke an expression and assign the return value of the expression to the variable address if the return value is not null:
JExpression myObject = address_lookup();
myObject.invoke(new Object[] { NAME,COMPANY }, ERowType INSERT);
if(!myObject.isResultNull()) {
String address = myObject.getStringBuffer();
}