KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > syndication > feed > rss > Item


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.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.ArrayList JavaDoc;
24 import java.util.Date JavaDoc;
25 import java.util.List JavaDoc;
26 import java.io.Serializable JavaDoc;
27
28 /**
29  * Bean for items of RSS feeds.
30  * <p>
31  * It handles all RSS versions without loosing information.
32  * <p>
33  * For RSS1.0 it supports Dublin Core and Syndication modules. Note that
34  * those modules currently support simple syntax format only.
35  * <p>
36  * @author Alejandro Abdelnur
37  *
38  */

39 public class Item implements Cloneable JavaDoc,Serializable JavaDoc {
40     private ObjectBean _objBean;
41     private String JavaDoc _title;
42     private String JavaDoc _link;
43     private Description _description;
44     private Source _source;
45     private List JavaDoc _enclosures;
46     private List JavaDoc _categories;
47     private Guid _guid;
48     private String JavaDoc _comments;
49     private String JavaDoc _author;
50     private Date JavaDoc _pubDate;
51     private Date JavaDoc _expirationDate;
52     private List JavaDoc _modules;
53
54     /**
55      * Default constructor. All properties are set to <b>null</b>.
56      * <p>
57      *
58      */

59     public Item() {
60         _objBean = new ObjectBean(this.getClass(),this);
61     }
62
63     /**
64      * Creates a deep 'bean' clone of the object.
65      * <p>
66      * @return a clone of the object.
67      * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
68      *
69      */

70     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
71         return _objBean.clone();
72     }
73
74     /**
75      * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
76      * <p>
77      * @param other he reference object with which to compare.
78      * @return <b>true</b> if 'this' object is equal to the 'other' object.
79      *
80      */

81     public boolean equals(Object JavaDoc other) {
82         return _objBean.equals(other);
83     }
84
85     /**
86      * Returns a hashcode value for the object.
87      * <p>
88      * It follows the contract defined by the Object hashCode() method.
89      * <p>
90      * @return the hashcode of the bean object.
91      *
92      */

93     public int hashCode() {
94         return _objBean.hashCode();
95     }
96
97     /**
98      * Returns the String representation for the object.
99      * <p>
100      * @return String representation for the object.
101      *
102      */

103     public String JavaDoc toString() {
104         return _objBean.toString();
105     }
106
107     /**
108      * Returns the item title.
109      * <p>
110      * @return the item title, <b>null</b> if none.
111      *
112      */

113     public String JavaDoc getTitle() {
114         return _title;
115     }
116
117     /**
118      * Sets the item title.
119      * <p>
120      * @param title the item title to set, <b>null</b> if none.
121      *
122      */

123     public void setTitle(String JavaDoc title) {
124         _title = title;
125     }
126
127     /**
128      * Returns the item link.
129      * <p>
130      * @return the item link, <b>null</b> if none.
131      *
132      */

133     public String JavaDoc getLink() {
134         return _link;
135     }
136
137     /**
138      * Sets the item link.
139      * <p>
140      * @param link the item link to set, <b>null</b> if none.
141      *
142      */

143     public void setLink(String JavaDoc link) {
144         _link = link;
145     }
146
147     /**
148      * Returns the item description.
149      * <p>
150      * @return the item description, <b>null</b> if none.
151      *
152      */

153     public Description getDescription() {
154         return _description;
155     }
156
157     /**
158      * Sets the item description.
159      * <p>
160      * @param description the item description to set, <b>null</b> if none.
161      *
162      */

163     public void setDescription(Description description) {
164         _description = description;
165     }
166
167     /**
168      * Returns the item source.
169      * <p>
170      * @return the item source, <b>null</b> if none.
171      *
172      */

173     public Source getSource() {
174         return _source;
175     }
176
177     /**
178      * Sets the item source.
179      * <p>
180      * @param source the item source to set, <b>null</b> if none.
181      *
182      */

183     public void setSource(Source source) {
184         _source = source;
185     }
186
187     /**
188      * Returns the item enclosures.
189      * <p>
190      * @return a list of Enclosure elements with the item enclosures,
191      * an empty list if none.
192      *
193      */

194     public List JavaDoc getEnclosures() {
195         return (_enclosures==null) ? (_enclosures=new ArrayList JavaDoc()) : _enclosures;
196     }
197
198     /**
199      * Sets the item enclosures.
200      * <p>
201      * @param enclosures the list of Enclosure elements with the item enclosures to set,
202      * an empty list or <b>null</b> if none.
203      *
204      */

205     public void setEnclosures(List JavaDoc enclosures) {
206         _enclosures = enclosures;
207     }
208
209     /**
210      * Returns the item categories.
211      * <p>
212      * @return a list of Category elements with the item categories,
213      * an empty list if none.
214      *
215      */

216     public List JavaDoc getCategories() {
217         return (_categories==null) ? (_categories=new ArrayList JavaDoc()) : _categories;
218     }
219
220     /**
221      * Sets the item categories.
222      * <p>
223      * @param categories the list of Categories elements with the item categories to set,
224      * an empty list or <b>null</b> if none.
225      *
226      */

227     public void setCategories(List JavaDoc categories) {
228         _categories = categories;
229     }
230
231     /**
232      * Returns the item GUID.
233      * <p>
234      * @return the item GUID, <b>null</b> if none.
235      *
236      */

237     public Guid getGuid() {
238         return _guid;
239     }
240
241     /**
242      * Sets the item GUID.
243      * <p>
244      * @param guid the item GUID to set, <b>null</b> if none.
245      *
246      */

247     public void setGuid(Guid guid) {
248         _guid = guid;
249     }
250
251     /**
252      * Returns the item comments.
253      * <p>
254      * @return the item comments, <b>null</b> if none.
255      *
256      */

257     public String JavaDoc getComments() {
258         return _comments;
259     }
260
261     /**
262      * Sets the item comments.
263      * <p>
264      * @param comments the item comments to set, <b>null</b> if none.
265      *
266      */

267     public void setComments(String JavaDoc comments) {
268         _comments = comments;
269     }
270
271     /**
272      * Returns the item author.
273      * <p>
274      * @return the item author, <b>null</b> if none.
275      *
276      */

277     public String JavaDoc getAuthor() {
278         return _author;
279     }
280
281     /**
282      * Sets the item author.
283      * <p>
284      * @param author the item author to set, <b>null</b> if none.
285      *
286      */

287     public void setAuthor(String JavaDoc author) {
288         _author = author;
289     }
290
291     /**
292      * Returns the item modules.
293      * <p>
294      * @return a list of ModuleImpl elements with the item modules,
295      * an empty list if none.
296      *
297      */

298     public List JavaDoc getModules() {
299         return (_modules==null) ? (_modules=new ArrayList JavaDoc()) : _modules;
300     }
301
302     /**
303      * Sets the item modules.
304      * <p>
305      * @param modules the list of ModuleImpl elements with the item modules to set,
306      * an empty list or <b>null</b> if none.
307      *
308      */

309     public void setModules(List JavaDoc modules) {
310         _modules = modules;
311     }
312
313     /**
314      * Returns the module identified by a given URI.
315      * <p>
316      * @param uri the URI of the ModuleImpl.
317      * @return The module with the given URI, <b>null</b> if none.
318      */

319     public Module getModule(String JavaDoc uri) {
320         return ModuleUtils.getModule(_modules,uri);
321     }
322
323
324     /**
325      * Returns the item publishing date.
326      * <p>
327      * @return the item publishing date, <b>null</b> if none.
328      *
329      */

330     public Date JavaDoc getPubDate() {
331         return _pubDate;
332     }
333
334     /**
335      * Sets the item publishing date.
336      * <p>
337      * @param pubDate the item publishing date to set, <b>null</b> if none.
338      *
339      */

340     public void setPubDate(Date JavaDoc pubDate) {
341         _pubDate = pubDate;
342     }
343
344     /**
345      * Returns the item expiration date.
346      * <p>
347      * @return the item expiration date, <b>null</b> if none.
348      *
349      */

350     public Date JavaDoc getExpirationDate() {
351         return _expirationDate;
352     }
353
354     /**
355      * Sets the item expiration date.
356      * <p>
357      * @param expirationDate the item expiration date to set, <b>null</b> if none.
358      *
359      */

360     public void setExpirationDate(Date JavaDoc expirationDate) {
361         _expirationDate = expirationDate;
362     }
363
364 }
365
Popular Tags