|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jess.Context
public class Context
A Context represents a scope in which variables can be declared. It also holds a pointer to a Rete object in which code can be executed.
You can use getVariable(java.lang.String)
and
setVariable(java.lang.String, jess.Value)
to get and change the value of a variable from
Java code, respectively.
The function getEngine()
gives any Userfunction
access to the Rete
object in which it is executing.
When a Userfunction is called, a Context
argument is passed in as the final argument. You should pass this
jess.Context to any methods you call that expect a Context argument themselves.
Constructor Summary | |
---|---|
Context(Context c)
Create a new context subordinate to an existing one. |
|
Context(Context c,
Rete engine)
Create a new context subordinate to an existing one. |
Method Summary | |
---|---|
void |
clearReturnValue()
Clear the return flag and return value for this context. |
Value |
getBindingVariable(java.lang.String varName)
Return the value represented by a variable on the LHS of a rule; works only during pattern matching. |
Rete |
getEngine()
Returns the Rete engine associated with this context. |
Fact |
getFact()
If this context represents a join network node from a rule LHS, this will return the right input of the node. |
Funcall |
getFuncall()
Return the currently executing Funcall object. |
LineNumberRecord |
getLineNumberRecord()
Return information about the currently executing function. |
jess.LogicalNode |
getLogicalSupportNode()
If this context represents the RHS of a rule which is firing, and the LHS of the rule has provided logical support, this method will return the LogicalNode that lends support. |
Context |
getParent()
Return the parent of this context. |
Value |
getReturnValue()
Get the value set via setReturnValue |
java.util.Stack |
getStackData()
Returns some information about the runtime stack. |
Token |
getToken()
If this context represents a join network node from a rule LHS, this will return the left input of the node. |
Value |
getVariable(java.lang.String name)
Get the value of a variable |
java.util.Iterator |
getVariableNames()
Returns an iterator over the names of all the variables defined in this context. |
boolean |
isVariableDefined(java.lang.String name)
Report whether a variable has a value in this context |
Context |
pop()
Pop this context off the execution stack. |
void |
popStackFrame(Funcall funcall)
Remove stack information. |
Context |
push()
Create and return a new context subordinate to this one. |
void |
pushStackFrame(Funcall funcall)
Store stack information. |
void |
removeVariable(java.lang.String name)
Undefine any variable by the given name in this context or any parent context. |
boolean |
returning()
Returns true if the return flag has been set in this context. |
void |
setExistingVariable(java.lang.String name,
Value value)
Set an existing variable in an ancestor of this context to a value; if no existing variable, value is set in this context. |
Value |
setReturnValue(Value val)
Set the return flag to true, and supply a value to be returned. |
void |
setVariable(java.lang.String name,
Value value)
Set a variable in this context to some type and value. |
java.lang.String |
toString()
Returns a useful debug representation of the context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Context(Context c)
c
- The parent for the new contextpush()
public Context(Context c, Rete engine)
c
- The parent for the new contextengine
- The value to be returned from getEngineMethod Detail |
---|
public final Token getToken()
public final Fact getFact()
public final jess.LogicalNode getLogicalSupportNode()
public final boolean returning()
public final Value setReturnValue(Value val)
val
- The value that should be returned from this context
public final Value getReturnValue()
public final void clearReturnValue()
public java.util.Iterator getVariableNames()
public final Rete getEngine()
public Context push()
public Context pop()
public Context getParent()
public Value getVariable(java.lang.String name) throws JessException
name
- The name of the variable with no leading '?' or '$'
characters
JessException
- If the variable is undefinedpublic boolean isVariableDefined(java.lang.String name)
name
- The name of the variable with no leading '?' or '$'
characterspublic void setVariable(java.lang.String name, Value value) throws JessException
name
- Name of the variablevalue
- The value of the variable
JessException
public void setExistingVariable(java.lang.String name, Value value) throws JessException
name
- Name of the variablevalue
- The value of the variable
JessException
public void pushStackFrame(Funcall funcall) throws JessException
funcall
- a function call about to be invoked
JessException
- if anything goes wrongpublic java.util.Stack getStackData() throws JessException
JessException
public void popStackFrame(Funcall funcall) throws JessException
funcall
- a function call that has just been invoked
JessException
- if anything goes wrongpublic java.lang.String toString()
toString
in class java.lang.Object
public Funcall getFuncall() throws JessException
JessException
- if anything goes wrong.public LineNumberRecord getLineNumberRecord() throws JessException
JessException
- if anything goes wrongpublic Value getBindingVariable(java.lang.String varName) throws JessException
varName
- the name of a variable
JessException
- if anything goes wrong.public void removeVariable(java.lang.String name)
name
- the name of the variable to remove.
|
© 2013 Sandia Corporation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |