0
votes

I'm implementing a methond in my application that uses the Jessp parser class in order to open a file and getting the deftemplates and deffacts inside of it. The problem is that when trying to obtain the result into a object variable, it asks on the constructor for a JessTokenStream. I tried to pass a JessToken, but then it complains about the type, that it should be e8. Searched through the Jess documentation but didn't found an explanation for the arguments, only the syntax of the constructor. Anyone can help?. Thanks in advance!!!

1
Do you mean jess.Jesp? And the current Jess API does not contain a class JessTokenStream. - What's the code you have got so far? Which documentation were you searching, and the API/javadoc sure contains explanations of all parameters. Probably I should also ask for the Jess version.laune
@laune Well, the only reference i got in the documentation of the Jess apiis this:public Deftemplate parseDeftemplate(Context context, Rete engine, jess.JessTokenStream jts) throws JessExceptioncreator4983
@laune I'm using the last jess version (71p2). Why is it that i can't use return for line feed when posting a reply here?. It goes straight to the save comment. that's the reason the previous post looks a bit weird. Will try to search through the site the way to insert code well indented in order to be readable. Thanks in advance!creator4983
Hmm, strange. It's possible that here is the borderline of what you may access with a trial version. I can't call any Jesp method. Maybe ejfh will clarify this.laune
What is you intent for trying to parse files by calling Jesp? It's not something you'd normally want or need to do in order to run a Jess session.laune

1 Answers

0
votes

The class JessTokenStream is not public, so you can't actually call those parseXXX() methods. They are public for historical reasons but aren't actually usable by clients. They should actually be removed from the public interface.

Instead, use the two-argument form of parseExpression(), and then test the returned object to determine its type. Then you can do what you want with the returned object:

Rete engine = ...
Jesp jesp = ...
Object o = jesp.parseExpression(engine.getGlobalContext(), false);
if (o instanceof Deffacts) {
    Deffacts d = (Deffacts) o;
    for (int i = 0; i<d.getNFacts(); ++i) {
        Fact f = d.getFact(i);
        Deftemplate t = f.getDeftemplate();
        System.out.println("Fact name is " + f.getName();
        System.out.println("Fact name is " + f.getName();
        for (String name: t.getSlotNames())
            System.out.println("Slot " + name + " contains " + f.getSlotValue(name));
    }
}