1 package org.oddjob.schedules.schedules; 2 3 import java.io.Serializable ; 4 import java.util.Date ; 5 6 import org.apache.log4j.Logger; 7 import org.oddjob.schedules.AbstractSchedule; 8 import org.oddjob.schedules.DateUtils; 9 import org.oddjob.schedules.Interval; 10 import org.oddjob.schedules.Schedule; 11 import org.oddjob.schedules.ScheduleContext; 12 13 30 31 final public class AfterSchedule extends AbstractSchedule implements Serializable { 32 33 private static final long serialVersionUID = 20050226; 34 35 private static final Logger logger = Logger.getLogger(AfterSchedule.class); 36 37 public Interval nextDue(ScheduleContext context) { 38 Date now = context.getDate(); 39 if (getChildSchedule() == null) { 40 throw new IllegalStateException ("After must have a child schedule."); 41 } 42 43 logger.debug(this + ": in date is " + now); 44 45 Schedule child = getChildSchedule(); 46 child.setLimits(getLimits()); 47 Interval next = child.nextDue(context); 48 if (next == null) { 49 return null; 50 } 51 Date after = DateUtils.oneMillisAfter(next.getToDate()); 52 if (after == null) { 53 return null; 54 } 55 return new Interval(after, after); 56 } 57 } 58 | Popular Tags |