1   /*
2   
3    * Copyright 2001-2004 The Apache Software Foundation.
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */ 
17  
18  
19  package org.apache.commons.betwixt.examples.rss;
20  
21  import java.io.Serializable;
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  
26  /***
27   * <p>Implementation object representing a <strong>channel</strong> in the
28   * <em>Rich Site Summary</em> DTD, version 0.91.  This class may be subclassed
29   * to further specialize its behavior.</p>
30   *
31   * <p>Based on the Jakarta Commons <code>Digester</code> implementation.</p>
32   *
33   * @author Craig R. McClanahan
34   * @author Ted Husted
35   * @version $Revision: 155402 $ $Date: 2005-02-26 12:52:00 +0000 (Sat, 26 Feb 2005) $
36   */
37  
38  public class Channel implements Serializable {
39  
40  
41      // ----------------------------------------------------- Instance Variables
42  
43  
44      /***
45       * The set of items associated with this Channel.
46       */
47      protected ArrayList items = new ArrayList();
48  
49  
50      /***
51       * The set of skip days for this channel.
52       */
53      protected ArrayList skipDays = new ArrayList();
54  
55  
56      /***
57       * The set of skip hours for this channel.
58       */
59      protected ArrayList skipHours = new ArrayList();
60  
61  
62      // ------------------------------------------------------------- Properties
63  
64  
65      /***
66       * The channel copyright (1-100 characters).
67       */
68      protected String copyright = null;
69  
70      public String getCopyright() {
71          if (this.copyright == null) {
72              return "Public Domain";
73          } else {
74              return (this.copyright);
75          }
76      }
77  
78      public void setCopyright(String copyright) {
79          this.copyright = copyright;
80      }
81  
82  
83      /***
84       * The channel description (1-500 characters).
85       */
86      protected String description = null;
87  
88      public String getDescription() {
89          return (this.description);
90      }
91  
92      public void setDescription(String description) {
93          this.description = description;
94      }
95  
96  
97      /***
98       * The channel description file URL (1-500 characters).
99       */
100     protected String docs = null;
101 
102     public String getDocs() {
103         return (this.docs);
104     }
105 
106     public void setDocs(String docs) {
107         this.docs = docs;
108     }
109 
110 
111     /***
112      * The image describing this channel.
113      */
114     protected Image image = null;
115 
116     public Image getImage() {
117         return (this.image);
118     }
119 
120     public void setImage(Image image) {
121         this.image = image;
122     }
123 
124 
125     /***
126      * The channel language (2-5 characters).
127      */
128     protected String language = null;
129 
130     public String getLanguage() {
131         return (this.language);
132     }
133 
134     public void setLanguage(String language) {
135         this.language = language;
136     }
137 
138 
139     /***
140      * The channel last build date (1-100 characters).
141      */
142     protected String lastBuildDate = null;
143 
144     public String getLastBuildDate() {
145         return (this.lastBuildDate);
146     }
147 
148     public void setLastBuildDate(String lastBuildDate) {
149         this.lastBuildDate = lastBuildDate;
150     }
151 
152 
153     /***
154      * The channel link (1-500 characters).
155      */
156     protected String link = null;
157 
158     public String getLink() {
159         return (this.link);
160     }
161 
162     public void setLink(String link) {
163         this.link = link;
164     }
165 
166 
167     /***
168      * The managing editor (1-100 characters).
169      */
170     protected String managingEditor = null;
171 
172     public String getManagingEditor() {
173         return (this.managingEditor);
174     }
175 
176     public void setManagingEditor(String managingEditor) {
177         this.managingEditor = managingEditor;
178     }
179 
180 
181     /***
182      * The channel publication date (1-100 characters).
183      */
184     protected String pubDate = null;
185 
186     public String getPubDate() {
187         return (this.pubDate);
188     }
189 
190     public void setPubDate(String pubDate) {
191         this.pubDate = pubDate;
192     }
193 
194 
195     /***
196      * The channel rating (20-500 characters).
197      */
198     protected String rating = null;
199 
200     public String getRating() {
201         return (this.rating);
202     }
203 
204     public void setRating(String rating) {
205         this.rating = rating;
206     }
207 
208 
209     /***
210      * The text input description for this channel.
211      */
212     protected TextInput textInput = null;
213 
214     public TextInput getTextInput() {
215         return (this.textInput);
216     }
217 
218     public void setTextInput(TextInput textInput) {
219         this.textInput = textInput;
220     }
221 
222 
223     /***
224      * The channel title (1-100 characters).
225      */
226     protected String title = null;
227 
228     public String getTitle() {
229         return (this.title);
230     }
231 
232     public void setTitle(String title) {
233         this.title = title;
234     }
235 
236 
237     /***
238      * The RSS specification version number used to create this Channel.
239      */
240     protected double version = 0.91;
241 
242     public double getVersion() {
243         return (this.version);
244     }
245 
246     public void setVersion(double version) {
247         this.version = version;
248     }
249 
250 
251     /***
252      * The webmaster email address (1-100 characters).
253      */
254     protected String webMaster = null;
255 
256     public String getWebMaster() {
257         return (this.webMaster);
258     }
259 
260     public void setWebMaster(String webMaster) {
261         this.webMaster = webMaster;
262     }
263 
264 
265     // --------------------------------------------------------- Public Methods
266 
267 
268     /***
269      * Add an additional item.
270      *
271      * @param item The item to be added
272      */
273     public void addItem(Item item) {
274         synchronized (items) {
275             items.add(item);
276         }
277     }
278 
279 
280     /***
281      * Add an additional skip day name.
282      *
283      * @param skipDay The skip day to be added
284      */
285     public void addSkipDay(String skipDay) {
286         synchronized (skipDays) {
287             skipDays.add(skipDay);
288         }
289     }
290 
291 
292     /***
293      * Add an additional skip hour name.
294      *
295      * @param skipHour The skip hour to be added
296      */
297     public void addSkipHour(String skipHour) {
298         synchronized (skipHours) {
299             skipHours.add(skipHour);
300         }
301     }
302 
303     /***
304      * Return the items for this channel.
305      */
306     public List getItems() {
307         return items;
308     }
309 
310 
311     /***
312      * Return the skip days for this channel.
313      */
314     public String[] findSkipDays() {
315         synchronized (skipDays) {
316             String skipDays[] = new String[this.skipDays.size()];
317             return ((String[]) this.skipDays.toArray(skipDays));
318         }
319     }
320 
321 
322     /***
323      * Return the skip hours for this channel.
324      */
325     public String[] getSkipHours() {
326         return findSkipHours();
327     }
328 
329 
330     /***
331      * Return the skip hours for this channel.
332      */
333     public String[] findSkipHours() {
334         synchronized (skipHours) {
335             String skipHours[] = new String[this.skipHours.size()];
336             return ((String[]) this.skipHours.toArray(skipHours));
337         }
338     }
339 
340 
341     /***
342      * Return the skip days for this channel.
343      */
344     public String[] getSkipDays() {
345         return findSkipDays();
346     }
347 
348 
349     /***
350      * Remove an item for this channel.
351      *
352      * @param item The item to be removed
353      */
354     public void removeItem(Item item) {
355         synchronized (items) {
356             items.remove(item);
357         }
358     }
359 
360 
361     /***
362      * Remove a skip day for this channel.
363      *
364      * @param skipDay The skip day to be removed
365      */
366     public void removeSkipDay(String skipDay) {
367         synchronized (skipDays) {
368             skipDays.remove(skipDay);
369         }
370     }
371 
372 
373     /***
374      * Remove a skip hour for this channel.
375      *
376      * @param skipHour The skip hour to be removed
377      */
378     public void removeSkipHour(String skipHour) {
379         synchronized (skipHours) {
380             skipHours.remove(skipHour);
381         }
382     }
383 }