org.drools.spi
Interface KnowledgeHelper

All Known Implementing Classes:
DefaultKnowledgeHelper

public interface KnowledgeHelper

KnowledgeHelper implementation types are injected into consequenses instrumented at compile time and instances passed at runtime. It provides convenience methods for users to interact with the WorkingMemory.

Of particular interest is the modifyObject method as it allows an object to be modified without having to specify the facthandle, because they are not passed to the consequence at runtime. To achieve this the implementation will need to lookup the fact handle of the object form the WorkingMemory.

 

Method Summary
 void assertLogicalObject(java.lang.Object object)
           
 void assertLogicalObject(java.lang.Object object, boolean dynamic)
           
 void assertObject(java.lang.Object object)
          Asserts an object, notice that it does not return the FactHandle
 void assertObject(java.lang.Object object, boolean dynamic)
          Asserts an object specifying that it implement the onPropertyChange listener, notice that it does not return the FactHandle.
 void clearAgenda()
          Clears the agenda causing all existing Activations to fire ActivationCancelled events.
 void clearAgendaGroup(java.lang.String group)
           
 java.lang.Object get(Declaration declaration)
           
 Activation getActivation()
           
 AgendaGroup getFocus()
           
 java.util.List getObjects()
           
 java.util.List getObjects(java.lang.Class objectClass)
          Retruns a List of Objects that match the given Class in the paremeter.
 QueryResults getQueryResults(java.lang.String query)
           
 Rule getRule()
           
 Tuple getTuple()
           
 WorkingMemory getWorkingMemory()
           
 void modifyObject(FactHandle handle, java.lang.Object newObject)
           
 void retractObject(FactHandle handle)
           
 void setFocus(AgendaGroup focus)
           
 void setFocus(java.lang.String focus)
           
 

Method Detail

assertObject

public void assertObject(java.lang.Object object)
                  throws FactException
Asserts an object, notice that it does not return the FactHandle

Throws:
FactException - - Exceptions can be thrown by conditions which are wrapped and returned as a FactException
Parameters:
object - - the object to be asserted

assertObject

public void assertObject(java.lang.Object object,
                         boolean dynamic)
                  throws FactException
Asserts an object specifying that it implement the onPropertyChange listener, notice that it does not return the FactHandle.

Throws:
FactException - - Exceptions can be thrown by conditions which are wrapped and returned as a FactException
Parameters:
object - - the object to be asserted
dynamic - - specifies the object implements onPropertyChangeListener

assertLogicalObject

public void assertLogicalObject(java.lang.Object object)
                         throws FactException
Throws:
FactException

assertLogicalObject

public void assertLogicalObject(java.lang.Object object,
                                boolean dynamic)
                         throws FactException
Throws:
FactException

modifyObject

public void modifyObject(FactHandle handle,
                         java.lang.Object newObject)
                  throws FactException
Throws:
FactException

retractObject

public void retractObject(FactHandle handle)
                   throws FactException
Throws:
FactException

get

public java.lang.Object get(Declaration declaration)

getRule

public Rule getRule()
Returns:
- The rule name

getTuple

public Tuple getTuple()

getActivation

public Activation getActivation()

getWorkingMemory

public WorkingMemory getWorkingMemory()

getObjects

public java.util.List getObjects()
Returns:
- A List of the objects in the WorkingMemory

getObjects

public java.util.List getObjects(java.lang.Class objectClass)
Retruns a List of Objects that match the given Class in the paremeter.

Parameters:
objectClass - - The Class to filter by
Returns:
- All the Objects in the WorkingMemory that match the given Class filter

getQueryResults

public QueryResults getQueryResults(java.lang.String query)

clearAgenda

public void clearAgenda()
Clears the agenda causing all existing Activations to fire ActivationCancelled events.


clearAgendaGroup

public void clearAgendaGroup(java.lang.String group)

getFocus

public AgendaGroup getFocus()

setFocus

public void setFocus(java.lang.String focus)

setFocus

public void setFocus(AgendaGroup focus)