Use "shadow" facts.

see http://www.jessrules.com/jesswiki/view?FactsVsShadowFacts

On Nov 4, 2011, at 1:08 PM, Hunter McMillen wrote:

> Hi everyone, 
> 
> I am trying to assert to Jess that an object exists when I encounter a new 
> object in my Java program. Right now I am using a template to mirror that 
> object (i.e I have slot values for all of the Java objects fields)  but this 
> seems redundant to me. Is there any way to just bind a Java object to a Jess 
> variable without creating a new Java object? 
> 
> A lot of the examples I see online and from JIA are of the form:
> (bind ?map (new HashMap))
> 
> or
> 
> (call Classname method params...)
> 
> but these either create  a new object or call static methods. I already have 
> the Java object and just want to store it.
> 
> But I was hoping that there was someway I could do something like this:
> public Rete engine = new Rete();
> 
> public void unitDiscovered()
> {
>     Unit unit = <some unit encountered>; //Java object
>     engine.executeCommand("(bind ?unit unit)");
>     engine.executeCommand("(assert ?unit)");
> }
> 
> Or would I have to use the store() and fetch() methods for this?
> 
> public void unitDiscovered()
> {
>     Unit unit = <some unit encountered>; //Java object
>     engine.store("UNIT", unit);
>     engine.executeCommand("(bind ?unit (fetch "UNIT")");
>     engine.executeCommand("(assert ?unit)");
> }
> 
> Basically I want to know the best practice for binding Java objects to Jess 
> variables so I can assert them to the engine.
> 
> Thanks,
> Hunter McMillen



--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
--------------------------------------------------------------------

Reply via email to