From f0c39ed94632de5243140c3745368ec07d69eb73 Mon Sep 17 00:00:00 2001 From: kebernet Date: Fri, 1 Apr 2011 05:09:11 +0000 Subject: [PATCH] Initial Checking from J.N --- LICENSE | 2 + pom.xml | 7 +- .../com/sun/syndication/feed/CopyFrom.java | 7 +- .../com/sun/syndication/feed/WireFeed.java | 16 +- .../sun/syndication/feed/atom/Category.java | 7 + .../sun/syndication/feed/atom/Content.java | 9 +- .../com/sun/syndication/feed/atom/Entry.java | 731 +++++++++--------- .../com/sun/syndication/feed/atom/Feed.java | 50 +- .../sun/syndication/feed/atom/Generator.java | 8 +- .../com/sun/syndication/feed/atom/Link.java | 4 + .../com/sun/syndication/feed/atom/Person.java | 4 + .../sun/syndication/feed/module/DCModule.java | 62 +- .../syndication/feed/module/DCModuleImpl.java | 40 +- .../feed/module/DCSubjectImpl.java | 10 +- .../syndication/feed/module/Extendable.java | 4 +- .../syndication/feed/module/ModuleImpl.java | 7 + .../sun/syndication/feed/module/SyModule.java | 12 +- .../syndication/feed/module/SyModuleImpl.java | 11 +- .../feed/module/impl/ModuleUtils.java | 34 +- .../sun/syndication/feed/rss/Category.java | 7 + .../com/sun/syndication/feed/rss/Channel.java | 66 +- .../com/sun/syndication/feed/rss/Cloud.java | 4 + .../com/sun/syndication/feed/rss/Content.java | 134 ++-- .../sun/syndication/feed/rss/Description.java | 7 + .../sun/syndication/feed/rss/Enclosure.java | 8 + .../com/sun/syndication/feed/rss/Guid.java | 8 + .../com/sun/syndication/feed/rss/Image.java | 19 +- .../com/sun/syndication/feed/rss/Item.java | 37 +- .../com/sun/syndication/feed/rss/Source.java | 8 + .../sun/syndication/feed/rss/TextInput.java | 8 + .../syndication/feed/synd/SyndCategory.java | 1 + .../feed/synd/SyndCategoryImpl.java | 35 +- .../syndication/feed/synd/SyndContent.java | 2 +- .../feed/synd/SyndContentImpl.java | 5 +- .../syndication/feed/synd/SyndEnclosure.java | 2 +- .../feed/synd/SyndEnclosureImpl.java | 5 +- .../sun/syndication/feed/synd/SyndEntry.java | 35 +- .../syndication/feed/synd/SyndEntryImpl.java | 58 +- .../sun/syndication/feed/synd/SyndFeed.java | 26 +- .../syndication/feed/synd/SyndFeedImpl.java | 3 +- .../sun/syndication/feed/synd/SyndImage.java | 1 + .../syndication/feed/synd/SyndImageImpl.java | 3 +- .../sun/syndication/feed/synd/SyndLink.java | 4 + .../syndication/feed/synd/SyndLinkImpl.java | 8 + .../sun/syndication/feed/synd/SyndPerson.java | 1 + .../syndication/feed/synd/SyndPersonImpl.java | 11 +- .../feed/synd/impl/ConverterForAtom03.java | 1 + .../feed/synd/impl/ConverterForRSS094.java | 16 +- .../io/impl/RSS091UserlandGenerator.java | 372 +++++---- .../unittest/TestSyndFeedRSS094.java | 38 +- .../{Issue1Test.java => Issue1TestX.java} | 4 +- .../unittest/issues/Issue2Test.java | 44 ++ 52 files changed, 1156 insertions(+), 850 deletions(-) rename src/test/java/com/sun/syndication/unittest/issues/{Issue1Test.java => Issue1TestX.java} (91%) create mode 100644 src/test/java/com/sun/syndication/unittest/issues/Issue2Test.java diff --git a/LICENSE b/LICENSE index f43cdb1..d4ba69e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,6 @@ Copyright 2004 Sun Microsystems, Inc. +Copyright 2011 The ROME Team + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pom.xml b/pom.xml index e9198a5..7d34c25 100644 --- a/pom.xml +++ b/pom.xml @@ -1,11 +1,10 @@ 4.0.0 - org.rometools rome ROME, RSS and atOM utilitiEs for Java - 1.5-SNAPSHOT + 1.1-SNAPSHOT jar All Roads Lead to ROME. ROME is a set of Atom/RSS Java utilities that make it easy to work in Java with most syndication formats. Today it accepts all flavors of RSS @@ -105,8 +104,8 @@ maven-compiler-plugin 2.0.2 - 1.4 - 1.4 + 1.5 + 1.5 ${project.build.sourceEncoding} diff --git a/src/main/java/com/sun/syndication/feed/CopyFrom.java b/src/main/java/com/sun/syndication/feed/CopyFrom.java index c40f761..fbcad95 100644 --- a/src/main/java/com/sun/syndication/feed/CopyFrom.java +++ b/src/main/java/com/sun/syndication/feed/CopyFrom.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +20,7 @@ package com.sun.syndication.feed; /** * @author Alejandro Abdelnur */ -public interface CopyFrom { +public interface CopyFrom { /** * Returns the interface the copyFrom works on. @@ -29,7 +30,7 @@ public interface CopyFrom { *

* @return the interface the copyFrom works on. */ - public Class getInterface(); + public Class getInterface(); /** * Copies all the properties of the given bean into this one. @@ -42,6 +43,6 @@ public interface CopyFrom { * @param obj the instance to copy properties from. * */ - public void copyFrom(Object obj); + public void copyFrom(CopyFrom obj); } diff --git a/src/main/java/com/sun/syndication/feed/WireFeed.java b/src/main/java/com/sun/syndication/feed/WireFeed.java index 16a34ec..1799f9c 100644 --- a/src/main/java/com/sun/syndication/feed/WireFeed.java +++ b/src/main/java/com/sun/syndication/feed/WireFeed.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +43,7 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable { private ObjectBean _objBean; private String _feedType; private String _encoding; - private List _modules; + private List _modules; private List _foreignMarkup; /** @@ -72,6 +73,7 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -83,10 +85,14 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { if (other == null) { return false; } + if (!(other instanceof WireFeed)){ + return false; + } // can't use foreign markup in equals, due to JDOM equals impl Object fm = getForeignMarkup(); setForeignMarkup(((WireFeed)other).getForeignMarkup()); @@ -104,6 +110,7 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -114,6 +121,7 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } @@ -175,8 +183,8 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable { * an empty list if none. * */ - public List getModules() { - return (_modules==null) ? (_modules=new ArrayList()) : _modules; + public List getModules() { + return (_modules==null) ? (_modules=new ArrayList()) : _modules; } /** @@ -186,7 +194,7 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable { * an empty list or null if none. * */ - public void setModules(List modules) { + public void setModules(List modules) { _modules = modules; } diff --git a/src/main/java/com/sun/syndication/feed/atom/Category.java b/src/main/java/com/sun/syndication/feed/atom/Category.java index eac01ec..f521957 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Category.java +++ b/src/main/java/com/sun/syndication/feed/atom/Category.java @@ -50,6 +50,7 @@ public class Category implements Cloneable, Serializable { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -61,7 +62,11 @@ public class Category implements Cloneable, Serializable { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof Category)){ + return false; + } return _objBean.equals(other); } @@ -73,6 +78,7 @@ public class Category implements Cloneable, Serializable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -83,6 +89,7 @@ public class Category implements Cloneable, Serializable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/atom/Content.java b/src/main/java/com/sun/syndication/feed/atom/Content.java index 1f8dda4..8e90181 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Content.java +++ b/src/main/java/com/sun/syndication/feed/atom/Content.java @@ -55,7 +55,7 @@ public class Content implements Cloneable,Serializable { public static final String ESCAPED = "escaped"; private String _mode; - private static final Set MODES = new HashSet(); + private static final Set MODES = new HashSet(); static { MODES.add(XML); MODES.add(BASE64); @@ -79,6 +79,7 @@ public class Content implements Cloneable,Serializable { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -90,7 +91,11 @@ public class Content implements Cloneable,Serializable { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof Content)){ + return false; + } return _objBean.equals(other); } @@ -102,6 +107,7 @@ public class Content implements Cloneable,Serializable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -112,6 +118,7 @@ public class Content implements Cloneable,Serializable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/atom/Entry.java b/src/main/java/com/sun/syndication/feed/atom/Entry.java index fdd7896..cc0683f 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Entry.java +++ b/src/main/java/com/sun/syndication/feed/atom/Entry.java @@ -1,6 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. - * + * Copyright 2011 ROME Team * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,16 +16,18 @@ */ package com.sun.syndication.feed.atom; -import com.sun.syndication.feed.module.Module; -import com.sun.syndication.feed.module.impl.ModuleUtils; import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.module.Extendable; +import com.sun.syndication.feed.module.Module; +import com.sun.syndication.feed.module.impl.ModuleUtils; + +import java.io.Serializable; import java.util.ArrayList; import java.util.Date; -import java.util.List; -import java.io.Serializable; import java.util.Iterator; +import java.util.List; + /** * Bean for entry elements of Atom feeds. @@ -34,29 +36,24 @@ import java.util.Iterator; * @author Dave Johnson (updated for Atom 1.0) */ public class Entry implements Cloneable, Serializable, Extendable { - - private ObjectBean _objBean; - - private String _xmlBase; - private List _authors; - private List _contributors; - private List _categories; - private List _contents; - private String _id; - private Date _published; // AKA issued - private String _rights; - private Feed _source; private Content _summary; private Content _title; - private Date _updated; // AKA modified - private List _alternateLinks; - private List _otherLinks; - private List _foreignMarkup; - - private List _modules; - - private Date _created; // Atom 0.3 only - + private Date _created; // Atom 0.3 only + private Date _published; // AKA issued + private Date _updated; // AKA modified + private Feed _source; + private List _alternateLinks; + private List _authors; + private List _categories; + private List _contents; + private List _contributors; + private List _foreignMarkup; + private List _modules; + private List _otherLinks; + private ObjectBean _objBean; + private String _id; + private String _rights; + private String _xmlBase; /** * Default constructor. All properties are set to null. @@ -64,111 +61,7 @@ public class Entry implements Cloneable, Serializable, Extendable { * */ public Entry() { - _objBean = new ObjectBean(this.getClass(),this); - } - - /** - * Creates a deep 'bean' clone of the object. - *

- * @return a clone of the object. - * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. - * - */ - public Object clone() throws CloneNotSupportedException { - return _objBean.clone(); - } - - /** - * Indicates whether some other object is "equal to" this one as defined by the Object equals() method. - *

- * @param other he reference object with which to compare. - * @return true if 'this' object is equal to the 'other' object. - * - */ - public boolean equals(Object other) { - if (other == null) { - return false; - } - // can't use foreign markup in equals, due to JDOM equals impl - Object fm = getForeignMarkup(); - setForeignMarkup(((Entry)other).getForeignMarkup()); - boolean ret = _objBean.equals(other); - // restore foreign markup - setForeignMarkup(fm); - return ret; - } - - /** - * Returns a hashcode value for the object. - *

- * It follows the contract defined by the Object hashCode() method. - *

- * @return the hashcode of the bean object. - * - */ - public int hashCode() { - return _objBean.hashCode(); - } - - /** - * Returns the String representation for the object. - *

- * @return String representation for the object. - * - */ - public String toString() { - return _objBean.toString(); - } - - /** - * Returns the entry title. - *

- * @return the entry title, null if none. - * - */ - public String getTitle() { - if (_title != null) return _title.getValue(); - return null; - } - - /** - * Sets the entry title. - *

- * @param title the entry title, null if none. - * - */ - public void setTitle(String title) { - if (_title == null) _title = new Content(); - _title.setValue(title); - } - - /** - * Returns the entry title as a text construct. - *

- * @return the entry title, null if none. - * - */ - public Content getTitleEx() { - return _title; - } - - /** - * Sets the entry title as a text construct. - *

- * @param title the entry title, null if none. - * - */ - public void setTitleEx(Content title) { - _title = title; - } - - /** - * Returns the entry alternate links. - *

- * @return a list of Link elements with the entry alternate links, an empty list if none. - */ - public List getAlternateLinks() { - return (_alternateLinks==null) ? (_alternateLinks=new ArrayList()) : _alternateLinks; + _objBean = new ObjectBean(this.getClass(), this); } /** @@ -177,38 +70,17 @@ public class Entry implements Cloneable, Serializable, Extendable { * @param alternateLinks the list of Link elements with the entry alternate links to set, * an empty list or null if none. */ - public void setAlternateLinks(List alternateLinks) { + public void setAlternateLinks(List alternateLinks) { _alternateLinks = alternateLinks; } /** - * Returns the entry non-alternate links. + * Returns the entry alternate links. *

- * @return the list of Link elements with the entry non-alternate links to set, - * an empty list if none. + * @return a list of Link elements with the entry alternate links, an empty list if none. */ - public List getOtherLinks() { - return (_otherLinks==null) ? (_otherLinks=new ArrayList()) : _otherLinks; - } - - /** - * Sets the entry non-alternate links. - *

- * @param otherLinks the list Link elements with the entry non-alternate links to set, - * an empty list or null if none. - */ - public void setOtherLinks(List otherLinks) { - _otherLinks = otherLinks; - } - - /** - * Returns the entry author. - *

- * @return the entry author, null if none. - * - */ - public List getAuthors() { - return (_authors==null) ? (_authors=new ArrayList()) : _authors; + public List getAlternateLinks() { + return (_alternateLinks == null) ? (_alternateLinks = new ArrayList()) : _alternateLinks; } /** @@ -217,134 +89,38 @@ public class Entry implements Cloneable, Serializable, Extendable { * @param authors the author of the entry, null if none. * */ - public void setAuthors(List authors) { + public void setAuthors(List authors) { _authors = authors; } /** - * Returns the entry contributors. + * Returns the entry author. *

- * @return a list of Person elements with the entry contributors, - * an empty list if none. + * @return the entry author, null if none. * */ - public List getContributors() { - return (_contributors==null) ? (_contributors=new ArrayList()) : _contributors; + public List getAuthors() { + return (_authors == null) ? (_authors = new ArrayList()) : _authors; } /** - * Sets the entry contributors. + * Set the categories *

- * @param contributors the list of Person elements with the entry contributors to set, - * an empty list or null if none. - * + * @param categories The categories to set. + * @since Atom 1.0 */ - public void setContributors(List contributors) { - _contributors = contributors; + public void setCategories(List categories) { + _categories = categories; } /** - * Returns the entry ID. + * Returns the categories *

- * @return the entry ID, null if none. - * + * @return Returns the categories. + * @since Atom 1.0 */ - public String getId() { - return _id; - } - - /** - * Sets the entry ID. - *

- * @param id the entry ID, null if none. - * - */ - public void setId(String id) { - _id = id; - } - - /** - * Returns the entry modified date (Atom 0.3, maps to {@link #getUpdated()}). - *

- * @return the entry modified date, null if none. - */ - public Date getModified() { - return _updated; - } - - /** - * Sets the entry modified date (Atom 0.3, maps to {@link #setUpdated(java.util.Date)}). - *

- * @param modified the entry modified date, null if none. - */ - public void setModified(Date modified) { - _updated = modified; - } - - /** - * Returns the entry issued date (Atom 0.3, maps to {@link #getPublished()}). - *

- * @return the entry issued date, null if none. - */ - public Date getIssued() { - return _published; - } - - /** - * Sets the entry issued date (Atom 0.3, maps to {@link #setPublished(java.util.Date)}). - *

- * @param issued the entry issued date, null if none. - */ - public void setIssued(Date issued) { - _published = issued; - } - - /** - * Returns the entry created date (Atom 0.3 only) - *

- * @return the entry created date, null if none. - */ - public Date getCreated() { - return _created; - } - - /** - * Sets the entry created date (Atom 0.3 only) - *

- * @param created the entry created date, null if none. - */ - public void setCreated(Date created) { - _created = created; - } - - /** - * Returns the entry summary. - *

- * @return the entry summary, null if none. - * - */ - public Content getSummary() { - return _summary; - } - - /** - * Sets the entry summary. - *

- * @param summary the entry summary, null if none. - * - */ - public void setSummary(Content summary) { - _summary = summary; - } - - /** - * Returns the entry contents. - *

- * @return a list of Content elements with the entry contents, - * an empty list if none. - */ - public List getContents() { - return (_contents==null) ? (_contents=new ArrayList()) : _contents; + public List getCategories() { + return (_categories == null) ? (_categories = new ArrayList()) : _categories; } /** @@ -358,14 +134,161 @@ public class Entry implements Cloneable, Serializable, Extendable { } /** - * Returns the entry modules. + * Returns the entry contents. *

- * @return a list of ModuleImpl elements with the entry modules, - * an emtpy list if none. + * @return a list of Content elements with the entry contents, + * an empty list if none. + */ + public List getContents() { + return (_contents == null) ? (_contents = new ArrayList()) : _contents; + } + + /** + * Sets the entry contributors. + *

+ * @param contributors the list of Person elements with the entry contributors to set, + * an empty list or null if none. * */ - public List getModules() { - return (_modules==null) ? (_modules=new ArrayList()) : _modules; + public void setContributors(List contributors) { + _contributors = contributors; + } + + /** + * Returns the entry contributors. + *

+ * @return a list of Person elements with the entry contributors, + * an empty list if none. + * + */ + public List getContributors() { + return (_contributors == null) ? (_contributors = new ArrayList()) : _contributors; + } + + /** + * Sets the entry created date (Atom 0.3 only) + *

+ * @param created the entry created date, null if none. + */ + public void setCreated(Date created) { + _created = new Date(created.getTime()); + } + + /** + * Returns the entry created date (Atom 0.3 only) + *

+ * @return the entry created date, null if none. + */ + public Date getCreated() { + return _created == null ? null : new Date(_created.getTime()); + } + + /** + * Sets foreign markup found at entry level. + *

+ * @param foreignMarkup Opaque object to discourage use + * + */ + public void setForeignMarkup(Object foreignMarkup) { + _foreignMarkup = (List) foreignMarkup; + } + + /** + * Returns foreign markup found at entry level. + *

+ * @return list of Opaque object to discourage use + * + */ + public Object getForeignMarkup() { + return (_foreignMarkup == null) ? (_foreignMarkup = new ArrayList()) : _foreignMarkup; + } + + /** + * Sets the entry ID. + *

+ * @param id the entry ID, null if none. + * + */ + public void setId(String id) { + _id = id; + } + + /** + * Returns the entry ID. + *

+ * @return the entry ID, null if none. + * + */ + public String getId() { + return _id; + } + + /** + * Sets the entry issued date (Atom 0.3, maps to {@link #setPublished(java.util.Date)}). + *

+ * @param issued the entry issued date, null if none. + */ + public void setIssued(Date issued) { + _published = new Date(issued.getTime()); + } + + /** + * Returns the entry issued date (Atom 0.3, maps to {@link #getPublished()}). + *

+ * @return the entry issued date, null if none. + */ + public Date getIssued() { + return new Date(_published.getTime()); + } + + /** + * Returns true if entry is a media entry, i.e. has rel="edit-media". + * + * @return true if entry is a media entry + */ + public boolean isMediaEntry() { + boolean mediaEntry = false; + List links = getOtherLinks(); + + for (Iterator it = links.iterator(); it.hasNext();) { + Link link = (Link) it.next(); + + if ("edit-media".equals(link.getRel())) { + mediaEntry = true; + + break; + } + } + + return mediaEntry; + } + + /** + * Sets the entry modified date (Atom 0.3, maps to {@link #setUpdated(java.util.Date)}). + *

+ * @param modified the entry modified date, null if none. + */ + public void setModified(Date modified) { + _updated = new Date(modified.getTime()); + } + + /** + * Returns the entry modified date (Atom 0.3, maps to {@link #getUpdated()}). + *

+ * @return the entry modified date, null if none. + */ + public Date getModified() { + return new Date(_updated.getTime()); + } + + /** + * Returns the module identified by a given URI. + *

+ * @param uri the URI of the ModuleImpl. + * @return The module with the given URI, null if none. + */ + public Module getModule(String uri) { + return ModuleUtils.getModule(_modules, uri); } /** @@ -380,25 +303,36 @@ public class Entry implements Cloneable, Serializable, Extendable { } /** - * Returns the module identified by a given URI. + * Returns the entry modules. *

- * @param uri the URI of the ModuleImpl. - * @return The module with the given URI, null if none. + * @return a list of ModuleImpl elements with the entry modules, + * an emtpy list if none. + * */ - public Module getModule(String uri) { - return ModuleUtils.getModule(_modules,uri); + public List getModules() { + return (_modules == null) ? (_modules = new ArrayList()) : _modules; } - + /** - * Returns the published + * Sets the entry non-alternate links. *

- * @return Returns the published. - * @since Atom 1.0 + * @param otherLinks the list Link elements with the entry non-alternate links to set, + * an empty list or null if none. */ - public Date getPublished() { - return _published; + public void setOtherLinks(List otherLinks) { + _otherLinks = otherLinks; } - + + /** + * Returns the entry non-alternate links. + *

+ * @return the list of Link elements with the entry non-alternate links to set, + * an empty list if none. + */ + public List getOtherLinks() { + return (_otherLinks == null) ? (_otherLinks = new ArrayList()) : _otherLinks; + } + /** * Set the published *

@@ -406,19 +340,19 @@ public class Entry implements Cloneable, Serializable, Extendable { * @since Atom 1.0 */ public void setPublished(Date published) { - _published = published; + _published = new Date(published.getTime()); } - + /** - * Returns the rights + * Returns the published *

- * @return Returns the rights. + * @return Returns the published. * @since Atom 1.0 */ - public String getRights() { - return _rights; + public Date getPublished() { + return _published == null ? null : new Date(_published.getTime()); } - + /** * Set the rights *

@@ -428,16 +362,17 @@ public class Entry implements Cloneable, Serializable, Extendable { public void setRights(String rights) { _rights = rights; } - + /** - * Returns the source + * Returns the rights *

- * @return Returns the source. + * @return Returns the rights. + * @since Atom 1.0 */ - public Feed getSource() { - return _source; + public String getRights() { + return _rights; } - + /** * Set the source *

@@ -446,17 +381,84 @@ public class Entry implements Cloneable, Serializable, Extendable { public void setSource(Feed source) { _source = source; } - + /** - * Returns the updated + * Returns the source *

- * @return Returns the updated. - * @since Atom 1.0 + * @return Returns the source. */ - public Date getUpdated() { - return _updated; + public Feed getSource() { + return _source; } - + + /** + * Sets the entry summary. + *

+ * @param summary the entry summary, null if none. + * + */ + public void setSummary(Content summary) { + _summary = summary; + } + + /** + * Returns the entry summary. + *

+ * @return the entry summary, null if none. + * + */ + public Content getSummary() { + return _summary; + } + + /** + * Sets the entry title. + *

+ * @param title the entry title, null if none. + * + */ + public void setTitle(String title) { + if (_title == null) { + _title = new Content(); + } + + _title.setValue(title); + } + + /** + * Returns the entry title. + *

+ * @return the entry title, null if none. + * + */ + public String getTitle() { + if (_title != null) { + return _title.getValue(); + } + + return null; + } + + /** + * Sets the entry title as a text construct. + *

+ * @param title the entry title, null if none. + * + */ + public void setTitleEx(Content title) { + _title = title; + } + + /** + * Returns the entry title as a text construct. + *

+ * @return the entry title, null if none. + * + */ + public Content getTitleEx() { + return _title; + } + /** * Set the updated *

@@ -464,28 +466,27 @@ public class Entry implements Cloneable, Serializable, Extendable { * @since Atom 1.0 */ public void setUpdated(Date updated) { - _updated = updated; + _updated = new Date(updated.getTime()); } - - /** - * Returns the categories - *

- * @return Returns the categories. - * @since Atom 1.0 - */ - public List getCategories() { - return (_categories==null) ? (_categories=new ArrayList()) : _categories; - } - /** - * Set the categories + * Returns the updated *

- * @param categories The categories to set. + * @return Returns the updated. * @since Atom 1.0 */ - public void setCategories(List categories) { - _categories = categories; + public Date getUpdated() { + return new Date(_updated.getTime()); + } + + /** + * Set the xmlBase + *

+ * @param xmlBase The xmlBase to set. + * @since Atom 1.0 + */ + public void setXmlBase(String xmlBase) { + _xmlBase = xmlBase; } /** @@ -497,54 +498,66 @@ public class Entry implements Cloneable, Serializable, Extendable { public String getXmlBase() { return _xmlBase; } - + /** - * Set the xmlBase + * Creates a deep 'bean' clone of the object. *

- * @param xmlBase The xmlBase to set. - * @since Atom 1.0 - */ - public void setXmlBase(String xmlBase) { - _xmlBase = xmlBase; - } - - - /** - * Returns foreign markup found at entry level. - *

- * @return list of Opaque object to discourage use + * @return a clone of the object. + * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ - public Object getForeignMarkup() { - return (_foreignMarkup==null) ? (_foreignMarkup=new ArrayList()) : _foreignMarkup; + @Override + public Object clone() throws CloneNotSupportedException { + return _objBean.clone(); } /** - * Sets foreign markup found at entry level. + * Indicates whether some other object is "equal to" this one as defined by the Object equals() method. *

- * @param foreignMarkup Opaque object to discourage use + * @param other he reference object with which to compare. + * @return true if 'this' object is equal to the 'other' object. * */ - public void setForeignMarkup(Object foreignMarkup) { - _foreignMarkup = (List)foreignMarkup; - } - - /** - * Returns true if entry is a media entry, i.e. has rel="edit-media". - * - * @return true if entry is a media entry - */ - public boolean isMediaEntry() { - boolean mediaEntry = false; - List links = getOtherLinks(); - for (Iterator it = links.iterator(); it.hasNext();) { - Link link = (Link) it.next(); - if ("edit-media".equals(link.getRel())) { - mediaEntry = true; - break; - } + @Override + public boolean equals(Object other) { + if (other == null) { + return false; } - return mediaEntry; - } + if(!(other instanceof Entry)){ + return false; + } + // can't use foreign markup in equals, due to JDOM equals impl + Object fm = getForeignMarkup(); + setForeignMarkup(((Entry) other).getForeignMarkup()); + boolean ret = _objBean.equals(other); + // restore foreign markup + setForeignMarkup(fm); + + return ret; + } + + /** + * Returns a hashcode value for the object. + *

+ * It follows the contract defined by the Object hashCode() method. + *

+ * @return the hashcode of the bean object. + * + */ + @Override + public int hashCode() { + return _objBean.hashCode(); + } + + /** + * Returns the String representation for the object. + *

+ * @return String representation for the object. + * + */ + @Override + public String toString() { + return _objBean.toString(); + } } diff --git a/src/main/java/com/sun/syndication/feed/atom/Feed.java b/src/main/java/com/sun/syndication/feed/atom/Feed.java index ce8bb46..e79b81b 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Feed.java +++ b/src/main/java/com/sun/syndication/feed/atom/Feed.java @@ -35,9 +35,9 @@ import java.util.List; public class Feed extends WireFeed { private String _xmlBase; - private List _categories; - private List _authors; - private List _contributors; + private List _categories; + private List _authors; + private List _contributors; private Generator _generator; private String _icon; private String _id; @@ -46,11 +46,11 @@ public class Feed extends WireFeed { private Content _subtitle; // AKA tagline private Content _title; private Date _updated; // AKA modified - private List _alternateLinks; - private List _otherLinks; - private List _entries; + private List _alternateLinks; + private List _otherLinks; + private List _entries; - private List _modules; + private List _modules; private Content _info; // Atom 0.3 only private String _language; // Atom 0.3 only @@ -140,8 +140,8 @@ public class Feed extends WireFeed { * @return a list of Link elements with the feed alternate links, * an empty list if none. */ - public List getAlternateLinks() { - return (_alternateLinks==null) ? (_alternateLinks=new ArrayList()) : _alternateLinks; + public List getAlternateLinks() { + return (_alternateLinks==null) ? (_alternateLinks=new ArrayList()) : _alternateLinks; } /** @@ -150,7 +150,7 @@ public class Feed extends WireFeed { * @param alternateLinks the list of Link elements with the feed alternate links to set, * an empty list or null if none. */ - public void setAlternateLinks(List alternateLinks) { + public void setAlternateLinks(List alternateLinks) { _alternateLinks = alternateLinks; } @@ -160,7 +160,7 @@ public class Feed extends WireFeed { * @return a list of Link elements with the feed other links (non-alternate ones), * an empty list if none. */ - public List getOtherLinks() { + public List getOtherLinks() { return (_otherLinks==null) ? (_otherLinks=new ArrayList()) : _otherLinks; } @@ -170,7 +170,7 @@ public class Feed extends WireFeed { * @param otherLinks the list of Link elements with the feed other links (non-alternate ones) to set, * an empty list or null if none. */ - public void setOtherLinks(List otherLinks) { + public void setOtherLinks(List otherLinks) { _otherLinks = otherLinks; } @@ -180,8 +180,8 @@ public class Feed extends WireFeed { * @return the feed author, null if none. * */ - public List getAuthors() { - return (_authors==null) ? (_authors=new ArrayList()) : _authors; + public List getAuthors() { + return (_authors==null) ? (_authors=new ArrayList()) : _authors; } /** @@ -190,7 +190,7 @@ public class Feed extends WireFeed { * @param authors the feed author to set, null if none. * */ - public void setAuthors(List authors) { + public void setAuthors(List authors) { _authors = authors; } @@ -201,8 +201,8 @@ public class Feed extends WireFeed { * an empty list if none. * */ - public List getContributors() { - return (_contributors==null) ? (_contributors=new ArrayList()) : _contributors; + public List getContributors() { + return (_contributors==null) ? (_contributors=new ArrayList()) : _contributors; } /** @@ -212,7 +212,7 @@ public class Feed extends WireFeed { * an empty list or null if none. * */ - public void setContributors(List contributors) { + public void setContributors(List contributors) { _contributors = contributors; } @@ -335,8 +335,8 @@ public class Feed extends WireFeed { * an empty list if none. * */ - public List getEntries() { - return (_entries==null) ? (_entries=new ArrayList()) : _entries; + public List getEntries() { + return (_entries==null) ? (_entries=new ArrayList()) : _entries; } /** @@ -357,8 +357,8 @@ public class Feed extends WireFeed { * an empty list if none. * */ - public List getModules() { - return (_modules==null) ? (_modules=new ArrayList()) : _modules; + public List getModules() { + return (_modules==null) ? (_modules=new ArrayList()) : _modules; } /** @@ -368,7 +368,8 @@ public class Feed extends WireFeed { * an empty list or null if none. * */ - public void setModules(List modules) { + @Override + public void setModules(List modules) { _modules = modules; } @@ -378,6 +379,7 @@ public class Feed extends WireFeed { * @param uri the URI of the ModuleImpl. * @return The module with the given URI, null if none. */ + @Override public Module getModule(String uri) { return ModuleUtils.getModule(_modules,uri); } @@ -398,7 +400,7 @@ public class Feed extends WireFeed { * @param categories The categories to set. * @since Atom 1.0 */ - public void setCategories(List categories) { + public void setCategories(List categories) { _categories = categories; } diff --git a/src/main/java/com/sun/syndication/feed/atom/Generator.java b/src/main/java/com/sun/syndication/feed/atom/Generator.java index 4e9e307..2763fb5 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Generator.java +++ b/src/main/java/com/sun/syndication/feed/atom/Generator.java @@ -16,7 +16,6 @@ */ package com.sun.syndication.feed.atom; -import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.impl.ObjectBean; import java.io.Serializable; @@ -49,6 +48,7 @@ public class Generator implements Cloneable,Serializable { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -60,7 +60,11 @@ public class Generator implements Cloneable,Serializable { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof Generator)){ + return false; + } return _objBean.equals(other); } @@ -72,6 +76,7 @@ public class Generator implements Cloneable,Serializable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -82,6 +87,7 @@ public class Generator implements Cloneable,Serializable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/atom/Link.java b/src/main/java/com/sun/syndication/feed/atom/Link.java index d18c4cd..5a88cfa 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Link.java +++ b/src/main/java/com/sun/syndication/feed/atom/Link.java @@ -54,6 +54,7 @@ public class Link implements Cloneable,Serializable { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -65,6 +66,7 @@ public class Link implements Cloneable,Serializable { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { return _objBean.equals(other); } @@ -77,6 +79,7 @@ public class Link implements Cloneable,Serializable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -87,6 +90,7 @@ public class Link implements Cloneable,Serializable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/atom/Person.java b/src/main/java/com/sun/syndication/feed/atom/Person.java index 73b0d12..29f178f 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Person.java +++ b/src/main/java/com/sun/syndication/feed/atom/Person.java @@ -58,6 +58,7 @@ public class Person implements Cloneable,Serializable, Extendable * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -69,6 +70,7 @@ public class Person implements Cloneable,Serializable, Extendable * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { return _objBean.equals(other); } @@ -81,6 +83,7 @@ public class Person implements Cloneable,Serializable, Extendable * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -91,6 +94,7 @@ public class Person implements Cloneable,Serializable, Extendable * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/module/DCModule.java b/src/main/java/com/sun/syndication/feed/module/DCModule.java index 623ef55..8786f76 100644 --- a/src/main/java/com/sun/syndication/feed/module/DCModule.java +++ b/src/main/java/com/sun/syndication/feed/module/DCModule.java @@ -28,7 +28,7 @@ import java.util.Date; * @author Alejandro Abdelnur * */ -public interface DCModule extends Module,CopyFrom { +public interface DCModule extends Module, CopyFrom { /** * URI of the Dublin Core Module (http://purl.org/dc/elements/1.1/). @@ -43,7 +43,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getTitles(); + List getTitles(); /** * Sets the DublinCore module titles. @@ -52,7 +52,7 @@ public interface DCModule extends Module,CopyFrom { * to set, an empty list or null if none. * */ - void setTitles(List titles); + void setTitles(List titles); /** * Gets the DublinCore module title. Convenience method that can be used @@ -78,7 +78,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getCreators(); + List getCreators(); /** * Sets the DublinCore module creators. @@ -87,7 +87,7 @@ public interface DCModule extends Module,CopyFrom { * creators to set, an empty list or null if none. * */ - void setCreators(List creators); + void setCreators(List creators); /** * Gets the DublinCore module creator. Convenience method that can be used @@ -113,7 +113,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getSubjects(); + List getSubjects(); /** * Sets the DublinCore module subjects. @@ -122,7 +122,7 @@ public interface DCModule extends Module,CopyFrom { * module subjects to set, an empty list or null if none. * */ - void setSubjects(List subjects); + void setSubjects(List subjects); /** * Gets the DublinCore module subject. Convenience method that can be used @@ -148,7 +148,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getDescriptions(); + List getDescriptions(); /** * Sets the DublinCore module descriptions. @@ -157,7 +157,7 @@ public interface DCModule extends Module,CopyFrom { * module descriptions to set, an empty list or null if none. * */ - void setDescriptions(List descriptions); + void setDescriptions(List descriptions); /** * Gets the DublinCore module description. Convenience method that can be @@ -183,7 +183,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getPublishers(); + List getPublishers(); /** * Sets the DublinCore module publishers. @@ -192,7 +192,7 @@ public interface DCModule extends Module,CopyFrom { * publishers to set, an empty list or null if none. * */ - void setPublishers(List publishers); + void setPublishers(List publishers); /** * Gets the DublinCore module publisher. Convenience method that can be @@ -218,7 +218,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getContributors(); + List getContributors(); /** * Sets the DublinCore module contributors. @@ -227,7 +227,7 @@ public interface DCModule extends Module,CopyFrom { * contributors to set, an empty list or null if none. * */ - void setContributors(List contributors); + void setContributors(List contributors); /** * Gets the DublinCore module contributor. Convenience method that can be @@ -253,7 +253,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getDates(); + List getDates(); /** * Sets the DublinCore module dates. @@ -262,7 +262,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list or null if none. * */ - void setDates(List dates); + void setDates(List dates); /** * Gets the DublinCore module date. Convenience method that can be used to @@ -288,7 +288,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getTypes(); + List getTypes(); /** * Sets the DublinCore module types. @@ -297,7 +297,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list or null if none. * */ - void setTypes(List types); + void setTypes(List types); /** * Gets the DublinCore module type. Convenience method that can be used @@ -323,7 +323,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getFormats(); + List getFormats(); /** * Sets the DublinCore module formats. @@ -332,7 +332,7 @@ public interface DCModule extends Module,CopyFrom { * formats to set, an empty list or null if none. * */ - void setFormats(List formats); + void setFormats(List formats); /** * Gets the DublinCore module format. Convenience method that can be used @@ -358,7 +358,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getIdentifiers(); + List getIdentifiers(); /** * Sets the DublinCore module identifiers. @@ -367,7 +367,7 @@ public interface DCModule extends Module,CopyFrom { * identifiers to set, an empty list or null if none. * */ - void setIdentifiers(List identifiers); + void setIdentifiers(List identifiers); /** * Gets the DublinCore module identifier. Convenience method that can be @@ -393,7 +393,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getSources(); + List getSources(); /** * Sets the DublinCore module sources. @@ -402,7 +402,7 @@ public interface DCModule extends Module,CopyFrom { * sources to set, an empty list or null if none. * */ - void setSources(List sources); + void setSources(List sources); /** * Gets the DublinCore module subject. Convenience method that can be used @@ -428,7 +428,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getLanguages(); + List getLanguages(); /** * Sets the DublinCore module languages. @@ -437,7 +437,7 @@ public interface DCModule extends Module,CopyFrom { * languages to set, an empty list or null if none. * */ - void setLanguages(List languages); + void setLanguages(List languages); /** * Gets the DublinCore module language. Convenience method that can be used @@ -463,7 +463,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getRelations(); + List getRelations(); /** * Sets the DublinCore module relations. @@ -472,7 +472,7 @@ public interface DCModule extends Module,CopyFrom { * relations to set, an empty list or null if none. * */ - void setRelations(List relations); + void setRelations(List relations); /** * Gets the DublinCore module relation. Convenience method that can be used @@ -498,7 +498,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getCoverages(); + List getCoverages(); /** * Sets the DublinCore module coverages. @@ -507,7 +507,7 @@ public interface DCModule extends Module,CopyFrom { * coverages to set, an empty list or null if none. * */ - void setCoverages(List coverages); + void setCoverages(List coverages); /** * Gets the DublinCore module coverage. Convenience method that can be used @@ -533,7 +533,7 @@ public interface DCModule extends Module,CopyFrom { * an empty list if none. * */ - List getRightsList(); + List getRightsList(); /** * Sets the DublinCore module rightss. @@ -542,7 +542,7 @@ public interface DCModule extends Module,CopyFrom { * rights to set, an empty list or null if none. * */ - void setRightsList(List rights); + void setRightsList(List rights); /** * Gets the DublinCore module right. Convenience method that can be used diff --git a/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java b/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java index c3ac5b9..7359efc 100644 --- a/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java +++ b/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java @@ -16,6 +16,7 @@ */ package com.sun.syndication.feed.module; +import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.impl.CopyFromHelper; import com.sun.syndication.feed.impl.ObjectBean; @@ -31,21 +32,21 @@ import java.util.*; */ public class DCModuleImpl extends ModuleImpl implements DCModule { private ObjectBean _objBean; - private List _title; - private List _creator; - private List _subject; - private List _description; - private List _publisher; - private List _contributors; - private List _date; - private List _type; - private List _format; - private List _identifier; - private List _source; - private List _language; - private List _relation; - private List _coverage; - private List _rights; + private List _title; + private List _creator; + private List _subject; + private List _description; + private List _publisher; + private List _contributors; + private List _date; + private List _type; + private List _format; + private List _identifier; + private List _source; + private List _language; + private List _relation; + private List _coverage; + private List _rights; /** * Properties to be ignored when cloning. @@ -364,7 +365,7 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { * an empty list if none. * */ - public List getDates() { + public List getDates() { return (_date == null) ? (_date = new ArrayList()) : _date; } @@ -375,7 +376,7 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { * to set, an empty list or null if none. * */ - public void setDates(List dates) { + public void setDates(List dates) { _date = dates; } @@ -800,15 +801,16 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { * @return String representation for the object. * */ + @Override public final String toString() { return _objBean.toString(); } - public final Class getInterface() { + public final Class getInterface() { return DCModule.class; } - public final void copyFrom(Object obj) { + public final void copyFrom(CopyFrom obj) { COPY_FROM_HELPER.copy(this,obj); } diff --git a/src/main/java/com/sun/syndication/feed/module/DCSubjectImpl.java b/src/main/java/com/sun/syndication/feed/module/DCSubjectImpl.java index e585966..038d5e3 100644 --- a/src/main/java/com/sun/syndication/feed/module/DCSubjectImpl.java +++ b/src/main/java/com/sun/syndication/feed/module/DCSubjectImpl.java @@ -16,6 +16,7 @@ */ package com.sun.syndication.feed.module; +import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.impl.CopyFromHelper; @@ -52,6 +53,7 @@ public class DCSubjectImpl implements Cloneable,Serializable, DCSubject { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -63,7 +65,11 @@ public class DCSubjectImpl implements Cloneable,Serializable, DCSubject { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof DCSubjectImpl)){ + return false; + } return _objBean.equals(other); } @@ -75,6 +81,7 @@ public class DCSubjectImpl implements Cloneable,Serializable, DCSubject { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -85,6 +92,7 @@ public class DCSubjectImpl implements Cloneable,Serializable, DCSubject { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } @@ -133,7 +141,7 @@ public class DCSubjectImpl implements Cloneable,Serializable, DCSubject { return DCSubject.class; } - public void copyFrom(Object obj) { + public void copyFrom(CopyFrom obj) { COPY_FROM_HELPER.copy(this,obj); } diff --git a/src/main/java/com/sun/syndication/feed/module/Extendable.java b/src/main/java/com/sun/syndication/feed/module/Extendable.java index ce4ad47..f58f774 100644 --- a/src/main/java/com/sun/syndication/feed/module/Extendable.java +++ b/src/main/java/com/sun/syndication/feed/module/Extendable.java @@ -40,7 +40,7 @@ public interface Extendable { * an empty list if none. * */ - List getModules(); + List getModules(); /** * Sets the entry modules. @@ -49,5 +49,5 @@ public interface Extendable { * an empty list or null if none. * */ - void setModules(List modules); + void setModules(List modules); } diff --git a/src/main/java/com/sun/syndication/feed/module/ModuleImpl.java b/src/main/java/com/sun/syndication/feed/module/ModuleImpl.java index b98764b..7e80031 100644 --- a/src/main/java/com/sun/syndication/feed/module/ModuleImpl.java +++ b/src/main/java/com/sun/syndication/feed/module/ModuleImpl.java @@ -49,6 +49,7 @@ public abstract class ModuleImpl implements Cloneable,Serializable,Module { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -60,7 +61,11 @@ public abstract class ModuleImpl implements Cloneable,Serializable,Module { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof ModuleImpl)){ + return false; + } return _objBean.equals(other); } @@ -72,6 +77,7 @@ public abstract class ModuleImpl implements Cloneable,Serializable,Module { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -82,6 +88,7 @@ public abstract class ModuleImpl implements Cloneable,Serializable,Module { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/module/SyModule.java b/src/main/java/com/sun/syndication/feed/module/SyModule.java index bfc4322..f241e91 100644 --- a/src/main/java/com/sun/syndication/feed/module/SyModule.java +++ b/src/main/java/com/sun/syndication/feed/module/SyModule.java @@ -31,13 +31,13 @@ public interface SyModule extends Module { * URI of the Syndication ModuleImpl (http://purl.org/rss/1.0/modules/syndication/). * */ - String URI = "http://purl.org/rss/1.0/modules/syndication/"; + static final String URI = "http://purl.org/rss/1.0/modules/syndication/"; - String HOURLY = new String("hourly"); - String DAILY = new String("daily"); - String WEEKLY = new String("weekly"); - String MONTHLY = new String("monthly"); - String YEARLY = new String("yearly"); + static final String HOURLY = "hourly"; + static final String DAILY = "daily"; + static final String WEEKLY = "weekly"; + static final String MONTHLY = "monthly"; + static final String YEARLY = "yearly"; /** * Returns the Syndication module update period. diff --git a/src/main/java/com/sun/syndication/feed/module/SyModuleImpl.java b/src/main/java/com/sun/syndication/feed/module/SyModuleImpl.java index c89285a..a87e8a9 100644 --- a/src/main/java/com/sun/syndication/feed/module/SyModuleImpl.java +++ b/src/main/java/com/sun/syndication/feed/module/SyModuleImpl.java @@ -16,6 +16,7 @@ */ package com.sun.syndication.feed.module; +import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.impl.CopyFromHelper; import java.util.*; @@ -28,7 +29,7 @@ import java.util.*; * */ public class SyModuleImpl extends ModuleImpl implements SyModule { - private static final Set PERIODS = new HashSet(); + private static final Set PERIODS = new HashSet(); static { PERIODS.add(HOURLY ); @@ -102,7 +103,7 @@ public class SyModuleImpl extends ModuleImpl implements SyModule { * */ public Date getUpdateBase() { - return _updateBase; + return new Date(_updateBase.getTime()); } /** @@ -112,14 +113,14 @@ public class SyModuleImpl extends ModuleImpl implements SyModule { * */ public void setUpdateBase(Date updateBase) { - _updateBase = updateBase; + _updateBase = new Date(updateBase.getTime()); } - public Class getInterface() { + public Class getInterface() { return SyModule.class; } - public void copyFrom(Object obj) { + public void copyFrom(CopyFrom obj) { COPY_FROM_HELPER.copy(this,obj); } diff --git a/src/main/java/com/sun/syndication/feed/module/impl/ModuleUtils.java b/src/main/java/com/sun/syndication/feed/module/impl/ModuleUtils.java index da59a12..ca1738c 100644 --- a/src/main/java/com/sun/syndication/feed/module/impl/ModuleUtils.java +++ b/src/main/java/com/sun/syndication/feed/module/impl/ModuleUtils.java @@ -25,33 +25,41 @@ import java.util.List; */ public class ModuleUtils { - public static List cloneModules(List modules) { - List cModules = null; + public static List cloneModules(List modules) { + List cModules = null; if (modules!=null) { - cModules = new ArrayList(); - for (int i=0;i(); + for (Module module : modules) { try { - Object c = module.clone(); + Module c = (Module) module.clone(); cModules.add(c); } catch (Exception ex) { - throw new RuntimeException("Cloning modules",ex); + throw new RuntimeException("Cloning modules "+module.getUri(),ex); } } } return cModules; } - public static Module getModule(List modules,String uri) { + /** + * + * + * @since 1.5 Changed to return the first, not the last. + * + * @param modules + * @param uri + * @return + */ + public static Module getModule(List modules,String uri) { Module module = null; - for (int i=0;module==null && modules!=null && itrue if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof Category)){ + return false; + } return _objBean.equals(other); } @@ -80,6 +86,7 @@ public class Category implements Cloneable,Serializable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/rss/Channel.java b/src/main/java/com/sun/syndication/feed/rss/Channel.java index f27e32b..a9e6749 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Channel.java +++ b/src/main/java/com/sun/syndication/feed/rss/Channel.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,16 +41,18 @@ public class Channel extends WireFeed { public static final String FRIDAY = "friday"; public static final String SATURDAY = "saturday"; - private static final Set DAYS = new HashSet(); + private static final Set DAYS; static { - DAYS.add(SUNDAY ); - DAYS.add(MONDAY ); - DAYS.add(TUESDAY ); - DAYS.add(WEDNESDAY); - DAYS.add(THURSDAY ); - DAYS.add(FRIDAY ); - DAYS.add(SATURDAY ); + HashSet days = new HashSet(); + days.add(SUNDAY ); + days.add(MONDAY ); + days.add(TUESDAY ); + days.add(WEDNESDAY); + days.add(THURSDAY ); + days.add(FRIDAY ); + days.add(SATURDAY ); + DAYS = Collections.unmodifiableSet(days); } private String _title; @@ -67,13 +70,13 @@ public class Channel extends WireFeed { private String _docs; private String _managingEditor; private String _webMaster; - private List _skipHours; - private List _skipDays; + private List _skipHours; + private List _skipDays; private Cloud _cloud; - private List _categories; + private List _categories; private String _generator; private int _ttl = -1; - private List _modules; + private List _modules; /** * Default constructor, for bean cloning purposes only. @@ -197,8 +200,8 @@ public class Channel extends WireFeed { * an empty list if none. * */ - public List getItems() { - return (_items==null) ? (_items=new ArrayList()) : _items; + public List getItems() { + return (_items==null) ? (_items=new ArrayList()) : _items; } /** @@ -208,7 +211,7 @@ public class Channel extends WireFeed { * an empty list or null if none. * */ - public void setItems(List items) { + public void setItems(List items) { _items = items; } @@ -299,7 +302,7 @@ public class Channel extends WireFeed { * */ public Date getPubDate() { - return _pubDate; + return _pubDate == null ? null : new Date(_pubDate.getTime()); } /** @@ -309,7 +312,7 @@ public class Channel extends WireFeed { * */ public void setPubDate(Date pubDate) { - _pubDate = pubDate; + _pubDate = pubDate == null ? null : new Date( pubDate.getTime()); } /** @@ -319,7 +322,7 @@ public class Channel extends WireFeed { * */ public Date getLastBuildDate() { - return _lastBuildDate; + return _lastBuildDate == null ? null : new Date(_lastBuildDate.getTime()); } /** @@ -329,7 +332,7 @@ public class Channel extends WireFeed { * */ public void setLastBuildDate(Date lastBuildDate) { - _lastBuildDate = lastBuildDate; + _lastBuildDate = lastBuildDate == null ? null : new Date( lastBuildDate.getTime()); } /** @@ -399,7 +402,7 @@ public class Channel extends WireFeed { * an empty list if none. * */ - public List getSkipHours() { + public List getSkipHours() { return (_skipHours!=null) ? _skipHours : new ArrayList(); } @@ -410,7 +413,7 @@ public class Channel extends WireFeed { * an empty list or null if none. * */ - public void setSkipHours(List skipHours) { + public void setSkipHours(List skipHours) { if (skipHours!=null) { for (int i=0;i getSkipDays() { + return (_skipDays!=null) ? _skipDays : new ArrayList(); } /** @@ -446,7 +449,7 @@ public class Channel extends WireFeed { * an empty list or null if none. * */ - public void setSkipDays(List skipDays) { + public void setSkipDays(List skipDays) { if (skipDays!=null) { for (int i=0;i getCategories() { + return (_categories==null) ? (_categories=new ArrayList()) : _categories; } /** @@ -503,7 +506,7 @@ public class Channel extends WireFeed { * an empty list or null if none. * */ - public void setCategories(List categories) { + public void setCategories(List categories) { _categories = categories; } @@ -554,8 +557,9 @@ public class Channel extends WireFeed { * an empty list if none. * */ - public List getModules() { - return (_modules==null) ? (_modules=new ArrayList()) : _modules; + @Override + public List getModules() { + return (_modules==null) ? (_modules=new ArrayList()) : _modules; } /** @@ -565,7 +569,8 @@ public class Channel extends WireFeed { * an empty list or null if none. * */ - public void setModules(List modules) { + @Override + public void setModules(List modules) { _modules = modules; } @@ -575,6 +580,7 @@ public class Channel extends WireFeed { * @param uri the URI of the ModuleImpl. * @return The module with the given URI, null if none. */ + @Override public Module getModule(String uri) { return ModuleUtils.getModule(_modules,uri); } diff --git a/src/main/java/com/sun/syndication/feed/rss/Cloud.java b/src/main/java/com/sun/syndication/feed/rss/Cloud.java index 1f300ae..69c27ae 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Cloud.java +++ b/src/main/java/com/sun/syndication/feed/rss/Cloud.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,6 +51,7 @@ public class Cloud implements Cloneable,Serializable { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -73,6 +75,7 @@ public class Cloud implements Cloneable,Serializable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -83,6 +86,7 @@ public class Cloud implements Cloneable,Serializable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/rss/Content.java b/src/main/java/com/sun/syndication/feed/rss/Content.java index 3c1da6f..07a47df 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Content.java +++ b/src/main/java/com/sun/syndication/feed/rss/Content.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,19 +21,19 @@ import com.sun.syndication.feed.impl.ObjectBean; import java.io.Serializable; + /** * Bean for item descriptions of RSS feeds. *

* @author Alejandro Abdelnur * */ -public class Content implements Cloneable,Serializable { +public class Content implements Cloneable, Serializable { + public static final String HTML = "html"; + public static final String TEXT = "text"; private ObjectBean _objBean; private String _type; private String _value; - - public static final String HTML = "html"; - public static final String TEXT = "text"; /** * Default constructor. All properties are set to null. @@ -40,61 +41,7 @@ public class Content implements Cloneable,Serializable { * */ public Content() { - _objBean = new ObjectBean(this.getClass(),this); - } - - /** - * Creates a deep 'bean' clone of the object. - *

- * @return a clone of the object. - * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. - * - */ - public Object clone() throws CloneNotSupportedException { - return _objBean.clone(); - } - - /** - * Indicates whether some other object is "equal to" this one as defined by the Object equals() method. - *

- * @param other he reference object with which to compare. - * @return true if 'this' object is equal to the 'other' object. - * - */ - public boolean equals(Object other) { - return _objBean.equals(other); - } - - /** - * Returns a hashcode value for the object. - *

- * It follows the contract defined by the Object hashCode() method. - *

- * @return the hashcode of the bean object. - * - */ - public int hashCode() { - return _objBean.hashCode(); - } - - /** - * Returns the String representation for the object. - *

- * @return String representation for the object. - * - */ - public String toString() { - return _objBean.toString(); - } - - /** - * Returns the description type. - *

- * @return the description type, null if none. - * - */ - public String getType() { - return _type; + _objBean = new ObjectBean(this.getClass(), this); } /** @@ -108,13 +55,13 @@ public class Content implements Cloneable,Serializable { } /** - * Returns the description value. + * Returns the description type. *

- * @return the description value, null if none. + * @return the description type, null if none. * */ - public String getValue() { - return _value; + public String getType() { + return _type; } /** @@ -127,4 +74,65 @@ public class Content implements Cloneable,Serializable { _value = value; } + /** + * Returns the description value. + *

+ * @return the description value, null if none. + * + */ + public String getValue() { + return _value; + } + + /** + * Creates a deep 'bean' clone of the object. + *

+ * @return a clone of the object. + * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. + * + */ + @Override + public Object clone() throws CloneNotSupportedException { + return _objBean.clone(); + } + + /** + * Indicates whether some other object is "equal to" this one as defined by the Object equals() method. + *

+ * @param other he reference object with which to compare. + * @return true if 'this' object is equal to the 'other' object. + * + */ + @Override + public boolean equals(Object other) { + if (!(other instanceof Content)) { + return false; + } + + return _objBean.equals(other); + } + + /** + * Returns a hashcode value for the object. + *

+ * It follows the contract defined by the Object hashCode() method. + *

+ * @return the hashcode of the bean object. + * + */ + @Override + public int hashCode() { + return _objBean.hashCode(); + } + + /** + * Returns the String representation for the object. + *

+ * @return String representation for the object. + * + */ + @Override + public String toString() { + return _objBean.toString(); + } } diff --git a/src/main/java/com/sun/syndication/feed/rss/Description.java b/src/main/java/com/sun/syndication/feed/rss/Description.java index b624c3a..c032abe 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Description.java +++ b/src/main/java/com/sun/syndication/feed/rss/Description.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +59,11 @@ public class Description implements Cloneable,Serializable { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof Description)){ + return false; + } return _objBean.equals(other); } @@ -70,6 +75,7 @@ public class Description implements Cloneable,Serializable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -80,6 +86,7 @@ public class Description implements Cloneable,Serializable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/rss/Enclosure.java b/src/main/java/com/sun/syndication/feed/rss/Enclosure.java index 6ec1190..4d22131 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Enclosure.java +++ b/src/main/java/com/sun/syndication/feed/rss/Enclosure.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +49,7 @@ public class Enclosure implements Cloneable,Serializable { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -59,7 +61,11 @@ public class Enclosure implements Cloneable,Serializable { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof Enclosure)){ + return false; + } return _objBean.equals(other); } @@ -71,6 +77,7 @@ public class Enclosure implements Cloneable,Serializable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -81,6 +88,7 @@ public class Enclosure implements Cloneable,Serializable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/rss/Guid.java b/src/main/java/com/sun/syndication/feed/rss/Guid.java index 29986e0..e75ace4 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Guid.java +++ b/src/main/java/com/sun/syndication/feed/rss/Guid.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,6 +48,7 @@ public class Guid implements Cloneable,Serializable { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -58,7 +60,11 @@ public class Guid implements Cloneable,Serializable { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof Guid)){ + return false; + } return _objBean.equals(other); } @@ -70,6 +76,7 @@ public class Guid implements Cloneable,Serializable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -80,6 +87,7 @@ public class Guid implements Cloneable,Serializable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/rss/Image.java b/src/main/java/com/sun/syndication/feed/rss/Image.java index 208a2fd..4971683 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Image.java +++ b/src/main/java/com/sun/syndication/feed/rss/Image.java @@ -31,8 +31,8 @@ public class Image implements Cloneable,Serializable { private String _title; private String _url; private String _link; - private int _width = -1; - private int _height = -1; + private Integer _width = -1; + private Integer _height = -1; private String _description; /** @@ -51,6 +51,7 @@ public class Image implements Cloneable,Serializable { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -62,7 +63,11 @@ public class Image implements Cloneable,Serializable { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof Image)){ + return false; + } return _objBean.equals(other); } @@ -74,6 +79,7 @@ public class Image implements Cloneable,Serializable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -84,6 +90,7 @@ public class Image implements Cloneable,Serializable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } @@ -154,7 +161,7 @@ public class Image implements Cloneable,Serializable { * @return the image width, null if none. * */ - public int getWidth() { + public Integer getWidth() { return _width; } @@ -164,7 +171,7 @@ public class Image implements Cloneable,Serializable { * @param width the image width to set, null if none. * */ - public void setWidth(int width) { + public void setWidth(Integer width) { _width = width; } @@ -174,7 +181,7 @@ public class Image implements Cloneable,Serializable { * @return the image height, null if none. * */ - public int getHeight() { + public Integer getHeight() { return _height; } @@ -184,7 +191,7 @@ public class Image implements Cloneable,Serializable { * @param height the image height to set, null if none. * */ - public void setHeight(int height) { + public void setHeight(Integer height) { _height = height; } diff --git a/src/main/java/com/sun/syndication/feed/rss/Item.java b/src/main/java/com/sun/syndication/feed/rss/Item.java index cc6004e..9931dd8 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Item.java +++ b/src/main/java/com/sun/syndication/feed/rss/Item.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,14 +46,14 @@ public class Item implements Cloneable, Serializable, Extendable { private Description _description; private Content _content; private Source _source; - private List _enclosures; - private List _categories; + private List _enclosures; + private List _categories; private Guid _guid; private String _comments; private String _author; private Date _pubDate; private Date _expirationDate; - private List _modules; + private List _modules; private List _foreignMarkup; /** @@ -71,6 +72,7 @@ public class Item implements Cloneable, Serializable, Extendable { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -82,8 +84,9 @@ public class Item implements Cloneable, Serializable, Extendable { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { - if (other == null) { + if (other == null || !(other instanceof Item)) { return false; } // can't use foreign markup in equals, due to JDOM equals impl @@ -103,6 +106,7 @@ public class Item implements Cloneable, Serializable, Extendable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -113,6 +117,7 @@ public class Item implements Cloneable, Serializable, Extendable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } @@ -242,8 +247,8 @@ public class Item implements Cloneable, Serializable, Extendable { * an empty list if none. * */ - public List getEnclosures() { - return (_enclosures==null) ? (_enclosures=new ArrayList()) : _enclosures; + public List getEnclosures() { + return (_enclosures==null) ? (_enclosures=new ArrayList()) : _enclosures; } /** @@ -253,7 +258,7 @@ public class Item implements Cloneable, Serializable, Extendable { * an empty list or null if none. * */ - public void setEnclosures(List enclosures) { + public void setEnclosures(List enclosures) { _enclosures = enclosures; } @@ -265,7 +270,7 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public List getCategories() { - return (_categories==null) ? (_categories=new ArrayList()) : _categories; + return (_categories==null) ? (_categories=new ArrayList()) : _categories; } /** @@ -275,7 +280,7 @@ public class Item implements Cloneable, Serializable, Extendable { * an empty list or null if none. * */ - public void setCategories(List categories) { + public void setCategories(List categories) { _categories = categories; } @@ -346,8 +351,8 @@ public class Item implements Cloneable, Serializable, Extendable { * an empty list if none. * */ - public List getModules() { - return (_modules==null) ? (_modules=new ArrayList()) : _modules; + public List getModules() { + return (_modules==null) ? (_modules=new ArrayList()) : _modules; } /** @@ -357,7 +362,7 @@ public class Item implements Cloneable, Serializable, Extendable { * an empty list or null if none. * */ - public void setModules(List modules) { + public void setModules(List modules) { _modules = modules; } @@ -379,7 +384,7 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public Date getPubDate() { - return _pubDate; + return _pubDate == null ? null : new Date( _pubDate.getTime()); } /** @@ -389,7 +394,7 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public void setPubDate(Date pubDate) { - _pubDate = pubDate; + _pubDate = pubDate == null ? null : new Date( pubDate.getTime()); } /** @@ -399,7 +404,7 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public Date getExpirationDate() { - return _expirationDate; + return _expirationDate == null ? null : new Date(_expirationDate.getTime()); } /** @@ -409,7 +414,7 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public void setExpirationDate(Date expirationDate) { - _expirationDate = expirationDate; + _expirationDate = expirationDate == null ? null : new Date(expirationDate.getTime()); } /** diff --git a/src/main/java/com/sun/syndication/feed/rss/Source.java b/src/main/java/com/sun/syndication/feed/rss/Source.java index d681b0c..8122e39 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Source.java +++ b/src/main/java/com/sun/syndication/feed/rss/Source.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,6 +48,7 @@ public class Source implements Cloneable,Serializable { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -58,7 +60,11 @@ public class Source implements Cloneable,Serializable { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof Source)){ + return false; + } return _objBean.equals(other); } @@ -70,6 +76,7 @@ public class Source implements Cloneable,Serializable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -80,6 +87,7 @@ public class Source implements Cloneable,Serializable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/rss/TextInput.java b/src/main/java/com/sun/syndication/feed/rss/TextInput.java index ea73a23..b797941 100644 --- a/src/main/java/com/sun/syndication/feed/rss/TextInput.java +++ b/src/main/java/com/sun/syndication/feed/rss/TextInput.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,6 +50,7 @@ public class TextInput implements Cloneable,Serializable { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -60,7 +62,11 @@ public class TextInput implements Cloneable,Serializable { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof TextInput)){ + return false; + } return _objBean.equals(other); } @@ -72,6 +78,7 @@ public class TextInput implements Cloneable,Serializable { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -82,6 +89,7 @@ public class TextInput implements Cloneable,Serializable { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndCategory.java b/src/main/java/com/sun/syndication/feed/synd/SyndCategory.java index 450ab6a..6354c33 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndCategory.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndCategory.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java index 9db36ba..eacefbb 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java @@ -1,6 +1,7 @@ /* * Copyright 2004 Sun Microsystems, Inc. - * + * Copyright 2011 ROME Team + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -31,7 +32,7 @@ import java.io.Serializable; * @author Alejandro Abdelnur * */ -public class SyndCategoryImpl implements Serializable,SyndCategory { +public class SyndCategoryImpl implements Serializable, SyndCategory { private ObjectBean _objBean; private DCSubject _subject; @@ -53,6 +54,7 @@ public class SyndCategoryImpl implements Serializable,SyndCategory { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -64,7 +66,11 @@ public class SyndCategoryImpl implements Serializable,SyndCategory { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof SyndCategoryImpl)){ + return false; + } return _objBean.equals(other); } @@ -76,6 +82,7 @@ public class SyndCategoryImpl implements Serializable,SyndCategory { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -86,6 +93,7 @@ public class SyndCategoryImpl implements Serializable,SyndCategory { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } @@ -168,14 +176,14 @@ public class SyndCategoryImpl implements Serializable,SyndCategory { * @author Alejandro Abdelnur * */ -class SyndCategoryListFacade extends AbstractList { - private List _subjects; +class SyndCategoryListFacade extends AbstractList { + private List _subjects; /** * Default constructor. Creates and empty list. */ public SyndCategoryListFacade() { - this(new ArrayList()); + this(new ArrayList()); } /** @@ -184,7 +192,7 @@ class SyndCategoryListFacade extends AbstractList { * @param subjects the list of subjects to create the facade. * */ - public SyndCategoryListFacade(List subjects) { + public SyndCategoryListFacade(List subjects) { _subjects = subjects; } @@ -195,7 +203,7 @@ class SyndCategoryListFacade extends AbstractList { * @return the SyndCategoryImpl in position index, null if none. * */ - public Object get(int index) { + public SyndCategory get(int index) { return new SyndCategoryImpl((DCSubject) _subjects.get(index)); } @@ -217,7 +225,8 @@ class SyndCategoryListFacade extends AbstractList { * @return the SyndCategoryImpl object that is being replaced, null if none. * */ - public Object set(int index,Object obj) { + @Override + public SyndCategory set(int index, SyndCategory obj) { SyndCategoryImpl sCat = (SyndCategoryImpl) obj; DCSubject subject = (sCat!=null) ? sCat.getSubject() : null; subject = (DCSubject) _subjects.set(index,subject); @@ -231,7 +240,8 @@ class SyndCategoryListFacade extends AbstractList { * @param obj the SyndCategoryImpl object to add. * */ - public void add(int index,Object obj) { + @Override + public void add(int index,SyndCategory obj) { SyndCategoryImpl sCat = (SyndCategoryImpl) obj; DCSubject subject = (sCat!=null) ? sCat.getSubject() : null; _subjects.add(index,subject); @@ -244,7 +254,8 @@ class SyndCategoryListFacade extends AbstractList { * @return the SyndCategoryImpl being removed from position index, null if none. * */ - public Object remove(int index) { + @Override + public SyndCategory remove(int index) { DCSubject subject = (DCSubject) _subjects.remove(index); return (subject!=null) ? new SyndCategoryImpl(subject) : null; } @@ -257,8 +268,8 @@ class SyndCategoryListFacade extends AbstractList { * @return a list with DCSubject elements corresponding to the categories in the given list. * */ - public static List convertElementsSyndCategoryToSubject(List cList) { - List sList = null; + public static List convertElementsSyndCategoryToSubject(List cList) { + List sList = null; if (cList!=null) { sList = new ArrayList(); for (int i=0;i { /** * Returns the content type. *

diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndContentImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndContentImpl.java index 251b1d5..7fd7f28 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndContentImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndContentImpl.java @@ -16,6 +16,7 @@ */ package com.sun.syndication.feed.synd; +import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.impl.CopyFromHelper; @@ -30,7 +31,7 @@ import java.io.Serializable; * @author Alejandro Abdelnur * */ -public class SyndContentImpl implements Serializable,SyndContent { +public class SyndContentImpl implements Serializable, SyndContent { private ObjectBean _objBean; private String _type; private String _value; @@ -157,7 +158,7 @@ public class SyndContentImpl implements Serializable,SyndContent { return SyndContent.class; } - public void copyFrom(Object obj) { + public void copyFrom(CopyFrom obj) { COPY_FROM_HELPER.copy(this,obj); } diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndEnclosure.java b/src/main/java/com/sun/syndication/feed/synd/SyndEnclosure.java index 344b0c8..34ee4e6 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndEnclosure.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndEnclosure.java @@ -5,7 +5,7 @@ import com.sun.syndication.feed.CopyFrom; /** * @author Alejandro Abdelnur */ -public interface SyndEnclosure extends Cloneable, CopyFrom { +public interface SyndEnclosure extends Cloneable, CopyFrom { /** * Returns the enclosure URL. *

diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndEnclosureImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndEnclosureImpl.java index eeb2cbf..2bb64ba 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndEnclosureImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndEnclosureImpl.java @@ -1,5 +1,6 @@ package com.sun.syndication.feed.synd; +import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.impl.CopyFromHelper; @@ -130,11 +131,11 @@ public class SyndEnclosureImpl implements Serializable,SyndEnclosure { _type = type; } - public Class getInterface() { + public Class getInterface() { return SyndEnclosure.class; } - public void copyFrom(Object obj) { + public void copyFrom(CopyFrom obj) { COPY_FROM_HELPER.copy(this,obj); } diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndEntry.java b/src/main/java/com/sun/syndication/feed/synd/SyndEntry.java index 2e3d6e6..fb7a286 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndEntry.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndEntry.java @@ -22,7 +22,6 @@ import java.util.List; import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.module.Extendable; import com.sun.syndication.feed.module.Module; -import com.sun.syndication.feed.rss.Item; /** * Bean interface for entries of SyndFeedImpl feeds. @@ -112,7 +111,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * @return the entry links, null if none. * */ - List getLinks(); + List getLinks(); /** * Sets the entry links. @@ -120,7 +119,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * @param links the entry links to set, null if none. * */ - void setLinks(List links); + void setLinks(List links); /** * Returns the entry description. @@ -145,7 +144,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * an empty list if none. * */ - List getContents(); + List getContents(); /** * Sets the entry contents. @@ -154,7 +153,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * an empty list or null if none. * */ - void setContents(List contents); + void setContents(List contents); /** * Returns the entry enclosures. @@ -163,7 +162,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * an empty list if none. * */ - public List getEnclosures(); + public List getEnclosures(); /** * Sets the entry enclosures. @@ -172,7 +171,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * an empty list or null if none. * */ - public void setEnclosures(List enclosures); + public void setEnclosures(List enclosures); /** * Returns the entry published date. @@ -220,7 +219,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * @return the feed author, null if none. * */ - List getAuthors(); + List getAuthors(); /** * Sets the entry author. @@ -232,7 +231,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * @param authors the feed author to set, null if none. * */ - void setAuthors(List authors); + void setAuthors(List authors); /** * Returns the name of the first entry author in the collection of authors. @@ -266,7 +265,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * @return the feed author, null if none. * */ - List getContributors(); + List getContributors(); /** * Sets the feed contributors. @@ -276,7 +275,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * @param contributors the feed contributors to set, null if none. * */ - void setContributors(List contributors); + void setContributors(List contributors); /** * Returns the entry categories. @@ -287,7 +286,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * an empty list if none. * */ - List getCategories(); + List getCategories(); /** * Sets the entry categories. @@ -298,7 +297,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * an empty list or null if none. * */ - void setCategories(List categories); + void setCategories(List categories); /** * Returns the entry source. @@ -346,7 +345,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * an empty list if none. * */ - List getModules(); + List getModules(); /** * Sets the entry modules. @@ -355,7 +354,7 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { * an empty list or null if none. * */ - void setModules(List modules); + void setModules(List modules); /** * Returns foreign markup found at channel level. @@ -382,4 +381,10 @@ public interface SyndEntry extends Cloneable, CopyFrom, Extendable { */ public Object clone() throws CloneNotSupportedException; + /** + * Returns the first instance of a SyndLink with the specified relation, or null + * + */ + public SyndLink findRelatedLink(String relation); + } diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java index ccee36b..13119cd 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java @@ -16,6 +16,7 @@ */ package com.sun.syndication.feed.synd; +import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.module.*; import com.sun.syndication.feed.module.impl.ModuleUtils; @@ -38,12 +39,12 @@ public class SyndEntryImpl implements Serializable,SyndEntry { private Date _updatedDate; private SyndContent _title; private SyndContent _description; - private List _links; - private List _contents; // deprecated by Atom 1.0 - private List _modules; - private List _enclosures; - private List _authors; - private List _contributors; + private List _links; + private List _contents; // deprecated by Atom 1.0 + private List _modules; + private List _enclosures; + private List _authors; + private List _contributors; private SyndFeed _source; private List _foreignMarkup; private Object wireEntry; // com.sun.syndication.feed.atom.Entry or com.sun.syndication.feed.rss.Item @@ -95,6 +96,7 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -106,6 +108,7 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { if (other == null) { return false; @@ -132,6 +135,7 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -142,6 +146,7 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } @@ -266,8 +271,8 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * an empty list if none. * */ - public List getContents() { - return (_contents==null) ? (_contents=new ArrayList()) : _contents; + public List getContents() { + return (_contents==null) ? (_contents=new ArrayList()) : _contents; } /** @@ -277,7 +282,7 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * an empty list or null if none. * */ - public void setContents(List contents) { + public void setContents(List contents) { _contents = contents; } @@ -288,8 +293,8 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * an empty list if none. * */ - public List getEnclosures() { - return (_enclosures==null) ? (_enclosures=new ArrayList()) : _enclosures; + public List getEnclosures() { + return (_enclosures==null) ? (_enclosures=new ArrayList()) : _enclosures; } /** @@ -299,7 +304,7 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * an empty list or null if none. * */ - public void setEnclosures(List enclosures) { + public void setEnclosures(List enclosures) { _enclosures = enclosures; } @@ -335,7 +340,7 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * an empty list if none. * */ - public List getCategories() { + public List getCategories() { return _categories; } @@ -348,7 +353,7 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * an empty list or null if none. * */ - public void setCategories(List categories) { + public void setCategories(List categories) { _categories = categories; } @@ -359,9 +364,9 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * an empty list if none. * */ - public List getModules() { + public List getModules() { if (_modules==null) { - _modules=new ArrayList(); + _modules=new ArrayList(); } if (ModuleUtils.getModule(_modules,DCModule.URI)==null) { _modules.add(new DCModuleImpl()); @@ -376,7 +381,7 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * an empty list or null if none. * */ - public void setModules(List modules) { + public void setModules(List modules) { _modules = modules; } @@ -403,7 +408,7 @@ public class SyndEntryImpl implements Serializable,SyndEntry { return SyndEntry.class; } - public void copyFrom(Object obj) { + public void copyFrom(CopyFrom obj) { COPY_FROM_HELPER.copy(this,obj); } @@ -434,8 +439,8 @@ public class SyndEntryImpl implements Serializable,SyndEntry { *

* @return Returns the links. */ - public List getLinks() { - return (_links==null) ? (_links=new ArrayList()) : _links; + public List getLinks() { + return (_links==null) ? (_links=new ArrayList()) : _links; } /** @@ -453,7 +458,7 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * @return Returns the updatedDate. */ public Date getUpdatedDate() { - return _updatedDate; + return _updatedDate == null ? null : new Date(_updatedDate.getTime()); } /** @@ -462,7 +467,7 @@ public class SyndEntryImpl implements Serializable,SyndEntry { * @param updatedDate The updatedDate to set. */ public void setUpdatedDate(Date updatedDate) { - _updatedDate = updatedDate; + _updatedDate = new Date(updatedDate.getTime()); } public List getAuthors() { @@ -568,4 +573,13 @@ public class SyndEntryImpl implements Serializable,SyndEntry { public void setWireEntry(Object wireEntry) { this.wireEntry = wireEntry; } + + public SyndLink findRelatedLink(String relation) { + for(SyndLink l : this.getLinks()){ + if(relation.equals(l.getRel())){ + return l; + } + } + return null; + } } diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndFeed.java b/src/main/java/com/sun/syndication/feed/synd/SyndFeed.java index 090fb88..c6ba350 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndFeed.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndFeed.java @@ -39,7 +39,7 @@ public interface SyndFeed extends Cloneable, CopyFrom, Extendable { *

* @return the real feed type supported. */ - List getSupportedFeedTypes(); + List getSupportedFeedTypes(); /** * Creates a real feed containing the information of the SyndFeedImpl. @@ -235,7 +235,7 @@ public interface SyndFeed extends Cloneable, CopyFrom, Extendable { * @return the entry links, null if none. * */ - List getLinks(); + List getLinks(); /** * Sets the entry links. @@ -243,7 +243,7 @@ public interface SyndFeed extends Cloneable, CopyFrom, Extendable { * @param links the entry links to set, null if none. * */ - void setLinks(List links); + void setLinks(List links); /** * Returns the feed description. @@ -307,7 +307,7 @@ public interface SyndFeed extends Cloneable, CopyFrom, Extendable { * @return the feed authors, null if none. * */ - List getAuthors(); + List getAuthors(); /** * Sets the feed authors. @@ -319,7 +319,7 @@ public interface SyndFeed extends Cloneable, CopyFrom, Extendable { * @param authors the feed authors to set, null if none. * */ - void setAuthors(List authors); + void setAuthors(List authors); /** * Returns the name of the first feed author in the collection of authors. @@ -354,7 +354,7 @@ public interface SyndFeed extends Cloneable, CopyFrom, Extendable { * @return the feed author, null if none. * */ - public List getContributors(); + public List getContributors(); /** * Sets the feed author. @@ -364,7 +364,7 @@ public interface SyndFeed extends Cloneable, CopyFrom, Extendable { * @param contributors the feed contributors to set, null if none. * */ - void setContributors(List contributors); + void setContributors(List contributors); /** * Returns the feed copyright. @@ -411,7 +411,7 @@ public interface SyndFeed extends Cloneable, CopyFrom, Extendable { * an empty list if none. * */ - List getCategories(); + List getCategories(); /** * Sets the feed categories. @@ -422,16 +422,16 @@ public interface SyndFeed extends Cloneable, CopyFrom, Extendable { * an empty list or null if none. * */ - void setCategories(List categories); + void setCategories(List categories); /** * Returns the feed entries. *

- * @return a list of SyndEntryImpl elements with the feed entries, + * @return a list of SyndEntry elements with the feed entries, * an empty list if none. * */ - List getEntries(); + List getEntries(); /** * Sets the feed entries. @@ -440,7 +440,7 @@ public interface SyndFeed extends Cloneable, CopyFrom, Extendable { * an empty list or null if none. * */ - void setEntries(List entries); + void setEntries(List entries); /** * Returns the feed language. @@ -477,7 +477,7 @@ public interface SyndFeed extends Cloneable, CopyFrom, Extendable { * an empty list if none. * */ - List getModules(); + List getModules(); /** * Sets the feed modules. diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java index 531d612..4e8ff37 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java @@ -16,6 +16,7 @@ */ package com.sun.syndication.feed.synd; +import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.impl.CopyFromHelper; import com.sun.syndication.feed.WireFeed; @@ -657,7 +658,7 @@ public class SyndFeedImpl implements Serializable, SyndFeed { return SyndFeed.class; } - public void copyFrom(Object obj) { + public void copyFrom(CopyFrom obj) { COPY_FROM_HELPER.copy(this,obj); } diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndImage.java b/src/main/java/com/sun/syndication/feed/synd/SyndImage.java index cfff70b..423530e 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndImage.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndImage.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndImageImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndImageImpl.java index f9383f2..3193c58 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndImageImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndImageImpl.java @@ -16,6 +16,7 @@ */ package com.sun.syndication.feed.synd; +import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.impl.CopyFromHelper; @@ -174,7 +175,7 @@ public class SyndImageImpl implements Serializable,SyndImage { return SyndImage.class; } - public void copyFrom(Object syndImage) { + public void copyFrom(CopyFrom syndImage) { COPY_FROM_HELPER.copy(this,syndImage); } diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndLink.java b/src/main/java/com/sun/syndication/feed/synd/SyndLink.java index f3da26a..f16a3d4 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndLink.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndLink.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +38,7 @@ public interface SyndLink { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public abstract boolean equals(Object other); /** @@ -47,6 +49,7 @@ public interface SyndLink { * @return the hashcode of the bean object. * */ + @Override public abstract int hashCode(); /** @@ -55,6 +58,7 @@ public interface SyndLink { * @return String representation for the object. * */ + @Override public abstract String toString(); /** diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndLinkImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndLinkImpl.java index a996488..8ab5e0e 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndLinkImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndLinkImpl.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +54,7 @@ public class SyndLinkImpl implements Cloneable,Serializable, SyndLink { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -64,7 +66,11 @@ public class SyndLinkImpl implements Cloneable,Serializable, SyndLink { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof SyndLinkImpl)){ + return false; + } return _objBean.equals(other); } @@ -76,6 +82,7 @@ public class SyndLinkImpl implements Cloneable,Serializable, SyndLink { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -86,6 +93,7 @@ public class SyndLinkImpl implements Cloneable,Serializable, SyndLink { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndPerson.java b/src/main/java/com/sun/syndication/feed/synd/SyndPerson.java index 869f479..8b22b79 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndPerson.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndPerson.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndPersonImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndPersonImpl.java index c77ea23..c6c7989 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndPersonImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndPersonImpl.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,12 +18,9 @@ package com.sun.syndication.feed.synd; import com.sun.syndication.feed.impl.ObjectBean; -import com.sun.syndication.feed.module.DCSubjectImpl; -import com.sun.syndication.feed.module.DCSubject; import com.sun.syndication.feed.module.Module; import com.sun.syndication.feed.module.impl.ModuleUtils; -import java.util.AbstractList; import java.util.List; import java.util.ArrayList; import java.io.Serializable; @@ -55,6 +53,7 @@ public class SyndPersonImpl implements Serializable, SyndPerson { * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * */ + @Override public Object clone() throws CloneNotSupportedException { return _objBean.clone(); } @@ -66,7 +65,11 @@ public class SyndPersonImpl implements Serializable, SyndPerson { * @return true if 'this' object is equal to the 'other' object. * */ + @Override public boolean equals(Object other) { + if(!(other instanceof SyndPersonImpl)){ + return false; + } return _objBean.equals(other); } @@ -78,6 +81,7 @@ public class SyndPersonImpl implements Serializable, SyndPerson { * @return the hashcode of the bean object. * */ + @Override public int hashCode() { return _objBean.hashCode(); } @@ -88,6 +92,7 @@ public class SyndPersonImpl implements Serializable, SyndPerson { * @return String representation for the object. * */ + @Override public String toString() { return _objBean.toString(); } diff --git a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForAtom03.java b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForAtom03.java index 81149ba..6b76f12 100644 --- a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForAtom03.java +++ b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForAtom03.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Sun Microsystems, Inc. + * Copyright 2011 The ROME Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForRSS094.java b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForRSS094.java index 128354a..25eca4f 100644 --- a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForRSS094.java +++ b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForRSS094.java @@ -23,6 +23,8 @@ import com.sun.syndication.feed.rss.Guid; import com.sun.syndication.feed.rss.Item; import com.sun.syndication.feed.synd.SyndEntry; import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.feed.synd.SyndLink; +import com.sun.syndication.feed.synd.SyndLinkImpl; import com.sun.syndication.feed.synd.SyndPerson; import java.util.ArrayList; @@ -42,6 +44,7 @@ public class ConverterForRSS094 extends ConverterForRSS093 { super(type); } + @Override public void copyInto(WireFeed feed,SyndFeed syndFeed) { Channel channel = (Channel) feed; super.copyInto(channel,syndFeed); @@ -54,6 +57,7 @@ public class ConverterForRSS094 extends ConverterForRSS093 { } } + @Override protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) { SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem); @@ -80,6 +84,12 @@ public class ConverterForRSS094 extends ConverterForRSS093 { else { syndEntry.setUri(item.getLink()); } + if(item.getComments() != null){ + SyndLinkImpl comments = new SyndLinkImpl(); + comments.setRel("comments"); + comments.setHref(item.getComments()); + comments.setType("text/html"); + } return syndEntry; } @@ -93,6 +103,7 @@ public class ConverterForRSS094 extends ConverterForRSS093 { return channel; } + @Override protected Item createRSSItem(SyndEntry sEntry) { Item item = super.createRSSItem(sEntry); if (sEntry.getAuthors()!=null && sEntry.getAuthors().size() > 0) { @@ -116,7 +127,10 @@ public class ConverterForRSS094 extends ConverterForRSS093 { } } item.setGuid(guid); - + SyndLink comments = sEntry.findRelatedLink("comments"); + if(comments != null && (comments.getType() == null || comments.getType().endsWith("html"))){ + item.setComments(comments.getHref()); + } return item; } diff --git a/src/main/java/com/sun/syndication/io/impl/RSS091UserlandGenerator.java b/src/main/java/com/sun/syndication/io/impl/RSS091UserlandGenerator.java index 317d831..ad7c3b1 100644 --- a/src/main/java/com/sun/syndication/io/impl/RSS091UserlandGenerator.java +++ b/src/main/java/com/sun/syndication/io/impl/RSS091UserlandGenerator.java @@ -21,13 +21,15 @@ import com.sun.syndication.feed.rss.Description; import com.sun.syndication.feed.rss.Image; import com.sun.syndication.feed.rss.Item; import com.sun.syndication.io.FeedException; + import org.jdom.Attribute; import org.jdom.Document; import org.jdom.Element; import org.jdom.Namespace; -import java.util.List; import java.util.Date; +import java.util.List; + /** * Feed Generator for RSS 0.91 @@ -40,148 +42,18 @@ public class RSS091UserlandGenerator extends RSS090Generator { private String _version; public RSS091UserlandGenerator() { - this("rss_0.91U","0.91"); + this("rss_0.91U", "0.91"); } - protected RSS091UserlandGenerator(String type,String version) { + protected RSS091UserlandGenerator(String type, String version) { super(type); _version = version; } - protected String getVersion() { - return _version; - } - protected Namespace getFeedNamespace() { return Namespace.NO_NAMESPACE; } - protected Document createDocument(Element root) { - return new Document(root); - } - - protected Element createRootElement(Channel channel) { - Element root = new Element("rss",getFeedNamespace()); - Attribute version = new Attribute("version", getVersion()); - root.setAttribute(version); - root.addNamespaceDeclaration(getContentNamespace()); - generateModuleNamespaceDefs(root); - return root; - } - - protected void populateFeed(Channel channel,Element parent) throws FeedException { - addChannel(channel,parent); - } - - protected void addChannel(Channel channel,Element parent) throws FeedException { - super.addChannel(channel,parent); - Element eChannel = parent.getChild("channel",getFeedNamespace()); - - addImage(channel,eChannel); - addTextInput(channel,eChannel); - addItems(channel,eChannel); - } - - protected void populateChannel(Channel channel,Element eChannel) { - super.populateChannel(channel,eChannel); - String language = channel.getLanguage(); - if (language != null) { - eChannel.addContent(generateSimpleElement("language", language)); - } - - String rating = channel.getRating(); - if (rating != null) { - eChannel.addContent(generateSimpleElement("rating", rating)); - } - - String copyright = channel.getCopyright(); - if (copyright != null) { - eChannel.addContent(generateSimpleElement("copyright", copyright)); - } - - Date pubDate = channel.getPubDate(); - if (pubDate != null) { - eChannel.addContent(generateSimpleElement("pubDate", DateParser.formatRFC822(pubDate))); - } - - Date lastBuildDate = channel.getLastBuildDate(); - if (lastBuildDate != null) { - eChannel.addContent(generateSimpleElement("lastBuildDate", DateParser.formatRFC822(lastBuildDate))); - } - - String docs = channel.getDocs(); - if (docs != null) { - eChannel.addContent(generateSimpleElement("docs", docs)); - } - - String managingEditor = channel.getManagingEditor(); - if (managingEditor != null) { - eChannel.addContent(generateSimpleElement("managingEditor", managingEditor)); - } - - String webMaster = channel.getWebMaster(); - if (webMaster != null) { - eChannel.addContent(generateSimpleElement("webMaster", webMaster)); - } - - List skipHours = channel.getSkipHours(); - if (skipHours != null && skipHours.size()>0) { - eChannel.addContent(generateSkipHoursElement(skipHours)); - } - - List skipDays = channel.getSkipDays(); - if (skipDays != null && skipDays.size()>0) { - eChannel.addContent(generateSkipDaysElement(skipDays)); - } - } - - protected Element generateSkipHoursElement(List hours) { - Element skipHoursElement = new Element("skipHours",getFeedNamespace()); - for (int i = 0; i < hours.size(); i++) { - skipHoursElement.addContent(generateSimpleElement("hour", hours.get(i).toString())); - } - return skipHoursElement; - } - - protected Element generateSkipDaysElement(List days) { - Element skipDaysElement = new Element("skipDays"); - for (int i = 0; i < days.size(); i++) { - skipDaysElement.addContent(generateSimpleElement("day", days.get(i).toString())); - } - return skipDaysElement; - } - - protected void populateImage(Image image,Element eImage) { - super.populateImage(image,eImage); - - int width = image.getWidth(); - if (width>-1) { - eImage.addContent(generateSimpleElement("width",String.valueOf(width))); - } - int height = image.getHeight(); - if (height>-1) { - eImage.addContent(generateSimpleElement("height",String.valueOf(height))); - } - - String description = image.getDescription(); - if (description!=null) { - eImage.addContent(generateSimpleElement("description",description)); - } - } - - protected void populateItem(Item item, Element eItem, int index) { - super.populateItem(item,eItem, index); - Description description = item.getDescription(); - if (description!=null) { - eItem.addContent(generateSimpleElement("description",description.getValue())); - } - if (item.getModule(getContentNamespace().getURI()) == null && item.getContent() != null) { - Element elem = new Element("encoded", getContentNamespace()); - elem.addContent(item.getContent().getValue()); - eItem.addContent(elem); - } - } - /** * To be overriden by RSS 0.91 Netscape and RSS 0.94 */ @@ -189,63 +61,223 @@ public class RSS091UserlandGenerator extends RSS090Generator { return true; } - protected void checkChannelConstraints(Element eChannel) throws FeedException { - checkNotNullAndLength(eChannel,"title", 1, 100); - checkNotNullAndLength(eChannel,"description", 1, 500); - checkNotNullAndLength(eChannel,"link", 1, 500); - checkNotNullAndLength(eChannel,"language", 2, 5); + protected String getVersion() { + return _version; + } - checkLength(eChannel,"rating", 20, 500); - checkLength(eChannel,"copyright", 1, 100); - checkLength(eChannel,"pubDate", 1, 100); - checkLength(eChannel,"lastBuildDate", 1, 100); - checkLength(eChannel,"docs", 1, 500); - checkLength(eChannel,"managingEditor", 1, 100); - checkLength(eChannel,"webMaster", 1, 100); + protected void addChannel(Channel channel, Element parent) + throws FeedException { + super.addChannel(channel, parent); + + Element eChannel = parent.getChild("channel", getFeedNamespace()); + + addImage(channel, eChannel); + addTextInput(channel, eChannel); + addItems(channel, eChannel); + } + + protected void checkChannelConstraints(Element eChannel) + throws FeedException { + checkNotNullAndLength(eChannel, "title", 1, 100); + checkNotNullAndLength(eChannel, "description", 1, 500); + checkNotNullAndLength(eChannel, "link", 1, 500); + checkNotNullAndLength(eChannel, "language", 2, 5); + + checkLength(eChannel, "rating", 20, 500); + checkLength(eChannel, "copyright", 1, 100); + checkLength(eChannel, "pubDate", 1, 100); + checkLength(eChannel, "lastBuildDate", 1, 100); + checkLength(eChannel, "docs", 1, 500); + checkLength(eChannel, "managingEditor", 1, 100); + checkLength(eChannel, "webMaster", 1, 100); Element skipHours = eChannel.getChild("skipHours"); - if (skipHours!=null) { + + if (skipHours != null) { List hours = skipHours.getChildren(); - for (int i=0;i24) { - throw new FeedException("Invalid hour value "+value+", it must be between 1 and 24"); + if ((value < 1) || (value > 24)) { + throw new FeedException("Invalid hour value " + value + ", it must be between 1 and 24"); } - } - else { - if (value<0 || value>23) { - throw new FeedException("Invalid hour value "+value+", it must be between 0 and 23"); + } else { + if ((value < 0) || (value > 23)) { + throw new FeedException("Invalid hour value " + value + ", it must be between 0 and 23"); } } } } } - protected void checkImageConstraints(Element eImage) throws FeedException { - checkNotNullAndLength(eImage,"title", 1, 100); - checkNotNullAndLength(eImage,"url", 1, 500); + protected void checkImageConstraints(Element eImage) + throws FeedException { + checkNotNullAndLength(eImage, "title", 1, 100); + checkNotNullAndLength(eImage, "url", 1, 500); - checkLength(eImage,"link", 1, 500); - checkLength(eImage,"width", 1, 3); - checkLength(eImage,"width", 1, 3); - checkLength(eImage,"description", 1, 100); + checkLength(eImage, "link", 1, 500); + checkLength(eImage, "width", 1, 3); + checkLength(eImage, "width", 1, 3); + checkLength(eImage, "description", 1, 100); } + protected void checkItemConstraints(Element eItem) + throws FeedException { + checkNotNullAndLength(eItem, "title", 1, 100); + checkNotNullAndLength(eItem, "link", 1, 500); - protected void checkTextInputConstraints(Element eTextInput) throws FeedException { - checkNotNullAndLength(eTextInput,"title", 1, 100); - checkNotNullAndLength(eTextInput,"description", 1, 500); - checkNotNullAndLength(eTextInput,"name", 1, 20); - checkNotNullAndLength(eTextInput,"link", 1, 500); + checkLength(eItem, "description", 1, 500); } - protected void checkItemConstraints(Element eItem) throws FeedException { - checkNotNullAndLength(eItem,"title", 1, 100); - checkNotNullAndLength(eItem,"link", 1, 500); - - checkLength(eItem,"description", 1, 500); + protected void checkTextInputConstraints(Element eTextInput) + throws FeedException { + checkNotNullAndLength(eTextInput, "title", 1, 100); + checkNotNullAndLength(eTextInput, "description", 1, 500); + checkNotNullAndLength(eTextInput, "name", 1, 20); + checkNotNullAndLength(eTextInput, "link", 1, 500); } + protected Document createDocument(Element root) { + return new Document(root); + } + + protected Element createRootElement(Channel channel) { + Element root = new Element("rss", getFeedNamespace()); + Attribute version = new Attribute("version", getVersion()); + root.setAttribute(version); + root.addNamespaceDeclaration(getContentNamespace()); + generateModuleNamespaceDefs(root); + + return root; + } + + protected Element generateSkipDaysElement(List days) { + Element skipDaysElement = new Element("skipDays"); + + for (int i = 0; i < days.size(); i++) { + skipDaysElement.addContent(generateSimpleElement("day", days.get(i).toString())); + } + + return skipDaysElement; + } + + protected Element generateSkipHoursElement(List hours) { + Element skipHoursElement = new Element("skipHours", getFeedNamespace()); + + for (int i = 0; i < hours.size(); i++) { + skipHoursElement.addContent(generateSimpleElement("hour", hours.get(i).toString())); + } + + return skipHoursElement; + } + + protected void populateChannel(Channel channel, Element eChannel) { + super.populateChannel(channel, eChannel); + + String language = channel.getLanguage(); + + if (language != null) { + eChannel.addContent(generateSimpleElement("language", language)); + } + + String rating = channel.getRating(); + + if (rating != null) { + eChannel.addContent(generateSimpleElement("rating", rating)); + } + + String copyright = channel.getCopyright(); + + if (copyright != null) { + eChannel.addContent(generateSimpleElement("copyright", copyright)); + } + + Date pubDate = channel.getPubDate(); + + if (pubDate != null) { + eChannel.addContent(generateSimpleElement("pubDate", DateParser.formatRFC822(pubDate))); + } + + Date lastBuildDate = channel.getLastBuildDate(); + + if (lastBuildDate != null) { + eChannel.addContent(generateSimpleElement("lastBuildDate", DateParser.formatRFC822(lastBuildDate))); + } + + String docs = channel.getDocs(); + + if (docs != null) { + eChannel.addContent(generateSimpleElement("docs", docs)); + } + + String managingEditor = channel.getManagingEditor(); + + if (managingEditor != null) { + eChannel.addContent(generateSimpleElement("managingEditor", managingEditor)); + } + + String webMaster = channel.getWebMaster(); + + if (webMaster != null) { + eChannel.addContent(generateSimpleElement("webMaster", webMaster)); + } + + List skipHours = channel.getSkipHours(); + + if ((skipHours != null) && (skipHours.size() > 0)) { + eChannel.addContent(generateSkipHoursElement(skipHours)); + } + + List skipDays = channel.getSkipDays(); + + if ((skipDays != null) && (skipDays.size() > 0)) { + eChannel.addContent(generateSkipDaysElement(skipDays)); + } + } + + protected void populateFeed(Channel channel, Element parent) + throws FeedException { + addChannel(channel, parent); + } + + protected void populateImage(Image image, Element eImage) { + super.populateImage(image, eImage); + + Integer width = image.getWidth(); + + if (width != null) { + eImage.addContent(generateSimpleElement("width", String.valueOf(width))); + } + + Integer height = image.getHeight(); + + if (height != null) { + eImage.addContent(generateSimpleElement("height", String.valueOf(height))); + } + + String description = image.getDescription(); + + if (description != null) { + eImage.addContent(generateSimpleElement("description", description)); + } + } + + protected void populateItem(Item item, Element eItem, int index) { + super.populateItem(item, eItem, index); + + Description description = item.getDescription(); + + if (description != null) { + eItem.addContent(generateSimpleElement("description", description.getValue())); + } + + if ((item.getModule(getContentNamespace().getURI()) == null) && (item.getContent() != null)) { + Element elem = new Element("encoded", getContentNamespace()); + elem.addContent(item.getContent().getValue()); + eItem.addContent(elem); + } + } } diff --git a/src/test/java/com/sun/syndication/unittest/TestSyndFeedRSS094.java b/src/test/java/com/sun/syndication/unittest/TestSyndFeedRSS094.java index 293a27a..f33b983 100644 --- a/src/test/java/com/sun/syndication/unittest/TestSyndFeedRSS094.java +++ b/src/test/java/com/sun/syndication/unittest/TestSyndFeedRSS094.java @@ -14,37 +14,43 @@ import java.util.List; * */ public class TestSyndFeedRSS094 extends TestSyndFeedRSS093 { - - public TestSyndFeedRSS094() { - super("rss_0.94"); - } + public TestSyndFeedRSS094() { + super("rss_0.94"); + } protected TestSyndFeedRSS094(String type) { super(type); } - protected TestSyndFeedRSS094(String feedType,String feedFileName) { - super(feedType,feedFileName); + protected TestSyndFeedRSS094(String feedType, String feedFileName) { + super(feedType, feedFileName); } public void testCategories() throws Exception { - _testCategories(getCachedSyndFeed().getCategories(),"channel"); + _testCategories(getCachedSyndFeed().getCategories(), "channel"); } + + + @Override + protected void _testDescriptionType(SyndEntry entry, int i) + throws Exception { + } + + @Override protected void _testItem(int i) throws Exception { super._testItem(i); - List items = getCachedSyndFeed().getEntries(); + + List items = getCachedSyndFeed() + .getEntries(); SyndEntry entry = (SyndEntry) items.get(i); - assertProperty(entry.getAuthor(),"channel.item["+i+"].author"); + assertProperty(entry.getAuthor(), "channel.item[" + i + "].author"); + } - protected void _testDescriptionType(SyndEntry entry,int i) throws Exception { + @Override + protected void _testUri(SyndEntry entry, int i) throws Exception { + assertProperty(entry.getUri(), "channel.item[" + i + "].guid"); } - - protected void _testUri(SyndEntry entry,int i) throws Exception { - assertProperty(entry.getUri(),"channel.item["+i+"].guid"); - } - - } diff --git a/src/test/java/com/sun/syndication/unittest/issues/Issue1Test.java b/src/test/java/com/sun/syndication/unittest/issues/Issue1TestX.java similarity index 91% rename from src/test/java/com/sun/syndication/unittest/issues/Issue1Test.java rename to src/test/java/com/sun/syndication/unittest/issues/Issue1TestX.java index 66f2356..7c0e39e 100644 --- a/src/test/java/com/sun/syndication/unittest/issues/Issue1Test.java +++ b/src/test/java/com/sun/syndication/unittest/issues/Issue1TestX.java @@ -23,9 +23,9 @@ import com.sun.syndication.unittest.SyndFeedTest; * * @author robert.cooper */ -public class Issue1Test extends SyndFeedTest { +public class Issue1TestX extends SyndFeedTest { - public Issue1Test(){ + public Issue1TestX(){ super("rss_2.0", "jira_issue1.xml"); } diff --git a/src/test/java/com/sun/syndication/unittest/issues/Issue2Test.java b/src/test/java/com/sun/syndication/unittest/issues/Issue2Test.java new file mode 100644 index 0000000..fbe1032 --- /dev/null +++ b/src/test/java/com/sun/syndication/unittest/issues/Issue2Test.java @@ -0,0 +1,44 @@ +/* + * Copyright 2011 robert.cooper. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * under the License. + */ + +package com.sun.syndication.unittest.issues; + +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.unittest.TestSyndFeedRSS094; +import java.util.List; + +/** + * + * @author robert.cooper + */ +public class Issue2Test extends TestSyndFeedRSS094 { + + @Override + protected void _testItem(int i) throws Exception { + super._testItem(i); + List items = getCachedSyndFeed() + .getEntries(); + SyndEntry entry = items.get(i); + _testComments(entry, i); + } + + protected void _testComments(SyndEntry entry, int i) + throws Exception { + assertProperty(entry.findRelatedLink("comments").getHref(), "rss_0.94.channel.item[" + i + "].comments"); + } + +}