com.ibm.wbiserver.brules.mgmt.ruleset

Interface RuleBlock

All Superinterfaces:
BusinessRuleChangeDetector, BusinessRuleValidateable, java.lang.Iterable<RuleSetRule>, java.io.Serializable

  1. public interface RuleBlock
  2. extends BusinessRuleValidateable, BusinessRuleChangeDetector, java.io.Serializable, java.lang.Iterable<RuleSetRule>
This interface represents a rule block within a ruleset. A rule block contains a list of rules that are executed at runtime to perform the function of the rule block. The order of the rules in the list determines the order in which they are executed. Each rule is either a hard-coded rule or is a rule that was created based on a rule template. Hard-coded rules cannot be changed, added, or removed by this API. They can, however, be reordered using either the moveUp, moveDown, or move methods. Rules created from a rule template (template instance rules) can be reordered, just like hard-coded rules. They can also be created, added to the rule block, and removed from the rule block. The removeRule method can be used to remove a given template instance rule from the rule block. To add a new template instance rule, first create a rule based on the template using the createRuleFromTemplate method on the RuleTemplate class and then add it to the rule block using one of the addRule methods.

Field Summary

Modifier and Type Field and Description
  1. static
  2. java.lang.String
COPYRIGHT

Method Summary

Modifier and Type Method and Description
  1. void
addRule(int index,RuleSetTemplateInstanceRule newRule)
Insert the specified rule at the specified index in the list of rules in this rule block.
  1. void
addRule(RuleSetTemplateInstanceRule newRule)
Add the specified rule to the end of the list of rules in this rule block.
  1. RuleSet
getParentRuleSet()
Get the ruleset that contains this rule block.
  1. RuleSetRule
getRule(int index)
Get the rule at the specified index in the list of rules for this rule block.
  1. java.util.Iterator<RuleSetRule>
iterator()
Get an iterator over the list of rules in this rule block.
  1. void
move(RuleSetRule ruleToMove,int newIndex)
Move the specified rule to the specified index in the list of rules for this rule block.
  1. void
moveDown(RuleSetRule ruleToMove)
Move the specified rule down in the list of rules for this rule block.
  1. void
moveUp(RuleSetRule ruleToMove)
Move the specified rule up in the list of rules for this rule block.
  1. int
numberOfRules()
Get the number of rules in this rule block.
  1. boolean
removeRule(RuleSetTemplateInstanceRule rule)
Remove the specified rule from the list of rules in this rule block.
Methods inherited from interface com.ibm.wbiserver.brules.mgmt.BusinessRuleValidateable
validate
Methods inherited from interface com.ibm.wbiserver.brules.mgmt.BusinessRuleChangeDetector
hasChanges

Field Detail

  1. static final java.lang.String COPYRIGHT
See Also:

Method Detail

iterator

  1. java.util.Iterator<RuleSetRule> iterator( )
Get an iterator over the list of rules in this rule block. The iterator returned does not support making changes to the underlying list, i.e. it does not support the remove method of the Iterator interface. If that method is called, an UnsupportedOperationException is thrown.

Other methods on the RuleBlock class are used to make structural modifications to the list of rules. These methods synchronize on this RuleBlock object. If the client code is multi-threaded, you should synchronize on the RuleBlock object while using the iterator.

Specified by:
iterator in interface java.lang.Iterable<RuleSetRule>
Returns:
An iterator over the underlying list of rules that does not support modifications.

getRule

  1. RuleSetRule getRule(int index)
Get the rule at the specified index in the list of rules for this rule block.
Parameters:
index - The index of the rule to retrieve.
Returns:
The rule at the specified index.

addRule

  1. void addRule(RuleSetTemplateInstanceRule newRule)
  2. throws ValidationException
Add the specified rule to the end of the list of rules in this rule block. The associated template for the new rule is checked to ensure that it is part of the ruleset containing this rule block. If it is not, then a ValidationException is thrown. The name of the new rule must also not already be in used for another rule in this rule block.
Parameters:
newRule - The rule to be added to this rule block. If null, then an IllegalArgumentException is thrown.
Throws:
ValidationException - if any of the following are true:
  1. The template for the new rule is not part of the ruleset containing this rule block.
  2. The name of the new rule is already in use for another rule in this rule block.
java.lang.IllegalArgumentException - if newRule is null.
ChangesNotAllowedException - if changes to this object are temporarily disallowed while other changes are being published.

addRule

  1. void addRule(int index,
  2. RuleSetTemplateInstanceRule newRule)
  3. throws ValidationException
Insert the specified rule at the specified index in the list of rules in this rule block. The rule currently at the specified index and any subsequent rules are moved down in the list (one is added to their indexes). The associated template for the new rule is checked to ensure that it is part of the ruleset containing this rule block. If it is not, then a ValidationException is thrown. The name of the new rule must also not already be in used for another rule in this rule block.
Parameters:
index - The index at which the new rule is to be inserted. The index is zero-based so the first rule in the rule block has index 0.
newRule - The rule to be added to this rule block. If null, then a IllegalArgumentException is thrown.
Throws:
ValidationException - if any of the following are true:
  1. The template for the new rule is not part of the ruleset containing this rule block.
  2. The name of the new rule is already in use for another rule in this rule block.
java.lang.IndexOutOfBoundsException - if the index is out of range (index <0 ||index> numberOfRules()).
java.lang.IllegalArgumentException - if newRule is null.
ChangesNotAllowedException - if changes to this object are temporarily disallowed while other changes are being published.

removeRule

  1. boolean removeRule(RuleSetTemplateInstanceRule rule)
Remove the specified rule from the list of rules in this rule block. Only rules that were originally created from a rule template can be removed. If the specified rule is not in this rule block, then the rule block is unchanged.
Parameters:
rule - The rule to be removed. Must be of type TemplateInstanceRule since only rules that were originally created from a rule template can be removed. If null, then an IllegalArgumentException is thrown.
Returns:
true if the RuleBlock contained the specified template instance rule. Otherwise false.
Throws:
java.lang.IllegalArgumentException - if rule is null.
ChangesNotAllowedException - if changes to this object are temporarily disallowed while other changes are being published.

moveUp

  1. void moveUp(RuleSetRule ruleToMove)
  2. throws java.lang.IllegalArgumentException
Move the specified rule up in the list of rules for this rule block. One is subtracted from the index for this rule in the list. If the rule is already at the top of the list (its index is 0), then no change is made and no exception is thrown. The rule that was at the new index is moved down one in the list (one is added to its index).
Parameters:
ruleToMove - The rule to be moved.
Throws:
java.lang.IllegalArgumentException - if the specified rule is null or is not in the list of rules for this rule block.
ChangesNotAllowedException - if changes to this object are temporarily disallowed while other changes are being published.

moveDown

  1. void moveDown(RuleSetRule ruleToMove)
  2. throws java.lang.IllegalArgumentException
Move the specified rule down in the list of rules for this rule block. One is added to the index for this rule in the list. If the rule is already at the bottom of the list (its index is one less than the length of the list), then no change is made and no exception is thrown. The rule that was at the new index is moved up one in the list (one is subtracted from its index).
Parameters:
ruleToMove - The rule to be moved.
Throws:
java.lang.IllegalArgumentException - if the specified rule is null or is not in the list of rules for this rule block.
ChangesNotAllowedException - if changes to this object are temporarily disallowed while other changes are being published.

move

  1. void move(RuleSetRule ruleToMove,
  2. int newIndex)
  3. throws java.lang.IllegalArgumentException
Move the specified rule to the specified index in the list of rules for this rule block. The rule currently at the specified index and all subsequent rules will move down one (one will be added to their indexes). The rule after the specified rule and all subsequent rules will move up (one will be subtracted from their indexes) to fill in the gap.
Parameters:
ruleToMove - The rule to be moved.
newIndex - The new index for the rule. The index is zero-based so the first rule in the rule block has index 0.
Throws:
java.lang.IllegalArgumentException - if the specified rule is null or is not in the list of rules for this rule block
java.lang.IndexOutOfBoundsException - if newIndex is out of range (newIndex <0 ||newindex>= numberOfRules())
ChangesNotAllowedException - if changes to this object are temporarily disallowed while other changes are being published.

numberOfRules

  1. int numberOfRules()
Get the number of rules in this rule block.
Returns:
The number of rules in this rule block.

getParentRuleSet

  1. RuleSet getParentRuleSet()
Get the ruleset that contains this rule block.
Returns:
The RuleSet that contains this RuleBlock.