OScript API/Built-in Package Index |
The built-in functions in the JavaObject package provide the ability to access Java classes and services from OScript. The major functionalities offered in the JavaObject package are the following:
SetField() Sets the value of an instance field.
To deploy your jar files in Livelink JVM, added the jar files in OTHOME/ojlib/ or OTHOME/module/somemodule_1_0_0/ojlib/ directory (and their subdirectories) to be recognized by the JVM's application classloader.
OScript |
Java |
---|---|
Assoc |
java.util.Map
|
Boolean |
boolean,
Boolean |
Integer |
short,
Short int, Integer long, Long |
List, Record, RecArray |
java.util.List
|
Long |
short,
Short
int, Integer long, Long |
Real |
float,
Float double, Double |
String |
String |
Undefined |
null |
Java |
OScript |
---|---|
boolean,
Boolean |
Boolean |
byte
char, Character short, Short int, Integer |
Integer |
float,
Float double, Double |
Real |
long,
Long |
Long |
java.util.List 1 | List |
java.util.Map
1 |
Assoc |
String |
String |
null |
Undefined |
Java types not
listed in this table |
JavaObject |
1. This conversion is not backward compatible with the earlier versions of Livelink which convert this type to JavaObject. To switch to the old behavior, you can set "ReturnAsCollectionType=false" in the [JavaObject] section of opentext.ini file. But we strongly recommend that you update your code to comply with the new conversion.
Returns the JNI exception error message from the last operation.
Returns a List for the stack trace associated with an exception in the last JNI operation.
Returns the value of a static field.
Invokes a static method defined for a Java class.
Creates a new instance of a Java class.
Sets the value of a static field.
Returns the value of an instance field.
Invokes an instance method defined for a Java class.
Sets the value of an instance field.
Returns the JNI exception error message from the last operation.
A string containing JNI exception error message from the last operation.
If no exception occurs, an empty string is returned.
Here is an example:
Dynamic result = JavaObject.SetStaticField( "com.opentext.util.DateFormat", "fDefaultMonthFormat", { "mm" } ) if IsError( result ) echo( JavaObject.GetError() ) end
Returns a List for the stack trace associated with an exception in the last JNI operation.
A [[List]] of [[String]] from the Java stack trace elements at the time of an exception. Each [[String]] represents a single stack frame. As described in the Java API specification documentation for Class StackTraceElement, all stack frames except for the one at the top of the stack represent a method invocation. The frame at the top of the stack represents the the execution point at which the stack trace was generated.
If no exception has occurred, an empty [[List]] is returned.
Here is an example:
List errStack String s JavaObject fileStream = JavaObject.New( "java.io.FileInputStream", { 'c:\badfile' } ) if IsError( fileStream ) errStack = JavaObject.GetErrorStack() for s in errStack echo( s ) end end
Returns the value of a static field.
The name of the class that defines the field.
The name of the field to get the value of.
Here is an example:
Dynamic result = JavaObject.GetStaticField( "com.opentext.util.DateFormat", "fDefaultMonthFormat" )
Invokes a static method defined for a Java class.
The name of the class that defines the method.
The name of the method to invoke.
The parameter list to pass to the method.
Here is an example:
Dynamic result = JavaObject.InvokeStaticMethod( "com.opentext.util.DateFormat", "GetDefaultMonthFormat", {} )
Creates a new instance of a Java class.
The name of the class to instantiate.
The parameter list to pass to the constructor.
The return value can be either an Error object if it fails or a JavaObject if it succeeds.
Here is an example:
JavaObject dateFormat = JavaObject.New( "com.opentext.util.DateFormat", {} )
Sets the value of a static field.
The name of the class that defines the field.
The name of the field to set the value of.
The value to set the static field.
Here is an example:
Dynamic result = JavaObject.SetStaticField( "com.opentext.util.DateFormat", "fDefaultMonthFormat", { "mm" } )
Invokes an instance method defined for a Java class.
The name of the method to invoke.
The parameter list to pass to the method.
Here is an example:
Dynamic result = dateFormat.InvokeMethod( "GetMonthFormat", {} )
Sets the value of an instance field.
The name of the field to set the value of.
The value to set the field.
Here is an example:
Dynamic result = dateFormat.SetField( "fMonthFormat", { "mm" } )
Copyright © 2023 OpenText Corporation. All rights reserved. |