com.ibm.commerce.condition
Class ConditionUtil

java.lang.Object
  |
  +--com.ibm.commerce.condition.ConditionUtil
All Implemented Interfaces:
ConditionConstants

public class ConditionUtil
extends java.lang.Object
implements ConditionConstants

This class provides utility methods that may be used by Evaluator implementors.


Field Summary
static java.lang.String COPYRIGHT
          Copyright.
 
Fields inherited from interface com.ibm.commerce.condition. ConditionConstants
AND_LIST_CONDITION, OPEN_CONDITION, OPERATOR_CONTAINS, OPERATOR_DOES_NOT_CONTAIN, OPERATOR_DOES_NOT_END_WITH, OPERATOR_DOES_NOT_START_WITH, OPERATOR_ENDS_WITH, OPERATOR_EQUAL_TO, OPERATOR_GREATER_THAN, OPERATOR_GREATER_THAN_OR_EQUAL_TO, OPERATOR_LESS_THAN, OPERATOR_LESS_THAN_OR_EQUAL_TO, OPERATOR_NOT_EQUAL_TO, OPERATOR_STARTS_WITH, OR_LIST_CONDITION, SIMPLE_CONDITION, TRUE_CONDITION, XML_DTD_FRAGMENT, XML_INDENT
 
Constructor Summary
ConditionUtil()
           
 
Method Summary
static boolean evaluate2Strings(java.lang.String value1, java.lang.String value2, java.lang.String operator, java.lang.String value3)
          This method will compare two string values to a third using the specified operator.
static boolean evaluateBigDecimal(java.math.BigDecimal value1, java.lang.String operator, java.math.BigDecimal value2)
          This method will compare two big decimal values using the specified operator.
static boolean evaluateDate(java.lang.String value1, java.lang.String operator, java.lang.String value2)
          This method will compare two date values using the specified operator.
static boolean evaluateDurationInDays(java.sql.Timestamp timestamp, java.lang.String operator, java.lang.Integer value)
          This method will compare a timestamp to an integer value using the specified operator.
static boolean evaluateInteger(java.lang.Integer value1, java.lang.String operator, java.lang.Integer value2)
          This method will compare two integer values using the specified operator.
static boolean evaluateString(java.lang.String value1, java.lang.String operator, java.lang.String value2)
          This method will compare two string values using the specified operator.
static boolean evaluateStringIgnoreCase(java.lang.String value1, java.lang.String operator, java.lang.String value2)
          This method will compare two string values using the specified operator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail
public static final java.lang.String COPYRIGHT
Copyright.
See Also:
Constant Field Values
Constructor Detail

ConditionUtil

public ConditionUtil()
Method Detail

evaluateString

public static boolean evaluateString(java.lang.String value1,
                                     java.lang.String operator,
                                     java.lang.String value2)
This method will compare two string values using the specified operator.
Parameters:
value1 - a string value
operator - the operator used to compare the string values. The following values are supported: OPERATOR_EQUAL_TO OPERATOR_NOT_EQUAL_TO OPERATOR_STARTS_WITH OPERATOR_DOES_NOT_START_WITH OPERATOR_ENDS_WITH OPERATOR_DOES_NOT_END_WITH OPERATOR_CONTAINS OPERATOR_DOES_NOT_CONTAIN
value2 - a string value
Returns:
true if the expression evaluates to true.

evaluateStringIgnoreCase

public static boolean evaluateStringIgnoreCase(java.lang.String value1,
                                               java.lang.String operator,
                                               java.lang.String value2)
This method will compare two string values using the specified operator. All operations will ignore the case of the text.
Parameters:
value1 - a string value
operator - the operator used to compare the string values. The following values are supported: OPERATOR_EQUAL_TO OPERATOR_NOT_EQUAL_TO OPERATOR_STARTS_WITH OPERATOR_DOES_NOT_START_WITH OPERATOR_ENDS_WITH OPERATOR_DOES_NOT_END_WITH OPERATOR_CONTAINS OPERATOR_DOES_NOT_CONTAIN
value2 - a string value
Returns:
true if the expression evaluates to true.

evaluate2Strings

public static boolean evaluate2Strings(java.lang.String value1,
                                       java.lang.String value2,
                                       java.lang.String operator,
                                       java.lang.String value3)
This method will compare two string values to a third using the specified operator. If either of the first two strings results in a true condition, then the result will be true.
Parameters:
value1 - a string value
value2 - a string value
operator - the operator used to compare the string values. The following values are supported: OPERATOR_EQUAL_TO OPERATOR_NOT_EQUAL_TO OPERATOR_STARTS_WITH OPERATOR_DOES_NOT_START_WITH OPERATOR_ENDS_WITH OPERATOR_DOES_NOT_END_WITH OPERATOR_CONTAINS OPERATOR_DOES_NOT_CONTAIN
value3 - a string value
Returns:
true if the expression evaluates to true.

evaluateInteger

public static boolean evaluateInteger(java.lang.Integer value1,
                                      java.lang.String operator,
                                      java.lang.Integer value2)
This method will compare two integer values using the specified operator.
Parameters:
value1 - an integer value
operator - the operator used to compare the integer values. The following values are supported: OPERATOR_EQUAL_TO OPERATOR_NOT_EQUAL_TO OPERATOR_LESS_THAN OPERATOR_GREATER_THAN OPERATOR_LESS_THAN_OR_EQUAL_TO OPERATOR_GREATER_THAN_OR_EQUAL_TO
Returns:
true if the expression evaluates to true.

evaluateBigDecimal

public static boolean evaluateBigDecimal(java.math.BigDecimal value1,
                                         java.lang.String operator,
                                         java.math.BigDecimal value2)
This method will compare two big decimal values using the specified operator.
Parameters:
value1 - a big decimal value
operator - the operator used to compare the big decimal values. The following values are supported: OPERATOR_EQUAL_TO OPERATOR_NOT_EQUAL_TO OPERATOR_LESS_THAN OPERATOR_GREATER_THAN OPERATOR_LESS_THAN_OR_EQUAL_TO OPERATOR_GREATER_THAN_OR_EQUAL_TO
value2 - a big decimal value
Returns:
true if the expression evaluates to true.

evaluateDurationInDays

public static boolean evaluateDurationInDays(java.sql.Timestamp timestamp,
                                             java.lang.String operator,
                                             java.lang.Integer value)
This method will compare a timestamp to an integer value using the specified operator. The integer value represents the number of days from the current time.
Parameters:
timestamp - a timestamp
operator - the operator used to compare the string values. The following values are supported: OPERATOR_EQUAL_TO OPERATOR_NOT_EQUAL_TO OPERATOR_LESS_THAN OPERATOR_GREATER_THAN OPERATOR_LESS_THAN_OR_EQUAL_TO OPERATOR_GREATER_THAN_OR_EQUAL_TO
value - days since the current time
Returns:
true if the expression evaluates to true.

evaluateDate

public static boolean evaluateDate(java.lang.String value1,
                                   java.lang.String operator,
                                   java.lang.String value2)
This method will compare two date values using the specified operator.
Parameters:
value1 - a date value in the form yyyy-mm-dd
operator - the operator used to compare the date values. The following values are supported: OPERATOR_EQUAL_TO OPERATOR_NOT_EQUAL_TO OPERATOR_LESS_THAN OPERATOR_GREATER_THAN OPERATOR_LESS_THAN_OR_EQUAL_TO OPERATOR_GREATER_THAN_OR_EQUAL_TO
value2 - a date value in the form yyyy-mm-dd
Returns:
true if the expression evaluates to true.