1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.sun.syndication.feed;
18
19 import com.sun.syndication.common.ObjectBean;
20 import com.sun.syndication.feed.module.Module;
21 import com.sun.syndication.feed.module.impl.ModuleUtils;
22
23 import java.util.List;
24 import java.util.ArrayList;
25
26 /***
27 * Parent class of the RSS (Channel) and Atom (Feed) feed beans.
28 * <p>
29 * NOTE: We don't like this class at this package level but the alternative would have
30 * been a proliferation of packages (one more level to hold atom and rss package with
31 * this class just in that package).
32 * <p>
33 * The format of the 'type' property must be [FEEDNAME]_[FEEDVERSION] with the FEEDNAME in lower case,
34 * for example: rss_0.9, rss_0.93, atom_0.3
35 * <p>
36 * @author Alejandro Abdelnur
37 *
38 */
39 public abstract class WireFeed extends ObjectBean {
40 private String _feedType;
41 private String _encoding;
42 private List _modules;
43
44 /***
45 * Default constructor, for bean cloning purposes only.
46 * <p>
47 * @param beanClass the class/interface to be used for property scanning.
48 */
49 protected WireFeed(Class beanClass) {
50 super(beanClass);
51 }
52
53 /***
54 * Creates a feed for a given type.
55 * <p>
56 * @param beanClass the class/interface to be used for property scanning.
57 * @param type of the feed to create.
58 *
59 */
60 protected WireFeed(Class beanClass,String type) {
61 this(beanClass);
62 _feedType = type;
63 }
64
65 /***
66 * Sets the feedType of a the feed. <b>Do not use</b>, for bean cloning purposes only.
67 * <p>
68 * @param feedType the feedType of the feed.
69 *
70 */
71 public void setFeedType(String feedType) {
72 _feedType = feedType;
73 }
74
75 /***
76 * Returns the type of the feed.
77 *
78 * @return the type of the feed.
79 */
80 public String getFeedType() {
81 return _feedType;
82 }
83
84 /***
85 * Returns the charset encoding of a the feed. This is not set by Rome parsers.
86 * <p>
87 * @return the charset encoding of the feed.
88 *
89 */
90 public String getEncoding() {
91 return _encoding;
92 }
93
94 /***
95 * Sets the charset encoding of a the feed. This is not set by Rome parsers.
96 * <p>
97 * @param encoding the charset encoding of the feed.
98 *
99 */
100 public void setEncoding(String encoding) {
101 _encoding = encoding;
102 }
103
104
105 /***
106 * Returns the channel modules.
107 * <p>
108 * @return a list of ModuleImpl elements with the channel modules,
109 * an empty list if none.
110 *
111 */
112 public List getModules() {
113 return (_modules==null) ? (_modules=new ArrayList()) : _modules;
114 }
115
116 /***
117 * Sets the channel modules.
118 * <p>
119 * @param modules the list of ModuleImpl elements with the channel modules to set,
120 * an empty list or <b>null</b> if none.
121 *
122 */
123 public void setModules(List modules) {
124 _modules = modules;
125 }
126
127 /***
128 * Returns the module identified by a given URI.
129 * <p>
130 * @param uri the URI of the ModuleImpl.
131 * @return The module with the given URI, <b>null</b> if none.
132 */
133 public Module getModule(String uri) {
134 return ModuleUtils.getModule(_modules,uri);
135 }
136
137 }