1 package org.drools.jsr94.rules;
2
3 import org.drools.AssertionException;
4 import org.drools.RetractionException;
5 import org.drools.RuleBase;
6 import org.drools.WorkingMemory;
7
8 import java.util.ArrayList;
9 import java.util.List;
10
11 /***
12 * Provide access to the list of objects currently asserted to the working memory.
13 *
14 * @author <a href="mailto:thomas.diesler@softcon-itec.de">thomas diesler</a>
15 */
16 public class WorkingMemoryImpl extends WorkingMemory
17 {
18
19 /*** contains the objects currently in the working memory. */
20 private List objectList = new ArrayList();
21
22 /***
23 * Construct a new working memory for a ruleBase.
24 *
25 * @param ruleBase The rule base with which this memory is associated.
26 */
27 WorkingMemoryImpl( RuleBase ruleBase )
28 {
29 super( ruleBase );
30 }
31
32 /***
33 * Get a list of objects currently asserted to the working memory.
34 */
35 public List getObjectList()
36 {
37 return objectList;
38 }
39
40 /*** Assert a new fact object into this working memory.
41 *
42 * @param object The object to assert.
43 *
44 * @throws AssertionException if an error occurs during assertion.
45 */
46 public synchronized void assertObject( Object object ) throws AssertionException
47 {
48 super.assertObject( object );
49 objectList.add( object );
50 }
51
52 /*** Retract a fact object from this working memory.
53 *
54 * @param object The object to retract.
55 *
56 * @throws RetractionException if an error occurs during retraction.
57 */
58 public synchronized void retractObject( Object object ) throws RetractionException
59 {
60 super.retractObject( object );
61 objectList.remove( object );
62 }
63 }
This page was automatically generated by Maven