[ Team LiB ] Previous Section Next Section

Dealing with the Data Types

After jCOM is configured and up and running, you'll find that the only real day-to-day programming task you'll encounter is in dealing with the data types that you send and receive from the server objects you've exposed. From a Java or COM client perspective, you'll need to reconcile between individual idiosyncrasies in the primitive data type mappings that jCOM provides.

Overall, jCOM should be given credit for providing a workable solution to a difficult problem and doing a very good job of mapping primitive and complex data types across platforms into a form familiar to programmers on either side. But as with all integration efforts, you shouldn't expect perfection. For example, a COM VariantEnumeration type is mapped to a java.lang.Enumeration in Java. COM enumerations have no equivalent to the hasMoreElements() method, so you'll have to work around this by using the nextElement method until you get a NoSuchElementException.

As an alternative, under the Server/ServerName/Connections/jCOM tab on the WebLogic Server Console, you can check Prefetch Enums. In the background, jCOM will pre-fetch the next element so that hasMoreElements() will work correctly.

See Table 33.2 for a sample of how types are mapped between COM and Java. I refer you to the J-Integra Web site documentation where you will find very useful detailed listings of all the latest type mappings: http://www.intrinsyc.com/support/j-integra/doc/. In Contents, look under Reference/Type Mapping.

Table 33.2. Late Binding Type Mapping and Coercion Early Versus Late Binding Summary

Visual Basic Variant Type

Java Primitive Type

VARIANT BOOL

java.lang.Boolean

unsigned char

java.lang.Byte

double

java.lang.Double

float

java.lang.Float

long

java.lang.Integer

short

java.lang.Short

Decimal

java.math.BigDecimal

DATE

java.util.Date

BSTR

java.lang.String

    [ Team LiB ] Previous Section Next Section