KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > xml > CalendarBundle


1 /*
2  * Copyright 2004-2005 OpenSymphony
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  *
16  */

17
18 /*
19  * Previously Copyright (c) 2001-2004 James House
20  */

21 package org.quartz.xml;
22
23 import org.quartz.Calendar;
24
25 /**
26  * Wraps a <code>Calendar</code>.
27  *
28  * @author <a HREF="mailto:bonhamcm@thirdeyeconsulting.com">Chris Bonham</a>
29  */

30 public class CalendarBundle implements Calendar {
31     static final long serialVersionUID = 6970348562827644914L;
32     
33     /*
34      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35      *
36      * Data members.
37      *
38      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39      */

40      
41     protected String JavaDoc calendarName;
42
43     protected String JavaDoc className;
44     
45     protected Calendar calendar;
46     
47     protected boolean replace;
48
49     /*
50      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51      *
52      * Constructors.
53      *
54      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55      */

56
57     public CalendarBundle() {
58     }
59
60     /*
61      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62      *
63      * Interface.
64      *
65      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66      */

67
68     public String JavaDoc getCalendarName() {
69         return calendarName;
70     }
71
72     public void setCalendarName(String JavaDoc calendarName) {
73         this.calendarName = calendarName;
74     }
75     
76     public String JavaDoc getClassName() {
77         return className;
78     }
79
80     public void setClassName(String JavaDoc className)
81         throws ClassNotFoundException JavaDoc, InstantiationException JavaDoc, IllegalAccessException JavaDoc {
82         this.className = className;
83         createCalendar();
84     }
85
86     public Calendar getCalendar() {
87         return calendar;
88     }
89
90     public void setCalendar(Calendar calendar) {
91         this.calendar = calendar;
92     }
93     
94     public boolean getReplace() {
95         return replace;
96     }
97     
98     public void setReplace(boolean replace) {
99         this.replace = replace;
100     }
101     
102     public Calendar getBaseCalendar() {
103         return calendar.getBaseCalendar();
104     }
105     
106     public void setBaseCalendar(Calendar baseCalendar) {
107         if (baseCalendar instanceof CalendarBundle) {
108             baseCalendar = ((CalendarBundle)baseCalendar).getCalendar();
109         }
110         calendar.setBaseCalendar(baseCalendar);
111     }
112     
113     public String JavaDoc getDescription() {
114         return calendar.getDescription();
115     }
116
117     public void setDescription(String JavaDoc description) {
118         calendar.setDescription(description);
119     }
120     
121     public boolean isTimeIncluded(long timeStamp) {
122         return calendar.isTimeIncluded(timeStamp);
123     }
124
125     public long getNextIncludedTime(long timeStamp) {
126         return calendar.getNextIncludedTime(timeStamp);
127     }
128     
129     protected void createCalendar()
130         throws ClassNotFoundException JavaDoc, InstantiationException JavaDoc, IllegalAccessException JavaDoc {
131         Class JavaDoc clazz = Thread.currentThread().getContextClassLoader().loadClass(getClassName());
132         setCalendar((Calendar)clazz.newInstance());
133     }
134 }
135
Popular Tags