com.ibm.websphere.brb.implementor
Class RuleRange

java.lang.Object
  extended bycom.ibm.websphere.brb.implementor.RuleRange
All Implemented Interfaces:
RuleImplementor

public class RuleRange
extends java.lang.Object
implements RuleImplementor

Constraint type rule algorithm that returns a true ConstraintReturn if a <= x <= b, where x arrives as a firing parameter and a and b are either provided as initialization parameters or as firing parameters.


Constructor Summary
RuleRange()
          Parameterless constructor for creating an instance of RuleRange.
 
Method Summary
 java.lang.Object fire(TriggerPoint tp, java.lang.Object target, IRuleCopy rule, java.lang.Object[] parms)
          This is where the algorithm implemented by this rule is performed.
 java.lang.String getDescription()
          The programmer's description of what the algorithm does.
 void init(java.lang.Object[] parms, java.lang.String[] dependentRules, java.lang.String userDefinedData, IRuleCopy rule)
          Initializes constants used by this rule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuleRange

public RuleRange()
Parameterless constructor for creating an instance of RuleRange.

Method Detail

fire

public java.lang.Object fire(TriggerPoint tp,
                             java.lang.Object target,
                             IRuleCopy rule,
                             java.lang.Object[] parms)
                      throws BusinessRuleBeansException
This is where the algorithm implemented by this rule is performed. Two alternative signatures are supported, depending on whether this rule was initialized with parameters on the init method or whether the parameters are all passed on the fire. The first signature takes only one firing parameter, the number to be evaluated. The other signature takes three firing parameters: the lower bound, number to be tested, and upper bound. A true ConstraintReturn is returned if the number to be tested is in the range; a false constraint return is returned otherwise.

If the lower and upper bounds are passed on this method and the lower bound is greater than the upper bound, an exception is thrown. Also, if the wrong number of parameters is passed or if any parameters are null, an exception is thrown.

Specified by:
fire in interface RuleImplementor
Parameters:
tp - the trigger point which is firing this rule implementor.
target - the target object of the trigger point
rule - the rule that the implementor is running on behalf of
Returns:
The result of firing the rule implementor. Implementors that carry out classifications must return a single String. Implementors which check constraints should generally return a ConstraintReturn, especially if the results are to be combined and returned by the BRBeans framework.
Throws:
BusinessRuleBeansException

getDescription

public java.lang.String getDescription()
The programmer's description of what the algorithm does.

Specified by:
getDescription in interface RuleImplementor
Returns:
A description of this rule implementor.

init

public void init(java.lang.Object[] parms,
                 java.lang.String[] dependentRules,
                 java.lang.String userDefinedData,
                 IRuleCopy rule)
          throws BusinessRuleBeansException
Initializes constants used by this rule. Two initialization parameter can be passed: the lower and upper bounds. If no initialization parameters are supplied, the lower and upper bounds can be passed as firing parameters.

If the lower and upper bounds are passed on this method and the lower bound is greater than the upper bound, an exception is thrown. Also, if the wrong number of parameters is passed or if any parameters are null, an exception is thrown.

Specified by:
init in interface RuleImplementor
Parameters:
parms - the parameters needed to initialize this RuleImplementor
dependentRules - the names of the dependent rules to this rule; if there are none, null is passed
userDefinedData - userDefinedData property from the Rule
rule - the Rule on whose behalf the rule implementor is running
Throws:
BusinessRuleBeansException