Subject: Re: JPL 1.1 Type Conversion

From: Fred Dushin <[email-masked]>
Date: Tue, 01 Feb 2000 19:18:53 -0500

> What is the best (easiest) way to convert a (JPL)Variable,
> that is instantiatetd to a Interger by query,
> to an (ordinary) Java Integer ??

The jpl.Integer class has a value() accessor:

public final int value()

You can convert this to a java.lang.Integer with one of the java.lang.Integer
constructors.  I'd write something like:

	jpl.Variable X = new jpl.Variable();
	jpl.Query query = // construct query
	java.lang.Integer i = 
	    new java.lang.Integer(
	        ((jpl.Integer)query.oneSolution().get( X )).value() );

Though this is not directly relevent to your question, JPL 1.2 will have support
for returning instances of your own extensions of the Compound class when
returning compound terms from Prolog.  In 1.0, you always get back a
jpl.Compound, if, say, a Variable is bound for a complex term (e.g., f(a)).  In
1.2, you can register a CompoundFactory which creates an instance of a class of
the user's design, which can make things a bit neater for JPL programming.

Also in 1.2, I'd like to change the return type of oneSolution to
java.util.Dictionary, instead of java.util.Hashtable, since all we really use
are the Dictionary interfaces that Hashtable implements.  Thoughts?

Fred