private int findNextDay(Calendar calendar, BitSet daysOfMonth, int dayOfMonth, BitSet daysOfWeek, int dayOfWeek, List<Integer> resets) { int count = 0; int max = 366; // the DAY_OF_WEEK values in java.util.Calendar start with 1 (Sunday), // but in the cron pattern, they start with 0, so we subtract 1 here while ((!daysOfMonth.get(dayOfMonth) || !daysOfWeek.get(dayOfWeek - 1)) && count++ < max) { calendar.add(Calendar.DAY_OF_MONTH, 1); dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); reset(calendar, resets); } if (count >= max) { throw new IllegalArgumentException("Overflow in day for expression \"" + this.expression + "\""); } return dayOfMonth; }
/** * Search the bits provided for the next set bit after the value provided, * and reset the calendar. * @param bits a {@link BitSet} representing the allowed values of the field * @param value the current value of the field * @param calendar the calendar to increment as we move through the bits * @param field the field to increment in the calendar (@see * {@link Calendar} for the static constants defining valid fields) * @param lowerOrders the Calendar field ids that should be reset (i.e. the * ones of lower significance than the field of interest) * @return the value of the calendar field that is next in the sequence */ private int findNext(BitSet bits, int value, Calendar calendar, int field, int nextField, List<Integer> lowerOrders) { int nextValue = bits.nextSetBit(value); // roll over if needed if (nextValue == -1) { calendar.add(nextField, 1); reset(calendar, Collections.singletonList(field)); nextValue = bits.nextSetBit(0); } if (nextValue != value) { calendar.set(field, nextValue); reset(calendar, lowerOrders); } return nextValue; }
private int findNextDay(Calendar calendar, BitSet daysOfMonth, int dayOfMonth, BitSet daysOfWeek, int dayOfWeek, List<Integer> resets) { int count = 0; int max = 366; // the DAY_OF_WEEK values in java.util.Calendar start with 1 (Sunday), // but in the cron pattern, they start with 0, so we subtract 1 here while ((!daysOfMonth.get(dayOfMonth) || !daysOfWeek.get(dayOfWeek - 1)) && count++ < max) { calendar.add(Calendar.DAY_OF_MONTH, 1); dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); reset(calendar, resets); } if (count >= max) { throw new IllegalArgumentException("Overflow in day for expression \"" + this.expression + "\""); } return dayOfMonth; }
/** * Search the bits provided for the next set bit after the value provided, * and reset the calendar. * @param bits a {@link BitSet} representing the allowed values of the field * @param value the current value of the field * @param calendar the calendar to increment as we move through the bits * @param field the field to increment in the calendar (@see * {@link Calendar} for the static constants defining valid fields) * @param lowerOrders the Calendar field ids that should be reset (i.e. the * ones of lower significance than the field of interest) * @return the value of the calendar field that is next in the sequence */ private int findNext(BitSet bits, int value, Calendar calendar, int field, int nextField, List<Integer> lowerOrders) { int nextValue = bits.nextSetBit(value); // roll over if needed if (nextValue == -1) { calendar.add(nextField, 1); reset(calendar, Collections.singletonList(field)); nextValue = bits.nextSetBit(0); } if (nextValue != value) { calendar.set(field, nextValue); reset(calendar, lowerOrders); } return nextValue; }
private int findNextDay(Calendar calendar, BitSet daysOfMonth, int dayOfMonth, BitSet daysOfWeek, int dayOfWeek, List<Integer> resets) { int count = 0; int max = 366; // the DAY_OF_WEEK values in java.util.Calendar start with 1 (Sunday), // but in the cron pattern, they start with 0, so we subtract 1 here while ((!daysOfMonth.get(dayOfMonth) || !daysOfWeek.get(dayOfWeek - 1)) && count++ < max) { calendar.add(Calendar.DAY_OF_MONTH, 1); dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); reset(calendar, resets); } if (count >= max) { throw new IllegalArgumentException("Overflow in day for expression \"" + this.expression + "\""); } return dayOfMonth; }
/** * Search the bits provided for the next set bit after the value provided, * and reset the calendar. * @param bits a {@link BitSet} representing the allowed values of the field * @param value the current value of the field * @param calendar the calendar to increment as we move through the bits * @param field the field to increment in the calendar (@see * {@link Calendar} for the static constants defining valid fields) * @param lowerOrders the Calendar field ids that should be reset (i.e. the * ones of lower significance than the field of interest) * @return the value of the calendar field that is next in the sequence */ private int findNext(BitSet bits, int value, Calendar calendar, int field, int nextField, List<Integer> lowerOrders) { int nextValue = bits.nextSetBit(value); // roll over if needed if (nextValue == -1) { calendar.add(nextField, 1); reset(calendar, Collections.singletonList(field)); nextValue = bits.nextSetBit(0); } if (nextValue != value) { calendar.set(field, nextValue); reset(calendar, lowerOrders); } return nextValue; }