int cur = f.valueOf(cal); int next = f.floor(this,cur); if (cur==next) continue; // this field is already in a good shape. move on to next l.clear(cal); f.rollUp(cal,-1); f.setTo(cal,f.last(this)); f.addTo(cal,1); CalendarField.MINUTE.addTo(cal,-1); f.setTo(cal,next); f.addTo(cal,1); CalendarField.MINUTE.addTo(cal,-1); if (f.redoAdjustmentIfModified) continue OUTER; // when we modify DAY_OF_MONTH and DAY_OF_WEEK, do it all over from the top
int cur = f.valueOf(cal); int next = f.floor(this,cur); if (cur==next) continue; // this field is already in a good shape. move on to next l.clear(cal); f.rollUp(cal,-1); f.setTo(cal,f.last(this)); f.addTo(cal,1); CalendarField.MINUTE.addTo(cal,-1); f.setTo(cal,next); f.addTo(cal,1); CalendarField.MINUTE.addTo(cal,-1); if (f.redoAdjustmentIfModified) continue OUTER; // when we modify DAY_OF_MONTH and DAY_OF_WEEK, do it all over from the top
while (true) { for (CalendarField f : CalendarField.ADJUST_ORDER) { int cur = f.valueOf(cal); int next = f.floor(this, cur); if (cur == next) { l.clear(cal); f.rollUp(cal, -1); f.setTo(cal, f.last(this)); f.addTo(cal, 1); CalendarField.MINUTE.addTo(cal, -1); f.setTo(cal, next); f.addTo(cal, 1); CalendarField.MINUTE.addTo(cal, -1); if (f.redoAdjustmentIfModified) { continue OUTER; // when we modify DAY_OF_MONTH and DAY_OF_WEEK, do it all over from the top
while (true) { for (CalendarField f : CalendarField.ADJUST_ORDER) { int cur = f.valueOf(cal); int next = f.floor(this,cur); if (cur==next) continue; // this field is already in a good shape. move on to next l.clear(cal); f.rollUp(cal,-1); f.setTo(cal,f.last(this)); f.addTo(cal,1); CalendarField.MINUTE.addTo(cal,-1); f.setTo(cal,next); f.addTo(cal,1); CalendarField.MINUTE.addTo(cal,-1); if (f.redoAdjustmentIfModified) continue OUTER; // when we modify DAY_OF_MONTH and DAY_OF_WEEK, do it all over from the top
while (true) { for (CalendarField f : CalendarField.ADJUST_ORDER) { int cur = f.valueOf(cal); int next = f.floor(this,cur); if (cur==next) continue; // this field is already in a good shape. move on to next l.clear(cal); f.rollUp(cal,-1); f.setTo(cal,f.last(this)); f.addTo(cal,1); CalendarField.MINUTE.addTo(cal,-1); f.setTo(cal,next); f.addTo(cal,1); CalendarField.MINUTE.addTo(cal,-1); if (f.redoAdjustmentIfModified) continue OUTER; // when we modify DAY_OF_MONTH and DAY_OF_WEEK, do it all over from the top
int cur = f.valueOf(cal); int next = f.ceil(this,cur); if (cur==next) continue; // this field is already in a good shape. move on to next l.clear(cal); f.rollUp(cal, 1); f.setTo(cal,f.first(this)); f.setTo(cal,next); if (f.redoAdjustmentIfModified) continue OUTER; // when we modify DAY_OF_MONTH and DAY_OF_WEEK, do it all over from the top
while (true) { for (CalendarField f : CalendarField.ADJUST_ORDER) { int cur = f.valueOf(cal); int next = f.floor(this,cur); if (cur==next) continue; // this field is already in a good shape. move on to next l.clear(cal); f.rollUp(cal,-1); f.setTo(cal,f.last(this)); f.addTo(cal,1); CalendarField.MINUTE.addTo(cal,-1); f.setTo(cal,next); f.addTo(cal,1); CalendarField.MINUTE.addTo(cal,-1); if (f.redoAdjustmentIfModified) continue OUTER; // when we modify DAY_OF_MONTH and DAY_OF_WEEK, do it all over from the top
while (true) { for (CalendarField f : CalendarField.ADJUST_ORDER) { int cur = f.valueOf(cal); int next = f.ceil(this, cur); if (cur == next) { l.clear(cal); f.rollUp(cal, 1); f.setTo(cal, f.first(this)); f.setTo(cal, next); if (f.redoAdjustmentIfModified) { continue OUTER; // when we modify DAY_OF_MONTH and DAY_OF_WEEK, do it all over from the top
/** * See {@link #ceil(long)}. * * This method modifies the given calendar and returns the same object. */ public Calendar ceil(Calendar cal) { OUTER: while (true) { for (CalendarField f : CalendarField.ADJUST_ORDER) { int cur = f.valueOf(cal); int next = f.ceil(this,cur); if (cur==next) continue; // this field is already in a good shape. move on to next // we are modifying this field, so clear all the lower level fields for (CalendarField l=f.lowerField; l!=null; l=l.lowerField) l.clear(cal); if (next<0) { // we need to roll over to the next field. f.rollUp(cal, 1); f.setTo(cal,f.first(this)); // since higher order field is affected by this, we need to restart from all over continue OUTER; } else { f.setTo(cal,next); if (f.redoAdjustmentIfModified) continue OUTER; // when we modify DAY_OF_MONTH and DAY_OF_WEEK, do it all over from the top } } return cal; // all fields adjusted } }
/** * See {@link #ceil(long)}. * * This method modifies the given calendar and returns the same object. */ public Calendar ceil(Calendar cal) { OUTER: while (true) { for (CalendarField f : CalendarField.ADJUST_ORDER) { int cur = f.valueOf(cal); int next = f.ceil(this,cur); if (cur==next) continue; // this field is already in a good shape. move on to next // we are modifying this field, so clear all the lower level fields for (CalendarField l=f.lowerField; l!=null; l=l.lowerField) l.clear(cal); if (next<0) { // we need to roll over to the next field. f.rollUp(cal, 1); f.setTo(cal,f.first(this)); // since higher order field is affected by this, we need to restart from all over continue OUTER; } else { f.setTo(cal,next); if (f.redoAdjustmentIfModified) continue OUTER; // when we modify DAY_OF_MONTH and DAY_OF_WEEK, do it all over from the top } } return cal; // all fields adjusted } }
/** * See {@link #ceil(long)}. * * This method modifies the given calendar and returns the same object. */ public Calendar ceil(Calendar cal) { OUTER: while (true) { for (CalendarField f : CalendarField.ADJUST_ORDER) { int cur = f.valueOf(cal); int next = f.ceil(this,cur); if (cur==next) continue; // this field is already in a good shape. move on to next // we are modifying this field, so clear all the lower level fields for (CalendarField l=f.lowerField; l!=null; l=l.lowerField) l.clear(cal); if (next<0) { // we need to roll over to the next field. f.rollUp(cal, 1); f.setTo(cal,f.first(this)); // since higher order field is affected by this, we need to restart from all over continue OUTER; } else { f.setTo(cal,next); if (f.redoAdjustmentIfModified) continue OUTER; // when we modify DAY_OF_MONTH and DAY_OF_WEEK, do it all over from the top } } return cal; // all fields adjusted } }
/** * Given the value 'n' (which represents the current value), finds the * smallest x such that: 1) x matches the specified {@link CronTab} (as * far as this field is concerned.) 2) x>=n (inclusive) * * If there's no such bit, return -1. Note that if 'n' already matches * the crontab, the same n will be returned. */ private int ceil(CronTab c, int n) { long bits = bits(c); while ((bits | (1L << n)) != bits) { if (n > 60) { return -1; } n++; } return n; }
/** * Given the value 'n' (which represents the current value), finds the smallest x such that: * 1) x matches the specified {@link CronTab} (as far as this field is concerned.) * 2) x>=n (inclusive) * * If there's no such bit, return -1. Note that if 'n' already matches the crontab, the same n will be returned. */ private int ceil(CronTab c, int n) { long bits = bits(c); while ((bits|(1L<<n))!=bits) { if (n>60) return -1; n++; } return n; }
/** * Given the value 'n' (which represents the current value), finds the smallest x such that: * 1) x matches the specified {@link CronTab} (as far as this field is concerned.) * 2) x>=n (inclusive) * * If there's no such bit, return -1. Note that if 'n' already matches the crontab, the same n will be returned. */ private int ceil(CronTab c, int n) { long bits = bits(c); while ((bits|(1L<<n))!=bits) { if (n>60) return -1; n++; } return n; }
/** * Given the value 'n' (which represents the current value), finds the smallest x such that: * 1) x matches the specified {@link CronTab} (as far as this field is concerned.) * 2) x>=n (inclusive) * * If there's no such bit, return -1. Note that if 'n' already matches the crontab, the same n will be returned. */ private int ceil(CronTab c, int n) { long bits = bits(c); while ((bits|(1L<<n))!=bits) { if (n>60) return -1; n++; } return n; }
void clear(Calendar c) { setTo(c, min); }
void clear(Calendar c) { setTo(c, min); }
private int last(CronTab c) { return floor(c,63); }
void clear(Calendar c) { setTo(c, min); }
private int last(CronTab c) { return floor(c,63); }