com.ibm.websphere.brb.implementor
Class ImplementorHelper

java.lang.Object
  extended bycom.ibm.websphere.brb.implementor.ImplementorHelper

public abstract class ImplementorHelper
extends java.lang.Object

A helper class for RuleImplementor implementations.


Field Summary
static int EQUALS
           
static int GREATER_THAN
           
static int GREATER_THAN_EQUALS
           
static int LESS_THAN
           
static int LESS_THAN_EQUALS
           
static int RANGE_INCLUSIVE
           
static int RANGE_NONINCLUSIVE
           
 
Constructor Summary
ImplementorHelper()
           
 
Method Summary
static void assertParamLength(java.lang.Object[] params, int correctParamLength, java.lang.String name)
          Ensure that the parameter list which is passed has the given number of parameters, and that each parameter is non-null.
static void assertParamLengthAllowNulls(java.lang.Object[] params, int correctParamLength, java.lang.String name)
          Ensure that the parameter list which is passed has the given number of parameters.
static ConstraintReturn compare(java.lang.Object val1, java.lang.Object val2, java.lang.Object val3, int operator, java.lang.String name)
          Compare the values using the given operator and return the result.
static java.lang.String getMessage(java.lang.String resourceKey, java.lang.Object[] formatArgs)
          Retrieve a translated message from the Business Rule Beans default resource bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQUALS

public static final int EQUALS
See Also:
Constant Field Values

LESS_THAN

public static final int LESS_THAN
See Also:
Constant Field Values

LESS_THAN_EQUALS

public static final int LESS_THAN_EQUALS
See Also:
Constant Field Values

GREATER_THAN

public static final int GREATER_THAN
See Also:
Constant Field Values

GREATER_THAN_EQUALS

public static final int GREATER_THAN_EQUALS
See Also:
Constant Field Values

RANGE_INCLUSIVE

public static final int RANGE_INCLUSIVE
See Also:
Constant Field Values

RANGE_NONINCLUSIVE

public static final int RANGE_NONINCLUSIVE
See Also:
Constant Field Values
Constructor Detail

ImplementorHelper

public ImplementorHelper()
Method Detail

assertParamLength

public static void assertParamLength(java.lang.Object[] params,
                                     int correctParamLength,
                                     java.lang.String name)
                              throws BRBeansIllegalArgumentException
Ensure that the parameter list which is passed has the given number of parameters, and that each parameter is non-null. If the wrong number of parameters is given, or any of the parameters are null, an exception is thrown which contains, as a replacement value, the given method name. An exception is also thrown if params is null.

Parameters:
params - the parameter list to check
correctParamLength - the proper length of the parameter list
name - the class and method name of the calling method to fill in as replacement text.
Throws:
BRBeansIllegalArgumentException - if the parameter list is the wrong length, or any of the parameters are null

assertParamLengthAllowNulls

public static void assertParamLengthAllowNulls(java.lang.Object[] params,
                                               int correctParamLength,
                                               java.lang.String name)
                                        throws BRBeansIllegalArgumentException
Ensure that the parameter list which is passed has the given number of parameters. Individual parameters are allowed to be null. If the wrong number of parameters is given, an exception is thrown which contains, as a replacement value, the given method name. An exception is also thrown if params is null.

Parameters:
params - the parameter list to check
correctParamLength - the proper length of the parameter list
name - the class and method name of the calling method to fill in as replacement text.
Throws:
BRBeansIllegalArgumentException - if the parameter list is the wrong length

compare

public static ConstraintReturn compare(java.lang.Object val1,
                                       java.lang.Object val2,
                                       java.lang.Object val3,
                                       int operator,
                                       java.lang.String name)
                                throws BRBeansIllegalArgumentException
Compare the values using the given operator and return the result. All numeric types are converted to Double before performing the comparison. If a String can be converted to a number (using Double.valueOf()), it will be treated as a Double for comparison. If a String cannot be converted to a number, it will be compared as a String. If all values passed are Strings and all can be converted to numbers, then they will be compared as numbers. If any cannot be converted to numbers, then they will be compared as Strings. If the types passed are not compatible for comparison, an exception is thrown. For example, a Double cannot be compared with a Date. The allowed types are java.lang.String, java.lang.Float, java.lang.Integer, java.lang.Long, java.lang.Double, and java.util.Date.

If the operator specified is RANGE_INCLUSIVE or RANGE_NONINCLUSIVE, then all three values must be specified (none can be null). In this case val1 is the lower bound of the range, val2 is the value to be checked, and val3 is the upper bound. If any of the three values is null, an exception is thrown. For other operators only val1 and val2 are used. val3 is ignored. val1 is the left-hand operand and val2 is the right-hand operand.

Parameters:
val1 - the left-hand operand
val2 - the right-hand operand, or middle operand if val3 is non-null
val3 - the right-hand operand for a three-operand operator, or null
operator - the operator to use
name - the rule implementor calling this method
Returns:
the results of the comparison
Throws:
BRBeansIllegalArgumentException

getMessage

public static java.lang.String getMessage(java.lang.String resourceKey,
                                          java.lang.Object[] formatArgs)
Retrieve a translated message from the Business Rule Beans default resource bundle.

Parameters:
resourceKey - The key in the resource bundle that will be used to select the specific message that is retrieved for getMessage().