com.ibm.wbiserver.brules.mgmt.ruleset
Interface RuleBlock
All Superinterfaces:
BusinessRuleChangeDetector, BusinessRuleValidateable, java.lang.Iterable<RuleSetRule>, java.io.Serializable
- public interface RuleBlock
- extends BusinessRuleValidateable, BusinessRuleChangeDetector, java.io.Serializable, java.lang.Iterable<RuleSetRule>
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 |
---|---|
|
COPYRIGHT
|
Method Summary
Modifier and Type | Method and Description |
---|---|
|
addRule(int index,RuleSetTemplateInstanceRule newRule)
Insert the specified rule at the specified index in the list of rules in this rule block.
|
|
addRule(RuleSetTemplateInstanceRule newRule)
Add the specified rule to the end of the list of rules in this rule block.
|
getParentRuleSet()
Get the ruleset that contains this rule block.
|
|
getRule(int index)
Get the rule at the specified index in the list of rules for this rule block.
|
|
|
iterator()
Get an iterator over the list of rules in this rule block.
|
|
move(RuleSetRule ruleToMove,int newIndex)
Move the specified rule to the specified index in the list of rules for this rule
block.
|
|
moveDown(RuleSetRule ruleToMove)
Move the specified rule down in the list of rules for this rule block.
|
|
moveUp(RuleSetRule ruleToMove)
Move the specified rule up in the list of rules for this rule block.
|
|
numberOfRules()
Get the number of rules in this rule block.
|
|
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
COPYRIGHT
- static final java.lang.String COPYRIGHT
See Also:
Method Detail
iterator
- java.util.Iterator<RuleSetRule> 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
- 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
- void addRule(RuleSetTemplateInstanceRule newRule)
- 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:
- The template for the new rule is not part of the ruleset containing this rule block.
- 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
- void addRule(int index,
- RuleSetTemplateInstanceRule newRule)
- 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:
- The template for the new rule is not part of the ruleset containing this rule block.
- 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
- 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
- void moveUp(RuleSetRule ruleToMove)
- 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
- void moveDown(RuleSetRule ruleToMove)
- 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
- void move(RuleSetRule ruleToMove,
- int newIndex)
- 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
- int numberOfRules()
Get the number of rules in this rule block.
Returns:
The number of rules in this rule block.
getParentRuleSet
- RuleSet getParentRuleSet()
Get the ruleset that contains this rule block.
Returns:
The
RuleSet
that contains this RuleBlock
.
remove
method of theIterator
interface. If that method is called, anUnsupportedOperationException
is thrown.Other methods on the
RuleBlock
class are used to make structural modifications to the list of rules. These methods synchronize on thisRuleBlock
object. If the client code is multi-threaded, you should synchronize on theRuleBlock
object while using the iterator.