JESS: Is there a better Jess equivalent for pack.age.MyClass.class?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

JESS: Is there a better Jess equivalent for pack.age.MyClass.class?

Wolfgang Laun-2
If there's an object of a class around, one can do (?obj getClass).

Given only the class name,  the only thing I can think of is
   (call Class forName pack.age.MyClass)
which can be wrapped into a deffunction but still needs the
full class name as an argument.

There's no static field "class" in a class, and therefore
   (call MyClass class)
cannot work (after an import of MyClass).

Is there any better way?
-W

Reply | Threaded
Open this post in threaded view
|

RE: JESS: Is there a better Jess equivalent for pack.age.MyClass.class?

Friedman-Hill, Ernest
There's a method "findClass()" in jess.Rete which finds Class objects. It leverages
the data from the Jess "import" command so that class names don't have to be
fully qualified. So you could say
 
((engine) findClass MyClass)
 
I love it when a question has a clear, unambiguous, helpful answer! :)


From: [hidden email] [mailto:[hidden email]] On Behalf Of Wolfgang Laun
Sent: Wednesday, August 10, 2011 7:27 AM
To: jess-users
Subject: JESS: Is there a better Jess equivalent for pack.age.MyClass.class?

If there's an object of a class around, one can do (?obj getClass).

Given only the class name,  the only thing I can think of is
   (call Class forName pack.age.MyClass)
which can be wrapped into a deffunction but still needs the
full class name as an argument.

There's no static field "class" in a class, and therefore
   (call MyClass class)
cannot work (after an import of MyClass).

Is there any better way?
-W