Esempio n. 1
0
  /**
   * @see DataType#DATE_DAYS_SINCE_1960
   * @see DataType#DATE_DAYS_SINCE_1970
   * @see DataType#DATE_DAYS_SINCE_1980
   */
  private static DaysSinceDate toDaysSinceDate(Object value, LocalDate epoch) {

    if (value instanceof DaysSinceDate) {
      DaysSinceDate period = (DaysSinceDate) value;

      if ((period.getEpoch()).equals(epoch)) {
        return period;
      }
    }

    throw new TypeCheckException(DataType.DATE_DAYS_SINCE_1970, value);
  }
Esempio n. 2
0
  /** @return The data type of the value. */
  public static DataType getDataType(Object value) {

    if (value instanceof String) {
      return DataType.STRING;
    } else if (value instanceof Integer) {
      return DataType.INTEGER;
    } else if (value instanceof Float) {
      return DataType.FLOAT;
    } else if (value instanceof Double) {
      return DataType.DOUBLE;
    } else if (value instanceof Boolean) {
      return DataType.BOOLEAN;
    } else if (value instanceof LocalDate) {
      return DataType.DATE;
    } else if (value instanceof LocalTime) {
      return DataType.TIME;
    } else if (value instanceof LocalDateTime) {
      return DataType.DATE_TIME;
    } else if (value instanceof DaysSinceDate) {
      DaysSinceDate period = (DaysSinceDate) value;

      LocalDate epoch = period.getEpoch();

      if ((epoch).equals(YEAR_1960)) {
        return DataType.DATE_DAYS_SINCE_1960;
      } else if ((epoch).equals(YEAR_1970)) {
        return DataType.DATE_DAYS_SINCE_1970;
      } else if ((epoch).equals(YEAR_1980)) {
        return DataType.DATE_DAYS_SINCE_1980;
      }
    } else if (value instanceof SecondsSinceMidnight) {
      return DataType.TIME_SECONDS;
    } else if (value instanceof SecondsSinceDate) {
      SecondsSinceDate period = (SecondsSinceDate) value;

      LocalDate epoch = period.getEpoch();

      if ((epoch).equals(YEAR_1960)) {
        return DataType.DATE_TIME_SECONDS_SINCE_1960;
      } else if ((epoch).equals(YEAR_1970)) {
        return DataType.DATE_TIME_SECONDS_SINCE_1970;
      } else if ((epoch).equals(YEAR_1980)) {
        return DataType.DATE_TIME_SECONDS_SINCE_1980;
      }
    }

    throw new EvaluationException();
  }