Example usage for java.sql Timestamp compareTo

List of usage examples for java.sql Timestamp compareTo

Introduction

In this page you can find the example usage for java.sql Timestamp compareTo.

Prototype

public int compareTo(java.util.Date o) 

Source Link

Document

Compares this Timestamp object to the given Date object.

Usage

From source file:gov.nih.nci.cadsr.sentinel.tool.AlertRec.java

/**
 * Return true if the alert is "Active", otherwise false.
 * //  w ww .  ja v a2 s. com
 * @param target_ The time stamp to compare to the Active setting
 *      in the Alert Definition.
 * @return True if active.
 */
public boolean isActive(Timestamp target_) {
    if (_active == 'A' || _active == 'F')
        return true;
    else if (_active == 'D') {
        if (_start == null || _start.compareTo(target_) <= 0) {
            if (_end == null || target_.compareTo(_end) < 0)
                return true;
        }
    }
    return false;
}

From source file:org.apache.hive.storage.jdbc.spitter.TimestampIntervalSplitter.java

@Override
public List<MutablePair<String, String>> getIntervals(String lowerBound, String upperBound, int numPartitions,
        TypeInfo typeInfo) {//from   w w w . j  av a2  s. com
    List<MutablePair<String, String>> intervals = new ArrayList<>();
    Timestamp timestampLower = Timestamp.valueOf(lowerBound);
    Timestamp timestampUpper = Timestamp.valueOf(upperBound);
    // Note nano is not fully represented as the precision limit
    double timestampInterval = (timestampUpper.getTime() - timestampLower.getTime()) / (double) numPartitions;
    Timestamp splitTimestampLower, splitTimestampUpper;
    for (int i = 0; i < numPartitions; i++) {
        splitTimestampLower = new Timestamp(Math.round(timestampLower.getTime() + timestampInterval * i));
        splitTimestampUpper = new Timestamp(Math.round(timestampLower.getTime() + timestampInterval * (i + 1)));
        if (splitTimestampLower.compareTo(splitTimestampUpper) < 0) {
            intervals.add(new MutablePair<String, String>(splitTimestampLower.toString(),
                    splitTimestampUpper.toString()));
        }
    }
    return intervals;
}

From source file:org.kuali.kfs.module.purap.document.service.impl.PurapServiceImpl.java

/**
 * @see org.kuali.kfs.module.purap.document.service.PurapService#isDateMoreThanANumberOfDaysAway(java.sql.Date, int)
 *//* w  ww.  j  a  v a2  s .  com*/
@Override
public boolean isDateMoreThanANumberOfDaysAway(Date compareDate, int daysAway) {
    LOG.debug("isDateMoreThanANumberOfDaysAway() started");

    Date todayAtMidnight = dateTimeService.getCurrentSqlDateMidnight();
    Calendar daysAwayCalendar = dateTimeService.getCalendar(todayAtMidnight);
    daysAwayCalendar.add(Calendar.DATE, daysAway);
    Timestamp daysAwayTime = new Timestamp(daysAwayCalendar.getTime().getTime());
    Calendar compareCalendar = dateTimeService.getCalendar(compareDate);
    compareCalendar.set(Calendar.HOUR, 0);
    compareCalendar.set(Calendar.MINUTE, 0);
    compareCalendar.set(Calendar.SECOND, 0);
    compareCalendar.set(Calendar.MILLISECOND, 0);
    compareCalendar.set(Calendar.AM_PM, Calendar.AM);
    Timestamp compareTime = new Timestamp(compareCalendar.getTime().getTime());
    return (compareTime.compareTo(daysAwayTime) > 0);
}

From source file:org.kuali.kfs.pdp.businessobject.PaymentDetail.java

/**
 * Determines if the disbursement date is past the number of days old (configured in system parameter) in which actions can take
 * place// w ww. j ava 2 s. c o  m
 * 
 * @return true if actions are allowed on disbursement, false otherwise
 */
public boolean isDisbursementActionAllowed() {
    if (paymentGroup.getDisbursementDate() == null) {
        if (PdpConstants.PaymentStatusCodes.EXTRACTED.equals(paymentGroup.getPaymentStatus().getCode())) {
            return false;
        }
        return true;
    }

    String daysStr = SpringContext.getBean(ParameterService.class).getParameterValueAsString(
            PaymentDetail.class, PdpParameterConstants.DISBURSEMENT_CANCELLATION_DAYS);
    int days = Integer.valueOf(daysStr);

    Calendar c = Calendar.getInstance();
    c.add(Calendar.DATE, (days * -1));
    c.set(Calendar.HOUR, 12);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    c.set(Calendar.AM_PM, Calendar.AM);
    Timestamp lastDisbursementActionDate = new Timestamp(c.getTimeInMillis());

    Calendar c2 = Calendar.getInstance();
    c2.setTime(paymentGroup.getDisbursementDate());
    c2.set(Calendar.HOUR, 11);
    c2.set(Calendar.MINUTE, 59);
    c2.set(Calendar.SECOND, 59);
    c2.set(Calendar.MILLISECOND, 59);
    c2.set(Calendar.AM_PM, Calendar.PM);
    Timestamp disbursementDate = new Timestamp(c2.getTimeInMillis());

    // date is equal to or after lastActionDate Allowed
    return ((disbursementDate.compareTo(lastDisbursementActionDate)) >= 0);
}

From source file:org.kuali.kra.protocol.noteattachment.ProtocolAttachmentProtocolBase.java

/**
 * Gets the versions attribute. /*from  w w  w  .j a  va  2s. c  o m*/
 * @return Returns the versions.
 */
public List<ProtocolAttachmentProtocolBase> getVersions() {
    if (this.versions == null) {
        this.versions = new ArrayList<ProtocolAttachmentProtocolBase>();
    }
    this.versions.clear();
    // TODO : since this will be called by tag, so should not call service  
    //this.versions.addAll(KraServiceLocator.getService(ProtocolAttachmentService.class).getAttachmentsWithOlderFileVersions(this, ProtocolAttachmentProtocolBase.class));  
    // need this refresh here.  change and save will not update this list automatically.  not sure why ?  
    // this is still calling persistenceservice eventually  
    // probably do it in postsave  
    //this.getProtocol().refreshReferenceObject("attachmentProtocols");  
    for (ProtocolAttachmentProtocolBase attachment : this.getProtocol().getAttachmentProtocols()) {

        if (attachment.getDocumentId().equals(this.getDocumentId())
                && StringUtils.equals(attachment.getVersioningId(), this.getVersioningId())) {
            this.versions.add(attachment);
        }
    }
    if (this.versions.size() == 1) {
        this.versions.clear();
    }
    Collections.sort(this.versions, new Comparator<ProtocolAttachmentProtocolBase>() {

        public int compare(ProtocolAttachmentProtocolBase attachment1,
                ProtocolAttachmentProtocolBase attachment2) {
            Timestamp timestamp1 = attachment1.getUpdateTimestamp();
            Timestamp timestamp2 = attachment2.getUpdateTimestamp();
            if (timestamp1 != null) {
                if (timestamp2 != null) {
                    return timestamp1.compareTo(timestamp2);
                } else {
                    return 1;
                }
            } else {
                if (timestamp2 != null) {
                    return -1;
                }
            }
            return 0;
        }
    });
    return this.versions;
}

From source file:org.kuali.ole.module.purap.document.service.impl.InvoiceServiceImpl.java

/**
 * @see org.kuali.ole.module.purap.document.service.InvoiceService#isInvoiceDateAfterToday(java.sql.Date)
 */// w w  w  .j  av  a  2s. com
@Override
public boolean isInvoiceDateAfterToday(Date invoiceDate) {
    // Check invoice date to make sure it is today or before
    Calendar now = Calendar.getInstance();
    now.set(Calendar.HOUR, 11);
    now.set(Calendar.MINUTE, 59);
    now.set(Calendar.SECOND, 59);
    now.set(Calendar.MILLISECOND, 59);
    Timestamp nowTime = new Timestamp(now.getTimeInMillis());
    Calendar invoiceDateC = Calendar.getInstance();
    invoiceDateC.setTime(invoiceDate);
    // set time to midnight
    invoiceDateC.set(Calendar.HOUR, 0);
    invoiceDateC.set(Calendar.MINUTE, 0);
    invoiceDateC.set(Calendar.SECOND, 0);
    invoiceDateC.set(Calendar.MILLISECOND, 0);
    Timestamp invoiceDateTime = new Timestamp(invoiceDateC.getTimeInMillis());
    return ((invoiceDateTime.compareTo(nowTime)) > 0);
}

From source file:org.kuali.rice.kew.docsearch.SearchableAttributeDateTimeValue.java

@Override
public Boolean isRangeValid(String lowerValue, String upperValue) {
    if (allowsRangeSearches()) {
        Timestamp lowerTime = convertStringToTimestamp(lowerValue);
        Timestamp upperTime = convertStringToTimestamp(upperValue);
        if ((lowerTime != null) && (upperTime != null)) {
            return (lowerTime.compareTo(upperTime) <= 0);
        }//w ww. j a  va2 s . c om
        return true;
    }
    return null;
}

From source file:org.kuali.rice.kns.service.impl.DictionaryValidationServiceImpl.java

/**
 * The attributeDataType parameter should be one of the data types specified by the SearchableAttribute
 * interface; will default to DATA_TYPE_STRING if a data type other than the ones from SearchableAttribute
 * is specified./*from  w  w  w  .  j  av a2s .co m*/
 *
 * @deprecated since 1.1
 */
@Override
@Deprecated
public void validateAttributeFormat(String objectClassName, String attributeName, String attributeInValue,
        String attributeDataType, String errorKey) {
    boolean checkDateBounds = false; // this is used so we can check date bounds
    Class<?> formatterClass = null;

    if (LOG.isDebugEnabled()) {
        LOG.debug("(bo, attributeName, attributeValue) = (" + objectClassName + "," + attributeName + ","
                + attributeInValue + ")");
    }

    /*
    *  This will return a list of searchable attributes. so if the value is
    *  12/07/09 .. 12/08/09 it will return [12/07/09,12/08/09]
    */

    final List<String> attributeValues = SQLUtils.getCleanedSearchableValues(attributeInValue,
            attributeDataType);

    if (attributeValues == null || attributeValues.isEmpty()) {
        return;
    }

    for (String attributeValue : attributeValues) {

        // FIXME: JLR : Replacing this logic with KS-style validation is trickier, since KS validation requires a DataProvider object that can
        // look back and find other attribute values aside from the one we're working on.
        // Also - the date stuff below is implemented very differently.
        //validator.validateAttributeField(businessObject, fieldName);

        if (StringUtils.isNotBlank(attributeValue)) {
            Integer minLength = getDataDictionaryService().getAttributeMinLength(objectClassName,
                    attributeName);
            if ((minLength != null) && (minLength.intValue() > attributeValue.length())) {
                String errorLabel = getDataDictionaryService().getAttributeErrorLabel(objectClassName,
                        attributeName);
                GlobalVariables.getMessageMap().putError(errorKey, RiceKeyConstants.ERROR_MIN_LENGTH,
                        new String[] { errorLabel, minLength.toString() });
                return;
            }
            Integer maxLength = getDataDictionaryService().getAttributeMaxLength(objectClassName,
                    attributeName);
            if ((maxLength != null) && (maxLength.intValue() < attributeValue.length())) {
                String errorLabel = getDataDictionaryService().getAttributeErrorLabel(objectClassName,
                        attributeName);
                GlobalVariables.getMessageMap().putError(errorKey, RiceKeyConstants.ERROR_MAX_LENGTH,
                        new String[] { errorLabel, maxLength.toString() });
                return;
            }
            Pattern validationExpression = getDataDictionaryService()
                    .getAttributeValidatingExpression(objectClassName, attributeName);
            if (validationExpression != null && !validationExpression.pattern().equals(".*")) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("(bo, attributeName, validationExpression) = (" + objectClassName + ","
                            + attributeName + "," + validationExpression + ")");
                }

                if (!validationExpression.matcher(attributeValue).matches()) {
                    // Retrieving formatter class
                    if (formatterClass == null) {
                        // this is just a cache check... all dates ranges get called twice
                        formatterClass = getDataDictionaryService().getAttributeFormatter(objectClassName,
                                attributeName);
                    }

                    if (formatterClass != null) {
                        boolean valuesAreValid = true;
                        boolean isError = true;
                        String errorKeyPrefix = "";
                        try {

                            // this is a special case for date ranges in order to set the proper error message
                            if (DateFormatter.class.isAssignableFrom(formatterClass)) {
                                String[] values = attributeInValue.split("\\.\\."); // is it a range
                                if (values.length == 2 && attributeValues.size() == 2) { // make sure it's not like a .. b | c
                                    checkDateBounds = true; // now we need to check that a <= b
                                    if (attributeValues.indexOf(attributeValue) == 0) { // only care about lower bound
                                        errorKeyPrefix = KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX;
                                    }
                                }
                            }

                            Method validatorMethod = formatterClass.getDeclaredMethod(VALIDATE_METHOD,
                                    new Class<?>[] { String.class });
                            Object o = validatorMethod.invoke(formatterClass.newInstance(), attributeValue);
                            if (o instanceof Boolean) {
                                isError = !((Boolean) o).booleanValue();
                            }
                            valuesAreValid &= !isError;
                        } catch (Exception e) {
                            if (LOG.isDebugEnabled()) {
                                LOG.debug(e.getMessage(), e);
                            }
                            isError = true;
                            valuesAreValid = false;
                        }
                        if (isError) {
                            checkDateBounds = false; // it's already invalid, no need to check date bounds
                            String errorMessageKey = getDataDictionaryService()
                                    .getAttributeValidatingErrorMessageKey(objectClassName, attributeName);
                            String[] errorMessageParameters = getDataDictionaryService()
                                    .getAttributeValidatingErrorMessageParameters(objectClassName,
                                            attributeName);
                            GlobalVariables.getMessageMap().putError(errorKeyPrefix + errorKey, errorMessageKey,
                                    errorMessageParameters);
                        }
                    } else {
                        // if it fails the default validation and has no formatter class then it's still a std failure.
                        String errorMessageKey = getDataDictionaryService()
                                .getAttributeValidatingErrorMessageKey(objectClassName, attributeName);
                        String[] errorMessageParameters = getDataDictionaryService()
                                .getAttributeValidatingErrorMessageParameters(objectClassName, attributeName);
                        GlobalVariables.getMessageMap().putError(errorKey, errorMessageKey,
                                errorMessageParameters);
                    }
                }
            }
            /*BigDecimal*/
            String exclusiveMin = getDataDictionaryService().getAttributeExclusiveMin(objectClassName,
                    attributeName);
            if (exclusiveMin != null) {
                try {
                    BigDecimal exclusiveMinBigDecimal = new BigDecimal(exclusiveMin);
                    if (exclusiveMinBigDecimal.compareTo(new BigDecimal(attributeValue)) >= 0) {
                        String errorLabel = getDataDictionaryService().getAttributeErrorLabel(objectClassName,
                                attributeName);
                        GlobalVariables.getMessageMap().putError(errorKey, RiceKeyConstants.ERROR_EXCLUSIVE_MIN,
                                // todo: Formatter for currency?
                                new String[] { errorLabel, exclusiveMin.toString() });
                        return;
                    }
                } catch (NumberFormatException e) {
                    // quash; this indicates that the DD contained a min for a non-numeric attribute
                }
            }
            /*BigDecimal*/
            String inclusiveMax = getDataDictionaryService().getAttributeInclusiveMax(objectClassName,
                    attributeName);
            if (inclusiveMax != null) {
                try {
                    BigDecimal inclusiveMaxBigDecimal = new BigDecimal(inclusiveMax);
                    if (inclusiveMaxBigDecimal.compareTo(new BigDecimal(attributeValue)) < 0) {
                        String errorLabel = getDataDictionaryService().getAttributeErrorLabel(objectClassName,
                                attributeName);
                        GlobalVariables.getMessageMap().putError(errorKey, RiceKeyConstants.ERROR_INCLUSIVE_MAX,
                                // todo: Formatter for currency?
                                new String[] { errorLabel, inclusiveMax.toString() });
                        return;
                    }
                } catch (NumberFormatException e) {
                    // quash; this indicates that the DD contained a max for a non-numeric attribute
                }
            }
        }
    }

    if (checkDateBounds) {
        // this means that we only have 2 values and it's a date range.
        java.sql.Timestamp lVal = null;
        java.sql.Timestamp uVal = null;
        try {
            lVal = CoreApiServiceLocator.getDateTimeService().convertToSqlTimestamp(attributeValues.get(0));
            uVal = CoreApiServiceLocator.getDateTimeService().convertToSqlTimestamp(attributeValues.get(1));
        } catch (Exception ex) {
            // this shouldn't happen because the tests passed above.
            String errorMessageKey = getDataDictionaryService()
                    .getAttributeValidatingErrorMessageKey(objectClassName, attributeName);
            String[] errorMessageParameters = getDataDictionaryService()
                    .getAttributeValidatingErrorMessageParameters(objectClassName, attributeName);
            GlobalVariables.getMessageMap().putError(
                    KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX + errorKey, errorMessageKey,
                    errorMessageParameters);
        }

        if (lVal != null && lVal.compareTo(uVal) > 0) { // check the bounds
            String errorMessageKey = getDataDictionaryService()
                    .getAttributeValidatingErrorMessageKey(objectClassName, attributeName);
            String[] errorMessageParameters = getDataDictionaryService()
                    .getAttributeValidatingErrorMessageParameters(objectClassName, attributeName);
            GlobalVariables.getMessageMap().putError(
                    KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX + errorKey,
                    errorMessageKey + ".range", errorMessageParameters);
        }
    }
}

From source file:org.kuali.rice.krad.datadictionary.validation.processor.ValidCharactersConstraintProcessor.java

protected ConstraintValidationResult validateDateOrder(String firstDateTime, String secondDateTime,
        String entryName, String attributeName) {
    // this means that we only have 2 values and it's a date range.
    java.sql.Timestamp lVal = null;
    java.sql.Timestamp uVal = null;
    try {/*from  w  ww.jav  a 2s  .co m*/
        lVal = CoreApiServiceLocator.getDateTimeService().convertToSqlTimestamp(firstDateTime);
        uVal = CoreApiServiceLocator.getDateTimeService().convertToSqlTimestamp(secondDateTime);
    } catch (Exception ex) {
        // this shouldn't happen because the tests passed above.
        String errorMessageKey = KRADServiceLocatorWeb.getDataDictionaryService()
                .getAttributeValidatingErrorMessageKey(entryName, attributeName);
        String[] errorMessageParameters = KRADServiceLocatorWeb.getDataDictionaryService()
                .getAttributeValidatingErrorMessageParameters(entryName, attributeName);
        ConstraintValidationResult constraintValidationResult = new ConstraintValidationResult(CONSTRAINT_NAME);
        constraintValidationResult.setEntryName(entryName);
        constraintValidationResult
                .setAttributeName(KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX + attributeName);
        constraintValidationResult.setError(errorMessageKey, errorMessageParameters);
        return constraintValidationResult;
    }

    if (lVal != null && lVal.compareTo(uVal) > 0) { // check the bounds
        String errorMessageKey = KRADServiceLocatorWeb.getDataDictionaryService()
                .getAttributeValidatingErrorMessageKey(entryName, attributeName);
        String[] errorMessageParameters = KRADServiceLocatorWeb.getDataDictionaryService()
                .getAttributeValidatingErrorMessageParameters(entryName, attributeName);
        ConstraintValidationResult constraintValidationResult = new ConstraintValidationResult(CONSTRAINT_NAME);
        constraintValidationResult.setEntryName(entryName);
        constraintValidationResult
                .setAttributeName(KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX + attributeName);
        constraintValidationResult.setError(errorMessageKey + ".range", errorMessageParameters);
        return constraintValidationResult;
    }

    return null;
}

From source file:org.ofbiz.base.util.ObjectType.java

public static Boolean doRealCompare(Object value1, Object value2, String operator, String type, String format,
        List<Object> messages, Locale locale, ClassLoader loader, boolean value2InlineConstant) {
    boolean verboseOn = Debug.verboseOn();

    if (verboseOn)
        Debug.logVerbose("Comparing value1: \"" + value1 + "\" " + operator + " value2:\"" + value2 + "\"",
                module);//www .  j  ava 2 s. c  o  m

    try {
        if (!"PlainString".equals(type)) {
            Class<?> clz = ObjectType.loadClass(type, loader);
            type = clz.getName();
        }
    } catch (ClassNotFoundException e) {
        Debug.logWarning("The specified type [" + type
                + "] is not a valid class or a known special type, may see more errors later because of this: "
                + e.getMessage(), module);
    }

    if (value1 == null) {
        // some default behavior for null values, results in a bit cleaner operation
        if ("is-null".equals(operator)) {
            return Boolean.TRUE;
        } else if ("is-not-null".equals(operator)) {
            return Boolean.FALSE;
        } else if ("is-empty".equals(operator)) {
            return Boolean.TRUE;
        } else if ("is-not-empty".equals(operator)) {
            return Boolean.FALSE;
        } else if ("contains".equals(operator)) {
            return Boolean.FALSE;
        }
    }

    int result = 0;

    Object convertedValue2 = null;
    if (value2 != null) {
        Locale value2Locale = locale;
        if (value2InlineConstant) {
            value2Locale = UtilMisc.parseLocale("en");
        }
        try {
            convertedValue2 = ObjectType.simpleTypeConvert(value2, type, format, value2Locale);
        } catch (GeneralException e) {
            Debug.logError(e, module);
            messages.add("Could not convert value2 for comparison: " + e.getMessage());
            return null;
        }
    }

    // have converted value 2, now before converting value 1 see if it is a Collection and we are doing a contains comparison
    if ("contains".equals(operator) && value1 instanceof Collection<?>) {
        Collection<?> col1 = (Collection<?>) value1;
        return col1.contains(convertedValue2) ? Boolean.TRUE : Boolean.FALSE;
    }

    Object convertedValue1 = null;
    try {
        convertedValue1 = ObjectType.simpleTypeConvert(value1, type, format, locale);
    } catch (GeneralException e) {
        Debug.logError(e, module);
        messages.add("Could not convert value1 for comparison: " + e.getMessage());
        return null;
    }

    // handle null values...
    if (convertedValue1 == null || convertedValue2 == null) {
        if ("equals".equals(operator)) {
            return convertedValue1 == null && convertedValue2 == null ? Boolean.TRUE : Boolean.FALSE;
        } else if ("not-equals".equals(operator)) {
            return convertedValue1 == null && convertedValue2 == null ? Boolean.FALSE : Boolean.TRUE;
        } else if ("is-not-empty".equals(operator) || "is-empty".equals(operator)) {
            // do nothing, handled later...
        } else {
            if (convertedValue1 == null) {
                messages.add("Left value is null, cannot complete compare for the operator " + operator);
                return null;
            }
            if (convertedValue2 == null) {
                messages.add("Right value is null, cannot complete compare for the operator " + operator);
                return null;
            }
        }
    }

    if ("contains".equals(operator)) {
        if ("java.lang.String".equals(type) || "PlainString".equals(type)) {
            String str1 = (String) convertedValue1;
            String str2 = (String) convertedValue2;

            return str1.indexOf(str2) < 0 ? Boolean.FALSE : Boolean.TRUE;
        } else {
            messages.add(
                    "Error in XML file: cannot do a contains compare between a String and a non-String type");
            return null;
        }
    } else if ("is-empty".equals(operator)) {
        if (convertedValue1 == null)
            return Boolean.TRUE;
        if (convertedValue1 instanceof String && ((String) convertedValue1).length() == 0)
            return Boolean.TRUE;
        if (convertedValue1 instanceof List<?> && ((List<?>) convertedValue1).size() == 0)
            return Boolean.TRUE;
        if (convertedValue1 instanceof Map<?, ?> && ((Map<?, ?>) convertedValue1).size() == 0)
            return Boolean.TRUE;
        return Boolean.FALSE;
    } else if ("is-not-empty".equals(operator)) {
        if (convertedValue1 == null)
            return Boolean.FALSE;
        if (convertedValue1 instanceof String && ((String) convertedValue1).length() == 0)
            return Boolean.FALSE;
        if (convertedValue1 instanceof List<?> && ((List<?>) convertedValue1).size() == 0)
            return Boolean.FALSE;
        if (convertedValue1 instanceof Map<?, ?> && ((Map<?, ?>) convertedValue1).size() == 0)
            return Boolean.FALSE;
        return Boolean.TRUE;
    }

    if ("java.lang.String".equals(type) || "PlainString".equals(type)) {
        String str1 = (String) convertedValue1;
        String str2 = (String) convertedValue2;

        if (str1.length() == 0 || str2.length() == 0) {
            if ("equals".equals(operator)) {
                return str1.length() == 0 && str2.length() == 0 ? Boolean.TRUE : Boolean.FALSE;
            } else if ("not-equals".equals(operator)) {
                return str1.length() == 0 && str2.length() == 0 ? Boolean.FALSE : Boolean.TRUE;
            } else {
                messages.add(
                        "ERROR: Could not do a compare between strings with one empty string for the operator "
                                + operator);
                return null;
            }
        }
        result = str1.compareTo(str2);
    } else if ("java.lang.Double".equals(type) || "java.lang.Float".equals(type)
            || "java.lang.Long".equals(type) || "java.lang.Integer".equals(type)
            || "java.math.BigDecimal".equals(type)) {
        Number tempNum = (Number) convertedValue1;
        double value1Double = tempNum.doubleValue();

        tempNum = (Number) convertedValue2;
        double value2Double = tempNum.doubleValue();

        if (value1Double < value2Double)
            result = -1;
        else if (value1Double > value2Double)
            result = 1;
        else
            result = 0;
    } else if ("java.sql.Date".equals(type)) {
        java.sql.Date value1Date = (java.sql.Date) convertedValue1;
        java.sql.Date value2Date = (java.sql.Date) convertedValue2;
        result = value1Date.compareTo(value2Date);
    } else if ("java.sql.Time".equals(type)) {
        java.sql.Time value1Time = (java.sql.Time) convertedValue1;
        java.sql.Time value2Time = (java.sql.Time) convertedValue2;
        result = value1Time.compareTo(value2Time);
    } else if ("java.sql.Timestamp".equals(type)) {
        java.sql.Timestamp value1Timestamp = (java.sql.Timestamp) convertedValue1;
        java.sql.Timestamp value2Timestamp = (java.sql.Timestamp) convertedValue2;
        result = value1Timestamp.compareTo(value2Timestamp);
    } else if ("java.lang.Boolean".equals(type)) {
        Boolean value1Boolean = (Boolean) convertedValue1;
        Boolean value2Boolean = (Boolean) convertedValue2;
        if ("equals".equals(operator)) {
            if ((value1Boolean.booleanValue() && value2Boolean.booleanValue())
                    || (!value1Boolean.booleanValue() && !value2Boolean.booleanValue()))
                result = 0;
            else
                result = 1;
        } else if ("not-equals".equals(operator)) {
            if ((!value1Boolean.booleanValue() && value2Boolean.booleanValue())
                    || (value1Boolean.booleanValue() && !value2Boolean.booleanValue()))
                result = 0;
            else
                result = 1;
        } else {
            messages.add("Can only compare Booleans using the operators 'equals' or 'not-equals'");
            return null;
        }
    } else if ("java.lang.Object".equals(type)) {
        if (convertedValue1.equals(convertedValue2)) {
            result = 0;
        } else {
            result = 1;
        }
    } else {
        messages.add("Type \"" + type + "\" specified for compare not supported.");
        return null;
    }

    if (verboseOn)
        Debug.logVerbose("Got Compare result: " + result + ", operator: " + operator, module);
    if ("less".equals(operator)) {
        if (result >= 0)
            return Boolean.FALSE;
    } else if ("greater".equals(operator)) {
        if (result <= 0)
            return Boolean.FALSE;
    } else if ("less-equals".equals(operator)) {
        if (result > 0)
            return Boolean.FALSE;
    } else if ("greater-equals".equals(operator)) {
        if (result < 0)
            return Boolean.FALSE;
    } else if ("equals".equals(operator)) {
        if (result != 0)
            return Boolean.FALSE;
    } else if ("not-equals".equals(operator)) {
        if (result == 0)
            return Boolean.FALSE;
    } else {
        messages.add("Specified compare operator \"" + operator + "\" not known.");
        return null;
    }

    if (verboseOn)
        Debug.logVerbose("Returning true", module);
    return Boolean.TRUE;
}