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