|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zilonis.shell.GenericEventHandler
public class GenericEventHandler
| Field Summary | |
|---|---|
protected java.io.PrintStream |
console
|
protected static java.util.logging.Logger |
logger
|
protected boolean |
prettyPrint
|
protected Rete |
rete
|
protected Scope |
scope
|
protected java.io.PrintStream |
stderr
|
| Constructor Summary | |
|---|---|
GenericEventHandler(Rete rete)
|
|
GenericEventHandler(Rete rete,
java.io.PrintStream console)
|
|
| Method Summary | |
|---|---|
protected Action |
actionTemplate(java.lang.String strId,
int type,
java.lang.String clazz,
antlr.collections.AST child)
|
protected Action |
actionTemplateForClass(java.lang.String strId,
int type,
java.lang.String clazz,
antlr.collections.AST child)
|
void |
addProduction(java.lang.String name,
int salience,
Condition condition,
Action action)
|
protected Condition |
addRemainingAttributes(java.lang.String id,
java.util.LinkedList<AttributeValuePair> attributesList,
Condition condition)
This method adds the new required conditions to allow the modify actions remove the correct WME |
void |
assertTriplet(Triplet triplet)
|
protected Condition |
conditionTemplate(java.lang.String id,
java.lang.String clazz,
antlr.collections.AST child)
|
protected Condition |
conditionTemplateForClass(java.lang.String id,
java.lang.String clazz,
antlr.collections.AST child)
|
void |
defineAnonymousFact(java.lang.String id,
java.lang.String clazz,
antlr.collections.AST template)
|
void |
defineClassFact(java.lang.String id,
java.lang.String clazz,
antlr.collections.AST template)
|
void |
defineFact(antlr.collections.AST template)
|
Condition |
defineRule(java.lang.String name,
int salience,
antlr.collections.AST conditionList,
antlr.collections.AST actionList)
|
void |
endDocument()
|
void |
error(java.lang.Exception e,
java.lang.String message)
|
protected Action |
getAction(int id,
antlr.collections.AST action,
java.util.HashMap<java.lang.String,Entity> symbolTable)
|
protected Action |
getActionList(antlr.collections.AST actionList,
java.util.HashMap<java.lang.String,Entity> symbolTable)
|
protected Action |
getActionTemplate(int id,
int type,
antlr.collections.AST actionTemplate)
|
protected Condition |
getAssignmentCondition(java.lang.String id,
antlr.collections.AST condition,
antlr.collections.AST action,
java.util.HashMap<java.lang.String,Entity> symbolTable)
generates the conditions for an assignment on the left hand side example: (defrule wholesalerPricing ?x <- (SKU (wholesalerOnly true) (sellPrice ?price)) => (modify ?x (sellPrice 0) (listPrice (* ?price 0.75) (discountPrice (* 0.5 ?price)))) needs to be: (defrule wholesalerPricing (?id clazz SKU) // getConditionTemplate returns from here (?id wholesalerOnly true) (?id sellPrice ?price) // to here (?id listPrice ?id_var_1) (?id discountPrice ?id_var_2) => (retract (?id listPrice ?id_var_1)) (retract (?id discountPrice ?id_var_2)) (retract (?id sellPrice ?price)) (assert (?id sellPrice 0)) (assert (?id listPrice (* ?price 0.75))) (assert (?id discountPrice (* ?price 0.5)))) for achieving that, we first iterate over the actions to select the attributes that will be modified on the selected object. |
protected java.util.LinkedList<AttributeValuePair> |
getAttributesThatModifyActionsUseFromVariable(java.lang.String id,
java.lang.String variable,
antlr.collections.AST action)
this method returns the |
protected Condition |
getCondition(IdGenerator idGenerator,
antlr.collections.AST condition,
antlr.collections.AST action,
java.util.HashMap<java.lang.String,Entity> symbolTable)
|
protected Condition |
getConditionList(antlr.collections.AST conditionList,
antlr.collections.AST actionList,
java.util.HashMap<java.lang.String,Entity> symbolTable)
|
protected Condition |
getConditionList(IdGenerator idGenerator,
antlr.collections.AST conditionList,
antlr.collections.AST actionList,
java.util.HashMap<java.lang.String,Entity> symbolTable)
|
protected Condition |
getConditionTemplate(java.lang.String id,
antlr.collections.AST conditionTemplate)
|
protected Action |
getExpressionAction(int id,
antlr.collections.AST action,
java.util.HashMap<java.lang.String,Entity> symbolTable)
|
protected Action |
getModifyAction(antlr.collections.AST action,
java.util.HashMap<java.lang.String,Entity> symbolTable)
|
Rete |
getRete()
|
protected Action |
getRetractAction(Condition c)
|
Scope |
getScope()
|
Condition |
getTestCondition(antlr.collections.AST condition)
|
java.lang.String[] |
getVariables(antlr.collections.AST ast)
|
WME |
jumpUntilNewId(WME wme)
|
void |
link()
Used only in UI tools. |
void |
listFacts()
|
void |
loadFile(antlr.collections.AST filename)
|
void |
noPrettyPrint()
|
void |
prettyPrint()
|
protected void |
replace(java.util.LinkedList<AttributeValuePair> attributesList,
java.lang.String attribute,
java.lang.String value)
|
protected void |
replaceAttributesThatAreInConditions(java.util.LinkedList<AttributeValuePair> attributesList,
Condition condition)
We check each condition to make sure that the conditions that were already in the rule are not define twice |
void |
retractAllFacts()
|
void |
retractTriplet(Triplet triplet)
|
void |
run()
|
protected void |
setConditionsAndSalienceTo(Action action,
Condition earlierCondition,
int salience)
|
void |
setConsole(java.io.PrintStream console)
|
void |
setScope(Scope scope)
|
void |
startDocument()
|
void |
unlink()
Used by the UI tools To unlink the creation of rules from the UI |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Rete rete
protected Scope scope
protected java.io.PrintStream console
protected java.io.PrintStream stderr
protected boolean prettyPrint
protected static final java.util.logging.Logger logger
| Constructor Detail |
|---|
public GenericEventHandler(Rete rete)
public GenericEventHandler(Rete rete,
java.io.PrintStream console)
| Method Detail |
|---|
public Rete getRete()
public void setScope(Scope scope)
public Scope getScope()
public void setConsole(java.io.PrintStream console)
public void run()
run in interface ParserEventHandlerpublic void retractAllFacts()
retractAllFacts in interface ParserEventHandlerpublic void prettyPrint()
prettyPrint in interface ParserEventHandlerpublic void noPrettyPrint()
noPrettyPrint in interface ParserEventHandlerpublic void unlink()
unlink in interface ParserEventHandlerpublic void link()
ParserEventHandler
link in interface ParserEventHandlerpublic void listFacts()
listFacts in interface ParserEventHandlerpublic WME jumpUntilNewId(WME wme)
public void loadFile(antlr.collections.AST filename)
loadFile in interface ParserEventHandlerpublic void defineFact(antlr.collections.AST template)
defineFact in interface ParserEventHandler
public void defineAnonymousFact(java.lang.String id,
java.lang.String clazz,
antlr.collections.AST template)
public void defineClassFact(java.lang.String id,
java.lang.String clazz,
antlr.collections.AST template)
public Condition defineRule(java.lang.String name,
int salience,
antlr.collections.AST conditionList,
antlr.collections.AST actionList)
defineRule in interface ParserEventHandler
protected void setConditionsAndSalienceTo(Action action,
Condition earlierCondition,
int salience)
protected Condition getConditionList(antlr.collections.AST conditionList,
antlr.collections.AST actionList,
java.util.HashMap<java.lang.String,Entity> symbolTable)
protected Condition getConditionList(IdGenerator idGenerator,
antlr.collections.AST conditionList,
antlr.collections.AST actionList,
java.util.HashMap<java.lang.String,Entity> symbolTable)
protected Condition getCondition(IdGenerator idGenerator,
antlr.collections.AST condition,
antlr.collections.AST action,
java.util.HashMap<java.lang.String,Entity> symbolTable)
public Condition getTestCondition(antlr.collections.AST condition)
public java.lang.String[] getVariables(antlr.collections.AST ast)
protected Condition getAssignmentCondition(java.lang.String id,
antlr.collections.AST condition,
antlr.collections.AST action,
java.util.HashMap<java.lang.String,Entity> symbolTable)
protected Condition addRemainingAttributes(java.lang.String id,
java.util.LinkedList<AttributeValuePair> attributesList,
Condition condition)
protected void replaceAttributesThatAreInConditions(java.util.LinkedList<AttributeValuePair> attributesList,
Condition condition)
protected void replace(java.util.LinkedList<AttributeValuePair> attributesList,
java.lang.String attribute,
java.lang.String value)
protected java.util.LinkedList<AttributeValuePair> getAttributesThatModifyActionsUseFromVariable(java.lang.String id,
java.lang.String variable,
antlr.collections.AST action)
protected Condition getConditionTemplate(java.lang.String id,
antlr.collections.AST conditionTemplate)
protected Condition conditionTemplateForClass(java.lang.String id,
java.lang.String clazz,
antlr.collections.AST child)
protected Condition conditionTemplate(java.lang.String id,
java.lang.String clazz,
antlr.collections.AST child)
protected Action getActionList(antlr.collections.AST actionList,
java.util.HashMap<java.lang.String,Entity> symbolTable)
protected Action getAction(int id,
antlr.collections.AST action,
java.util.HashMap<java.lang.String,Entity> symbolTable)
protected Action getExpressionAction(int id,
antlr.collections.AST action,
java.util.HashMap<java.lang.String,Entity> symbolTable)
protected Action getModifyAction(antlr.collections.AST action,
java.util.HashMap<java.lang.String,Entity> symbolTable)
protected Action getRetractAction(Condition c)
protected Action getActionTemplate(int id,
int type,
antlr.collections.AST actionTemplate)
protected Action actionTemplateForClass(java.lang.String strId,
int type,
java.lang.String clazz,
antlr.collections.AST child)
protected Action actionTemplate(java.lang.String strId,
int type,
java.lang.String clazz,
antlr.collections.AST child)
public void startDocument()
public void endDocument()
public void assertTriplet(Triplet triplet)
public void retractTriplet(Triplet triplet)
public void addProduction(java.lang.String name,
int salience,
Condition condition,
Action action)
public void error(java.lang.Exception e,
java.lang.String message)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||