public class Rule extends Object implements Cloneable
| Constructor and Description |
|---|
Rule(int numNodes)
Creates a Rule with valid=false, successor="" and a list of decisions with one decision=Decision.Dontcare.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addDecision(int nodePos)
This method insert a new decision with value Decision.Dontcare on position nodePos
|
protected void |
addDecision(int nodePos,
Decision d)
This method insert a given decision on position nodePos
|
Rule |
clone()
This method returns a clone of this rule.
|
long |
getActualNumberOfRules()
Computes the number of "theoretical rules" in this rule.
If there are "don't care" decisions in this rule this number is greater than one. |
Decision |
getDecision(int nodePos)
This method returns the decision for a given node in this rule.
|
boolean |
getDisjunctCheckFailed()
Deprecated.
This method is replaced by isCheckFailed() for having a general checkFailed flag in this class as in class Node and will be removed in the future (2014 or later).
|
int |
getNumDecisions()
This method returns the number of decisions in this rule.
|
String |
getSuccessor()
This method returns the successor of this rule.
The successor usually is the file name of another decision table. |
boolean |
isCheckFailed()
This method tells a client that a check regarding to properties of this node failed.
|
boolean |
isDisjunct(Rule other)
Same as isDisjunct(Rule other, true).
|
boolean |
isDisjunct(Rule other,
boolean setCheckFailedFlag)
This method compares this rule with another rule for being disjunct.
Two rules are disjunct if one rule has a "Yes" decision at a position and the other one has "No" decision on this position. In the following examples "-" is written for a "don't care" - , "Y" for a "Yes" - and "Y" for a "No" - decision. Example 1 - Rule A and B are disjunct: rule A: Y N Y - Yrule B: Y N - N N---------------------^The arrow ---^ points to the position which makes the rules disjunct. Example 2 - Rule C and D are not disjunct: rule C: Y N Y -rule D: Y N - N |
boolean |
isValid()
This method returns a flag which tells if this rule is valid or not.
|
protected Decision |
removeDecision(int nodePos)
This method removes a decision from a node.
Please note that you need to call this method for all rules to make sure that each rule has same number of decisions! This is necessary since each node has one decision in each rule. |
Integer |
searchLastYes()
This method searches for the last Decision.Yes in this rule.
|
protected void |
setCheckFailed(boolean result)
This method tells a client that a check regarding to properties of this rule failed.
|
void |
setDecision(int nodePos,
Decision decision)
This method inserts a decision in a rule.
|
Integer |
setLastYesToNo()
This method searches for the last Decision.Yes in this rule.
|
void |
setSuccessor(String successor)
This method sets the successor of a rule.
The successor usually is the file name of another decision table. |
void |
setValid(boolean valid)
This method sets a rule to be valid or invalid.
|
public Rule(int numNodes)
throws IllegalArgumentException
numNodes - Number of nodes which the decision table has. Any rule needs to have so many decisions as nodes in the decision table. So a decision table is always a rectangular table.IllegalArgumentException - if number of nodes <= 0.https://www.securecoding.cert.org/confluence/display/java/OBJ11-J.+Be+wary+of+letting+constructors+throw+exceptionspublic Rule clone()
protected void addDecision(int nodePos)
nodePos - the position to insert the decisionprotected void addDecision(int nodePos,
Decision d)
nodePos - the position to insert the decisiond - the decision to insertprotected Decision removeDecision(int nodePos)
nodePos - the position to remove the decision frompublic Decision getDecision(int nodePos)
nodePos - the position of the node in this rulepublic void setDecision(int nodePos,
Decision decision)
nodePos - the position to insert the decisiondecision - a decisionpublic int getNumDecisions()
public String getSuccessor()
public void setSuccessor(String successor)
successor - the successor of this rulepublic boolean isValid()
public void setValid(boolean valid)
valid - set a rule to be valid if true; set a rule to be invalid if falsepublic boolean isCheckFailed()
public boolean getDisjunctCheckFailed()
protected void setCheckFailed(boolean result)
result - true if the check failed; false if the check passedpublic long getActualNumberOfRules()
public boolean isDisjunct(Rule other, boolean setCheckFailedFlag)
rule A: Y N Y - Yrule B: Y N - N N---------------------^rule C: Y N Y -rule D: Y N - Nother - the rule to compare with this rule; in our example this would be rule B resp. D.setCheckFailedFlag - If true it will mark each rule for which the check failed by setting the flag checkFailed to true.public boolean isDisjunct(Rule other)
public Integer searchLastYes()
public Integer setLastYesToNo()
Copyright © 2013. All Rights Reserved.