View Javadoc

1   /*
2    * Copyright 2004 Sun Microsystems, Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy 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,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   */
17  package com.sun.syndication.feed.rss;
18  
19  import com.sun.syndication.feed.WireFeed;
20  import com.sun.syndication.common.Enum;
21  
22  import java.util.ArrayList;
23  import java.util.Date;
24  import java.util.List;
25  
26  /***
27   * Bean for RSS feeds.
28   * <p>
29   * It handles all RSS versions (0.9, 0.91, 0.92, 0.93, 0.94, 1.0 and 2.0)
30   * without loosing information.
31   * <p>
32   * @author Alejandro Abdelnur
33   *
34   */
35  public class Channel extends WireFeed {
36  
37      /***
38       * Enumeration type for the 'skipDays' property of RSS Channels.
39       * <p>
40       * @author Alejandro Abdelnur
41       *
42       */
43      public static class Day extends Enum {
44          private Day(String name) {
45              super(name);
46          }
47      }
48  
49      public static final Day SUNDAY = new Day("sunday");
50      public static final Day MONDAY = new Day("monday");
51      public static final Day TUESDAY = new Day("tuesday");
52      public static final Day WEDNESDAY = new Day("wednesday");
53      public static final Day THURSDAY = new Day("thursday");
54      public static final Day FRIDAY = new Day("friday");
55      public static final Day SATURDAY = new Day("saturday");
56  
57  
58      private String _title;
59      private String _description;
60      private String _link;
61      private Image _image;
62      private List _items;
63      private TextInput _textInput;
64      private String _language;
65      private String _rating;
66      private String _copyright;
67      private Date _pubDate;
68      private Date _lastBuildDate;
69      private String _docs;
70      private String _managingEditor;
71      private String _webMaster;
72      private List _skipHours;
73      private List _skipDays;
74      private Cloud _cloud;
75      private List _categories;
76      private String _generator;
77      private int _ttl = -1;
78      private List _modules;
79  
80      /***
81       * Default constructor, for bean cloning purposes only.
82       *
83       */
84      public Channel() {
85          super();
86      }
87  
88      /***
89       * Channel Constructor. All properties, except the type, are set to <b>null</b>.
90       * <p>
91       * @param type the type of the RSS feed.
92       *
93       */
94      public Channel(String type) {
95          super(type);
96      }
97  
98      /***
99       * Returns the channel title.
100      * <p>
101      * @return the channel title, <b>null</b> if none.
102      *
103      */
104     public String getTitle() {
105         return _title;
106     }
107 
108     /***
109      * Sets the channel title.
110      * <p>
111      * @param title the channel title to set, <b>null</b> if none.
112      *
113      */
114     public void setTitle(String title) {
115         _title = title;
116     }
117 
118     /***
119      * Returns the channel description.
120      * <p>
121      * @return the channel description, <b>null</b> if none.
122      *
123      */
124     public String getDescription() {
125         return _description;
126     }
127 
128     /***
129      * Sets the channel description.
130      * <p>
131      * @param description the channel description to set, <b>null</b> if none.
132      *
133      */
134     public void setDescription(String description) {
135         _description = description;
136     }
137 
138     /***
139      * Returns the channel link.
140      * <p>
141      * @return the channel link, <b>null</b> if none.
142      *
143      */
144     public String getLink() {
145         return _link;
146     }
147 
148     /***
149      * Sets the channel link.
150      * <p>
151      * @param link the channel link to set, <b>null</b> if none.
152      *
153      */
154     public void setLink(String link) {
155         _link = link;
156     }
157 
158     /***
159      * Returns the channel image.
160      * <p>
161      * @return the channel image, <b>null</b> if none.
162      *
163      */
164     public Image getImage() {
165         return _image;
166     }
167 
168     /***
169      * Sets the channel image.
170      * <p>
171      * @param image the channel image to set, <b>null</b> if none.
172      *
173      */
174     public void setImage(Image image) {
175         _image = image;
176     }
177 
178     /***
179      * Returns the channel items.
180      * <p>
181      * @return a list of Item elements with the channel items,
182      *         an empty list if none.
183      *
184      */
185     public List getItems() {
186         return (_items==null) ? (_items=new ArrayList()) : _items;
187     }
188 
189     /***
190      * Sets the channel items.
191      * <p>
192      * @param items the list of Item elements with the channel items to set,
193      *        an empty list or <b>null</b> if none.
194      *
195      */
196     public void setItems(List items) {
197         _items = items;
198     }
199 
200     /***
201      * Returns the channel text input.
202      * <p>
203      * @return the channel text input, <b>null</b> if none.
204      *
205      */
206     public TextInput getTextInput() {
207         return _textInput;
208     }
209 
210     /***
211      * Sets the channel text input.
212      * <p>
213      * @param textInput the channel text input to set, <b>null</b> if none.
214      *
215      */
216     public void setTextInput(TextInput textInput) {
217         _textInput = textInput;
218     }
219 
220     /***
221      * Returns the channel language.
222      * <p>
223      * @return the channel language, <b>null</b> if none.
224      *
225      */
226     public String getLanguage() {
227         return _language;
228     }
229 
230     /***
231      * Sets the channel language.
232      * <p>
233      * @param language the channel language to set, <b>null</b> if none.
234      *
235      */
236     public void setLanguage(String language) {
237         _language = language;
238     }
239 
240     /***
241      * Returns the channel rating.
242      * <p>
243      * @return the channel rating, <b>null</b> if none.
244      *
245      */
246     public String getRating() {
247         return _rating;
248     }
249 
250     /***
251      * Sets the channel rating.
252      * <p>
253      * @param rating the channel rating to set, <b>null</b> if none.
254      *
255      */
256     public void setRating(String rating) {
257         _rating = rating;
258     }
259 
260     /***
261      * Returns the channel copyright.
262      * <p>
263      * @return the channel copyright, <b>null</b> if none.
264      *
265      */
266     public String getCopyright() {
267         return _copyright;
268     }
269 
270     /***
271      * Sets the channel copyright.
272      * <p>
273      * @param copyright the channel copyright to set, <b>null</b> if none.
274      *
275      */
276     public void setCopyright(String copyright) {
277         _copyright = copyright;
278     }
279 
280     /***
281      * Returns the channel publishing date.
282      * <p>
283      * @return the channel publishing date, <b>null</b> if none.
284      *
285      */
286     public Date getPubDate() {
287         return _pubDate;
288     }
289 
290     /***
291      * Sets the channel publishing date.
292      * <p>
293      * @param pubDate the channel publishing date to set, <b>null</b> if none.
294      *
295      */
296     public void setPubDate(Date pubDate) {
297         _pubDate = pubDate;
298     }
299 
300     /***
301      * Returns the channel last build date.
302      * <p>
303      * @return the channel last build date, <b>null</b> if none.
304      *
305      */
306     public Date getLastBuildDate() {
307         return _lastBuildDate;
308     }
309 
310     /***
311      * Sets the channel last build date.
312      * <p>
313      * @param lastBuildDate the channel last build date to set, <b>null</b> if none.
314      *
315      */
316     public void setLastBuildDate(Date lastBuildDate) {
317         _lastBuildDate = lastBuildDate;
318     }
319 
320     /***
321      * Returns the channel docs.
322      * <p>
323      * @return the channel docs, <b>null</b> if none.
324      *
325      */
326     public String getDocs() {
327         return _docs;
328     }
329 
330     /***
331      * Sets the channel docs.
332      * <p>
333      * @param docs the channel docs to set, <b>null</b> if none.
334      *
335      */
336     public void setDocs(String docs) {
337         _docs = docs;
338     }
339 
340     /***
341      * Returns the channel managing editor.
342      * <p>
343      * @return the channel managing editor, <b>null</b> if none.
344      *
345      */
346     public String getManagingEditor() {
347         return _managingEditor;
348     }
349 
350     /***
351      * Sets the channel managing editor.
352      * <p>
353      * @param managingEditor the channel managing editor to set, <b>null</b> if none.
354      *
355      */
356     public void setManagingEditor(String managingEditor) {
357         _managingEditor = managingEditor;
358     }
359 
360     /***
361      * Returns the channel web master.
362      * <p>
363      * @return the channel web master, <b>null</b> if none.
364      *
365      */
366     public String getWebMaster() {
367         return _webMaster;
368     }
369 
370     /***
371      * Sets the channel web master.
372      * <p>
373      * @param webMaster the channel web master to set, <b>null</b> if none.
374      *
375      */
376     public void setWebMaster(String webMaster) {
377         _webMaster = webMaster;
378     }
379 
380     /***
381      * Returns the channel skip hours.
382      * <p>
383      * @return a list of Integer elements with the channel skip hours,
384      *         an empty list if none.
385      *
386      */
387     public List getSkipHours() {
388         return (_skipHours!=null) ? _skipHours : new ArrayList();
389     }
390 
391     /***
392      * Sets the channel skip hours.
393      * <p>
394      * @param skipHours the list of Integer elements with the channel skip hours to set,
395      *        an empty list or <b>null</b> if none.
396      *
397      */
398     public void setSkipHours(List skipHours) {
399         _skipHours = skipHours;
400     }
401 
402     /***
403      * Returns the channel skip days.
404      * <p>
405      * @return a list of Day elements with the channel skip days,
406      *         an empty list if none.
407      *
408      */
409     public List getSkipDays() {
410         return (_skipDays!=null) ? _skipDays : new ArrayList();
411     }
412 
413     /***
414      * Sets the channel skip days.
415      * <p>
416      * @param skipDays the list of Day elements with the channel skip days to set,
417      *        an empty list or <b>null</b> if none.
418      *
419      */
420     public void setSkipDays(List skipDays) {
421         _skipDays = skipDays;
422     }
423 
424     /***
425      * Returns the channel cloud.
426      * <p>
427      * @return the channel cloud, <b>null</b> if none.
428      *
429      */
430     public Cloud getCloud() {
431         return _cloud;
432     }
433 
434     /***
435      * Sets the channel cloud.
436      * <p>
437      * @param cloud the channel cloud to set, <b>null</b> if none.
438      *
439      */
440     public void setCloud(Cloud cloud) {
441         _cloud = cloud;
442     }
443 
444     /***
445      * Returns the channel categories.
446      * <p>
447      * @return a list of Category elements with the channel categories,
448      *         an empty list if none.
449      *
450      */
451     public List getCategories() {
452         return (_categories==null) ? (_categories=new ArrayList()) : _categories;
453     }
454 
455     /***
456      * Sets the channel categories.
457      * <p>
458      * @param categories the list of Category elements with the channel categories to set,
459      *        an empty list or <b>null</b> if none.
460      *
461      */
462     public void setCategories(List categories) {
463         _categories = categories;
464     }
465 
466     /***
467      * Returns the channel generator.
468      * <p>
469      * @return the channel generator, <b>null</b> if none.
470      *
471      */
472     public String getGenerator() {
473         return _generator;
474     }
475 
476     /***
477      * Sets the channel generator.
478      * <p>
479      * @param generator the channel generator to set, <b>null</b> if none.
480      *
481      */
482     public void setGenerator(String generator) {
483         _generator = generator;
484     }
485 
486     /***
487      * Returns the channel time to live.
488      * <p>
489      * @return the channel time to live, <b>null</b> if none.
490      *
491      */
492     public int getTtl() {
493         return _ttl;
494     }
495 
496     /***
497      * Sets the channel time to live.
498      * <p>
499      * @param ttl the channel time to live to set, <b>null</b> if none.
500      *
501      */
502     public void setTtl(int ttl) {
503         _ttl = ttl;
504     }
505 
506     /***
507      * Returns the channel modules.
508      * <p>
509      * @return a list of Module elements with the channel modules,
510      *         an empty list if none.
511      *
512      */
513     public List getModules() {
514         return (_modules==null) ? (_modules=new ArrayList()) : _modules;
515     }
516 
517     /***
518      * Sets the channel modules.
519      * <p>
520      * @param modules the list of Module elements with the channel modules to set,
521      *        an empty list or <b>null</b> if none.
522      *
523      */
524     public void setModules(List modules) {
525         _modules = modules;
526     }
527 
528 }