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 Detail

    • 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.
      • evaluate2StringsIgnoreCase

        public static boolean evaluate2StringsIgnoreCase(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. All operations will ignore the case of the text.
        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
        value3 - an integer value
        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,
                                                     java.sql.Timestamp compareTime)

        This method will compare a timestamp to an integer value using the specified operator. The integer value represents the number of days from the specified time.

        This method can be used to answer whether or not a given timestamp is the same as, occurs before or occurs after a base, comparison timestamp.

        Parameters:
        timestamp - A timestamp
        operator - The operator used to compare the timestamps. 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 - Number of days since the compareTime.
        compareTime - The base timestamp used with value for comparison to timestamp.
        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 system time.

        This method can be used to answer whether or not a given timestamp is the same as, occurs before or occurs after the current system time.

        Parameters:
        timestamp - A timestamp
        operator - The operator used to compare the timestamps. 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 - Number of days since the current system 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.
      • removeSimpleConditionFromList

        public static Condition removeSimpleConditionFromList(Condition condition,
                                                              java.lang.String conditionVariable)
        This method takes a condition object and a variable name, and removes all simple condition objects with the given variable name within the given condition object.
        Parameters:
        condition - Original condition object.
        conditionVariable - Variable name of the simple condition to be removed.
        Returns:
        Updated condition object.
      • getCurrentTime

        public static java.sql.Timestamp getCurrentTime(ActivityToken token)
        This method returns the current time. If this command is being executed through a store preview environment, the current time will be the time returned from the preview context. Otherwise, the current time returned will be the current system time.
        Parameters:
        token - The activity token associated with the request. If null, the current time will be returned.
        Returns:
        The current time