|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjess.Rete
The reasoning engine and the central class in the Jess library. Executes the built Rete network, and coordinates many other activities. Rete is basically a facade for all the other classes in the Jess.
(C) 2003 Ernest J. Friedman-Hill and Sandia National Laboratories
$Id: Rete.java,v 1.23.2.1 2003/05/07 18:08:15 ejfried Exp $
Field Summary | |
static int |
ACTIVATE
|
static int |
EVERY_TIME
|
static int |
INSTALL
|
Constructor Summary | |
Rete()
|
|
Rete(java.applet.Applet applet)
|
|
Rete(java.lang.Object appObject)
|
Method Summary | |
protected void |
aboutToFire(Activation a)
|
Deffacts |
addDeffacts(Deffacts df)
Creates a new deffacts in this object |
Defglobal |
addDefglobal(Defglobal dg)
Creates a new Defglobal in this object. |
void |
addDefmodule(java.lang.String moduleName)
Define a new module, which becomes current. |
void |
addDefmodule(java.lang.String moduleName,
java.lang.String doccomment)
Define a new module, which becomes current. |
HasLHS |
addDefrule(HasLHS dr)
Creates a new defrule or defquery in this object |
Deftemplate |
addDeftemplate(Deftemplate dt)
Creates a new deftemplate in this object. |
void |
addInputRouter(java.lang.String s,
java.io.Reader is,
boolean consoleLike)
|
void |
addJessListener(JessListener jel)
|
void |
addOutputRouter(java.lang.String s,
java.io.Writer os)
|
Userfunction |
addUserfunction(Userfunction uf)
Creates a new function in this object Will happily destroy an old one. |
Userpackage |
addUserpackage(Userpackage up)
Add a Userpackage to this engine. |
Fact |
assert(Fact f)
Deprecated. Use assertFact instead. |
Fact |
assert(Fact f,
Context c)
Deprecated. Use assertFact instead |
Fact |
assertFact(Fact f)
Assert a fact |
Fact |
assertFact(Fact f,
Context c)
Assert a fact |
Fact |
assertString(java.lang.String s)
Assert a fact, as a String, using the global execution context |
Fact |
assertString(java.lang.String s,
Context c)
Assert a fact, as a String |
void |
bload(java.io.InputStream is)
Read this object's state from the given stream. |
void |
bsave(java.io.OutputStream os)
Save this object's state out to the given stream. |
void |
clear()
Reinitialize engine Thanks to Karl Mueller for idea |
void |
clearFocusStack()
Empty the focus stack. |
void |
clearStorage()
Clear the storage used by store() and fetch(). |
Value |
defclass(java.lang.String jessName,
java.lang.String clazz,
java.lang.String parent)
Add a defclass definition to this engine |
Value |
definstance(java.lang.String jessTypename,
java.lang.Object object,
boolean dynamic)
Tell this engine to pattern match on the given object. |
Value |
definstance(java.lang.String jessTypename,
java.lang.Object object,
boolean dynamic,
Context context)
|
int |
doPreAssertionProcessing(Fact f)
|
void |
eventHappened(JessEvent je)
This method is just an implementation detail. |
Value |
executeCommand(java.lang.String cmd)
Evaluate a Jess expression in this engine's global context. |
Value |
executeCommand(java.lang.String cmd,
Context context)
Evaluate a Jess expression in the given context. |
Value |
fetch(java.lang.String name)
Retrieve an object previously stored with store(). |
java.lang.Class |
findClass(java.lang.String clazz)
|
Deffacts |
findDeffacts(java.lang.String name)
Return the named deffacts object |
Defglobal |
findDefglobal(java.lang.String name)
Look up a defglobal by name. |
HasLHS |
findDefrule(java.lang.String name)
Find a defrule or defquery object with a certain name. |
Deftemplate |
findDeftemplate(java.lang.String name)
Find a deftemplate object with a certain name |
Fact |
findFactByFact(Fact f)
This find is fast, and can be used to find out quickly if a given fact is on the fact-list and if so, obtain a reference to it. |
Fact |
findFactByID(int id)
This "find" is very slow; don't use it unless you have to. |
Userfunction |
findUserfunction(java.lang.String name)
Find a userfunction, if there is one. |
java.lang.Object |
getActivationSemaphore()
The monitor of the object returned from this method will be signalled whenever an activation appears. |
java.applet.Applet |
getApplet()
Returns the applet this Rete is installed in. |
java.lang.Class |
getAppObjectClass()
Returns the "application object" for this Rete instance |
java.lang.String |
getCurrentModule()
Return the name of the current module. |
java.io.PrintWriter |
getErrStream()
|
int |
getEvalSalience()
Fetch the salience evaluation behaviour |
int |
getEventMask()
|
static Factory |
getFactory()
|
java.lang.String |
getFocus()
Query the focus module. |
Context |
getGlobalContext()
Fetch the global execution context. |
boolean |
getInputMode(java.lang.String s)
|
java.io.Reader |
getInputRouter(java.lang.String s)
|
java.io.Writer |
getOutputRouter(java.lang.String s)
|
java.io.PrintWriter |
getOutStream()
|
boolean |
getResetGlobals()
When resetGlobals is true, the initializers of global variables are evaluated when (reset) is executed. |
Strategy |
getStrategy()
Retrieve the Strategy object this engine is using to order activations on the agenda. |
java.util.ArrayList |
getSupportedFacts(Fact supporter)
Returns a list of Fact objects that receive logical support from the argument. |
java.util.ArrayList |
getSupportingTokens(Fact fact)
Returns a list of one or more jess.Token objects that provide logical support for this fact. |
Activation |
getThisActivation()
Get the activation record for the currently firing rule. |
java.lang.String |
getThisRuleName()
Find out the name of the currently firing rule. |
void |
halt()
Stop the engine from firing rules. |
void |
importClass(java.lang.String clazz)
|
void |
importPackage(java.lang.String pack)
|
java.lang.Class |
javaClassForDefclass(java.lang.String name)
Return the Java Class corresponding to a given Defclass name, or null if the name was not found. |
protected void |
justFired(Activation a)
|
java.util.Iterator |
listActivations()
Return an Iterator over all the activiations for the current module. |
java.util.Iterator |
listActivations(java.lang.String moduleName)
Return an Iterator over all the activiations for the named module. |
java.util.Iterator |
listDefclasses()
Return an Iterator over all the names of all defclasses. |
java.util.Iterator |
listDeffacts()
Return an Iterator over all the deffacts in this engine. |
java.util.Iterator |
listDefglobals()
Return an Iterator over all the defglobals in this engine. |
java.util.Iterator |
listDefinstances()
Return an Iterator over all the definstanced objects |
java.util.Iterator |
listDefrules()
Return an Iterator over all the defrules in this engine. |
java.util.Iterator |
listDeftemplates()
Return an Iterator over all the deftemplates in this engine, both explicit and implied. |
java.util.Iterator |
listFacts()
Return an Iterator over all the facts currently on the fact-list |
java.util.Iterator |
listFocusStack()
Iterate over the focus stack, from bottom to top. |
java.util.Iterator |
listFunctions()
Return an Iterator over all the functions in this engine: built-in, user, and deffunctions. |
java.util.Iterator |
listJessListeners()
|
java.util.Iterator |
listModules()
List all modules |
Fact |
modify(Fact fact,
java.lang.String slot,
Value value)
Modify a single slot in a fact. |
Fact |
modify(Fact fact,
java.lang.String slot,
Value value,
Context context)
Modify a single slot in a fact. |
java.lang.String |
popFocus(java.lang.String expected)
Remove the top module from the focus stack, and return it. |
void |
ppFacts(java.lang.String head,
java.io.Writer output)
Write the pretty print forms of the facts with the given head to the writer |
void |
ppFacts(java.io.Writer output)
Write the pretty print forms of all facts to the writer |
void |
removeInputRouter(java.lang.String s)
|
void |
removeJessListener(JessListener jel)
|
void |
removeOutputRouter(java.lang.String s)
|
void |
reset()
Reset the Rete engine. |
java.lang.String |
resolveName(java.lang.String name)
Decorate the name with the current module name, if it doesn't already contain a module name. |
Fact |
retract(Fact f)
Retract a fact. |
Fact |
retractString(java.lang.String s)
Karl Mueller NASA/GSFC Code 522.2 (Karl.R.Mueller@gsfc.nasa.gov) 27.January.1998 Retract a fact as a string |
int |
run()
Run the actual engine. |
int |
run(int max)
Run the rule engine. |
java.util.Iterator |
runQuery(java.lang.String name,
ValueVector params)
Quick way to run a defquery |
int |
runUntilHalt()
Run until halt() is called. |
void |
setApplet(java.applet.Applet applet)
Associates this Rete with an applet so that, for instance, the (batch) commands will look for scripts using the applet's document base URL. |
void |
setAppObject(java.lang.Object appObject)
Associates this Rete with an object so that, for instance, the (batch) commands will look for scripts using the object's class loader. |
java.lang.String |
setCurrentModule(java.lang.String name)
Change the current module. |
void |
setEvalSalience(int method)
Set the salience evaluation behaviour. |
void |
setEventMask(int i)
|
static void |
setFactory(Factory f)
|
void |
setFocus(java.lang.String name)
Change the focus module. |
void |
setPendingFact(Fact fact,
boolean assrt)
|
void |
setResetGlobals(boolean reset)
When resetGlobals is true, the initializers of global variables are evaluated when (reset) is executed. |
java.lang.String |
setStrategy(Strategy s)
Tell this engine to use the given Strategy object to order the rules on the agenda. |
Value |
store(java.lang.String name,
java.lang.Object val)
Store a value in the engine under a given name for later retrieval by fetch. |
Value |
store(java.lang.String name,
Value val)
Store a value in the engine under a given name for later retrieval by fetch. |
java.lang.String |
toString()
|
Fact |
undefinstance(java.lang.Object object)
Tell this engine to stop pattern matching on the given object |
Value |
unDefrule(java.lang.String name)
Remove a rule or query from this Rete object. |
void |
unwatch(int which)
Cancel some debugging information. |
void |
unwatchAll()
Cancel all debugging info. |
Value |
updateObject(java.lang.Object object)
Bring a shadow fact up to date. |
void |
verifyModule(java.lang.String moduleName)
Throw an exception if the argument isn't the name of a module. |
void |
waitForActivations()
Waits on the activation lock until a rule is activated. |
void |
watch(int which)
Produce some debugging information. |
void |
watchAll()
Produce all possible debugging info. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int INSTALL
public static final int ACTIVATE
public static final int EVERY_TIME
Constructor Detail |
public Rete()
public Rete(java.applet.Applet applet)
applet
- If this Rete object is being created inside
an applet, pass it as an argument.public Rete(java.lang.Object appObject)
Method Detail |
public void addInputRouter(java.lang.String s, java.io.Reader is, boolean consoleLike)
s
- The router nameis
- A Reader where the router's data comes fromconsoleLike
- See the Jess manualpublic void removeInputRouter(java.lang.String s)
s
- The name of the routerpublic java.io.Reader getInputRouter(java.lang.String s)
s
- The router name
public void addOutputRouter(java.lang.String s, java.io.Writer os)
s
- The router nameos
- Where the data should gopublic void removeOutputRouter(java.lang.String s)
s
- The name of the routerpublic boolean getInputMode(java.lang.String s)
s
- The router name
public java.io.Writer getOutputRouter(java.lang.String s)
s
- The router name
public java.io.PrintWriter getErrStream()
public java.io.PrintWriter getOutStream()
public int doPreAssertionProcessing(Fact f) throws JessException
JessException
public void clear() throws JessException
JessException
public void setPendingFact(Fact fact, boolean assrt)
public void reset() throws JessException
JessException
- If anything goes wrong.public Fact assertString(java.lang.String s, Context c) throws JessException
s
- A String representing a factc
- An execution context for resolving variables
JessException
- If something goes wrongpublic Fact assertString(java.lang.String s) throws JessException
s
- A String representing a fact
JessException
- If something goes wrongpublic Fact assert(Fact f) throws JessException
JessException
public Fact assertFact(Fact f) throws JessException
f
- A Fact object. This fact becomes the property of Jess
after calling assertFact() -- don't change any of its fields until
the fact is retracted!
JessException
- If anything goes wrongpublic Fact assert(Fact f, Context c) throws JessException
JessException
public Fact assertFact(Fact f, Context c) throws JessException
f
- A Fact object. This fact becomes the property of Jess
after calling assertFact() -- don't change any of its fields until
the fact is retracted!
JessException
- If anything goes wrongpublic Fact retractString(java.lang.String s) throws JessException
s
-
JessException
public Fact retract(Fact f) throws JessException
f
- A Fact object. Doesn't need to be the actual object
that appears on the fact-list; can just be a Fact that could
compare equal to one.
JessException
- If anything goes wrong.public Fact modify(Fact fact, java.lang.String slot, Value value) throws JessException
fact
- A fact that's currently in working memory.slot
- The name of a slot in the factvalue
- A new value for the slot
JessException
- If the slot name is bad or any other error occurs.public Fact modify(Fact fact, java.lang.String slot, Value value, Context context) throws JessException
fact
- A fact that's currently in working memory.slot
- The name of a slot in the factvalue
- A new value for the slotcontext
- The execution context
JessException
- If the slot name is bad or any other error occurs.public Fact findFactByID(int id) throws JessException
id
- The fact-id
JessException
- If something goes wrongpublic Fact findFactByFact(Fact f) throws JessException
JessException
public void ppFacts(java.lang.String head, java.io.Writer output) throws java.io.IOException
java.io.IOException
public void ppFacts(java.io.Writer output) throws java.io.IOException
java.io.IOException
public java.util.Iterator listDeffacts()
public Deffacts findDeffacts(java.lang.String name)
public java.util.Iterator listDeftemplates()
public java.util.Iterator listDefrules()
public java.util.Iterator listFacts()
public java.util.Iterator listDefinstances()
public java.util.Iterator listDefclasses()
findDeftemplate(java.lang.String)
,
javaClassForDefclass(java.lang.String)
public java.util.Iterator listDefglobals()
public java.util.Iterator listFunctions()
public final HasLHS findDefrule(java.lang.String name)
name
- The name
public java.lang.Class javaClassForDefclass(java.lang.String name)
public Deftemplate findDeftemplate(java.lang.String name) throws JessException
name
- The name
JessException
public Deftemplate addDeftemplate(Deftemplate dt) throws JessException
dt
-
JessException
- If the deftemplate is already definedpublic Deffacts addDeffacts(Deffacts df) throws JessException
df
- A new Deffacts object
JessException
- If an error occurs during event broadcastingpublic Defglobal addDefglobal(Defglobal dg) throws JessException
dg
- A new Defglobal object
JessException
- If an error occurspublic Defglobal findDefglobal(java.lang.String name)
name
- The name of the defglobal
public Userfunction addUserfunction(Userfunction uf)
uf
- A new USerfunction
public Userpackage addUserpackage(Userpackage up)
up
- The package object
public final Userfunction findUserfunction(java.lang.String name)
name
- The name of the function
public final HasLHS addDefrule(HasLHS dr) throws JessException
dr
- A Defrule or Defquery
JessException
- If anything goes wrong.public final Value unDefrule(java.lang.String name) throws JessException
name
- The name of the rule or query
JessException
- If anything goes wrongpublic void addDefmodule(java.lang.String moduleName) throws JessException
JessException
public void addDefmodule(java.lang.String moduleName, java.lang.String doccomment) throws JessException
JessException
public java.lang.String getCurrentModule()
public java.lang.String setCurrentModule(java.lang.String name) throws JessException
JessException
public java.util.Iterator listModules() throws JessException
JessException
public java.lang.String getFocus()
public void setFocus(java.lang.String name) throws JessException
JessException
public java.util.Iterator listFocusStack() throws JessException
JessException
public void clearFocusStack()
public java.lang.String popFocus(java.lang.String expected) throws JessException
JessException
public void verifyModule(java.lang.String moduleName) throws JessException
JessException
public java.lang.String resolveName(java.lang.String name)
public java.util.Iterator listActivations()
public java.util.Iterator listActivations(java.lang.String moduleName) throws JessException
JessException
Activation.isInactive()
public java.lang.Object getActivationSemaphore()
waitForActivations()
public void waitForActivations()
getActivationSemaphore()
public java.lang.String setStrategy(Strategy s) throws JessException
s
- The new conflict resolution strategy
JessException
public Strategy getStrategy()
public final void setEvalSalience(int method) throws JessException
method
- One of the acceptable values
JessException
- If something goes wrongpublic final int getEvalSalience()
setEvalSalience(int)
public int run() throws JessException
JessException
- If anything goes wrong.protected void aboutToFire(Activation a)
protected void justFired(Activation a)
public int run(int max) throws JessException
max
- The maximum number of rules to fire
JessException
- If anything goes wrong.public int runUntilHalt() throws JessException
JessException
public void halt() throws JessException
JessException
public java.lang.String getThisRuleName()
getThisActivation()
public Activation getThisActivation()
getThisRuleName()
public void addJessListener(JessListener jel)
public void removeJessListener(JessListener jel)
public java.util.Iterator listJessListeners()
public int getEventMask()
public void setEventMask(int i)
public void bload(java.io.InputStream is) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public void bsave(java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public Value definstance(java.lang.String jessTypename, java.lang.Object object, boolean dynamic) throws JessException
jessTypename
- The name of a defclassobject
- An object of the defclass's typedynamic
- true if PropertyChangeListeners should be used
JessException
public Value definstance(java.lang.String jessTypename, java.lang.Object object, boolean dynamic, Context context) throws JessException
JessException
public Fact undefinstance(java.lang.Object object) throws JessException
object
- An object of the defclass's type
JessException
public Value updateObject(java.lang.Object object) throws JessException
object
- A previously definstanced object
JessException
- If object isn't a definstanced object, or on error.public Value defclass(java.lang.String jessName, java.lang.String clazz, java.lang.String parent) throws JessException
jessName
- The name Jess should use for this defclassclazz
- The name of the Java classparent
- If non-null, a parent deftemplate or defclass name
JessException
public java.applet.Applet getApplet()
public java.lang.Class getAppObjectClass()
Rete(java.lang.Object)
public void setApplet(java.applet.Applet applet)
applet
- The appletpublic void setAppObject(java.lang.Object appObject)
appObject
- The app objectpublic final Context getGlobalContext()
public Value executeCommand(java.lang.String cmd) throws JessException
cmd
- A string containing a Jess expression
JessException
- If anything goes wrongpublic Value executeCommand(java.lang.String cmd, Context context) throws JessException
cmd
- A string containing a Jess expressioncontext
- The evaluation context
JessException
- If anything goes wrongpublic final void setResetGlobals(boolean reset)
reset
- The value of this propertypublic final boolean getResetGlobals()
public Value store(java.lang.String name, Value val)
name
- A key under which to file the valueval
- The value to store
fetch(java.lang.String)
public Value store(java.lang.String name, java.lang.Object val)
name
- A key under which to file the valueval
- The value to store
fetch(java.lang.String)
public Value fetch(java.lang.String name)
name
- The key under which to find an object
store(java.lang.String, jess.Value)
public void clearStorage()
public static Factory getFactory()
public static void setFactory(Factory f)
public java.lang.Class findClass(java.lang.String clazz) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public void importPackage(java.lang.String pack)
public void importClass(java.lang.String clazz)
public java.util.Iterator runQuery(java.lang.String name, ValueVector params) throws JessException
JessException
public void watch(int which) throws JessException
which
- One of the constants in WatchConstants
JessException
- If the argument is invalidWatchConstants
public void unwatch(int which) throws JessException
which
- One of the constants in WatchConstants
JessException
- If the argument is invalidWatchConstants
public void watchAll()
public void unwatchAll()
public void eventHappened(JessEvent je)
eventHappened
in interface JessListener
je
- An event objectpublic java.lang.String toString()
public java.util.ArrayList getSupportingTokens(Fact fact)
fact
- A fact of interest.
Token
,
Token.fact(int)
,
Token.size()
public java.util.ArrayList getSupportedFacts(Fact supporter)
supporter
- A fact of interest.
|
© 2001 E.J. Friedman-Hill and Sandia Corporation | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |