001: /*
002: * Copyright 2004 Sun Microsystems, Inc.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: *
016: */
017: package com.sun.syndication.feed.atom;
018:
019: import com.sun.syndication.feed.WireFeed;
020: import com.sun.syndication.feed.module.Module;
021: import com.sun.syndication.feed.module.impl.ModuleUtils;
022:
023: import java.util.ArrayList;
024: import java.util.Date;
025: import java.util.List;
026:
027: /**
028: * Bean for Atom feeds.
029: * <p>
030: * It handles Atom feeds version 0.3 without loosing any feed information.
031: * <p>
032: * @author Alejandro Abdelnur
033: * @author Dave Johnson (updated for Atom 1.0)
034: */
035: public class Feed extends WireFeed {
036:
037: private String _xmlBase;
038: private List _categories;
039: private List _authors;
040: private List _contributors;
041: private Generator _generator;
042: private String _icon;
043: private String _id;
044: private String _logo;
045: private String _rights; // AKA copyright
046: private Content _subtitle; // AKA tagline
047: private Content _title;
048: private Date _updated; // AKA modified
049: private List _alternateLinks;
050: private List _otherLinks;
051: private List _entries;
052:
053: private List _modules;
054:
055: private Content _info; // Atom 0.3 only
056: private String _language; // Atom 0.3 only
057:
058: /**
059: * Default constructor, for bean cloning purposes only.
060: *
061: */
062: public Feed() {
063: }
064:
065: /**
066: * Feed Constructor. All properties, except the type, are set to <b>null</b>.
067: * <p>
068: * @param type the type of the Atom feed.
069: *
070: */
071: public Feed(String type) {
072: super (type);
073: }
074:
075: /**
076: * Returns the feed language (Atom 0.3 only)
077: * <p>
078: * @return the feed language, <b>null</b> if none.
079: *
080: */
081: public String getLanguage() {
082: return _language;
083: }
084:
085: /**
086: * Sets the feed language (Atom 0.3 only)
087: * <p>
088: * @param language the feed language to set, <b>null</b> if none.
089: *
090: */
091: public void setLanguage(String language) {
092: _language = language;
093: }
094:
095: /**
096: * Returns the feed title.
097: * <p>
098: * @return the feed title, <b>null</b> if none.
099: *
100: */
101: public String getTitle() {
102: if (_title != null)
103: return _title.getValue();
104: return null;
105: }
106:
107: /**
108: * Sets the feed title.
109: * <p>
110: * @param title the feed title to set, <b>null</b> if none.
111: *
112: */
113: public void setTitle(String title) {
114: if (_title == null)
115: _title = new Content();
116: _title.setValue(title);
117: }
118:
119: /**
120: * Returns the feed title.
121: * <p>
122: * @return the feed title, <b>null</b> if none.
123: *
124: */
125: public Content getTitleEx() {
126: return _title;
127: }
128:
129: /**
130: * Sets the feed title.
131: * <p>
132: * @param title the feed title to set, <b>null</b> if none.
133: *
134: */
135: public void setTitleEx(Content title) {
136: _title = title;
137: }
138:
139: /**
140: * Returns the feed alternate links.
141: * <p>
142: * @return a list of Link elements with the feed alternate links,
143: * an empty list if none.
144: */
145: public List getAlternateLinks() {
146: return (_alternateLinks == null) ? (_alternateLinks = new ArrayList())
147: : _alternateLinks;
148: }
149:
150: /**
151: * Sets the feed alternate links.
152: * <p>
153: * @param alternateLinks the list of Link elements with the feed alternate links to set,
154: * an empty list or <b>null</b> if none.
155: */
156: public void setAlternateLinks(List alternateLinks) {
157: _alternateLinks = alternateLinks;
158: }
159:
160: /**
161: * Returns the feed other links (non-alternate ones).
162: * <p>
163: * @return a list of Link elements with the feed other links (non-alternate ones),
164: * an empty list if none.
165: */
166: public List getOtherLinks() {
167: return (_otherLinks == null) ? (_otherLinks = new ArrayList())
168: : _otherLinks;
169: }
170:
171: /**
172: * Sets the feed other links (non-alternate ones).
173: * <p>
174: * @param otherLinks the list of Link elements with the feed other links (non-alternate ones) to set,
175: * an empty list or <b>null</b> if none.
176: */
177: public void setOtherLinks(List otherLinks) {
178: _otherLinks = otherLinks;
179: }
180:
181: /**
182: * Returns the feed author.
183: * <p>
184: * @return the feed author, <b>null</b> if none.
185: *
186: */
187: public List getAuthors() {
188: return (_authors == null) ? (_authors = new ArrayList())
189: : _authors;
190: }
191:
192: /**
193: * Sets the feed author.
194: * <p>
195: * @param author the feed author to set, <b>null</b> if none.
196: *
197: */
198: public void setAuthors(List authors) {
199: _authors = authors;
200: }
201:
202: /**
203: * Returns the feed contributors.
204: * <p>
205: * @return a list of Person elements with the feed contributors,
206: * an empty list if none.
207: *
208: */
209: public List getContributors() {
210: return (_contributors == null) ? (_contributors = new ArrayList())
211: : _contributors;
212: }
213:
214: /**
215: * Sets the feed contributors.
216: * <p>
217: * @param contributors the list of Person elements with the feed contributors to set,
218: * an empty list or <b>null</b> if none.
219: *
220: */
221: public void setContributors(List contributors) {
222: _contributors = contributors;
223: }
224:
225: /**
226: * Returns the feed tag line (Atom 0.3, maps to {@link getSubtitle()}).
227: * <p>
228: * @return the feed tag line, <b>null</b> if none.
229: */
230: public Content getTagline() {
231: return _subtitle;
232: }
233:
234: /**
235: * Sets the feed tagline (Atom 0.3, maps to {@link getSubtitle()}).
236: * <p>
237: * @param tagline the feed tagline to set, <b>null</b> if none.
238: */
239: public void setTagline(Content tagline) {
240: _subtitle = tagline;
241: }
242:
243: /**
244: * Returns the feed ID.
245: * <p>
246: * @return the feed ID, <b>null</b> if none.
247: *
248: */
249: public String getId() {
250: return _id;
251: }
252:
253: /**
254: * Sets the feed ID.
255: * <p>
256: * @param id the feed ID to set, <b>null</b> if none.
257: *
258: */
259: public void setId(String id) {
260: _id = id;
261: }
262:
263: /**
264: * Returns the feed generator.
265: * <p>
266: * @return the feed generator, <b>null</b> if none.
267: *
268: */
269: public Generator getGenerator() {
270: return _generator;
271: }
272:
273: /**
274: * Sets the feed generator.
275: * <p>
276: * @param generator the feed generator to set, <b>null</b> if none.
277: *
278: */
279: public void setGenerator(Generator generator) {
280: _generator = generator;
281: }
282:
283: /**
284: * Returns the feed copyright (Atom 0.3, maps to {@link getRights()}).
285: * <p>
286: * @return the feed copyright, <b>null</b> if none.
287: */
288: public String getCopyright() {
289: return _rights;
290: }
291:
292: /**
293: * Sets the feed copyright (Atom 0.3, maps to {@link setRights()}).
294: * <p>
295: * @param copyright the feed copyright to set, <b>null</b> if none.
296: */
297: public void setCopyright(String copyright) {
298: _rights = copyright;
299: }
300:
301: /**
302: * Returns the feed info (Atom 0.3 only)
303: * <p>
304: * @return the feed info, <b>null</b> if none.
305: */
306: public Content getInfo() {
307: return _info;
308: }
309:
310: /**
311: * Sets the feed info (Atom 0.3 only)
312: * <p>
313: * @param info the feed info to set, <b>null</b> if none.
314: */
315: public void setInfo(Content info) {
316: _info = info;
317: }
318:
319: /**
320: * Returns the feed modified date (Atom 0.3, maps to {@link getUpdated()}).
321: * <p>
322: * @return the feed modified date, <b>null</b> if none.
323: */
324: public Date getModified() {
325: return _updated;
326: }
327:
328: /**
329: * Sets the feed modified date (Atom 0.3, maps to {@link setUpdated()}).
330: * <p>
331: * @param modified the feed modified date to set, <b>null</b> if none.
332: */
333: public void setModified(Date modified) {
334: _updated = modified;
335: }
336:
337: /**
338: * Returns the feed entries.
339: * <p>
340: * @return a list of Entry elements with the feed entries,
341: * an empty list if none.
342: *
343: */
344: public List getEntries() {
345: return (_entries == null) ? (_entries = new ArrayList())
346: : _entries;
347: }
348:
349: /**
350: * Sets the feed entries.
351: * <p>
352: * @param entries the list of Entry elements with the feed entries to set,
353: * an empty list or <b>null</b> if none.
354: *
355: */
356: public void setEntries(List entries) {
357: _entries = entries;
358: }
359:
360: /**
361: * Returns the feed modules.
362: * <p>
363: * @return a list of ModuleImpl elements with the feed modules,
364: * an empty list if none.
365: *
366: */
367: public List getModules() {
368: return (_modules == null) ? (_modules = new ArrayList())
369: : _modules;
370: }
371:
372: /**
373: * Sets the feed moduless.
374: * <p>
375: * @param modules the list of ModuleImpl elements with the feed moduless to set,
376: * an empty list or <b>null</b> if none.
377: *
378: */
379: public void setModules(List modules) {
380: _modules = modules;
381: }
382:
383: /**
384: * Returns the module identified by a given URI.
385: * <p>
386: * @param uri the URI of the ModuleImpl.
387: * @return The module with the given URI, <b>null</b> if none.
388: */
389: public Module getModule(String uri) {
390: return ModuleUtils.getModule(_modules, uri);
391: }
392:
393: /**
394: * Returns the categories
395: * <p>
396: * @return Returns the categories.
397: * @since Atom 1.0
398: */
399: public List getCategories() {
400: return _categories;
401: }
402:
403: /**
404: * Set the categories
405: * <p>
406: * @param categories The categories to set.
407: * @since Atom 1.0
408: */
409: public void setCategories(List categories) {
410: _categories = categories;
411: }
412:
413: /**
414: * Returns the icon
415: * <p>
416: * @return Returns the icon.
417: * @since Atom 1.0
418: */
419: public String getIcon() {
420: return _icon;
421: }
422:
423: /**
424: * Set the icon
425: * <p>
426: * @param icon The icon to set.
427: * @since Atom 1.0
428: */
429: public void setIcon(String icon) {
430: _icon = icon;
431: }
432:
433: /**
434: * Returns the logo
435: * <p>
436: * @return Returns the logo.
437: * @since Atom 1.0
438: */
439: public String getLogo() {
440: return _logo;
441: }
442:
443: /**
444: * Set the logo
445: * <p>
446: * @param logo The logo to set.
447: * @since Atom 1.0
448: */
449: public void setLogo(String logo) {
450: _logo = logo;
451: }
452:
453: /**
454: * Returns the rights
455: * <p>
456: * @return Returns the rights.
457: * @since Atom 1.0
458: */
459: public String getRights() {
460: return _rights;
461: }
462:
463: /**
464: * Set the rights
465: * <p>
466: * @param rights The rights to set.
467: * @since Atom 1.0
468: */
469: public void setRights(String rights) {
470: _rights = rights;
471: }
472:
473: /**
474: * Returns the subtitle
475: * <p>
476: * @return Returns the subtitle.
477: * @since Atom 1.0
478: */
479: public Content getSubtitle() {
480: return _subtitle;
481: }
482:
483: /**
484: * Set the subtitle
485: * <p>
486: * @param subtitle The subtitle to set.
487: * @since Atom 1.0
488: */
489: public void setSubtitle(Content subtitle) {
490: _subtitle = subtitle;
491: }
492:
493: /**
494: * Returns the updated
495: * <p>
496: * @return Returns the updated.
497: * @since Atom 1.0
498: */
499: public Date getUpdated() {
500: return _updated;
501: }
502:
503: /**
504: * Set the updated
505: * <p>
506: * @param updated The updated to set.
507: * @since Atom 1.0
508: */
509: public void setUpdated(Date updated) {
510: _updated = updated;
511: }
512:
513: /**
514: * Returns the xmlBase
515: * <p>
516: * @return Returns the xmlBase.
517: * @since Atom 1.0
518: */
519: public String getXmlBase() {
520: return _xmlBase;
521: }
522:
523: /**
524: * Set the xmlBase
525: * <p>
526: * @param xmlBase The xmlBase to set.
527: * @since Atom 1.0
528: */
529: public void setXmlBase(String xmlBase) {
530: _xmlBase = xmlBase;
531: }
532: }
|