org.drools.spi
Class DefaultKnowledgeHelper

java.lang.Object
  extended by org.drools.spi.DefaultKnowledgeHelper
All Implemented Interfaces:
KnowledgeHelper

public class DefaultKnowledgeHelper
extends java.lang.Object
implements KnowledgeHelper


Constructor Summary
DefaultKnowledgeHelper(Rule rule, Tuple tuple)
           
 
Method Summary
 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.
 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.
 java.lang.String getRuleName()
           
 void modifyObject(java.lang.Object object)
          Modifies an object.
 void modifyObject(java.lang.Object oldObject, java.lang.Object newObject)
          Modifies an object by looking up the handle of the oldObject and replacing the oldObject with the newObject for the FactHandle.
 void retractObject(java.lang.Object object)
          Retracts an object from the WorkingMemory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultKnowledgeHelper

public DefaultKnowledgeHelper(Rule rule,
                              Tuple tuple)
Method Detail

assertObject

public void assertObject(java.lang.Object object)
                  throws FactException
Description copied from interface: KnowledgeHelper
Asserts an object, notice that it does not return the FactHandle

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

assertObject

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

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

modifyObject

public void modifyObject(java.lang.Object object)
                  throws FactException
Description copied from interface: KnowledgeHelper
Modifies an object. Notice that the FactHandle is not passed so the implementation must lookup the FactHandle form the working memory.

Specified by:
modifyObject in interface KnowledgeHelper
Parameters:
object - - the object to be modified
Throws:
FactException - - Exceptions can be thrown by conditions which are wrapped and returned as a FactException

modifyObject

public void modifyObject(java.lang.Object oldObject,
                         java.lang.Object newObject)
                  throws FactException
Description copied from interface: KnowledgeHelper
Modifies an object by looking up the handle of the oldObject and replacing the oldObject with the newObject for the FactHandle. This is used for updating immutable objects.

Specified by:
modifyObject in interface KnowledgeHelper
Parameters:
oldObject - - The old object to be modified
newObject - - the new modified object
Throws:
FactException

retractObject

public void retractObject(java.lang.Object object)
                   throws FactException
Description copied from interface: KnowledgeHelper
Retracts an object from the WorkingMemory. All Activations on the Agenda that are cancelled should emit ActivationCancelled events.

Specified by:
retractObject in interface KnowledgeHelper
Parameters:
object - - the object to be retracted.
Throws:
FactException - - Wraps and returns any exception that may occur.

getRuleName

public java.lang.String getRuleName()
Specified by:
getRuleName in interface KnowledgeHelper
Returns:
- The rule name

getObjects

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

getObjects

public java.util.List getObjects(java.lang.Class objectClass)
Description copied from interface: KnowledgeHelper
Retruns a List of Objects that match the given Class in the paremeter.

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

clearAgenda

public void clearAgenda()
Description copied from interface: KnowledgeHelper
Clears the agenda causing all existing Activations to fire ActivationCancelled events.

Specified by:
clearAgenda in interface KnowledgeHelper