private SortedSet<Integer> getEligibleDaysOfMonth(Calendar cal) { if (this.hasRelativeDayOfMonth() == false) { return this.absoluteValues; SingleValue singleValue = (SingleValue) relativeValue; String value = singleValue.getValue(); Integer absoluteDayOfMonth = this.getAbsoluteDayOfMonth(cal, value); eligibleDaysOfMonth.add(absoluteDayOfMonth); } else if (relativeValue instanceof RangeValue) { if (this.isRelativeValue(start)) { dayOfMonthStart = this.getAbsoluteDayOfMonth(cal, start); } else { dayOfMonthStart = this.parseInt(start); if (this.isRelativeValue(end)) { dayOfMonthEnd = this.getAbsoluteDayOfMonth(cal, end); } else { dayOfMonthEnd = this.parseInt(end); this.assertValid(dayOfMonthStart); this.assertValid(dayOfMonthEnd); for (int i = dayOfMonthStart; i <= this.getMaxValue(); i++) { eligibleDaysOfMonth.add(i); for (int i = this.getMinValue(); i <= dayOfMonthEnd; i++) { eligibleDaysOfMonth.add(i);
public Integer getFirstMatch(Calendar cal) { if (this.scheduleExpressionType == ScheduleExpressionType.WILDCARD) { return Calendar.SUNDAY; } SortedSet<Integer> eligibleDaysOfMonth = this.getEligibleDaysOfMonth(cal); if (eligibleDaysOfMonth.isEmpty()) { return null; } return eligibleDaysOfMonth.first(); }
private Calendar computeNextDayOfMonth(Calendar nextCal) { Integer nextDayOfMonth = this.dayOfMonth.getNextMatch(nextCal); return null; nextDayOfMonth = this.dayOfMonth.getFirstMatch(nextCal); if (nextDayOfMonth == null) { return null;
@Override public boolean isRelativeValue(String value) { if (value == null) { throw EjbLogger.EJB3_TIMER_LOGGER.relativeValueIsNull(); } if (value.equalsIgnoreCase("last")) { return true; } if (this.isValidNegativeDayOfMonth(value)) { return true; } if (this.isDayOfWeekBased(value)) { return true; } return false; }
private Calendar advanceTillMonthHasDate(Calendar cal, Integer date) { resetTimeToFirstValues(cal); // make sure the month can handle the date while (monthHasDate(cal, date) == false) { if (cal.get(Calendar.YEAR) > Year.MAX_YEAR) { return null; } // this month can't handle the date, so advance month to next month // and get the next suitable matching month cal.add(Calendar.MONTH, 1); cal = this.computeNextMonth(cal); if (cal == null) { return null; } date = this.dayOfMonth.getFirstMatch(cal); if (date == null) { return null; } } cal.set(Calendar.DAY_OF_MONTH, date); return cal; }
this.hour = new Hour(schedule.getHour()); this.dayOfWeek = new DayOfWeek(schedule.getDayOfWeek()); this.dayOfMonth = new DayOfMonth(schedule.getDayOfMonth()); this.month = new Month(schedule.getMonth()); this.year = new Year(schedule.getYear());
return lastDayOfCurrentMonth; if (this.isValidNegativeDayOfMonth(trimmedRelativeDayOfMonth)) { Integer negativeRelativeDayOfMonth = Integer.parseInt(trimmedRelativeDayOfMonth); int lastDayOfCurrentMonth = CalendarUtil.getLastDateOfMonth(cal); return lastDayOfCurrentMonth + negativeRelativeDayOfMonth; if (this.isDayOfWeekBased(trimmedRelativeDayOfMonth)) {
private Calendar advanceTillMonthHasDate(Calendar cal, Integer date) { Calendar copy = this.copy(cal); // make sure the month can handle the date while (monthHasDate(copy, date) == false) { if (copy.get(Calendar.YEAR) > Year.MAX_YEAR) { return null; } // this month can't handle the date, so advance month to next month // and get the next suitable matching month copy.add(Calendar.MONTH, 1); copy = this.computeNextMonth(copy); if (copy == null) { return null; } date = this.dayOfMonth.getFirstMatch(copy); if (date == null) { return null; } copy.set(Calendar.SECOND, this.second.getFirst()); copy.set(Calendar.MINUTE, this.minute.getFirst()); copy.set(Calendar.HOUR_OF_DAY, this.hour.getFirst()); } copy.set(Calendar.DAY_OF_MONTH, date); return copy; }
this.hour = new Hour(schedule.getHour()); this.dayOfWeek = new DayOfWeek(schedule.getDayOfWeek()); this.dayOfMonth = new DayOfMonth(schedule.getDayOfMonth()); this.month = new Month(schedule.getMonth()); this.year = new Year(schedule.getYear());
private SortedSet<Integer> getEligibleDaysOfMonth(Calendar cal) { if (this.hasRelativeDayOfMonth() == false) { return this.absoluteValues; SingleValue singleValue = (SingleValue) relativeValue; String value = singleValue.getValue(); Integer absoluteDayOfMonth = this.getAbsoluteDayOfMonth(cal, value); eligibleDaysOfMonth.add(absoluteDayOfMonth); } else if (relativeValue instanceof RangeValue) { if (this.isRelativeValue(start)) { dayOfMonthStart = this.getAbsoluteDayOfMonth(cal, start); } else { dayOfMonthStart = this.parseInt(start); if (this.isRelativeValue(end)) { dayOfMonthEnd = this.getAbsoluteDayOfMonth(cal, end); } else { dayOfMonthEnd = this.parseInt(end); this.assertValid(dayOfMonthStart); this.assertValid(dayOfMonthEnd); for (int i = dayOfMonthStart; i <= this.getMaxValue(); i++) { eligibleDaysOfMonth.add(i); for (int i = this.getMinValue(); i <= dayOfMonthEnd; i++) { eligibleDaysOfMonth.add(i);
@Override public boolean isRelativeValue(String value) { if (value == null) { throw MESSAGES.relativeValueIsNull(); } if (value.equalsIgnoreCase("last")) { return true; } if (this.isValidNegativeDayOfMonth(value)) { return true; } if (this.isDayOfWeekBased(value)) { return true; } return false; }
Integer nextDayOfMonth = this.dayOfMonth.getNextMatch(currentCal); return null; nextDayOfMonth = this.dayOfMonth.getFirstMatch(nextCal); if (nextDayOfMonth == null) { return null;
public Integer getNextMatch(Calendar currentCal) { if (this.scheduleExpressionType == ScheduleExpressionType.WILDCARD) { return currentCal.get(Calendar.DAY_OF_MONTH); } int currentDayOfMonth = currentCal.get(Calendar.DAY_OF_MONTH); SortedSet<Integer> eligibleDaysOfMonth = this.getEligibleDaysOfMonth(currentCal); if (eligibleDaysOfMonth.isEmpty()) { return null; } for (Integer hour : eligibleDaysOfMonth) { if (currentDayOfMonth == hour) { return currentDayOfMonth; } if (hour > currentDayOfMonth) { return hour; } } return eligibleDaysOfMonth.first(); }
return lastDayOfCurrentMonth; if (this.isValidNegativeDayOfMonth(trimmedRelativeDayOfMonth)) { Integer negativeRelativeDayOfMonth = Integer.parseInt(trimmedRelativeDayOfMonth); int lastDayOfCurrentMonth = CalendarUtil.getLastDateOfMonth(cal); return lastDayOfCurrentMonth + negativeRelativeDayOfMonth; if (this.isDayOfWeekBased(trimmedRelativeDayOfMonth)) {
public Integer getFirstMatch(Calendar cal) { if (this.scheduleExpressionType == ScheduleExpressionType.WILDCARD) { return Calendar.SUNDAY; } SortedSet<Integer> eligibleDaysOfMonth = this.getEligibleDaysOfMonth(cal); if (eligibleDaysOfMonth.isEmpty()) { return null; } return eligibleDaysOfMonth.first(); }
public Integer getNextMatch(Calendar currentCal) { if (this.scheduleExpressionType == ScheduleExpressionType.WILDCARD) { return currentCal.get(Calendar.DAY_OF_MONTH); } int currentDayOfMonth = currentCal.get(Calendar.DAY_OF_MONTH); SortedSet<Integer> eligibleDaysOfMonth = this.getEligibleDaysOfMonth(currentCal); if (eligibleDaysOfMonth.isEmpty()) { return null; } for (Integer hour : eligibleDaysOfMonth) { if (currentDayOfMonth == hour) { return currentDayOfMonth; } if (hour > currentDayOfMonth) { return hour; } } return eligibleDaysOfMonth.first(); }