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.atom;
18  
19  import com.sun.syndication.feed.WireFeed;
20  import com.sun.syndication.feed.module.Module;
21  import com.sun.syndication.feed.module.impl.ModuleUtils;
22  
23  import java.util.ArrayList;
24  import java.util.Date;
25  import java.util.List;
26  
27  /***
28   * Bean for Atom feeds.
29   * <p>
30   * It handles Atom feeds version 0.3 without loosing any feed information.
31   * <p>
32   * @author Alejandro Abdelnur
33   * @author Dave Johnson (updated for Atom 1.0)
34   */
35  public class Feed extends WireFeed {
36      
37      private String    _xmlBase;
38      private List      _categories;    
39      private List      _authors; 
40      private List      _contributors;
41      private Generator _generator;
42      private String    _icon;       
43      private String    _id;
44      private String    _logo;
45      private String    _rights;         // AKA copyright
46      private Content   _subtitle;       // AKA tagline   
47      private String    _title;
48      private Date      _updated;        // AKA modified
49      private List      _alternateLinks; 
50      private List      _otherLinks;    
51      private List      _entries;
52      
53      private List      _modules;
54     
55      private Content   _info;           // Atom 0.3 only
56      private String    _language;       // Atom 0.3 only
57  
58      /***
59       * Default constructor, for bean cloning purposes only.
60       *
61       */
62      public Feed() {
63      }
64  
65      /***
66       * Feed Constructor. All properties, except the type, are set to <b>null</b>.
67       * <p>
68       * @param type the type of the Atom feed.
69       *
70       */
71      public Feed(String type) {
72          super(type);
73      }
74  
75      /***
76       * Returns the feed language (Atom 0.3 only)
77       * <p>
78       * @return the feed language, <b>null</b> if none.
79       *
80       */
81      public String getLanguage() {
82          return _language;
83      }
84  
85      /***
86       * Sets the feed language (Atom 0.3 only)
87       * <p>
88       * @param language the feed language to set, <b>null</b> if none.
89       *
90       */
91      public void setLanguage(String language) {
92          _language = language;
93      }
94  
95      /***
96       * Returns the feed title.
97       * <p>
98       * @return the feed title, <b>null</b> if none.
99       *
100      */
101     public String getTitle() {
102         return _title;
103     }
104 
105     /***
106      * Sets the feed title.
107      * <p>
108      * @param title the feed title to set, <b>null</b> if none.
109      *
110      */
111     public void setTitle(String title) {
112         _title = title;
113     }
114 
115     /***
116      * Returns the feed alternate links.
117      * <p>
118      * @return a list of Link elements with the feed alternate links,
119      *         an empty list if none.
120      */
121     public List getAlternateLinks() {
122         return (_alternateLinks==null) ? (_alternateLinks=new ArrayList()) : _alternateLinks;
123     }
124 
125     /***
126      * Sets the feed alternate links.
127      * <p>
128      * @param alternateLinks the list of Link elements with the feed alternate links to set,
129      *        an empty list or <b>null</b> if none.
130      */
131     public void setAlternateLinks(List alternateLinks) {
132         _alternateLinks = alternateLinks;
133     }
134 
135     /***
136      * Returns the feed other links (non-alternate ones).
137      * <p>
138      * @return a list of Link elements with the feed other links (non-alternate ones),
139      *         an empty list if none.
140      */
141     public List getOtherLinks() {
142         return (_otherLinks==null) ? (_otherLinks=new ArrayList()) : _otherLinks;
143     }
144 
145     /***
146      * Sets the feed other links (non-alternate ones).
147      * <p>
148      * @param otherLinks the list of Link elements with the feed other links (non-alternate ones) to set,
149      *        an empty list or <b>null</b> if none.
150      */
151     public void setOtherLinks(List otherLinks) {
152         _otherLinks = otherLinks;
153     }
154 
155     /***
156      * Returns the feed author.
157      * <p>
158      * @return the feed author, <b>null</b> if none.
159      * 
160      */
161     public List getAuthors() {
162         return (_authors==null) ? (_authors=new ArrayList()) : _authors;
163     }
164 
165     /***
166      * Sets the feed author.
167      * <p>
168      * @param author the feed author to set, <b>null</b> if none.
169      * 
170      */
171     public void setAuthors(List authors) {
172         _authors = authors;
173     }
174 
175     /***
176      * Returns the feed contributors.
177      * <p>
178      * @return a list of Person elements with the feed contributors,
179      *         an empty list if none.
180      *
181      */
182     public List getContributors() {
183         return (_contributors==null) ? (_contributors=new ArrayList()) : _contributors;
184     }
185 
186     /***
187      * Sets the feed contributors.
188      * <p>
189      * @param contributors the list of Person elements with the feed contributors to set,
190      *        an empty list or <b>null</b> if none.
191      *
192      */
193     public void setContributors(List contributors) {
194         _contributors = contributors;
195     }
196 
197     /***
198      * Returns the feed tag line (Atom 0.3, maps to {@link getSubtitle()}).
199      * <p>
200      * @return the feed tag line, <b>null</b> if none.
201      */
202     public Content getTagline() {
203         return _subtitle;
204     }
205 
206     /***
207      * Sets the feed tagline (Atom 0.3, maps to {@link getSubtitle()}).
208      * <p>
209      * @param tagline the feed tagline to set, <b>null</b> if none.
210      */
211     public void setTagline(Content tagline) {
212         _subtitle = tagline;
213     }
214 
215     /***
216      * Returns the feed ID.
217      * <p>
218      * @return the feed ID, <b>null</b> if none.
219      *
220      */
221     public String getId() {
222         return _id;
223     }
224 
225     /***
226      * Sets the feed ID.
227      * <p>
228      * @param id the feed ID to set, <b>null</b> if none.
229      *
230      */
231     public void setId(String id) {
232         _id = id;
233     }
234 
235     /***
236      * Returns the feed generator.
237      * <p>
238      * @return the feed generator, <b>null</b> if none.
239      *
240      */
241     public Generator getGenerator() {
242         return _generator;
243     }
244 
245     /***
246      * Sets the feed generator.
247      * <p>
248      * @param generator the feed generator to set, <b>null</b> if none.
249      *
250      */
251     public void setGenerator(Generator generator) {
252         _generator = generator;
253     }
254 
255     /***
256      * Returns the feed copyright (Atom 0.3, maps to {@link getRights()}).
257      * <p>
258      * @return the feed copyright, <b>null</b> if none.
259      */
260     public String getCopyright() {
261         return _rights;
262     }
263 
264     /***
265      * Sets the feed copyright (Atom 0.3, maps to {@link setRights()}).
266      * <p>
267      * @param copyright the feed copyright to set, <b>null</b> if none.
268      */
269     public void setCopyright(String copyright) {
270         _rights = copyright;
271     }
272 
273     /***
274      * Returns the feed info (Atom 0.3 only)
275      * <p>
276      * @return the feed info, <b>null</b> if none.
277      */
278     public Content getInfo() {
279         return _info;
280     }
281 
282     /***
283      * Sets the feed info (Atom 0.3 only)
284      * <p>
285      * @param info the feed info to set, <b>null</b> if none.
286      */
287     public void setInfo(Content info) {
288         _info = info;
289     }
290 
291     /***
292      * Returns the feed modified date (Atom 0.3, maps to {@link getUpdated()}).
293      * <p>
294      * @return the feed modified date, <b>null</b> if none.
295      */
296     public Date getModified() {
297         return _updated;
298     }
299 
300     /***
301      * Sets the feed modified date (Atom 0.3, maps to {@link setUpdated()}).
302      * <p>
303      * @param modified the feed modified date to set, <b>null</b> if none.
304      */
305     public void setModified(Date modified) {
306         _updated = modified;
307     }
308 
309     /***
310      * Returns the feed entries.
311      * <p>
312      * @return a list of Entry elements with the feed entries,
313      *         an empty list if none.
314      *
315      */
316     public List getEntries() {
317         return (_entries==null) ? (_entries=new ArrayList()) : _entries;
318     }
319 
320     /***
321      * Sets the feed entries.
322      * <p>
323      * @param entries the list of Entry elements with the feed entries to set,
324      *        an empty list or <b>null</b> if none.
325      *
326      */
327     public void setEntries(List entries) {
328         _entries = entries;
329     }
330 
331     /***
332      * Returns the feed modules.
333      * <p>
334      * @return a list of ModuleImpl elements with the feed modules,
335      *         an empty list if none.
336      *
337      */
338     public List getModules() {
339         return (_modules==null) ? (_modules=new ArrayList()) : _modules;
340     }
341 
342     /***
343      * Sets the feed moduless.
344      * <p>
345      * @param modules the list of ModuleImpl elements with the feed moduless to set,
346      *        an empty list or <b>null</b> if none.
347      *
348      */
349     public void setModules(List modules) {
350         _modules = modules;
351     }
352 
353     /***
354      * Returns the module identified by a given URI.
355      * <p>
356      * @param uri the URI of the ModuleImpl.
357      * @return The module with the given URI, <b>null</b> if none.
358      */
359     public Module getModule(String uri) {
360         return ModuleUtils.getModule(_modules,uri);
361     }
362 
363     /***
364      * Returns the categories
365      * <p>
366      * @return Returns the categories.
367      * @since Atom 1.0
368      */
369     public List getCategories() {
370         return _categories;
371     }
372     
373     /***
374      * Set the categories
375      * <p>
376      * @param categories The categories to set.
377      * @since Atom 1.0
378      */
379     public void setCategories(List categories) {
380         _categories = categories;
381     }
382     
383     /***
384      * Returns the icon
385      * <p>
386      * @return Returns the icon.
387      * @since Atom 1.0
388      */
389     public String getIcon() {
390         return _icon;
391     }
392     
393     /***
394      * Set the icon
395      * <p>
396      * @param icon The icon to set.
397      * @since Atom 1.0
398      */
399     public void setIcon(String icon) {
400         _icon = icon;
401     }
402         
403     /***
404      * Returns the logo
405      * <p>
406      * @return Returns the logo.
407      * @since Atom 1.0
408      */
409     public String getLogo() {
410         return _logo;
411     }
412     
413     /***
414      * Set the logo
415      * <p>
416      * @param logo The logo to set.
417      * @since Atom 1.0
418      */
419     public void setLogo(String logo) {
420         _logo = logo;
421     }
422     
423     /***
424      * Returns the rights
425      * <p>
426      * @return Returns the rights.
427      * @since Atom 1.0
428      */
429     public String getRights() {
430         return _rights;
431     }
432     
433     /***
434      * Set the rights
435      * <p>
436      * @param rights The rights to set.
437      * @since Atom 1.0
438      */
439     public void setRights(String rights) {
440         _rights = rights;
441     }
442     
443     /***
444      * Returns the subtitle
445      * <p>
446      * @return Returns the subtitle.
447      * @since Atom 1.0
448      */ 
449     public Content getSubtitle() {
450         return _subtitle;
451     }
452     
453     /***
454      * Set the subtitle
455      * <p>
456      * @param subtitle The subtitle to set.
457      * @since Atom 1.0
458      */
459     public void setSubtitle(Content subtitle) {
460         _subtitle = subtitle;
461     }
462     
463     /***
464      * Returns the updated
465      * <p>
466      * @return Returns the updated.
467      * @since Atom 1.0
468      */
469     public Date getUpdated() {
470         return _updated;
471     }
472     
473     /***
474      * Set the updated
475      * <p>
476      * @param updated The updated to set.
477      * @since Atom 1.0
478      */
479     public void setUpdated(Date updated) {
480         _updated = updated;
481     }
482 
483     /***
484      * Returns the xmlBase
485      * <p>
486      * @return Returns the xmlBase.
487      * @since Atom 1.0
488      */
489     public String getXmlBase() {
490         return _xmlBase;
491     }
492     
493     /***
494      * Set the xmlBase
495      * <p>
496      * @param xmlBase The xmlBase to set.
497      * @since Atom 1.0
498      */
499     public void setXmlBase(String xmlBase) {
500         _xmlBase = xmlBase;
501     }
502 }
503