For example, if I have:
class MyBean {
public MyBean(String name, int value) { this.name = name; this.value =
value; }
String name;
int value;
}
Then an equivalent as a Prolog functor might be something like:
my_bean(class, name/string, value/int).
And if I have:
MyBean testBean = new MyBean("test", 27).
Then an equivalent as a Prolog functor might be something like:
test_bean(instance/my_bean, name/"test", value/27).
Where one bean contains a reference to another, it might be
represented something like:
bean_a(instance/a, ... fields of a).
bean_b(instance/b, reference/bean_a, ... remaining fields of b).
I want to be able to query Prolog from Java and create a bean from a
variable that gets bound to a Prolog 'bean' in the results. And
conversely I'd like a library functor on the Prolog side, that takes a
bean argument and creates it on the Java heap.
Many thanks for any pointers or suggestions.
Rupert
http://www.swi-prolog.org/packages/jpl/
A long long time ago, I had done some Java - Prolog interconnecting using
Amzi!
I assume most popular Prologs, will probably offer some library, to
interface to Java or some other langugage.
? <rupert...@googlemail.com> ?????? ??? ??????
news:ef55d2df-8378-4300...@b1g2000hsg.googlegroups.com...
I can't see an obviously right, or consensus, mapping from Java beans
to Prolog terms, so unless someone else has already addressed pretty
much the same requirements as yours, I doubt there's a library.
> For example, if I have:
>
> class MyBean {
> public MyBean(String name, int value) { this.name = name; this.value =
> value; }
> String name;
> int value;
> }
>
> Then an equivalent as a Prolog functor might be something like:
>
> my_bean(class, name/string, value/int).
Consider using an established "map" ADT for representing the fields.
> And if I have:
>
> MyBean testBean = new MyBean("test", 27).
>
> Then an equivalent as a Prolog functor might be something like:
>
> test_bean(instance/my_bean, name/"test", value/27).
>
> Where one bean contains a reference to another, it might be
> represented something like:
>
> bean_a(instance/a, ... fields of a).
> bean_b(instance/b, reference/bean_a, ... remaining fields of b).
>
> I want to be able to query Prolog from Java and create a bean from a
> variable that gets bound to a Prolog 'bean' in the results. And
> conversely I'd like a library functor on the Prolog side, that takes a
> bean argument and creates it on the Java heap.
Have a look at the Java Serialization API, e.g.
http://java.sun.com/developer/technicalArticles/Programming/serialization/
SWI-Prolog's JPL lets you query Prolog from Java and explore Java
classes through the Reflection API
> Many thanks for any pointers or suggestions.
> Rupert
cheers - Paul Singleton