You deal with Java objects from Jess the same way you deal with them from Java. There is no special syntax for dealing with collections -- you just call the Java methods. To call a method "y" on a Java object in variable ?x with argument "z", you write

(?x y "z")

Here you want to call "get" on the ArrayList to get an element, and "getValue" on the result; it looks like

(bind ?theObject (?arraylist get 1))
(?theObject getValue "value1")

of course you can eliminate the extra variable ?theObject and write

((?arraylist get 1) getValue "value1")

Now, I'm a tiny bit concerned that you didn't actually mean "ArrayList" but rather "array" in your original post; which is it?


On Sep 26, 2007, at 3:15 PM, Andrew Meng wrote:

Hello,

I have a java arraylist collection declared in Jess. In a rule's defination, I want to get some value from a object contained in arraylist. like, (> arraylist[1].getValue("value1") arraylist[0].getValue ("value2") )

Can anyone tell me what is the right way to do it in Jess?

Thanks a lot in advance!
Andrew

Discover the new Windows Vista Learn more!

---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550                 http://www.jessrules.com

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to