// Create a text area; you'll need to add it to your GUI, of course TextArea ta = new TextArea(20, 80); // This is a sort of adapter that lets Jess print into a textarea. // There's also a JTextAreaWriter for Swing GUIs TextAreaWriter taw = new TextAreaWriter(ta); // Create a rule engine instance Rete engine = new Rete(); // Connect the "t" router to the TextArea. From this point on, // Jess code that executes "(printout t ..." will send its output // to the TextArea engine.addOutputRouter("t", taw);
import jess.*; // ... // Get Jess ready Rete engine = new Rete(); engine.batch("dates.clp"); engine.watchAll(); // Plug in the "chosen date" Date chosenDate = new Date(113, 4, 5); Fact fact = new Fact("chosendate", engine); fact.setSlotValue("__data", new Value(new ValueVector().add(chosenDate), RU.LIST)); engine.assertFact(fact); // Run the rule and report the result int count = engine.run(); if (count > 0) { int score = engine.getGlobalContext().getVariable("*var*").intValue(null); System.out.println("Score = " + score); } else { System.out.println("No matching date found."); }
public static void main(String[] args) { Bean testbean = new Bean(); testbean.setName("test"); Rete engine = new Rete(); engine.defclass("bean", "Bean", null, false); engine.definstance("bean", testbean, false); engine.eval("(facts)"); }
import jess.*; public class Main { public static void main( String[] args ) throws Exception { Rete rete = new Rete(); Value val = rete.batch("security.clp"); Data data = new Data(); data.setA( 42 ); data.setB( 24 ); rete.add( data ); rete.run(); System.out.println( "result = " + data.getRes() ); } }