org.drools
Interface WorkingMemory

All Superinterfaces:
Serializable
All Known Implementing Classes:
MockWorkingMemory, WorkingMemoryImpl

public interface WorkingMemory
extends Serializable

A knowledge session for a RuleBase.

Author:
bob mcwhirter

Method Summary
 void addEventListener(WorkingMemoryEventListener listener)
          Add an event listener.
 FactHandle assertObject(Object object)
          Assert a fact.
 FactHandle assertObject(Object object, boolean dynamic)
          Assert a fact registering JavaBean PropertyChangeListeners on the Object to automatically trigger modifyObject calls if dynamic is true.
 void clearAgenda()
          Clear the Agenda
 boolean containsObject(FactHandle handle)
          Determine if an object is associated with a FactHandle.
 void fireAllRules()
          Fire all items on the agenda until empty.
 void fireAllRules(AgendaFilter agendaFilter)
          Fire all items on the agenda until empty, using the given AgendaFiler
 Object getApplicationData(String name)
          Retrieve a specific piece of application data by name
 Map getApplicationDataMap()
          Retrieve all of the set application data in this memory
 List getEventListeners()
          Returns all event listeners.
 FactHandle getFactHandle(Object object)
          Retrieve the FactHandle associated with an Object.
 List getFactHandles()
          Retrieve all known Fact Handles.
 Object getObject(FactHandle handle)
          Retrieve the object associated with a FactHandle.
 List getObjects()
          Retrieve all known objects.
 List getObjects(Class objectClass)
          Retrieve all known objects of the specified class.
 RuleBase getRuleBase()
          Retrieve the RuleBase of this working memory.
 void modifyObject(FactHandle handle, Object object)
          Modify a fact.
 void removeEventListener(WorkingMemoryEventListener listener)
          Remove an event listener.
 void retractObject(FactHandle handle)
          Retract a fact.
 void setApplicationData(String name, Object value)
          Set a specific piece of application data in this working memory
 

Method Detail

addEventListener

public void addEventListener(WorkingMemoryEventListener listener)
Add an event listener.

Parameters:
listener - The listener to add.

removeEventListener

public void removeEventListener(WorkingMemoryEventListener listener)
Remove an event listener.

Parameters:
listener - The listener to remove.

getEventListeners

public List getEventListeners()
Returns all event listeners.

Returns:
listeners The listeners.

getApplicationDataMap

public Map getApplicationDataMap()
Retrieve all of the set application data in this memory

Returns:
the application data as a Map

setApplicationData

public void setApplicationData(String name,
                               Object value)
Set a specific piece of application data in this working memory

Parameters:
name - the name under which to populate the data
value - the application data

getApplicationData

public Object getApplicationData(String name)
Retrieve a specific piece of application data by name

Returns:
application data or null if nothing is set under this name

getRuleBase

public RuleBase getRuleBase()
Retrieve the RuleBase of this working memory.

Returns:
The RuleBase.

fireAllRules

public void fireAllRules()
                  throws FactException
Fire all items on the agenda until empty.

Throws:
FactException - If an error occurs.

fireAllRules

public void fireAllRules(AgendaFilter agendaFilter)
                  throws FactException
Fire all items on the agenda until empty, using the given AgendaFiler

Throws:
FactException - If an error occurs.

getObject

public Object getObject(FactHandle handle)
                 throws NoSuchFactObjectException
Retrieve the object associated with a FactHandle.

Parameters:
handle - The fact handle.
Returns:
The associated object.
Throws:
NoSuchFactObjectException - If no object is known to be associated with the specified handle.
See Also:
containsObject(org.drools.FactHandle)

getFactHandle

public FactHandle getFactHandle(Object object)
                         throws NoSuchFactHandleException
Retrieve the FactHandle associated with an Object.

Parameters:
object - The object.
Returns:
The associated fact handle.
Throws:
NoSuchFactHandleException - If no handle is known to be associated with the specified object.
See Also:
containsObject(org.drools.FactHandle)

getObjects

public List getObjects()
Retrieve all known objects.

Returns:
The list of all known objects.

getObjects

public List getObjects(Class objectClass)
Retrieve all known objects of the specified class.

Parameters:
objectClass - The class of object to return.
Returns:
The list of all known objects of the specified class.

getFactHandles

public List getFactHandles()
Retrieve all known Fact Handles.

Returns:
The list of all known fact handles.

containsObject

public boolean containsObject(FactHandle handle)
Determine if an object is associated with a FactHandle.

Parameters:
handle - The fact handle.
Returns:
true if an object is known to be associated with the specified handle, otherwise false.

assertObject

public FactHandle assertObject(Object object)
                        throws FactException
Assert a fact.

Parameters:
object - The fact object.
Returns:
The new fact-handle associated with the object.
Throws:
FactException - If an error occurs.

assertObject

public FactHandle assertObject(Object object,
                               boolean dynamic)
                        throws FactException
Assert a fact registering JavaBean PropertyChangeListeners on the Object to automatically trigger modifyObject calls if dynamic is true.

Parameters:
object - The fact object.
dynamic - true if Drools should add JavaBean PropertyChangeListeners to the object.
Returns:
The new fact-handle associated with the object.
Throws:
FactException - If an error occurs.

retractObject

public void retractObject(FactHandle handle)
                   throws FactException
Retract a fact.

Parameters:
handle - The fact-handle associated with the fact to retract.
Throws:
FactException - If an error occurs.

modifyObject

public void modifyObject(FactHandle handle,
                         Object object)
                  throws FactException
Modify a fact.

Parameters:
handle - The fact-handle associated with the fact to modify.
object - The new value of the fact.
Throws:
FactException - If an error occurs.

clearAgenda

public void clearAgenda()
Clear the Agenda



Copyright © 2001-2004 The Codehaus. All Rights Reserved.