JavaSetString function

Action

Sets a string parameter for the next function or constructor call.

Note: Parameters must exactly match the method signature and have to be in order.

Include file

Java.bdh

Syntax

JavaSetString( in hObject : number,
               in sParam  : string allownull,
               in nLen    : number optional,
               in eType   : string optional );
Parameter Description
hObject Valid handle to a java object or JAVA_STATIC_METHOD.
sParam The string to be set as parameter.
nLen The length of the string parameter (optional). Should be used if the string contains null bytes.
eType

(optional)

Can be:

  • JAVA_STRING (default)

  • JAVA_BYTE_ARRAY

  • JAVA_CHAR_ARRAY

Example

var
  hTestObj   : number; 

dcltrans
  transaction TInit
  begin
    // Load and start the JVM.
    JavaCreateJavaVM();

    // instantiate the java class
    hTestObj := JavaLoadObject("Test");
  end TInit;

  transaction TMyJavaTrans
  var
    fValue : float;
  begin
    ThinkTime(0.2);
    // set the first parameter
    JavaSetString(hTestObj, "1");
    // set the second parameter
    JavaSetNumber(hTestObj, 1, JAVA_BYTE);
     // invoke the method
    JavaCallMethod(hTestObj, "doFoo");
    // retrieve the result
    fValue := JavaGetFloat(hTestObj);
    Print("doFoo returned "+String(fValue));
  end TMyJavaTrans;

  transaction TEnd
  begin
    JavaFreeObject(hTestObj);
  end TEnd;

Sample scripts

JavaFrameworkBankSample.bdf

BankSample.java, Account.java, Customer.java, PremiumCustomer.java