예제 #1
0
  /**
   * @param cronStr
   * @throws CronParseException if cronStr is not a valid CRON string.
   */
  public void setCronString(String cronStr) throws CronParseException {

    // Try original simplistic parser...
    CronParser cp = new CronParser(cronStr);
    String recurrenceStr = null;
    try {
      recurrenceStr = cp.parseToRecurrenceString(); // throws CronParseException
    } catch (CronParseException e) {
      if (!CronExpression.isValidExpression(cronStr)) { // Parse with proper expression parser
        throw e;
      }
      recurrenceStr = null; // valid cronstring, not parse-able to recurrence string
    }

    if (null != recurrenceStr) {
      recurrenceEditor.inititalizeWithRecurrenceString(recurrenceStr);
      TemporalValue tv = recurrenceEditor.getTemporalState();
      ScheduleType rt = temporalValueToScheduleType(tv);
      setScheduleType(rt);
    } else {
      // its a cron string that cannot be parsed into a recurrence string, switch to cron string
      // editor.
      setScheduleType(ScheduleType.CRON);
    }

    cronEditor.setCronString(cronStr);
  }
예제 #2
0
 public void setRepeatInSecs(Integer repeatInSecs) {
   recurrenceEditor.inititalizeWithRepeatInSecs(repeatInSecs);
   TemporalValue tv = recurrenceEditor.getTemporalState();
   ScheduleType rt = temporalValueToScheduleType(tv);
   setScheduleType(rt);
 }