Data conversion between Java and B-Prolog

The following table shows how to convert data from Java to Prolog:
Java Prolog
Integer integer
Double real
Long integer
BigInteger integer
Boolean integer
Character string (list of codes)
String string (list of integers)
Object array list
Object $addr(I1,I2)
Note that primitive data types cannot be converted into Prolog. Data conversion from Prolog to Java follows the same protocol, except that a string is converted to an array of Integers rather than a String, and a Prolog atom is converted to a Java String.
Prolog Java
integer Integer
real Double
atom String
string Object array
list Object array
structure Object

The conversion between arrays and lists needs further explanation. A Java array of some type is converted into a list of elements of the corresponding converted type. For instance, an Integer array is converted into a list of integers. In contrast, a Prolog list of any type(s) of elements is converted into an array of Objects. When an array element is used as a specific type, it must be casted to that type.

Neng-Fa Zhou 2013-01-25