Thank you for the very quick answer!
Your email was very helpful in such way that I realized that my way of querying the attribute was not quite accurate. However, I am afraid that simply querying with the argument-list won't help me, because I need to find out if at least one elements of the argument-list is an element of the Vector. In addition, in the working memory is not just one fact, there is a large number of them.

Example:
argument-list = "black, white, red"

Let O be the set of all myObjects and o^i be the i-th element of O, then let this be the values of the vectors of the objects in the
working memory:
o^1 = "black, blue, red"
o^2 = "green, blue"
o^3 = "white"
o^4 = "red, white, yellow, purple"

I would like to have a way to ask Jess how many times any element from the argument-list occurs in the entire working memory occurs. In the above example, I would hence get "5" (1 x black + 2 x red + 2 x white).

I believe I am thinking to complex, but wouldn't I have to query the WM for every element? So, I need a way to ask Jess, if the query parameter is a subset of the vector property of any of the facts, right? Sorry for bothering the list, if this is a too obvious rookie-question. Yet, thank you for your help and patience with me!

Bastian

Ernest Friedman-Hill wrote:

If your Java object contains a Vector as a property, then it won't match a ValueVector; the Jess fact's slot will just contain the Vector. Since Vector implements equals(), the proper query parameter would be just "new Value(myVector)".

The NPE is probably happening because you're not calling hasNext() on the QueryResult first to check whether or not next() will advance to a valid record.

On Apr 13, 2007, at 5:30 PM, B. Tenbergen wrote:

Hello List,

I am not sure if I am using Jess right in my little application. I have written some code to query an Java Object's (the objct was asserted to Jess's Working Memory) variable that happens to be a java.util.Vector. What I essentially want to do is to check if each element in a given argument-list is element of the Vector of the Java object.

In order to do that, I believe that the argument-list needs to be added to a ValueVector so that I can run a query*, right? The argument-list must then be a Value of type RU.LIST. So, I add each element of the argument-list to a ValueVector, create a Value by using the constructor that takes a ValueVector and an int (i.e. RU.LIST) and add that Value to a new ValueVector. Is that the right procedure? It seems a little redunant to me to create add a Value, that consists of a ValueVector to a ValueVector...

However, here is some code I have written to accomplish this task.
The object looks like this:

public class myObject {

Vector<String> myVector = new Vector<String>();

...
}

And here is the code, I wrote to query this vector:

Rete r = new Rete();
myObject o = new myObject();

r.defclass("myObject", "PATH/TO/myObject.class", null);
r.definstance("myObject", o, false);
r.eval("(defquery myQuery (declare (variables ?var)) (myObject (myVector ?var) (crn ?crn)))");
ValueVector vv = new ValueVector();

               for (int i = 0; i < parameters.length; i++) {
                   vv.add(new Value(parameters[i], RU.STRING));
               }
                             ValueVector vv2 = new ValueVector();
               vv2.add(new Value(vv, RU.LIST));
QueryResult result = r.runQueryStar ("myQuery", vv2);

"parameters" is the argument-list I have mentioned above.
The code compliles and executes. However, when I try to access the QueryResult-object, I always get a NullPointerException. Unfortunately, I am not sure if this is because I pass the wrong ValueVector to the query of because none of the elements in the argument-list are in the slot... (that argument-list is passed from another program into my application and the Java object is created elsewhere too, so I have no influence about it...).

I would greatly appreciate any help that can tell me if I am on the right track.
Thank you all very much in advance!

Bastian

--------------------------------------------------------------------
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 owner-jess- [EMAIL PROTECTED]
--------------------------------------------------------------------


---------------------------------------------------------
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]
--------------------------------------------------------------------



--------------------------------------------------------------------
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