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.impl.ObjectBean;
20  import com.sun.syndication.feed.module.Module;
21  import com.sun.syndication.feed.module.impl.ModuleUtils;
22  import com.sun.syndication.feed.impl.ObjectBean;
23  
24  import java.util.ArrayList;
25  import java.util.Date;
26  import java.util.List;
27  import java.io.Serializable;
28  
29  /***
30   * Bean for entry elements of Atom feeds.
31   * <p>
32   * @author Alejandro Abdelnur
33   * @author Dave Johnson (updated for Atom 1.0)
34   */
35  public class Entry implements Cloneable,Serializable {
36      
37      private ObjectBean _objBean;
38      
39      private String  _xmlBase;
40      private List    _authors;
41      private List    _contributors;
42      private List    _categories;   
43      private List    _contents;       
44      private String  _id;
45      private Date    _published;      // AKA issued  
46      private String  _rights;        
47      private Feed    _source;     
48      private Content _summary;
49      private String  _title;
50      private Date    _updated;        // AKA modified
51      private List    _alternateLinks; 
52      private List    _otherLinks;   
53      
54      private List    _modules;
55      
56      private Date    _created;        // Atom 0.3 only
57  
58  
59      /***
60       * Default constructor. All properties are set to <b>null</b>.
61       * <p>
62       *
63       */
64      public Entry() {
65          _objBean = new ObjectBean(this.getClass(),this);
66      }
67  
68      /***
69       * Creates a deep 'bean' clone of the object.
70       * <p>
71       * @return a clone of the object.
72       * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
73       *
74       */
75      public Object clone() throws CloneNotSupportedException {
76          return _objBean.clone();
77      }
78  
79      /***
80       * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
81       * <p>
82       * @param other he reference object with which to compare.
83       * @return <b>true</b> if 'this' object is equal to the 'other' object.
84       *
85       */
86      public boolean equals(Object other) {
87          return _objBean.equals(other);
88      }
89  
90      /***
91       * Returns a hashcode value for the object.
92       * <p>
93       * It follows the contract defined by the Object hashCode() method.
94       * <p>
95       * @return the hashcode of the bean object.
96       *
97       */
98      public int hashCode() {
99          return _objBean.hashCode();
100     }
101 
102     /***
103      * Returns the String representation for the object.
104      * <p>
105      * @return String representation for the object.
106      *
107      */
108     public String toString() {
109         return _objBean.toString();
110     }
111 
112     /***
113      * Returns the entry title.
114      * <p>
115      * @return the entry title, <b>null</b> if none.
116      *
117      */
118     public String getTitle() {
119         return _title;
120     }
121 
122     /***
123      * Sets the entry title.
124      * <p>
125      * @param title the entry title, <b>null</b> if none.
126      *
127      */
128     public void setTitle(String title) {
129         _title = title;
130     }
131 
132     /***
133      * Returns the entry alternate links.
134      * <p>
135      * @return a list of Link elements with the entry alternate links, an empty list if none.
136      */
137     public List getAlternateLinks() {
138         return (_alternateLinks==null) ? (_alternateLinks=new ArrayList()) : _alternateLinks;
139     }
140 
141     /***
142      * Sets the entry alternate links.
143      * <p>
144      * @param alternateLinks the list of Link elements with the entry alternate links to set,
145      *        an empty list or <b>null</b> if none.
146      */
147     public void setAlternateLinks(List alternateLinks) {
148         _alternateLinks = alternateLinks;
149     }
150 
151     /***
152      * Returns the entry non-alternate links.
153      * <p>
154      * @return the list of Link elements with the entry non-alternate links to set,
155      *         an empty list if none.
156      */
157     public List getOtherLinks() {
158         return (_otherLinks==null) ? (_otherLinks=new ArrayList()) : _otherLinks;
159     }
160 
161     /***
162      * Sets the entry non-alternate links.
163      * <p>
164      * @param otherLinks the list Link elements with the entry non-alternate links to set,
165      *        an empty list or <b>null</b> if none.
166      */
167     public void setOtherLinks(List otherLinks) {
168         _otherLinks = otherLinks;
169     }
170 
171     /***
172      * Returns the entry author.
173      * <p>
174      * @return the entry author, <b>null</b> if none.
175      *
176      */
177     public List getAuthors() {
178         return _authors;
179     }
180 
181     /***
182      * Sets the author of the entry.
183      * <p>
184      * @param author the author of the entry, <b>null</b> if none.
185      *
186      */
187     public void setAuthors(List authors) {
188         _authors = authors;
189     }
190 
191     /***
192      * Returns the entry contributors.
193      * <p>
194      * @return a list of Person elements with the entry contributors,
195      *         an empty list if none.
196      *
197      */
198     public List getContributors() {
199         return (_contributors==null) ? (_contributors=new ArrayList()) : _contributors;
200     }
201 
202     /***
203      * Sets the entry contributors.
204      * <p>
205      * @param contributors the list of Person elements with the entry contributors to set,
206      *        an empty list or <b>null</b> if none.
207      *
208      */
209     public void setContributors(List contributors) {
210         _contributors = contributors;
211     }
212 
213     /***
214      * Returns the entry ID.
215      * <p>
216      * @return the entry ID, <b>null</b> if none.
217      *
218      */
219     public String getId() {
220         return _id;
221     }
222 
223     /***
224      * Sets the entry ID.
225      * <p>
226      * @param id the entry ID, <b>null</b> if none.
227      *
228      */
229     public void setId(String id) {
230         _id = id;
231     }
232 
233     /***
234      * Returns the entry modified date (Atom 0.3, maps to {@link getUpdated()}).
235      * <p>
236      * @return the entry modified date, <b>null</b> if none.
237      */
238     public Date getModified() {
239         return _updated;
240     }
241 
242     /***
243      * Sets the entry modified date (Atom 0.3, maps to {@link setUpdated()}).
244      * <p>
245      * @param modified the entry modified date, <b>null</b> if none.
246      */
247     public void setModified(Date modified) {
248         _updated = modified;
249     }
250 
251     /***
252      * Returns the entry issued date (Atom 0.3, maps to {@link getPublished()}).
253      * <p>
254      * @return the entry issued date, <b>null</b> if none.
255      */
256     public Date getIssued() {
257         return _published;
258     }
259 
260     /***
261      * Sets the entry issued date (Atom 0.3, maps to {@link setPublished()}).
262      * <p>
263      * @param issued the entry issued date, <b>null</b> if none.
264      */
265     public void setIssued(Date issued) {
266         _published = issued;
267     }
268 
269     /***
270      * Returns the entry created date (Atom 0.3 only)
271      * <p>
272      * @return the entry created date, <b>null</b> if none.
273      */
274     public Date getCreated() {
275         return _created;
276     }
277 
278     /***
279      * Sets the entry created date (Atom 0.3 only)
280      * <p>
281      * @param created the entry created date, <b>null</b> if none.
282      */
283     public void setCreated(Date created) {
284         _created = created;
285     }
286 
287     /***
288      * Returns the entry summary.
289      * <p>
290      * @return  the entry summary, <b>null</b> if none.
291      *
292      */
293     public Content getSummary() {
294         return _summary;
295     }
296 
297     /***
298      * Sets the entry summary.
299      * <p>
300      * @param summary the entry summary, <b>null</b> if none.
301      *
302      */
303     public void setSummary(Content summary) {
304         _summary = summary;
305     }
306 
307     /***
308      * Returns the entry contents.
309      * <p>
310      * @return a list of Content elements with the entry contents,
311      *         an empty list if none.
312      */
313     public List getContents() {
314         return (_contents==null) ? (_contents=new ArrayList()) : _contents;
315     }
316 
317     /***
318      * Sets the entry contents.
319      * <p>
320      * @param contents the list of Content elements with the entry contents to set,
321      *        an empty list or <b>null</b> if none.
322      */
323     public void setContents(List contents) {
324         _contents = contents;
325     }
326 
327     /***
328      * Returns the entry modules.
329      * <p>
330      * @return a list of ModuleImpl elements with the entry modules,
331      *         an emtpy list if none.
332      *
333      */
334     public List getModules() {
335         return (_modules==null) ? (_modules=new ArrayList()) : _modules;
336     }
337 
338     /***
339      * Sets the entry modules.
340      * <p>
341      * @param modules the list of ModuleImpl elements with the entry modules to set,
342      *        an empty list or <b>null</b> if none.
343      *
344      */
345     public void setModules(List modules) {
346         _modules = modules;
347     }
348 
349     /***
350      * Returns the module identified by a given URI.
351      * <p>
352      * @param uri the URI of the ModuleImpl.
353      * @return The module with the given URI, <b>null</b> if none.
354      */
355     public Module getModule(String uri) {
356         return ModuleUtils.getModule(_modules,uri);
357     }
358         
359     /***
360      * Returns the published
361      * <p>
362      * @return Returns the published.
363      * @since Atom 1.0
364      */
365     public Date getPublished() {
366         return _published;
367     }
368     
369     /***
370      * Set the published
371      * <p>
372      * @param published The published to set.
373      * @since Atom 1.0
374      */
375     public void setPublished(Date published) {
376         _published = published;
377     }
378     
379     /***
380      * Returns the rights
381      * <p>
382      * @return Returns the rights.
383      * @since Atom 1.0
384      */
385     public String getRights() {
386         return _rights;
387     }
388     
389     /***
390      * Set the rights
391      * <p>
392      * @param rights The rights to set.
393      * @since Atom 1.0
394      */
395     public void setRights(String rights) {
396         _rights = rights;
397     }
398     
399     /***
400      * Returns the source
401      * <p>
402      * @return Returns the source.
403      */
404     public Feed getSource() {
405         return _source;
406     }
407     
408     /***
409      * Set the source
410      * <p>
411      * @param source The source to set.
412      */
413     public void setSource(Feed source) {
414         _source = source;
415     }
416     
417     /***
418      * Returns the updated
419      * <p>
420      * @return Returns the updated.
421      * @since Atom 1.0
422      */
423     public Date getUpdated() {
424         return _updated;
425     }
426     
427     /***
428      * Set the updated
429      * <p>
430      * @param updated The updated to set.
431      * @since Atom 1.0
432      */
433     public void setUpdated(Date updated) {
434         _updated = updated;
435     }
436     
437     /***
438      * Returns the categories
439      * <p>
440      * @return Returns the categories.
441      * @since Atom 1.0
442      */
443     public List getCategories() {
444         return _categories;
445     }
446     
447     /***
448      * Set the categories
449      * <p>
450      * @param categories The categories to set.
451      * @since Atom 1.0
452      */
453     public void setCategories(List categories) {
454         _categories = categories;
455     }
456 
457     /***
458      * Returns the xmlBase
459      * <p>
460      * @return Returns the xmlBase.
461      * @since Atom 1.0
462      */
463     public String getXmlBase() {
464         return _xmlBase;
465     }
466     
467     /***
468      * Set the xmlBase
469      * <p>
470      * @param xmlBase The xmlBase to set.
471      * @since Atom 1.0
472      */
473     public void setXmlBase(String xmlBase) {
474         _xmlBase = xmlBase;
475     }
476 }