rule
Class Clause
java.lang.Object
|
+--rule.Clause
- Direct Known Subclasses:
- EffectorClause, SensorClause
- public class Clause
- extends java.lang.Object
The Clause
class implements the both the antecedent and
consequent parts of a rule.
Constructor Summary |
Clause()
Creates a clause. |
Clause(RuleVariable lhs,
Condition cond,
java.lang.String rhs)
Creates a clause with the given rule variable on the left-hand side, the
condition, and string value on the right-hand side. |
Method Summary |
void |
addRuleRef(Rule ref)
Registers the given rule with this clause. |
java.lang.Boolean |
check()
Performs a test of the clause. |
Rule |
getRule()
Retrieves the rule that owns this clause. |
void |
setConsequent()
Determines if the clause is a consequent clause. |
java.lang.String |
toString()
Retrieves the Clause in a format that can be displayed. |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
ruleRefs
java.util.Vector ruleRefs
lhs
RuleVariable lhs
rhs
java.lang.String rhs
cond
Condition cond
consequent
boolean consequent
truth
java.lang.Boolean truth
Clause
public Clause(RuleVariable lhs,
Condition cond,
java.lang.String rhs)
- Creates a clause with the given rule variable on the left-hand side, the
condition, and string value on the right-hand side.
- Parameters:
lhs
- the RuleVariable that makes up the left-hand side of this clausecond
- the Condition which tests equality, greater than, or less thanrhs
- the String that makes up the right-hand side of this clause
Clause
public Clause()
- Creates a clause.
toString
public java.lang.String toString()
- Retrieves the
Clause
in a format that can be displayed.
- Returns:
- the
String representation of this clause- Overrides:
- toString in class java.lang.Object
addRuleRef
public void addRuleRef(Rule ref)
- Registers the given rule with this clause.
- Parameters:
ref
- the Rule to be registered with this clause
check
public java.lang.Boolean check()
- Performs a test of the clause. This method handles String and numeric values.
It does not perform a lot of error checking!
- Returns:
- a Boolean
true
if the logical condition is true, false
if the logical condition is false, or null
if the
clause is a consequent clause or the left-hand side of the clause is
unbound.
setConsequent
public void setConsequent()
- Determines if the clause is a consequent clause.
getRule
public Rule getRule()
- Retrieves the rule that owns this clause.
- Returns:
- the owning rule if this clause is a consquent. Otherwise returns
null
.