Ernest,

Yes, I mean java collection class -- "ArrayList" in which it contains
multitple objects who have a getter for each of its property.

I insert the ArrayList into working memory and try to write a rule based on
the property's value of each object in the arraylist.

is this the right way to access it?

(( ?myArraylist get 0) getValue "value1") 

Before calling object.getValue("value1"), how do I cast the return value of
arraylist.get(0) to the object type it contains in Jess?

Thanks a lot!
Andrew



Ernest Friedman-Hill wrote:
> 
> 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]
> --------------------------------------------------------------------
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/JESS%3A-How-to-access-info-in-a-objects-cotained-in-a-arraylist.-tf4524484.html#a12910353
Sent from the Jess mailing list archive at Nabble.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