JiGlue Java - COM Data Types
This topic describes the Java™ - COM data type conversions between primitive
and reference Java data types and COM data types supported by the JiGlue COM
Bridge.
Topics include:
JiGlue COM
Bridge Java-to-COM Data Type Conversions
The JiGlue COM Bridge supports the following Java to COM data type conversions:
Reference (non-primitive) Java data types,
such as one-dimensional and multi-dimensional arrays and other Java objects,
are also supported (see JiGlue COM Bridge Programming
Guidelines below).
Caution If you are coding in Visual Basic®,
remember that in VB an integer (int) is a 16-bit value, whereas
in Java, int is a 32-bit two's complement value; for details, see
JiGlue COM Bridge Programming Guidelines below.
Java Data Type |
COM Data Type |
Data Type |
Description |
Size/Structure |
Data Type (VT_) |
boolean (java.lang.Boolean) |
Boolean value |
true or false |
Boolean (VT_I1) |
char (java.lang.Char) |
A single character |
16-bit single Unicode character |
2-byte unsigned (VT_UI2) |
short (java.lang.Short) |
Short integer |
16-bit two's complement |
2-byte signed integer (VT_I2) |
int (java.lang.Integer) |
Integer |
32-bit two's complement |
4-byte signed integer (VT_I4) |
long (java.lang.Long) |
Long integer |
64-bit two's complement |
4-byte signed integer (VT_I4)* |
float (java.lang.Float) |
Single-precision floating point |
32-bit IEEE 754 |
Float (VT_R4) |
double (java.lang.Double) |
Double-precision floating point |
64-bit IEEE 754 |
Double (VT_R8) |
java.lang.String |
Text string. |
String |
BSTR (VT_BSTR) |
java.util.Date |
Date |
Date |
Date (VT_DATE) |
Other Java object |
Reference |
Reference |
IDispatch (VT_DISPATCH) |
*Conversion of a Java Long integer
(long) to a COM 4-byte signed integer (VT_I4) may result in a loss of precision,
due to the conversion from a 64-bit value to a 32-bit value. |
JiGlue COM Bridge Programming
Guidelines
The following guidelines should be kept in mind when coding an application
using the JiGlue COM Bridge:
- When using the JiGlue COM Bridge, you must use the default (empty) constructor;
that is, a JiGlue method can only instantiate an object whose class has a
default constructor (without any argument).
- If you get a NoClassDefFoundError exception when using JiGlue, instantiate VWSession before any other classes. This will load the DOM parser needed. Both VWSession and VWWorkflowDefinition preload the DOM parser.
- You cannot use the JiGlue COM Bridge for two methods with the same name
(overloaded methods) when the methods have all of the following parameter-related
similarities:
- There is the same number of parameters in each method.
- There is at least one non-primitive (object) type, and each
of the methods has an object type in the same parameter position.
- The two methods have the same primitive (non-object) types,
for corresponding parameter positions.
- One of the non-primitive's (object) type is a different
type from the non-primitive type in the other method's corresponding parameter
position.
Example: Using foo(int, String) and foo(int, VWParticipant) with
the JiGlue COM bridge does not work correctly, but using foo(int, String)
and foo(boolean, VWParticipant) does work, because the arguments that are
primitives (int and boolean) differ.
- The JiGlue COM Bridge supports static method calls.
- The JiGlue COM Bridge requires that elements of a Variant array be of a
proper type, and they must be of the same type.
- For simple (non-object) types, you need not use the Set
statement in Visual Basic or VBScript code, as illustrated in the following
general, sample statements:
boolean = queuelement.getFieldValue("booleanField");
integer = queuelement.getFieldValue("intField");
float = queuelement.getFieldValue("floatField");
string = queuelement.getFieldValue("stringField");
time = queuelement.getFieldValue("timeField");
However, if a Java method returns an object other than the java.lang.* (see
below), the Set statement is needed.
- When using JiGlue with Visual Basic, you need to make the following registry change to enable running your application in debug mode: in HLM\Software\FileNet\eProcess, add a String value "max" and set it to -Xmx200m.
- JiGlue supports both one-dimensional and multi-dimensional arrays. The following
API methods (in addition to other Attribute-related methods) that take multi-dimensional
arrays as parameters can be called for JiGlue:
VWEventDefinition
String[][] getAssignments()
void setAssignments(String[][] theAssignments)
VWCompoundStepDefinition
VWInstructionDefinition createCreateInstruction(String theWorkClassName, String[][] theFieldAssignList)
VWInstructionDEfinition createAssignInstruction(String[][] assignPairs)
VWStepDefinition
String[][] getPreAssignments()
void setPreAssigtnments(String[][] thePreAssignments)
String[][] getPostAssignments()
void setPostAssignments(String[][] thePostAssignments)
- When specifying an integer array, be aware that in Visual Basic, an integer
is a 16-bit value, whereas in Java (and for the Process Engine), an integer
is a 32-bit value. If, for example, you specify a 2-byte integer array in
Visual Basic, it might be mapped in JiGlue to java.lang.Short, thereby causing
the API to throw an exception. For example, the following call to setDataFields
will fail:
Dim integerArray(2)
integerArray(0)=10
integerArray(1)=20
integerArray(2)=30
wob.setFieldValue "integerArrayField", integerArray, false
dataFields = wob.getDataFields(127,1)
wob.setDataFields dataFields, false
However, if you change the array to 4-byte integers, as follows, the call to setDataFields succeeds:
Dim integerArray(2)
integerArray(0)=CLng(10)
integerArray(1)=CLng(20)
integerArray(2)=CLng(30)
wob.setFieldValue "integerArrayField", integerArray, false
dataFields = wob.getDataFields(127,1)
wob.setDataFields dataFields, false
- The JiGlue COM Bridge allows you to remove explicit assignments for the
object references. The following examples demonstrate two ways of using the
data types supported by the JiGlue COM Bridge:
Example 1:
Dim myDate As Variant
Dim mySimpleDate As Object
Set mySimpleDate = JiGlue.newInstance("java.text.SimpleDateFormat")
myDate = mySimpleDate.parse("09/12/2001 11:58 am")
Example 2:
Dim myDate As Variant
Dim mySimpleDate As Variant
Set mySimpleDate = JiGlue.newInstance("java.text.SimpleDateFormat")
myDate = mySimpleDate.parse("09/12/2001 11:59 am")
In the examples shown above, mySimpleDate
was declared as both Object and Variant (in the
different examples); in both cases, the object reference was assigned by using
Set. Notice that in both cases myDate
was declared as Variant without using the Set
statement. The reason this works as coded, is because a SimpleDateFormat.parse
returns java.util.Date which is mapped to Visual Basic's Date
type (which is non-object see table above). As previously indicated,
if a Java method returns an object other than the java.lang.* (as indicated
above), the Set statement is needed. Note that the Jiglue.newInstance
method can only instantiate an object whose class has a default constructor;
that is, without any argument (see previous bullet).
- Jiglue does not support overloading of methods with the same number of arguments where the numeric-type parameters are in the same positions. For example, the following signatures may produce unpredictable behavior using Jiglue:
public int add (int a, int b);
public long add(long a, long b);
- When overloading methods, the argument types passed from an IDispatch-based environment to Java via Jiglue will need to be matching types. You cannot, for example, pass a BSTR to a Java method expecting an integer.