Date: 10/06/05 (Code WTF) Keywords: no keywords /** * What schedule am I on? * * I know this is kinda ugly! If you can think of a cleaner way * to do this, please jump in! * * @return A number specifying the type of schedule. See * calcRunTime(). * @exception Exception, a generic exception. */ private int evaluateJobType() throws Exception { // First start by checking if it's a day of the month job. if ( day_of_month < 0 ) { // Not a day of the month job... check weekday. if ( weekday < 0 ) { // Not a weekday job...check if by the hour. if ( hour < 0 ) { // Not an hourly job...check if it is by the minute if ( minute < 0 ) { // Not a by the minute job so must be by the second if ( second < 0) throw new Exception("Error in JobEntry. Bad Job parameter."); return SECOND; } else { // Must be a job run by the minute so we need minutes and // seconds. if ( minute < 0 || second < 0 ) throw new Exception("Error in JobEntry. Bad Job parameter."); return MINUTE; } } else { // Must be a daily job by hours minutes, and seconds. In // this case, we need the minute, second, and hour params. if ( minute < 0 || hour < 0 || second < 0) throw new Exception("Error in JobEntry. Bad Job parameter."); return DAILY; } } else { // Must be a weekday job. In this case, we need // minute, second, and hour params if ( minute < 0 || hour < 0 || second < 0 ) throw new Exception("Error in JobEntry. Bad Job parameter."); return WEEK_DAY; } } else { // Must be a day of the month job. In this case, we need // minute, second, and hour params if ( minute < 0 || hour < 0 ) throw new Exception("Error in JobEntry. Bad Job parameter."); return DAY_OF_MONTH; } } Source: http://www.livejournal.com/community/code_wtf/16294.html
|