/** * Returns true if the given calendar matches */ boolean check(Calendar cal) { Calendar checkCal = cal; if(specTimezone != null && !specTimezone.isEmpty()) { Calendar tzCal = Calendar.getInstance(TimeZone.getTimeZone(specTimezone)); tzCal.setTime(cal.getTime()); checkCal = tzCal; } if(!checkBits(bits[0],checkCal.get(MINUTE))) return false; if(!checkBits(bits[1],checkCal.get(HOUR_OF_DAY))) return false; if(!checkBits(bits[2],checkCal.get(DAY_OF_MONTH))) return false; if(!checkBits(bits[3],checkCal.get(MONTH)+1)) return false; if(!checkBits(dayOfWeek,checkCal.get(Calendar.DAY_OF_WEEK)-1)) return false; return true; }
/** * Returns true if the given calendar matches */ boolean check(Calendar cal) { if(!checkBits(bits[0],cal.get(MINUTE))) return false; if(!checkBits(bits[1],cal.get(HOUR_OF_DAY))) return false; if(!checkBits(bits[2],cal.get(DAY_OF_MONTH))) return false; if(!checkBits(bits[3],cal.get(MONTH)+1)) return false; if(!checkBits(dayOfWeek,cal.get(Calendar.DAY_OF_WEEK)-1)) return false; return true; }
/** * Returns true if the given calendar matches */ boolean check(Calendar cal) { if(!checkBits(bits[0],cal.get(MINUTE))) return false; if(!checkBits(bits[1],cal.get(HOUR_OF_DAY))) return false; if(!checkBits(bits[2],cal.get(DAY_OF_MONTH))) return false; if(!checkBits(bits[3],cal.get(MONTH)+1)) return false; if(!checkBits(dayOfWeek,cal.get(Calendar.DAY_OF_WEEK)-1)) return false; return true; }
/** * Returns true if the given calendar matches */ boolean check(Calendar cal) { if(!checkBits(bits[0],cal.get(MINUTE))) return false; if(!checkBits(bits[1],cal.get(HOUR_OF_DAY))) return false; if(!checkBits(bits[2],cal.get(DAY_OF_MONTH))) return false; if(!checkBits(bits[3],cal.get(MONTH)+1)) return false; if(!checkBits(dayOfWeek,cal.get(Calendar.DAY_OF_WEEK)-1)) return false; return true; }
/** * Returns true if the given calendar matches */ boolean check(Calendar cal) { if (!checkBits(bits[0], cal.get(MINUTE))) { return false; } if (!checkBits(bits[1], cal.get(HOUR_OF_DAY))) { return false; } if (!checkBits(bits[2], cal.get(DAY_OF_MONTH))) { return false; } if (!checkBits(bits[3], cal.get(MONTH) + 1)) { return false; } if (!checkBits(dayOfWeek, cal.get(Calendar.DAY_OF_WEEK) - 1)) { return false; } return true; }
/** * Returns true if the given calendar matches */ boolean check(Calendar cal) { Calendar checkCal = cal; if(specTimezone != null && !specTimezone.isEmpty()) { Calendar tzCal = Calendar.getInstance(TimeZone.getTimeZone(specTimezone)); tzCal.setTime(cal.getTime()); checkCal = tzCal; } if(!checkBits(bits[0],checkCal.get(MINUTE))) return false; if(!checkBits(bits[1],checkCal.get(HOUR_OF_DAY))) return false; if(!checkBits(bits[2],checkCal.get(DAY_OF_MONTH))) return false; if(!checkBits(bits[3],checkCal.get(MONTH)+1)) return false; if(!checkBits(dayOfWeek,checkCal.get(Calendar.DAY_OF_WEEK)-1)) return false; return true; }
/** * Checks if this crontab entry looks reasonable, * and if not, return an warning message. * * <p> * The point of this method is to catch syntactically correct * but semantically suspicious combinations, like * "* 0 * * *" */ public String checkSanity() { for( int i=0; i<5; i++ ) { long bitMask = (i<4)?bits[i]:(long)dayOfWeek; for( int j=LOWER_BOUNDS[i]; j<=UPPER_BOUNDS[i]; j++ ) { if(!checkBits(bitMask,j)) { // this rank has a sparse entry. // if we have a sparse rank, one of them better be the left-most. if(i>0) return "Do you really mean \"every minute\" when you say \""+spec+"\"? "+ "Perhaps you meant \"0 "+spec.substring(spec.indexOf(' ')+1)+"\""; // once we find a sparse rank, upper ranks don't matter return null; } } } return null; }
/** * Checks if this crontab entry looks reasonable, * and if not, return an warning message. * * <p> * The point of this method is to catch syntactically correct * but semantically suspicious combinations, like * "* 0 * * *" */ public String checkSanity() { for( int i=0; i<5; i++ ) { long bitMask = (i<4)?bits[i]:(long)dayOfWeek; for( int j=LOWER_BOUNDS[i]; j<=UPPER_BOUNDS[i]; j++ ) { if(!checkBits(bitMask,j)) { // this rank has a sparse entry. // if we have a sparse rank, one of them better be the left-most. if(i>0) return "Do you really mean \"every minute\" when you say \""+spec+"\"? "+ "Perhaps you meant \"0 "+spec.substring(spec.indexOf(' ')+1)+"\""; // once we find a sparse rank, upper ranks don't matter return null; } } } return null; }
/** * Checks if this crontab entry looks reasonable, * and if not, return an warning message. * * <p> * The point of this method is to catch syntactically correct * but semantically suspicious combinations, like * "* 0 * * *" */ public String checkSanity() { for( int i=0; i<5; i++ ) { long bitMask = (i<4)?bits[i]:(long)dayOfWeek; for( int j=LOWER_BOUNDS[i]; j<=UPPER_BOUNDS[i]; j++ ) { if(!checkBits(bitMask,j)) { // this rank has a sparse entry. // if we have a sparse rank, one of them better be the left-most. if(i>0) return "Do you really mean \"every minute\" when you say \""+spec+"\"? "+ "Perhaps you meant \"0 "+spec.substring(spec.indexOf(' ')+1)+"\""; // once we find a sparse rank, upper ranks don't matter return null; } } } return null; }
/** * Checks if this crontab entry looks reasonable, and if not, return an * warning message. * * <p> The point of this method is to catch syntactically correct but * semantically suspicious combinations, like "* 0 * * *" */ public String checkSanity() { for (int i = 0; i < 5; i++) { long bitMask = (i < 4) ? bits[i] : (long) dayOfWeek; for (int j = LOWER_BOUNDS[i]; j <= UPPER_BOUNDS[i]; j++) { if (!checkBits(bitMask, j)) { // this rank has a sparse entry. // if we have a sparse rank, one of them better be the left-most. if (i > 0) { return "Do you really mean \"every minute\" when you say \"" + spec + "\"? " + "Perhaps you meant \"0 " + spec.substring(spec.indexOf(' ') + 1) + "\""; } // once we find a sparse rank, upper ranks don't matter return null; } } } return null; } // lower/uppser bounds of fields