Casts an object to a type of your choice. Class cast will be valid for all further JavaCallMethod or JavaSetObject calls.
Java.bdh
JavaCastObject( in hObject : number, in sClassSpecifier : string ): boolean;
True if successful
false otherwise
Parameter | Description |
---|---|
hObject | Valid handle to a java object. |
sClassSpecifier |
Fully qualified classname to cast to. Example: fw60sample/Account |
dcltrans transaction TInit begin // Load and start the JVM. JavaCreateJavaVM(); end TInit; transaction TPureBdl var hJTable : number; hJKeyStr : number; hJValueStr : number; hJRetVal : number; sBuffer : string; begin // prepare the key/value pair // String jKeyStr = "hello"; // String jValueStr = "world"; hJKeyStr := JavaLoadString("hello"); hJValueStr := JavaLoadString("world"); // instantiate a Hashtable // Hashtable jTable = new Hashtable(); hJTable := JavaLoadObject("java/util/Hashtable"); // insert an Object into the Hashtable // jTable.put(jKeyStr, jValueStr); JavaCastObject(hJKeyStr, "java/lang/Object"); JavaSetObject(hJTable, hJKeyStr); JavaSetObject(hJTable, hJValueStr, "java/lang/Object"); JavaCallMethod(hJTable, "put"); // retrieve an Object from the Hashtable // Object jRetVal = jTable.get(jKeyStr); JavaSetObject(hJTable, hJKeyStr); JavaCallMethod(hJTable, "get"); hJRetVal := JavaGetObject(hJTable); // retrieve print out the java string object // System.out.println("Found value \""+jRetVal+"\" in Hashtable."); JavaCallMethod(hJRetVal, "toString"); JavaGetString(hJRetVal, sBuffer); Print("Found value \""+sBuffer+"\" in Hashtable."); // Free all objects JavaFreeObject(hJTable); JavaFreeObject(hJKeyStr); JavaFreeObject(hJValueStr); JavaFreeObject(hJRetVal); end TPureBdl; transaction TEnd begin end TEnd;
JavaFrameworkBankSample.bdf
BankSample.java, Account.java, Customer.java, PremiumCustomer.java