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