jSegue maps types used in COM and OLE Automation to Java
types. In many cases the mapping should be natural to Java
developers. For example, OLE Automation servers commonly use the
BSTR
type to represent a string containing wide
characters. jSegue maps the BSTR
type to
java.lang.String
.
When jSegue creates the Java object for a VARIANT
it will create an instance of a class that will represent the
VARIANT
's value. For example if the
VARIANT
contains a value of type VT_I2
,
jSegue will create a java.lang.Short
instance to
return the VARIANT
's value. To figure out the
specific object type use this mapping against the
VARTYPE
of the VARIANT
. For primitive
types use the corresponding Java object type. To pass in
VT_EMPTY
or VT_NULL
use
com.moesol.bindings.platform_sdk.component_services.VARIANT.EMPTY
or
com.moesol.bindings.platform_sdk.component_services.VARIANT.NULL
.
Below is the current jSegue mapping of COM/OLE types to Java types. One of the goals of these mappings was preserving the value range of the native type. For example, a BYTE (unsigned char) has a value range of 0 to 255. In java byte has a value range of -128 to 127, so the next larger integer form was choosen. Another possible mapping is mapping based on the size of the type. So a native BYTE would map to a java byte. Arrays would convert faster, but at the convenience of having to map 255 to -127. Post to the forums if you are interested in this change.
COM Type | Java Type | Notes |
---|---|---|
UI1 |
short |
short allows 255 |
UI2 |
char |
|
UI4 |
long |
|
UI8 |
java.math.BigInteger |
|
UINT |
long |
|
INT |
int |
|
I1 |
byte |
|
I2 |
short |
|
I4 |
int |
|
I8 |
long |
|
R4 |
float |
|
R8 |
double |
|
CY |
long |
Scaled by 10,000 (see VARIANTARG documentation) |
BSTR |
java.lang.String |
|
LPSTR |
java.lang.String |
|
LPWSTR |
java.lang.String |
|
DECIMAL |
not mapped | |
SCODE |
int |
|
VARIANT_BOOL |
boolean |
|
DATE |
java.util.Date |
DATE truncates java.util.Date to whole seconds |
DISPATCH |
com.moesol.bindings.platform_sdk |
|
VARIANT |
varies | (see comments above) |
UNKNOWN |
com.moesol.bindings.platform_sdk |
|
SAFEARRAY(com_type) |
jsegue_type[] |
For example, SAFEARRAY(INT) maps to int[] |
HRESULT |
/* HRESULT */ int |