Пример #1
0
  /**
   * Returns true if the present instance of RecurringDurationBase is greater than the parameter
   *
   * <p>Note : the order relation follows the W3C XML Schema draft i.e <tt>rd1 < rd2 iff
   * rd2-rd1>0</tt>
   *
   * @param reccD the recurring duration base to compare with the present instance
   * @return true if the present instance is the greatest, false if not
   */
  public boolean isGreater(RecurringDurationBase reccD) throws ValidationException {
    if (!(this.getPeriod().equals(reccD.getPeriod()))
        || !(this.getDuration().equals(reccD.getDuration()))) {
      String err =
          "Recurring Duration which have different values "
              + "for the duration and period can not be compared";
      throw new ValidationException(err);
    }

    boolean result = false;
    short[] val_this = this.getValues();
    short[] val_reccD = reccD.getValues();
    for (int i = 0; result != true || i < val_this.length; i++) {
      result = val_this[i] > val_reccD[i];
      if (val_this[i] < val_reccD[i]) {
        return false;
      }
    }
    return result;
  } // isGreater
Пример #2
0
  /**
   * Returns true if the present instance of Recurring Duration Base is equal to the parameter.
   *
   * <p>The equals relation is the following : <tt>rd1 equals rd2 iff each field of rd1 is equal to
   * the corresponding field of rd2 </tt>
   *
   * @param reccD the recurring duration to compare with the present instance
   * @return true if the present instance is equal to the parameter false if not
   */
  public boolean equal(RecurringDurationBase reccD) throws ValidationException {
    boolean result = false;
    if (!(this.getPeriod().equals(reccD.getPeriod()))
        || !(this.getDuration().equals(reccD.getDuration()))) {
      String err =
          "Recurring Duration which have different values "
              + "for the duration and period can not be compared";
      throw new ValidationException(err);
    }

    result = (this.getHour() == reccD.getHour());
    result = result && (this.getMinute() == reccD.getMinute());
    result = result && (this.getSeconds() == reccD.getSeconds());
    result = result && (this.getMilli() == reccD.getMilli());
    result = result && (this.isNegative() == this.isNegative());
    if (!reccD.isUTC()) {
      result = result && (!this.isUTC());
      result = result && (this.getZoneHour() == reccD.getZoneHour());
      result = result && (this.getZoneMinute() == reccD.getZoneMinute());
    }
    return result;
  } // equals