Re: JESS: Print Jess rule in detail using Java code

"Ernest Friedman-Hill" <[email protected]> Mon, 25 Apr 2011 10:18:46 -0400
Newsgroups gmane.comp.java.jess
Message-ID <[email protected]>
See http://www.jessrules.com/jess/docs/71/library.html#prettyprinting


On Apr 23, 2011, at 1:47 PM, Vu Le wrote:

> In my Java code, I have:
>             Rete engine = new Rete();
> engine.batch("myrule.clp");
> …
> Now how do I print out, by Java code, LHS and RHS of the rules that  
> are in "myrule.clp"?
> I had tried to use this to print the LHS:
> for (Iterator iterator = engine.listDefrules(); iterator.hasNext();) {
>             Defrule rule = (Defrule) iterator.next();
>             for (Iterator iterator2 = rule.getNodes();  
> iterator2.hasNext();) {
>                   Node node = (Node) iterator2.next();
>                   if (node.getNodeType() == 1) {
>                         System.out.println("--" + node);
>                   }
>             }
>             System.out.println("Action: " + rule.getAction(0));
>       }
> But the output looks really annoying.
> Can anyone help me?

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs
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].
--------------------------------------------------------------------