From fadushin@syr.edu  Wed Feb  2 01:15:51 2000
Received: from fadushin.ne.mediaone.net (fadushin.ne.mediaone.net [24.218.120.90])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id BAA28713
	for <prolog@swi.psy.uva.nl>; Wed, 2 Feb 2000 01:15:50 +0100 (MET)
Received: from syr.edu (localhost [127.0.0.1])
	by fadushin.ne.mediaone.net (8.9.3/8.9.3) with ESMTP id TAA26341;
	Tue, 1 Feb 2000 19:18:53 -0500
Sender: fadushin@fadushin.ne.mediaone.net
Message-ID: <389777ED.59101066@syr.edu>
Date: Tue, 01 Feb 2000 19:18:53 -0500
From: Fred Dushin <fadushin@syr.edu>
Organization: Adiron, LLC
X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.14 ppc)
X-Accept-Language: en
MIME-Version: 1.0
To: Hans-Ulrich Zimmermann <Hans-Ulrich.Zimmermann@FernUni-Hagen.de>
CC: SWI-Prolog <prolog@swi.psy.uva.nl>
Subject: Re: JPL 1.1 Type Conversion
References: <3896E5BB.FF01D166@fernuni-hagen.de>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

> 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

