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.feed.impl.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 import java.io.Serializable;
26
27 /***
28 * Parent class of the RSS (Channel) and Atom (Feed) feed beans.
29 * <p>
30 * NOTE: We don't like this class at this package level but the alternative would have
31 * been a proliferation of packages (one more level to hold atom and rss package with
32 * this class just in that package).
33 * <p>
34 * The format of the 'type' property must be [FEEDNAME]_[FEEDVERSION] with the FEEDNAME in lower case,
35 * for example: rss_0.9, rss_0.93, atom_0.3
36 * <p>
37 * @author Alejandro Abdelnur
38 *
39 */
40 public abstract class WireFeed implements Cloneable,Serializable {
41 private ObjectBean _objBean;
42 private String _feedType;
43 private String _encoding;
44 private List _modules;
45
46 /***
47 * Default constructor, for bean cloning purposes only.
48 * <p>
49 *
50 */
51 protected WireFeed() {
52 _objBean = new ObjectBean(this.getClass(),this);
53 }
54
55 /***
56 * Creates a feed for a given type.
57 * <p>
58 * @param type of the feed to create.
59 *
60 */
61 protected WireFeed(String type) {
62 this();
63 _feedType = type;
64 }
65
66 /***
67 * Creates a deep 'bean' clone of the object.
68 * <p>
69 * @return a clone of the object.
70 * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
71 *
72 */
73 public Object clone() throws CloneNotSupportedException {
74 return _objBean.clone();
75 }
76
77 /***
78 * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
79 * <p>
80 * @param other he reference object with which to compare.
81 * @return <b>true</b> if 'this' object is equal to the 'other' object.
82 *
83 */
84 public boolean equals(Object other) {
85 return _objBean.equals(other);
86 }
87
88 /***
89 * Returns a hashcode value for the object.
90 * <p>
91 * It follows the contract defined by the Object hashCode() method.
92 * <p>
93 * @return the hashcode of the bean object.
94 *
95 */
96 public int hashCode() {
97 return _objBean.hashCode();
98 }
99
100 /***
101 * Returns the String representation for the object.
102 * <p>
103 * @return String representation for the object.
104 *
105 */
106 public String toString() {
107 return _objBean.toString();
108 }
109
110
111
112
113
114 /***
115 * Sets the feedType of a the feed. <b>Do not use</b>, for bean cloning purposes only.
116 * <p>
117 * @param feedType the feedType of the feed.
118 *
119 */
120 public void setFeedType(String feedType) {
121 _feedType = feedType;
122 }
123
124 /***
125 * Returns the type of the feed.
126 *
127 * @return the type of the feed.
128 */
129 public String getFeedType() {
130 return _feedType;
131 }
132
133 /***
134 * Returns the charset encoding of a the feed. This is not set by Rome parsers.
135 * <p>
136 * @return the charset encoding of the feed.
137 *
138 */
139 public String getEncoding() {
140 return _encoding;
141 }
142
143 /***
144 * Sets the charset encoding of a the feed. This is not set by Rome parsers.
145 * <p>
146 * @param encoding the charset encoding of the feed.
147 *
148 */
149 public void setEncoding(String encoding) {
150 _encoding = encoding;
151 }
152
153
154 /***
155 * Returns the channel modules.
156 * <p>
157 * @return a list of ModuleImpl elements with the channel modules,
158 * an empty list if none.
159 *
160 */
161 public List getModules() {
162 return (_modules==null) ? (_modules=new ArrayList()) : _modules;
163 }
164
165 /***
166 * Sets the channel modules.
167 * <p>
168 * @param modules the list of ModuleImpl elements with the channel modules to set,
169 * an empty list or <b>null</b> if none.
170 *
171 */
172 public void setModules(List modules) {
173 _modules = modules;
174 }
175
176 /***
177 * Returns the module identified by a given URI.
178 * <p>
179 * @param uri the URI of the ModuleImpl.
180 * @return The module with the given URI, <b>null</b> if none.
181 */
182 public Module getModule(String uri) {
183 return ModuleUtils.getModule(_modules,uri);
184 }
185
186 }