KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > schedules > ScheduleElement


1 package org.oddjob.schedules;
2
3 import java.io.Serializable JavaDoc;
4
5 import org.oddjob.arooa.ArooaConstants;
6 import org.oddjob.arooa.ArooaContext;
7 import org.oddjob.arooa.ArooaHandler;
8 import org.oddjob.arooa.handlers.ValueHandler;
9
10
11 /**
12  * This class is used both as a Type and as the nested
13  * Schedule elements.
14  *
15  * @oddjob.description A schedule type defines an Oddjob Schedule as
16  * used in the schedule and retry elements of
17  * {@link org.oddjob.scheduling.OJScheduleInstruction} and
18  * {@link org.oddjob.scheduling.RepeatJob}.
19  * <p>
20  * A schedule type supports the following elements:
21  * <ul>
22  * <li>{@link org.oddjob.schedules.schedules.AfterSchedule}</li>
23  * <li>{@link org.oddjob.schedules.schedules.BrokenSchedule}</li>
24  * <li>{@link org.oddjob.schedules.schedules.CountSchedule}</li>
25  * <li>{@link org.oddjob.schedules.schedules.DateSchedule}</li>
26  * <li>{@link org.oddjob.schedules.schedules.DayAfterSchedule}</li>
27  * <li>{@link org.oddjob.schedules.schedules.DayOfMonthSchedule}</li>
28  * <li>{@link org.oddjob.schedules.schedules.DayOfWeekSchedule}</li>
29  * <li>{@link org.oddjob.schedules.schedules.DayOfYearSchedule}</li>
30  * <li>{@link org.oddjob.schedules.schedules.IntervalSchedule}</li>
31  * <li>{@link org.oddjob.schedules.schedules.LastSchedule}</li>
32  * <li>{@link org.oddjob.schedules.schedules.MonthSchedule}</li>
33  * <li>{@link org.oddjob.schedules.schedules.NowSchedule}</li>
34  * <li>{@link org.oddjob.schedules.schedules.OccurrenceSchedule}</li>
35  * <li>{@link org.oddjob.schedules.schedules.TimeSchedule}</li>
36  * </ul>
37  *
38  * @author Rob Gordon
39  */

40 public class ScheduleElement implements Serializable JavaDoc, RefineableSchedule {
41     private static final long serialVersionUID = 20051123;
42     
43     /**
44      * @oddjob.element <i>Any schedule element</i>
45      * @oddjob.description Any number of schedule elements listed above.
46      * @oddjob.required Yes.
47      */

48     private ScheduleList schedules = new ScheduleList();
49
50     /**
51      * Provide our own handler. This provides a ValuesHandler configured
52      * with the ScheduleFactory and the tag 'schedule' which will use the
53      * method addValueSchedule to add child schedules.
54      *
55      * @param context The ArooaContext.
56      * @return The new handler.
57      */

58     public ArooaHandler handlerFor(ArooaContext context) {
59         // 'Schedule' to match addValueSchedule
60
ValueHandler handler = new ValueHandler("schedule");
61         handler.setValueFactory(new ScheduleFactory());
62         context.set(ArooaConstants.ELEMENT_HANDLER, handler);
63         return handler;
64     }
65
66     /*
67      * (non-Javadoc)
68      * @see org.treesched.Schedule#setLimits(org.treesched.Interval)
69      */

70     public void setLimits(Interval limits) {
71         schedules.setLimits(limits);
72     }
73     
74     /*
75      * (non-Javadoc)
76      * @see org.treesched.RefineableSchedule#addChildSchedule(org.treesched.Schedule)
77      */

78     public void addValueSchedule(Schedule schedule) {
79         schedules.addValueSchedule(schedule);
80     }
81     
82     /*
83      * (non-Javadoc)
84      * @see org.treesched.Schedule#nextDue(java.util.Date)
85      */

86     public Interval nextDue(ScheduleContext context) {
87         return schedules.nextDue(context);
88     }
89
90     /**
91      *
92      */

93     public String JavaDoc toString() {
94         return schedules.toString();
95     }
96 }
97
Popular Tags