Refactored code
This commit is contained in:
parent
ef9345d55e
commit
bc845fe0aa
61 changed files with 3204 additions and 3069 deletions
4
pom.xml
4
pom.xml
|
@ -97,6 +97,10 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.rometools</groupId>
|
||||||
|
<artifactId>rome-utils</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jdom</groupId>
|
<groupId>org.jdom</groupId>
|
||||||
<artifactId>jdom</artifactId>
|
<artifactId>jdom</artifactId>
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
package com.sun.syndication.feed;
|
package com.sun.syndication.feed;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jdom2.Element;
|
import org.jdom2.Element;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.impl.ObjectBean;
|
import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
import com.sun.syndication.feed.module.Extendable;
|
import com.sun.syndication.feed.module.Extendable;
|
||||||
import com.sun.syndication.feed.module.Module;
|
import com.sun.syndication.feed.module.Module;
|
||||||
|
@ -38,13 +38,16 @@ import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
* The format of the 'type' property must be [FEEDNAME]_[FEEDVERSION] with the FEEDNAME in lower
|
* The format of the 'type' property must be [FEEDNAME]_[FEEDVERSION] with the FEEDNAME in lower
|
||||||
* case, for example: rss_0.9, rss_0.93, atom_0.3
|
* case, for example: rss_0.9, rss_0.93, atom_0.3
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -3608120400805691829L;
|
private static final long serialVersionUID = -3608120400805691829L;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
|
|
||||||
private String feedType;
|
private String feedType;
|
||||||
private String encoding;
|
private String encoding;
|
||||||
private String styleSheet;
|
private String styleSheet;
|
||||||
|
@ -53,8 +56,6 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor, for bean cloning purposes only.
|
* Default constructor, for bean cloning purposes only.
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
protected WireFeed() {
|
protected WireFeed() {
|
||||||
objBean = new ObjectBean(this.getClass(), this);
|
objBean = new ObjectBean(this.getClass(), this);
|
||||||
|
@ -62,10 +63,9 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a feed for a given type.
|
* Creates a feed for a given type.
|
||||||
* <p>
|
*
|
||||||
*
|
|
||||||
* @param type of the feed to create.
|
* @param type of the feed to create.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected WireFeed(final String type) {
|
protected WireFeed(final String type) {
|
||||||
this();
|
this();
|
||||||
|
@ -74,11 +74,10 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
*
|
||||||
*
|
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -88,20 +87,22 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
*
|
||||||
*
|
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(other instanceof WireFeed)) {
|
if (!(other instanceof WireFeed)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// can't use foreign markup in equals, due to JDOM equals impl
|
// can't use foreign markup in equals, due to JDOM equals impl
|
||||||
final List<Element> fm = getForeignMarkup();
|
final List<Element> fm = getForeignMarkup();
|
||||||
setForeignMarkup(((WireFeed) other).getForeignMarkup());
|
setForeignMarkup(((WireFeed) other).getForeignMarkup());
|
||||||
|
@ -109,6 +110,7 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
// restore foreign markup
|
// restore foreign markup
|
||||||
setForeignMarkup(fm);
|
setForeignMarkup(fm);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,9 +118,9 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -128,9 +130,9 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -140,9 +142,9 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the feedType of a the feed. <b>Do not use</b>, for bean cloning purposes only.
|
* Sets the feedType of a the feed. <b>Do not use</b>, for bean cloning purposes only.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param feedType the feedType of the feed.
|
* @param feedType the feedType of the feed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setFeedType(final String feedType) {
|
public void setFeedType(final String feedType) {
|
||||||
this.feedType = feedType;
|
this.feedType = feedType;
|
||||||
|
@ -150,7 +152,7 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the feed.
|
* Returns the type of the feed.
|
||||||
*
|
*
|
||||||
* @return the type of the feed.
|
* @return the type of the feed.
|
||||||
*/
|
*/
|
||||||
public String getFeedType() {
|
public String getFeedType() {
|
||||||
|
@ -163,9 +165,9 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
* This property is not set by feed parsers. But it is used by feed generators to set the
|
* This property is not set by feed parsers. But it is used by feed generators to set the
|
||||||
* encoding in the XML prolog.
|
* encoding in the XML prolog.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the charset encoding of the feed.
|
* @return the charset encoding of the feed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getEncoding() {
|
public String getEncoding() {
|
||||||
return encoding;
|
return encoding;
|
||||||
|
@ -177,9 +179,9 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
* This property is not set by feed parsers. But it is used by feed generators to set the
|
* This property is not set by feed parsers. But it is used by feed generators to set the
|
||||||
* encoding in the XML prolog.
|
* encoding in the XML prolog.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param encoding the charset encoding of the feed.
|
* @param encoding the charset encoding of the feed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setEncoding(final String encoding) {
|
public void setEncoding(final String encoding) {
|
||||||
this.encoding = encoding;
|
this.encoding = encoding;
|
||||||
|
@ -188,25 +190,22 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the channel modules.
|
* Returns the channel modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of ModuleImpl elements with the channel modules, an empty list if none.
|
* @return a list of ModuleImpl elements with the channel modules, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Module> getModules() {
|
public List<Module> getModules() {
|
||||||
if (modules == null) {
|
return modules = Lists.createWhenNull(modules);
|
||||||
modules = new ArrayList<Module>();
|
|
||||||
}
|
|
||||||
return modules;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the channel modules.
|
* Sets the channel modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param modules the list of ModuleImpl elements with the channel modules to set, an empty list
|
* @param modules the list of ModuleImpl elements with the channel modules to set, an empty list
|
||||||
* or <b>null</b> if none.
|
* or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModules(final List<Module> modules) {
|
public void setModules(final List<Module> modules) {
|
||||||
|
@ -216,7 +215,7 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the module identified by a given URI.
|
* Returns the module identified by a given URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the URI of the ModuleImpl.
|
* @param uri the URI of the ModuleImpl.
|
||||||
* @return The module with the given URI, <b>null</b> if none.
|
* @return The module with the given URI, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
@ -228,23 +227,20 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns foreign markup found at channel level.
|
* Returns foreign markup found at channel level.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Opaque object to discourage use
|
* @return Opaque object to discourage use
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Element> getForeignMarkup() {
|
public List<Element> getForeignMarkup() {
|
||||||
if (foreignMarkup == null) {
|
return foreignMarkup = Lists.createWhenNull(foreignMarkup);
|
||||||
foreignMarkup = new ArrayList<Element>();
|
|
||||||
}
|
|
||||||
return foreignMarkup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets foreign markup found at channel level.
|
* Sets foreign markup found at channel level.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param foreignMarkup Opaque object to discourage use
|
* @param foreignMarkup Opaque object to discourage use
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setForeignMarkup(final List<Element> foreignMarkup) {
|
public void setForeignMarkup(final List<Element> foreignMarkup) {
|
||||||
this.foreignMarkup = foreignMarkup;
|
this.foreignMarkup = foreignMarkup;
|
||||||
|
@ -252,7 +248,7 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL of XSL-Stylesheet.
|
* URL of XSL-Stylesheet.
|
||||||
*
|
*
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
* @return styleSheet URL or {@code null}
|
* @return styleSheet URL or {@code null}
|
||||||
*/
|
*/
|
||||||
|
@ -262,11 +258,12 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL of XSL-Stylesheet.
|
* URL of XSL-Stylesheet.
|
||||||
*
|
*
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
* @param styleSheet URL or {@code null}
|
* @param styleSheet URL or {@code null}
|
||||||
*/
|
*/
|
||||||
public void setStyleSheet(final String styleSheet) {
|
public void setStyleSheet(final String styleSheet) {
|
||||||
this.styleSheet = styleSheet;
|
this.styleSheet = styleSheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,17 @@ package com.sun.syndication.feed.atom;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.rometools.utils.Alternatives;
|
||||||
import com.sun.syndication.feed.impl.ObjectBean;
|
import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean for category elements of Atom feeds.
|
* Bean for category elements of Atom feeds.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Dave Johnson (added for Atom 1.0)
|
* @author Dave Johnson (added for Atom 1.0)
|
||||||
*/
|
*/
|
||||||
public class Category implements Cloneable, Serializable {
|
public class Category implements Cloneable, Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -2034251366664065410L;
|
private static final long serialVersionUID = -2034251366664065410L;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
|
@ -39,7 +41,7 @@ public class Category implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Category() {
|
public Category() {
|
||||||
objBean = new ObjectBean(this.getClass(), this);
|
objBean = new ObjectBean(this.getClass(), this);
|
||||||
|
@ -48,10 +50,10 @@ public class Category implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -62,10 +64,10 @@ public class Category implements Cloneable, Serializable {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -80,9 +82,9 @@ public class Category implements Cloneable, Serializable {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -92,9 +94,9 @@ public class Category implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -104,7 +106,7 @@ public class Category implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Get label for category.
|
* Get label for category.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Label for category.
|
* @return Label for category.
|
||||||
*/
|
*/
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
|
@ -114,7 +116,7 @@ public class Category implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Set label for category.
|
* Set label for category.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param label Label for category.
|
* @param label Label for category.
|
||||||
*/
|
*/
|
||||||
public void setLabel(final String label) {
|
public void setLabel(final String label) {
|
||||||
|
@ -124,7 +126,7 @@ public class Category implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Get Scheme URI for category.
|
* Get Scheme URI for category.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Scheme URI for category.
|
* @return Scheme URI for category.
|
||||||
*/
|
*/
|
||||||
public String getScheme() {
|
public String getScheme() {
|
||||||
|
@ -134,7 +136,7 @@ public class Category implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Set scheme URI for category.
|
* Set scheme URI for category.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param scheme Scheme URI for category.
|
* @param scheme Scheme URI for category.
|
||||||
*/
|
*/
|
||||||
public void setScheme(final String scheme) {
|
public void setScheme(final String scheme) {
|
||||||
|
@ -146,17 +148,13 @@ public class Category implements Cloneable, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSchemeResolved() {
|
public String getSchemeResolved() {
|
||||||
if (schemeResolved != null) {
|
return Alternatives.firstNotNull(schemeResolved, scheme);
|
||||||
return schemeResolved;
|
|
||||||
} else {
|
|
||||||
return scheme;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return term for category.
|
* Return term for category.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Term for category.
|
* @return Term for category.
|
||||||
*/
|
*/
|
||||||
public String getTerm() {
|
public String getTerm() {
|
||||||
|
@ -166,10 +164,11 @@ public class Category implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Set term for category.
|
* Set term for category.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param term Term for category.
|
* @param term Term for category.
|
||||||
*/
|
*/
|
||||||
public void setTerm(final String term) {
|
public void setTerm(final String term) {
|
||||||
this.term = term;
|
this.term = term;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,16 +20,18 @@ import java.io.Serializable;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.rometools.utils.Strings;
|
||||||
import com.sun.syndication.feed.impl.ObjectBean;
|
import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean for content elements of Atom feeds.
|
* Bean for content elements of Atom feeds.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
* @author Dave Johnson (updated for Atom 1.0)
|
* @author Dave Johnson (updated for Atom 1.0)
|
||||||
*/
|
*/
|
||||||
public class Content implements Cloneable, Serializable {
|
public class Content implements Cloneable, Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2036205883043031310L;
|
private static final long serialVersionUID = 2036205883043031310L;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
|
@ -67,7 +69,7 @@ public class Content implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Content() {
|
public Content() {
|
||||||
objBean = new ObjectBean(this.getClass(), this);
|
objBean = new ObjectBean(this.getClass(), this);
|
||||||
|
@ -76,10 +78,10 @@ public class Content implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -90,10 +92,10 @@ public class Content implements Cloneable, Serializable {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -108,9 +110,9 @@ public class Content implements Cloneable, Serializable {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -120,9 +122,9 @@ public class Content implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -134,7 +136,7 @@ public class Content implements Cloneable, Serializable {
|
||||||
* <p>
|
* <p>
|
||||||
* The type indicates how the value was/will-be encoded in the XML feed.
|
* The type indicates how the value was/will-be encoded in the XML feed.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
@ -146,7 +148,7 @@ public class Content implements Cloneable, Serializable {
|
||||||
* <p>
|
* <p>
|
||||||
* The type indicates how the value was/will-be encoded in the XML feed.
|
* The type indicates how the value was/will-be encoded in the XML feed.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
public void setType(final String type) {
|
public void setType(final String type) {
|
||||||
|
@ -158,7 +160,7 @@ public class Content implements Cloneable, Serializable {
|
||||||
* <p>
|
* <p>
|
||||||
* The mode indicates how the value was/will-be encoded in the XML feed.
|
* The mode indicates how the value was/will-be encoded in the XML feed.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the content mode, <b>null</b> if none.
|
* @return the content mode, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public String getMode() {
|
public String getMode() {
|
||||||
|
@ -170,17 +172,14 @@ public class Content implements Cloneable, Serializable {
|
||||||
* <p>
|
* <p>
|
||||||
* The mode indicates how the value was/will-be encoded in the XML feed.
|
* The mode indicates how the value was/will-be encoded in the XML feed.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param mode the content mode, <b>null</b> if none.
|
* @param mode the content mode, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public void setMode(String mode) {
|
public void setMode(final String mode) {
|
||||||
if (mode != null) {
|
this.mode = Strings.toLowerCase(mode);
|
||||||
mode = mode.toLowerCase();
|
|
||||||
}
|
|
||||||
if (mode == null || !MODES.contains(mode)) {
|
if (mode == null || !MODES.contains(mode)) {
|
||||||
throw new IllegalArgumentException("Invalid mode [" + mode + "]");
|
throw new IllegalArgumentException("Invalid mode [" + mode + "]");
|
||||||
}
|
}
|
||||||
this.mode = mode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -188,9 +187,9 @@ public class Content implements Cloneable, Serializable {
|
||||||
* <p>
|
* <p>
|
||||||
* The return value should be decoded.
|
* The return value should be decoded.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the content value, <b>null</b> if none.
|
* @return the content value, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
|
@ -201,9 +200,9 @@ public class Content implements Cloneable, Serializable {
|
||||||
* <p>
|
* <p>
|
||||||
* The value being set should be decoded.
|
* The value being set should be decoded.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param value the content value, <b>null</b> if none.
|
* @param value the content value, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setValue(final String value) {
|
public void setValue(final String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
@ -212,7 +211,7 @@ public class Content implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Returns the src
|
* Returns the src
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the src.
|
* @return Returns the src.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -223,7 +222,7 @@ public class Content implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Set the src
|
* Set the src
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param src The src to set.
|
* @param src The src to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,12 +17,13 @@
|
||||||
package com.sun.syndication.feed.atom;
|
package com.sun.syndication.feed.atom;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jdom2.Element;
|
import org.jdom2.Element;
|
||||||
|
|
||||||
|
import com.rometools.utils.Dates;
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.impl.ObjectBean;
|
import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
import com.sun.syndication.feed.module.Extendable;
|
import com.sun.syndication.feed.module.Extendable;
|
||||||
import com.sun.syndication.feed.module.Module;
|
import com.sun.syndication.feed.module.Module;
|
||||||
|
@ -32,12 +33,14 @@ import com.sun.syndication.feed.synd.SyndPerson;
|
||||||
/**
|
/**
|
||||||
* Bean for entry elements of Atom feeds.
|
* Bean for entry elements of Atom feeds.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
* @author Dave Johnson (updated for Atom 1.0)
|
* @author Dave Johnson (updated for Atom 1.0)
|
||||||
*/
|
*/
|
||||||
public class Entry implements Cloneable, Serializable, Extendable {
|
public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 4874483180016783939L;
|
private static final long serialVersionUID = 4874483180016783939L;
|
||||||
|
|
||||||
private Content summary;
|
private Content summary;
|
||||||
private Content title;
|
private Content title;
|
||||||
private Date created; // Atom 0.3 only
|
private Date created; // Atom 0.3 only
|
||||||
|
@ -60,7 +63,7 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Entry() {
|
public Entry() {
|
||||||
objBean = new ObjectBean(this.getClass(), this);
|
objBean = new ObjectBean(this.getClass(), this);
|
||||||
|
@ -69,7 +72,7 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the entry alternate links.
|
* Sets the entry alternate links.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param alternateLinks the list of Link elements with the entry alternate links to set, an
|
* @param alternateLinks the list of Link elements with the entry alternate links to set, an
|
||||||
* empty list or <b>null</b> if none.
|
* empty list or <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
@ -80,22 +83,19 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the entry alternate links.
|
* Returns the entry alternate links.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Link elements with the entry alternate links, an empty list if none.
|
* @return a list of Link elements with the entry alternate links, an empty list if none.
|
||||||
*/
|
*/
|
||||||
public List<Link> getAlternateLinks() {
|
public List<Link> getAlternateLinks() {
|
||||||
if (alternateLinks == null) {
|
return alternateLinks = Lists.createWhenNull(alternateLinks);
|
||||||
alternateLinks = new ArrayList<Link>();
|
|
||||||
}
|
|
||||||
return alternateLinks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the author of the entry.
|
* Sets the author of the entry.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param authors the author of the entry, <b>null</b> if none.
|
* @param authors the author of the entry, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setAuthors(final List<SyndPerson> authors) {
|
public void setAuthors(final List<SyndPerson> authors) {
|
||||||
this.authors = authors;
|
this.authors = authors;
|
||||||
|
@ -104,21 +104,18 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the entry author.
|
* Returns the entry author.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry author, <b>null</b> if none.
|
* @return the entry author, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<SyndPerson> getAuthors() {
|
public List<SyndPerson> getAuthors() {
|
||||||
if (authors == null) {
|
return authors = Lists.createWhenNull(authors);
|
||||||
authors = new ArrayList<SyndPerson>();
|
|
||||||
}
|
|
||||||
return authors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the categories
|
* Set the categories
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param categories The categories to set.
|
* @param categories The categories to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -129,21 +126,18 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the categories
|
* Returns the categories
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the categories.
|
* @return Returns the categories.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
public List<Category> getCategories() {
|
public List<Category> getCategories() {
|
||||||
if (categories == null) {
|
return categories = Lists.createWhenNull(categories);
|
||||||
categories = new ArrayList<Category>();
|
|
||||||
}
|
|
||||||
return categories;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the entry contents.
|
* Sets the entry contents.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param contents the list of Content elements with the entry contents to set, an empty list or
|
* @param contents the list of Content elements with the entry contents to set, an empty list or
|
||||||
* <b>null</b> if none.
|
* <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
@ -154,23 +148,20 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the entry contents.
|
* Returns the entry contents.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Content elements with the entry contents, an empty list if none.
|
* @return a list of Content elements with the entry contents, an empty list if none.
|
||||||
*/
|
*/
|
||||||
public List<Content> getContents() {
|
public List<Content> getContents() {
|
||||||
if (contents == null) {
|
return contents = Lists.createWhenNull(contents);
|
||||||
contents = new ArrayList<Content>();
|
|
||||||
}
|
|
||||||
return contents;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the entry contributors.
|
* Sets the entry contributors.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param contributors the list of Person elements with the entry contributors to set, an empty
|
* @param contributors the list of Person elements with the entry contributors to set, an empty
|
||||||
* list or <b>null</b> if none.
|
* list or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setContributors(final List<SyndPerson> contributors) {
|
public void setContributors(final List<SyndPerson> contributors) {
|
||||||
this.contributors = contributors;
|
this.contributors = contributors;
|
||||||
|
@ -179,47 +170,40 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the entry contributors.
|
* Returns the entry contributors.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Person elements with the entry contributors, an empty list if none.
|
* @return a list of Person elements with the entry contributors, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<SyndPerson> getContributors() {
|
public List<SyndPerson> getContributors() {
|
||||||
if (contributors == null) {
|
return contributors = Lists.createWhenNull(contributors);
|
||||||
contributors = new ArrayList<SyndPerson>();
|
|
||||||
}
|
|
||||||
return contributors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the entry created date (Atom 0.3 only)
|
* Sets the entry created date (Atom 0.3 only)
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param created the entry created date, <b>null</b> if none.
|
* @param created the entry created date, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public void setCreated(final Date created) {
|
public void setCreated(final Date created) {
|
||||||
this.created = new Date(created.getTime());
|
this.created = Dates.copy(created);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entry created date (Atom 0.3 only)
|
* Returns the entry created date (Atom 0.3 only)
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry created date, <b>null</b> if none.
|
* @return the entry created date, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public Date getCreated() {
|
public Date getCreated() {
|
||||||
if (created == null) {
|
return Dates.copy(created);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Date(created.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets foreign markup found at entry level.
|
* Sets foreign markup found at entry level.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param foreignMarkup Opaque object to discourage use
|
* @param foreignMarkup Opaque object to discourage use
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setForeignMarkup(final List<Element> foreignMarkup) {
|
public void setForeignMarkup(final List<Element> foreignMarkup) {
|
||||||
this.foreignMarkup = foreignMarkup;
|
this.foreignMarkup = foreignMarkup;
|
||||||
|
@ -228,23 +212,20 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns foreign markup found at entry level.
|
* Returns foreign markup found at entry level.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return list of Opaque object to discourage use
|
* @return list of Opaque object to discourage use
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Element> getForeignMarkup() {
|
public List<Element> getForeignMarkup() {
|
||||||
if (foreignMarkup == null) {
|
return foreignMarkup = Lists.createWhenNull(foreignMarkup);
|
||||||
foreignMarkup = new ArrayList<Element>();
|
|
||||||
}
|
|
||||||
return foreignMarkup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the entry ID.
|
* Sets the entry ID.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param id the entry ID, <b>null</b> if none.
|
* @param id the entry ID, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setId(final String id) {
|
public void setId(final String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -253,9 +234,9 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the entry ID.
|
* Returns the entry ID.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry ID, <b>null</b> if none.
|
* @return the entry ID, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -264,83 +245,64 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the entry issued date (Atom 0.3, maps to {@link #setPublished(java.util.Date)}).
|
* Sets the entry issued date (Atom 0.3, maps to {@link #setPublished(java.util.Date)}).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param issued the entry issued date, <b>null</b> if none.
|
* @param issued the entry issued date, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public void setIssued(final Date issued) {
|
public void setIssued(final Date issued) {
|
||||||
if (issued == null) {
|
published = Dates.copy(issued);
|
||||||
published = null;
|
|
||||||
} else {
|
|
||||||
published = new Date(issued.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entry issued date (Atom 0.3, maps to {@link #getPublished()} ).
|
* Returns the entry issued date (Atom 0.3, maps to {@link #getPublished()} ).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry issued date, <b>null</b> if none.
|
* @return the entry issued date, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public Date getIssued() {
|
public Date getIssued() {
|
||||||
if (published == null) {
|
return Dates.copy(published);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Date(published.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if entry is a media entry, i.e. has rel="edit-media".
|
* Returns true if entry is a media entry, i.e. has rel="edit-media".
|
||||||
*
|
*
|
||||||
* @return true if entry is a media entry
|
* @return true if entry is a media entry
|
||||||
*/
|
*/
|
||||||
public boolean isMediaEntry() {
|
public boolean isMediaEntry() {
|
||||||
boolean mediaEntry = false;
|
boolean mediaEntry = false;
|
||||||
final List<Link> links = getOtherLinks();
|
final List<Link> links = getOtherLinks();
|
||||||
|
|
||||||
for (final Link link : links) {
|
for (final Link link : links) {
|
||||||
if ("edit-media".equals(link.getRel())) {
|
if ("edit-media".equals(link.getRel())) {
|
||||||
mediaEntry = true;
|
mediaEntry = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mediaEntry;
|
return mediaEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the entry modified date (Atom 0.3, maps to {@link #setUpdated(java.util.Date)}).
|
* Sets the entry modified date (Atom 0.3, maps to {@link #setUpdated(java.util.Date)}).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param modified the entry modified date, <b>null</b> if none.
|
* @param modified the entry modified date, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public void setModified(final Date modified) {
|
public void setModified(final Date modified) {
|
||||||
if (modified == null) {
|
updated = Dates.copy(modified);
|
||||||
updated = null;
|
|
||||||
} else {
|
|
||||||
updated = new Date(modified.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entry modified date (Atom 0.3, maps to {@link #getUpdated()} ).
|
* Returns the entry modified date (Atom 0.3, maps to {@link #getUpdated()} ).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry modified date, <b>null</b> if none.
|
* @return the entry modified date, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public Date getModified() {
|
public Date getModified() {
|
||||||
if (updated == null) {
|
return Dates.copy(updated);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Date(updated.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the module identified by a given URI.
|
* Returns the module identified by a given URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the URI of the ModuleImpl.
|
* @param uri the URI of the ModuleImpl.
|
||||||
* @return The module with the given URI, <b>null</b> if none.
|
* @return The module with the given URI, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
@ -352,10 +314,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the entry modules.
|
* Sets the entry modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param modules the list of ModuleImpl elements with the entry modules to set, an empty list
|
* @param modules the list of ModuleImpl elements with the entry modules to set, an empty list
|
||||||
* or <b>null</b> if none.
|
* or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModules(final List<Module> modules) {
|
public void setModules(final List<Module> modules) {
|
||||||
|
@ -365,22 +327,19 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the entry modules.
|
* Returns the entry modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of ModuleImpl elements with the entry modules, an emtpy list if none.
|
* @return a list of ModuleImpl elements with the entry modules, an emtpy list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Module> getModules() {
|
public List<Module> getModules() {
|
||||||
if (modules == null) {
|
return modules = Lists.createWhenNull(modules);
|
||||||
modules = new ArrayList<Module>();
|
|
||||||
}
|
|
||||||
return modules;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the entry non-alternate links.
|
* Sets the entry non-alternate links.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param otherLinks the list Link elements with the entry non-alternate links to set, an empty
|
* @param otherLinks the list Link elements with the entry non-alternate links to set, an empty
|
||||||
* list or <b>null</b> if none.
|
* list or <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
@ -391,51 +350,40 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the entry non-alternate links.
|
* Returns the entry non-alternate links.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the list of Link elements with the entry non-alternate links to set, an empty list if
|
* @return the list of Link elements with the entry non-alternate links to set, an empty list if
|
||||||
* none.
|
* none.
|
||||||
*/
|
*/
|
||||||
public List<Link> getOtherLinks() {
|
public List<Link> getOtherLinks() {
|
||||||
if (otherLinks == null) {
|
return otherLinks = Lists.createWhenNull(otherLinks);
|
||||||
otherLinks = new ArrayList<Link>();
|
|
||||||
}
|
|
||||||
return otherLinks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the published
|
* Set the published
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param published The published to set.
|
* @param published The published to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
public void setPublished(final Date published) {
|
public void setPublished(final Date published) {
|
||||||
if (published == null) {
|
this.published = Dates.copy(published);
|
||||||
this.published = null;
|
|
||||||
} else {
|
|
||||||
this.published = new Date(published.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the published
|
* Returns the published
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the published.
|
* @return Returns the published.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
public Date getPublished() {
|
public Date getPublished() {
|
||||||
if (published == null) {
|
return Dates.copy(published);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Date(published.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the rights
|
* Set the rights
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param rights The rights to set.
|
* @param rights The rights to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -446,7 +394,7 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the rights
|
* Returns the rights
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the rights.
|
* @return Returns the rights.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -457,7 +405,7 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Set the source
|
* Set the source
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param source The source to set.
|
* @param source The source to set.
|
||||||
*/
|
*/
|
||||||
public void setSource(final Feed source) {
|
public void setSource(final Feed source) {
|
||||||
|
@ -467,7 +415,7 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the source
|
* Returns the source
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the source.
|
* @return Returns the source.
|
||||||
*/
|
*/
|
||||||
public Feed getSource() {
|
public Feed getSource() {
|
||||||
|
@ -477,9 +425,9 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the entry summary.
|
* Sets the entry summary.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param summary the entry summary, <b>null</b> if none.
|
* @param summary the entry summary, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setSummary(final Content summary) {
|
public void setSummary(final Content summary) {
|
||||||
this.summary = summary;
|
this.summary = summary;
|
||||||
|
@ -488,9 +436,9 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the entry summary.
|
* Returns the entry summary.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry summary, <b>null</b> if none.
|
* @return the entry summary, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Content getSummary() {
|
public Content getSummary() {
|
||||||
return summary;
|
return summary;
|
||||||
|
@ -499,39 +447,37 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the entry title.
|
* Sets the entry title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param title the entry title, <b>null</b> if none.
|
* @param title the entry title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setTitle(final String title) {
|
public void setTitle(final String title) {
|
||||||
if (this.title == null) {
|
if (this.title == null) {
|
||||||
this.title = new Content();
|
this.title = new Content();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.title.setValue(title);
|
this.title.setValue(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entry title.
|
* Returns the entry title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry title, <b>null</b> if none.
|
* @return the entry title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
return title.getValue();
|
return title.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the entry title as a text construct.
|
* Sets the entry title as a text construct.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param title the entry title, <b>null</b> if none.
|
* @param title the entry title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setTitleEx(final Content title) {
|
public void setTitleEx(final Content title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -540,9 +486,9 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the entry title as a text construct.
|
* Returns the entry title as a text construct.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry title, <b>null</b> if none.
|
* @return the entry title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Content getTitleEx() {
|
public Content getTitleEx() {
|
||||||
return title;
|
return title;
|
||||||
|
@ -551,37 +497,29 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Set the updated
|
* Set the updated
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param updated The updated to set.
|
* @param updated The updated to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
public void setUpdated(final Date updated) {
|
public void setUpdated(final Date updated) {
|
||||||
if (updated == null) {
|
this.updated = Dates.copy(updated);
|
||||||
this.updated = null;
|
|
||||||
} else {
|
|
||||||
this.updated = new Date(updated.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the updated
|
* Returns the updated
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the updated.
|
* @return Returns the updated.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
public Date getUpdated() {
|
public Date getUpdated() {
|
||||||
if (updated == null) {
|
return Dates.copy(updated);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Date(updated.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the xmlBase
|
* Set the xmlBase
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param xmlBase The xmlBase to set.
|
* @param xmlBase The xmlBase to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -592,7 +530,7 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the xmlBase
|
* Returns the xmlBase
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the xmlBase.
|
* @return Returns the xmlBase.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -603,10 +541,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -617,10 +555,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -646,9 +584,9 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -658,9 +596,9 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -668,11 +606,12 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Link findRelatedLink(final String relation) {
|
public Link findRelatedLink(final String relation) {
|
||||||
for (final Link l : otherLinks) {
|
for (final Link link : otherLinks) {
|
||||||
if (relation.equals(l.getRel())) {
|
if (relation.equals(link.getRel())) {
|
||||||
return l;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
*/
|
*/
|
||||||
package com.sun.syndication.feed.atom;
|
package com.sun.syndication.feed.atom;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.module.Module;
|
import com.sun.syndication.feed.module.Module;
|
||||||
import com.sun.syndication.feed.module.impl.ModuleUtils;
|
import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
|
@ -30,12 +30,14 @@ import com.sun.syndication.feed.synd.SyndPerson;
|
||||||
* <p>
|
* <p>
|
||||||
* It handles Atom feeds version 0.3 without loosing any feed information.
|
* It handles Atom feeds version 0.3 without loosing any feed information.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
* @author Dave Johnson (updated for Atom 1.0)
|
* @author Dave Johnson (updated for Atom 1.0)
|
||||||
*/
|
*/
|
||||||
public class Feed extends WireFeed {
|
public class Feed extends WireFeed {
|
||||||
|
|
||||||
private static final long serialVersionUID = -9175445106675422528L;
|
private static final long serialVersionUID = -9175445106675422528L;
|
||||||
|
|
||||||
private String xmlBase;
|
private String xmlBase;
|
||||||
private List<Category> categories;
|
private List<Category> categories;
|
||||||
private List<SyndPerson> authors;
|
private List<SyndPerson> authors;
|
||||||
|
@ -59,7 +61,7 @@ public class Feed extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor, for bean cloning purposes only.
|
* Default constructor, for bean cloning purposes only.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Feed() {
|
public Feed() {
|
||||||
}
|
}
|
||||||
|
@ -67,9 +69,9 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Feed Constructor. All properties, except the type, are set to <b>null</b>.
|
* Feed Constructor. All properties, except the type, are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param type the type of the Atom feed.
|
* @param type the type of the Atom feed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Feed(final String type) {
|
public Feed(final String type) {
|
||||||
super(type);
|
super(type);
|
||||||
|
@ -78,9 +80,9 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed language (Atom 0.3 only)
|
* Returns the feed language (Atom 0.3 only)
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed language, <b>null</b> if none.
|
* @return the feed language, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getLanguage() {
|
public String getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
|
@ -89,9 +91,9 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed language (Atom 0.3 only)
|
* Sets the feed language (Atom 0.3 only)
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param language the feed language to set, <b>null</b> if none.
|
* @param language the feed language to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setLanguage(final String language) {
|
public void setLanguage(final String language) {
|
||||||
this.language = language;
|
this.language = language;
|
||||||
|
@ -100,9 +102,9 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed title.
|
* Returns the feed title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed title, <b>null</b> if none.
|
* @return the feed title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
|
@ -114,9 +116,9 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed title.
|
* Sets the feed title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param title the feed title to set, <b>null</b> if none.
|
* @param title the feed title to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setTitle(final String title) {
|
public void setTitle(final String title) {
|
||||||
if (this.title == null) {
|
if (this.title == null) {
|
||||||
|
@ -128,9 +130,9 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed title.
|
* Returns the feed title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed title, <b>null</b> if none.
|
* @return the feed title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Content getTitleEx() {
|
public Content getTitleEx() {
|
||||||
return title;
|
return title;
|
||||||
|
@ -139,9 +141,9 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed title.
|
* Sets the feed title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param title the feed title to set, <b>null</b> if none.
|
* @param title the feed title to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setTitleEx(final Content title) {
|
public void setTitleEx(final Content title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -150,20 +152,17 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed alternate links.
|
* Returns the feed alternate links.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Link elements with the feed alternate links, an empty list if none.
|
* @return a list of Link elements with the feed alternate links, an empty list if none.
|
||||||
*/
|
*/
|
||||||
public List<Link> getAlternateLinks() {
|
public List<Link> getAlternateLinks() {
|
||||||
if (alternateLinks == null) {
|
return alternateLinks = Lists.createWhenNull(alternateLinks);
|
||||||
alternateLinks = new ArrayList<Link>();
|
|
||||||
}
|
|
||||||
return alternateLinks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the feed alternate links.
|
* Sets the feed alternate links.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param alternateLinks the list of Link elements with the feed alternate links to set, an
|
* @param alternateLinks the list of Link elements with the feed alternate links to set, an
|
||||||
* empty list or <b>null</b> if none.
|
* empty list or <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
@ -174,21 +173,18 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed other links (non-alternate ones).
|
* Returns the feed other links (non-alternate ones).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Link elements with the feed other links (non-alternate ones), an empty list
|
* @return a list of Link elements with the feed other links (non-alternate ones), an empty list
|
||||||
* if none.
|
* if none.
|
||||||
*/
|
*/
|
||||||
public List<Link> getOtherLinks() {
|
public List<Link> getOtherLinks() {
|
||||||
if (otherLinks == null) {
|
return otherLinks = Lists.createWhenNull(otherLinks);
|
||||||
otherLinks = new ArrayList<Link>();
|
|
||||||
}
|
|
||||||
return otherLinks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the feed other links (non-alternate ones).
|
* Sets the feed other links (non-alternate ones).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param otherLinks the list of Link elements with the feed other links (non-alternate ones) to
|
* @param otherLinks the list of Link elements with the feed other links (non-alternate ones) to
|
||||||
* set, an empty list or <b>null</b> if none.
|
* set, an empty list or <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
@ -199,23 +195,20 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed author.
|
* Returns the feed author.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed author, <b>null</b> if none.
|
* @return the feed author, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<SyndPerson> getAuthors() {
|
public List<SyndPerson> getAuthors() {
|
||||||
if (authors == null) {
|
return authors = Lists.createWhenNull(authors);
|
||||||
authors = new ArrayList<SyndPerson>();
|
|
||||||
}
|
|
||||||
return authors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the feed author.
|
* Sets the feed author.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param authors the feed author to set, <b>null</b> if none.
|
* @param authors the feed author to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setAuthors(final List<SyndPerson> authors) {
|
public void setAuthors(final List<SyndPerson> authors) {
|
||||||
this.authors = authors;
|
this.authors = authors;
|
||||||
|
@ -224,24 +217,21 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed contributors.
|
* Returns the feed contributors.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Person elements with the feed contributors, an empty list if none.
|
* @return a list of Person elements with the feed contributors, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<SyndPerson> getContributors() {
|
public List<SyndPerson> getContributors() {
|
||||||
if (contributors == null) {
|
return contributors = Lists.createWhenNull(contributors);
|
||||||
contributors = new ArrayList<SyndPerson>();
|
|
||||||
}
|
|
||||||
return contributors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the feed contributors.
|
* Sets the feed contributors.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param contributors the list of Person elements with the feed contributors to set, an empty
|
* @param contributors the list of Person elements with the feed contributors to set, an empty
|
||||||
* list or <b>null</b> if none.
|
* list or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setContributors(final List<SyndPerson> contributors) {
|
public void setContributors(final List<SyndPerson> contributors) {
|
||||||
this.contributors = contributors;
|
this.contributors = contributors;
|
||||||
|
@ -250,7 +240,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed tag line (Atom 0.3, maps to {@link #getSubtitle()}).
|
* Returns the feed tag line (Atom 0.3, maps to {@link #getSubtitle()}).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed tag line, <b>null</b> if none.
|
* @return the feed tag line, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public Content getTagline() {
|
public Content getTagline() {
|
||||||
|
@ -261,7 +251,7 @@ public class Feed extends WireFeed {
|
||||||
* Sets the feed tagline (Atom 0.3, maps to
|
* Sets the feed tagline (Atom 0.3, maps to
|
||||||
* {@link #setSubtitle(com.sun.syndication.feed.atom.Content)}).
|
* {@link #setSubtitle(com.sun.syndication.feed.atom.Content)}).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param tagline the feed tagline to set, <b>null</b> if none.
|
* @param tagline the feed tagline to set, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public void setTagline(final Content tagline) {
|
public void setTagline(final Content tagline) {
|
||||||
|
@ -271,9 +261,9 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed ID.
|
* Returns the feed ID.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed ID, <b>null</b> if none.
|
* @return the feed ID, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -282,9 +272,9 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed ID.
|
* Sets the feed ID.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param id the feed ID to set, <b>null</b> if none.
|
* @param id the feed ID to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setId(final String id) {
|
public void setId(final String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -293,9 +283,9 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed generator.
|
* Returns the feed generator.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed generator, <b>null</b> if none.
|
* @return the feed generator, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Generator getGenerator() {
|
public Generator getGenerator() {
|
||||||
return generator;
|
return generator;
|
||||||
|
@ -304,9 +294,9 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed generator.
|
* Sets the feed generator.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param generator the feed generator to set, <b>null</b> if none.
|
* @param generator the feed generator to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setGenerator(final Generator generator) {
|
public void setGenerator(final Generator generator) {
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
|
@ -315,7 +305,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed copyright (Atom 0.3, maps to {@link #getRights()}).
|
* Returns the feed copyright (Atom 0.3, maps to {@link #getRights()}).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed copyright, <b>null</b> if none.
|
* @return the feed copyright, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public String getCopyright() {
|
public String getCopyright() {
|
||||||
|
@ -325,7 +315,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed copyright (Atom 0.3, maps to {@link #setRights(java.lang.String)}).
|
* Sets the feed copyright (Atom 0.3, maps to {@link #setRights(java.lang.String)}).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param copyright the feed copyright to set, <b>null</b> if none.
|
* @param copyright the feed copyright to set, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public void setCopyright(final String copyright) {
|
public void setCopyright(final String copyright) {
|
||||||
|
@ -335,7 +325,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed info (Atom 0.3 only)
|
* Returns the feed info (Atom 0.3 only)
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed info, <b>null</b> if none.
|
* @return the feed info, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public Content getInfo() {
|
public Content getInfo() {
|
||||||
|
@ -345,7 +335,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed info (Atom 0.3 only)
|
* Sets the feed info (Atom 0.3 only)
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param info the feed info to set, <b>null</b> if none.
|
* @param info the feed info to set, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public void setInfo(final Content info) {
|
public void setInfo(final Content info) {
|
||||||
|
@ -355,7 +345,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed modified date (Atom 0.3, maps to {@link #getUpdated()}).
|
* Returns the feed modified date (Atom 0.3, maps to {@link #getUpdated()}).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed modified date, <b>null</b> if none.
|
* @return the feed modified date, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public Date getModified() {
|
public Date getModified() {
|
||||||
|
@ -365,7 +355,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed modified date (Atom 0.3, maps to {@link #setUpdated(java.util.Date)}).
|
* Sets the feed modified date (Atom 0.3, maps to {@link #setUpdated(java.util.Date)}).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param modified the feed modified date to set, <b>null</b> if none.
|
* @param modified the feed modified date to set, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public void setModified(final Date modified) {
|
public void setModified(final Date modified) {
|
||||||
|
@ -375,24 +365,21 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed entries.
|
* Returns the feed entries.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Entry elements with the feed entries, an empty list if none.
|
* @return a list of Entry elements with the feed entries, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Entry> getEntries() {
|
public List<Entry> getEntries() {
|
||||||
if (entries == null) {
|
return entries = Lists.createWhenNull(entries);
|
||||||
entries = new ArrayList<Entry>();
|
|
||||||
}
|
|
||||||
return entries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the feed entries.
|
* Sets the feed entries.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param entries the list of Entry elements with the feed entries to set, an empty list or
|
* @param entries the list of Entry elements with the feed entries to set, an empty list or
|
||||||
* <b>null</b> if none.
|
* <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setEntries(final List<Entry> entries) {
|
public void setEntries(final List<Entry> entries) {
|
||||||
this.entries = entries;
|
this.entries = entries;
|
||||||
|
@ -401,25 +388,22 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed modules.
|
* Returns the feed modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of ModuleImpl elements with the feed modules, an empty list if none.
|
* @return a list of ModuleImpl elements with the feed modules, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Module> getModules() {
|
public List<Module> getModules() {
|
||||||
if (modules == null) {
|
return modules = Lists.createWhenNull(modules);
|
||||||
modules = new ArrayList<Module>();
|
|
||||||
}
|
|
||||||
return modules;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the feed moduless.
|
* Sets the feed moduless.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param modules the list of ModuleImpl elements with the feed moduless to set, an empty list
|
* @param modules the list of ModuleImpl elements with the feed moduless to set, an empty list
|
||||||
* or <b>null</b> if none.
|
* or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModules(final List<Module> modules) {
|
public void setModules(final List<Module> modules) {
|
||||||
|
@ -429,7 +413,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the module identified by a given URI.
|
* Returns the module identified by a given URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the URI of the ModuleImpl.
|
* @param uri the URI of the ModuleImpl.
|
||||||
* @return The module with the given URI, <b>null</b> if none.
|
* @return The module with the given URI, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
@ -441,21 +425,18 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the categories
|
* Returns the categories
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the categories.
|
* @return Returns the categories.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
public List<Category> getCategories() {
|
public List<Category> getCategories() {
|
||||||
if (categories == null) {
|
return categories = Lists.createWhenNull(categories);
|
||||||
categories = new ArrayList<Category>();
|
|
||||||
}
|
|
||||||
return categories;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the categories
|
* Set the categories
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param categories The categories to set.
|
* @param categories The categories to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -466,7 +447,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the icon
|
* Returns the icon
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the icon.
|
* @return Returns the icon.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -477,7 +458,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Set the icon
|
* Set the icon
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param icon The icon to set.
|
* @param icon The icon to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -488,7 +469,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the logo
|
* Returns the logo
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the logo.
|
* @return Returns the logo.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -499,7 +480,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Set the logo
|
* Set the logo
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param logo The logo to set.
|
* @param logo The logo to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -510,7 +491,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the rights
|
* Returns the rights
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the rights.
|
* @return Returns the rights.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -521,7 +502,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Set the rights
|
* Set the rights
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param rights The rights to set.
|
* @param rights The rights to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -532,7 +513,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the subtitle
|
* Returns the subtitle
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the subtitle.
|
* @return Returns the subtitle.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -543,7 +524,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Set the subtitle
|
* Set the subtitle
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param subtitle The subtitle to set.
|
* @param subtitle The subtitle to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -554,7 +535,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the updated
|
* Returns the updated
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the updated.
|
* @return Returns the updated.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -565,7 +546,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Set the updated
|
* Set the updated
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param updated The updated to set.
|
* @param updated The updated to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -576,7 +557,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the xmlBase
|
* Returns the xmlBase
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the xmlBase.
|
* @return Returns the xmlBase.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -587,7 +568,7 @@ public class Feed extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Set the xmlBase
|
* Set the xmlBase
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param xmlBase The xmlBase to set.
|
* @param xmlBase The xmlBase to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,16 +18,18 @@ package com.sun.syndication.feed.atom;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.rometools.utils.Alternatives;
|
||||||
import com.sun.syndication.feed.impl.ObjectBean;
|
import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean for link elements of Atom feeds.
|
* Bean for link elements of Atom feeds.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
* @author Dave Johnson (updated for Atom 1.0)
|
* @author Dave Johnson (updated for Atom 1.0)
|
||||||
*/
|
*/
|
||||||
public class Link implements Cloneable, Serializable {
|
public class Link implements Cloneable, Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 670365139518027828L;
|
private static final long serialVersionUID = 670365139518027828L;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
|
@ -43,7 +45,7 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Link() {
|
public Link() {
|
||||||
objBean = new ObjectBean(this.getClass(), this);
|
objBean = new ObjectBean(this.getClass(), this);
|
||||||
|
@ -52,10 +54,10 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -66,10 +68,10 @@ public class Link implements Cloneable, Serializable {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -81,9 +83,9 @@ public class Link implements Cloneable, Serializable {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -93,9 +95,9 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -105,9 +107,9 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Returns the link rel.
|
* Returns the link rel.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the link rel, <b>null</b> if none.
|
* @return the link rel, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getRel() {
|
public String getRel() {
|
||||||
return rel;
|
return rel;
|
||||||
|
@ -116,9 +118,9 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Sets the link rel.
|
* Sets the link rel.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param rel the link rel,, <b>null</b> if none.
|
* @param rel the link rel,, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setRel(final String rel) {
|
public void setRel(final String rel) {
|
||||||
// TODO add check, ask P@ about the check
|
// TODO add check, ask P@ about the check
|
||||||
|
@ -128,9 +130,9 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Returns the link type.
|
* Returns the link type.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the link type, <b>null</b> if none.
|
* @return the link type, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
|
@ -139,9 +141,9 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Sets the link type.
|
* Sets the link type.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param type the link type, <b>null</b> if none.
|
* @param type the link type, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setType(final String type) {
|
public void setType(final String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -150,9 +152,9 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Returns the link href.
|
* Returns the link href.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the link href, <b>null</b> if none.
|
* @return the link href, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getHref() {
|
public String getHref() {
|
||||||
return href;
|
return href;
|
||||||
|
@ -161,9 +163,9 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Sets the link href.
|
* Sets the link href.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param href the link href, <b>null</b> if none.
|
* @param href the link href, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setHref(final String href) {
|
public void setHref(final String href) {
|
||||||
this.href = href;
|
this.href = href;
|
||||||
|
@ -174,19 +176,15 @@ public class Link implements Cloneable, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHrefResolved() {
|
public String getHrefResolved() {
|
||||||
if (hrefResolved != null) {
|
return Alternatives.firstNotNull(hrefResolved, href);
|
||||||
return hrefResolved;
|
|
||||||
} else {
|
|
||||||
return href;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the link title.
|
* Returns the link title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the link title, <b>null</b> if none.
|
* @return the link title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
|
@ -195,9 +193,9 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Sets the link title.
|
* Sets the link title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param title the link title, <b>null</b> if none.
|
* @param title the link title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setTitle(final String title) {
|
public void setTitle(final String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -206,7 +204,7 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Returns the hreflang
|
* Returns the hreflang
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the hreflang.
|
* @return Returns the hreflang.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -217,7 +215,7 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Set the hreflang
|
* Set the hreflang
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param hreflang The hreflang to set.
|
* @param hreflang The hreflang to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -228,7 +226,7 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Returns the length
|
* Returns the length
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the length.
|
* @return Returns the length.
|
||||||
*/
|
*/
|
||||||
public long getLength() {
|
public long getLength() {
|
||||||
|
@ -238,7 +236,7 @@ public class Link implements Cloneable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Set the length
|
* Set the length
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param length The length to set.
|
* @param length The length to set.
|
||||||
*/
|
*/
|
||||||
public void setLength(final long length) {
|
public void setLength(final long length) {
|
||||||
|
|
|
@ -17,9 +17,10 @@
|
||||||
package com.sun.syndication.feed.atom;
|
package com.sun.syndication.feed.atom;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rometools.utils.Alternatives;
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.impl.ObjectBean;
|
import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
import com.sun.syndication.feed.module.Extendable;
|
import com.sun.syndication.feed.module.Extendable;
|
||||||
import com.sun.syndication.feed.module.Module;
|
import com.sun.syndication.feed.module.Module;
|
||||||
|
@ -29,7 +30,7 @@ import com.sun.syndication.feed.synd.SyndPerson;
|
||||||
/**
|
/**
|
||||||
* Bean for person elements of Atom feeds.
|
* Bean for person elements of Atom feeds.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
* @author Dave Johnson (updated for Atom 1.0)
|
* @author Dave Johnson (updated for Atom 1.0)
|
||||||
*/
|
*/
|
||||||
|
@ -48,7 +49,7 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Person() {
|
public Person() {
|
||||||
objBean = new ObjectBean(this.getClass(), this);
|
objBean = new ObjectBean(this.getClass(), this);
|
||||||
|
@ -57,10 +58,10 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -71,10 +72,10 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -86,9 +87,9 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -98,9 +99,9 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -110,9 +111,9 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the person name.
|
* Returns the person name.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the person name, <b>null</b> if none.
|
* @return the person name, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -122,9 +123,9 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the personname.
|
* Sets the personname.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param name the person name, <b>null</b> if none.
|
* @param name the person name, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setName(final String name) {
|
public void setName(final String name) {
|
||||||
|
@ -134,7 +135,7 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the person URL (same as {@link #getUri()})
|
* Returns the person URL (same as {@link #getUri()})
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the person URL, <b>null</b> if none.
|
* @return the person URL, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
|
@ -144,7 +145,7 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the person URL (same as {@link #setUri(java.lang.String)})
|
* Sets the person URL (same as {@link #setUri(java.lang.String)})
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param url the person URL, <b>null</b> if none.
|
* @param url the person URL, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public void setUrl(final String url) {
|
public void setUrl(final String url) {
|
||||||
|
@ -156,19 +157,15 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUriResolved(final String resolveURI) {
|
public String getUriResolved(final String resolveURI) {
|
||||||
if (uriResolved != null) {
|
return Alternatives.firstNotNull(uriResolved, uri);
|
||||||
return uriResolved;
|
|
||||||
} else {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the person email.
|
* Returns the person email.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the person email, <b>null</b> if none.
|
* @return the person email, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
|
@ -178,9 +175,9 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the person email.
|
* Sets the person email.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param email the person email, <b>null</b> if none.
|
* @param email the person email, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setEmail(final String email) {
|
public void setEmail(final String email) {
|
||||||
|
@ -190,7 +187,7 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the uri
|
* Returns the uri
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the uri.
|
* @return Returns the uri.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -202,7 +199,7 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Set the uri
|
* Set the uri
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri The uri to set.
|
* @param uri The uri to set.
|
||||||
* @since Atom 1.0
|
* @since Atom 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -214,25 +211,22 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the entry modules.
|
* Returns the entry modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of ModuleImpl elements with the entry modules, an emtpy list if none.
|
* @return a list of ModuleImpl elements with the entry modules, an emtpy list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Module> getModules() {
|
public List<Module> getModules() {
|
||||||
if (modules == null) {
|
return modules = Lists.createWhenNull(modules);
|
||||||
modules = new ArrayList<Module>();
|
|
||||||
}
|
|
||||||
return modules;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the entry modules.
|
* Sets the entry modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param modules the list of ModuleImpl elements with the entry modules to set, an empty list
|
* @param modules the list of ModuleImpl elements with the entry modules to set, an empty list
|
||||||
* or <b>null</b> if none.
|
* or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModules(final List<Module> modules) {
|
public void setModules(final List<Module> modules) {
|
||||||
|
@ -242,7 +236,7 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the module identified by a given URI.
|
* Returns the module identified by a given URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the URI of the ModuleImpl.
|
* @param uri the URI of the ModuleImpl.
|
||||||
* @return The module with the given URI, <b>null</b> if none.
|
* @return The module with the given URI, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -28,21 +28,34 @@ import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
/**
|
/**
|
||||||
* Subject of the Dublin Core ModuleImpl, default implementation.
|
* Subject of the Dublin Core ModuleImpl, default implementation.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @see <a href="http://web.resource.org/rss/1.0/modules/dc/">Dublin Core module</a>.
|
* @see <a href="http://web.resource.org/rss/1.0/modules/dc/">Dublin Core module</a>.
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
||||||
|
|
||||||
private static final long serialVersionUID = 6276396184267118968L;
|
private static final long serialVersionUID = 6276396184267118968L;
|
||||||
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
private String taxonomyUri;
|
private String taxonomyUri;
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
static {
|
||||||
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
|
basePropInterfaceMap.put("taxonomyUri", String.class);
|
||||||
|
basePropInterfaceMap.put("value", String.class);
|
||||||
|
|
||||||
|
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom>, Class<?>> emptyMap();
|
||||||
|
|
||||||
|
COPY_FROM_HELPER = new CopyFromHelper(DCSubject.class, basePropInterfaceMap, basePropClassImplMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public DCSubjectImpl() {
|
public DCSubjectImpl() {
|
||||||
objBean = new ObjectBean(this.getClass(), this);
|
objBean = new ObjectBean(this.getClass(), this);
|
||||||
|
@ -51,10 +64,10 @@ public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -65,10 +78,10 @@ public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -83,9 +96,9 @@ public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -95,9 +108,9 @@ public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -107,9 +120,9 @@ public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
||||||
/**
|
/**
|
||||||
* Returns the DublinCore subject taxonomy URI.
|
* Returns the DublinCore subject taxonomy URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the DublinCore subject taxonomy URI, <b>null</b> if none.
|
* @return the DublinCore subject taxonomy URI, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getTaxonomyUri() {
|
public String getTaxonomyUri() {
|
||||||
|
@ -119,9 +132,9 @@ public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
||||||
/**
|
/**
|
||||||
* Sets the DublinCore subject taxonomy URI.
|
* Sets the DublinCore subject taxonomy URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param taxonomyUri the DublinCore subject taxonomy URI to set, <b>null</b> if none.
|
* @param taxonomyUri the DublinCore subject taxonomy URI to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setTaxonomyUri(final String taxonomyUri) {
|
public void setTaxonomyUri(final String taxonomyUri) {
|
||||||
|
@ -131,9 +144,9 @@ public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
||||||
/**
|
/**
|
||||||
* Returns the DublinCore subject value.
|
* Returns the DublinCore subject value.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the DublinCore subject value, <b>null</b> if none.
|
* @return the DublinCore subject value, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
|
@ -143,9 +156,9 @@ public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
||||||
/**
|
/**
|
||||||
* Sets the DublinCore subject value.
|
* Sets the DublinCore subject value.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param value the DublinCore subject value to set, <b>null</b> if none.
|
* @param value the DublinCore subject value to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setValue(final String value) {
|
public void setValue(final String value) {
|
||||||
|
@ -162,16 +175,4 @@ public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
||||||
COPY_FROM_HELPER.copy(this, obj);
|
COPY_FROM_HELPER.copy(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
|
||||||
|
|
||||||
static {
|
|
||||||
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
|
||||||
basePropInterfaceMap.put("taxonomyUri", String.class);
|
|
||||||
basePropInterfaceMap.put("value", String.class);
|
|
||||||
|
|
||||||
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom>, Class<?>> emptyMap();
|
|
||||||
|
|
||||||
COPY_FROM_HELPER = new CopyFromHelper(DCSubject.class, basePropInterfaceMap, basePropClassImplMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,37 +23,50 @@ import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.rometools.utils.Dates;
|
||||||
import com.sun.syndication.feed.CopyFrom;
|
import com.sun.syndication.feed.CopyFrom;
|
||||||
import com.sun.syndication.feed.impl.CopyFromHelper;
|
import com.sun.syndication.feed.impl.CopyFromHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Syndication ModuleImpl, default implementation.
|
* Syndication ModuleImpl, default implementation.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @see <a href="http://web.resource.org/rss/1.0/modules/syndication/">Syndication module</a>.
|
* @see <a href="http://web.resource.org/rss/1.0/modules/syndication/">Syndication module</a>.
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SyModuleImpl extends ModuleImpl implements SyModule {
|
public class SyModuleImpl extends ModuleImpl implements SyModule {
|
||||||
private static final long serialVersionUID = -8345879299577437933L;
|
|
||||||
private static final Set<String> PERIODS = new HashSet<String>();
|
|
||||||
|
|
||||||
static {
|
private static final long serialVersionUID = -8345879299577437933L;
|
||||||
PERIODS.add(HOURLY);
|
|
||||||
PERIODS.add(DAILY);
|
private static final Set<String> PERIODS = new HashSet<String>();
|
||||||
PERIODS.add(WEEKLY);
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
PERIODS.add(MONTHLY);
|
|
||||||
PERIODS.add(YEARLY);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String updatePeriod;
|
private String updatePeriod;
|
||||||
private int updateFrequency;
|
private int updateFrequency;
|
||||||
private Date updateBase;
|
private Date updateBase;
|
||||||
|
|
||||||
|
static {
|
||||||
|
|
||||||
|
PERIODS.add(HOURLY);
|
||||||
|
PERIODS.add(DAILY);
|
||||||
|
PERIODS.add(WEEKLY);
|
||||||
|
PERIODS.add(MONTHLY);
|
||||||
|
PERIODS.add(YEARLY);
|
||||||
|
|
||||||
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
|
basePropInterfaceMap.put("updatePeriod", String.class);
|
||||||
|
basePropInterfaceMap.put("updateFrequency", Integer.TYPE);
|
||||||
|
basePropInterfaceMap.put("updateBase", Date.class);
|
||||||
|
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom>, Class<?>> emptyMap();
|
||||||
|
COPY_FROM_HELPER = new CopyFromHelper(SyModule.class, basePropInterfaceMap, basePropClassImplMap);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public SyModuleImpl() {
|
public SyModuleImpl() {
|
||||||
super(SyModule.class, URI);
|
super(SyModule.class, URI);
|
||||||
|
@ -62,9 +75,9 @@ public class SyModuleImpl extends ModuleImpl implements SyModule {
|
||||||
/**
|
/**
|
||||||
* Returns the Syndication module update period.
|
* Returns the Syndication module update period.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the Syndication module update period, <b>null</b> if none.
|
* @return the Syndication module update period, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUpdatePeriod() {
|
public String getUpdatePeriod() {
|
||||||
|
@ -74,9 +87,9 @@ public class SyModuleImpl extends ModuleImpl implements SyModule {
|
||||||
/**
|
/**
|
||||||
* Sets the Syndication module update period.
|
* Sets the Syndication module update period.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param updatePeriod the Syndication module update period to set, <b>null</b> if none.
|
* @param updatePeriod the Syndication module update period to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setUpdatePeriod(final String updatePeriod) {
|
public void setUpdatePeriod(final String updatePeriod) {
|
||||||
|
@ -89,9 +102,9 @@ public class SyModuleImpl extends ModuleImpl implements SyModule {
|
||||||
/**
|
/**
|
||||||
* Returns the Syndication module update frequency.
|
* Returns the Syndication module update frequency.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the Syndication module update frequency, <b>null</b> if none.
|
* @return the Syndication module update frequency, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getUpdateFrequency() {
|
public int getUpdateFrequency() {
|
||||||
|
@ -101,9 +114,9 @@ public class SyModuleImpl extends ModuleImpl implements SyModule {
|
||||||
/**
|
/**
|
||||||
* Sets the Syndication module update frequency.
|
* Sets the Syndication module update frequency.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param updateFrequency the Syndication module update frequency to set, <b>null</b> if none.
|
* @param updateFrequency the Syndication module update frequency to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setUpdateFrequency(final int updateFrequency) {
|
public void setUpdateFrequency(final int updateFrequency) {
|
||||||
|
@ -113,25 +126,25 @@ public class SyModuleImpl extends ModuleImpl implements SyModule {
|
||||||
/**
|
/**
|
||||||
* Returns the Syndication module update base date.
|
* Returns the Syndication module update base date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the Syndication module update base date, <b>null</b> if none.
|
* @return the Syndication module update base date, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Date getUpdateBase() {
|
public Date getUpdateBase() {
|
||||||
return updateBase != null ? new Date(updateBase.getTime()) : null;
|
return Dates.copy(updateBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Syndication module update base date.
|
* Sets the Syndication module update base date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param updateBase the Syndication module update base date to set, <b>null</b> if none.
|
* @param updateBase the Syndication module update base date to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setUpdateBase(final Date updateBase) {
|
public void setUpdateBase(final Date updateBase) {
|
||||||
this.updateBase = new Date(updateBase.getTime());
|
this.updateBase = Dates.copy(updateBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -144,17 +157,4 @@ public class SyModuleImpl extends ModuleImpl implements SyModule {
|
||||||
COPY_FROM_HELPER.copy(this, obj);
|
COPY_FROM_HELPER.copy(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
|
||||||
|
|
||||||
static {
|
|
||||||
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
|
||||||
basePropInterfaceMap.put("updatePeriod", String.class);
|
|
||||||
basePropInterfaceMap.put("updateFrequency", Integer.TYPE);
|
|
||||||
basePropInterfaceMap.put("updateBase", Date.class);
|
|
||||||
|
|
||||||
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom>, Class<?>> emptyMap();
|
|
||||||
|
|
||||||
COPY_FROM_HELPER = new CopyFromHelper(SyModule.class, basePropInterfaceMap, basePropClassImplMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,14 @@
|
||||||
*/
|
*/
|
||||||
package com.sun.syndication.feed.rss;
|
package com.sun.syndication.feed.rss;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.rometools.utils.Dates;
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.module.Module;
|
import com.sun.syndication.feed.module.Module;
|
||||||
import com.sun.syndication.feed.module.impl.ModuleUtils;
|
import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
|
@ -34,12 +35,14 @@ import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
* It handles all RSS versions (0.9, 0.91, 0.92, 0.93, 0.94, 1.0 and 2.0) without losing
|
* It handles all RSS versions (0.9, 0.91, 0.92, 0.93, 0.94, 1.0 and 2.0) without losing
|
||||||
* information.
|
* information.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Channel extends WireFeed {
|
public class Channel extends WireFeed {
|
||||||
|
|
||||||
private static final long serialVersionUID = 745207486449728472L;
|
private static final long serialVersionUID = 745207486449728472L;
|
||||||
|
|
||||||
public static final String SUNDAY = "sunday";
|
public static final String SUNDAY = "sunday";
|
||||||
public static final String MONDAY = "monday";
|
public static final String MONDAY = "monday";
|
||||||
public static final String TUESDAY = "tuesday";
|
public static final String TUESDAY = "tuesday";
|
||||||
|
@ -87,7 +90,7 @@ public class Channel extends WireFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor, for bean cloning purposes only.
|
* Default constructor, for bean cloning purposes only.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Channel() {
|
public Channel() {
|
||||||
}
|
}
|
||||||
|
@ -95,9 +98,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Channel Constructor. All properties, except the type, are set to <b>null</b>.
|
* Channel Constructor. All properties, except the type, are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param type the type of the RSS feed.
|
* @param type the type of the RSS feed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Channel(final String type) {
|
public Channel(final String type) {
|
||||||
super(type);
|
super(type);
|
||||||
|
@ -106,9 +109,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel title.
|
* Returns the channel title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel title, <b>null</b> if none.
|
* @return the channel title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
|
@ -117,9 +120,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel title.
|
* Sets the channel title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param title the channel title to set, <b>null</b> if none.
|
* @param title the channel title to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setTitle(final String title) {
|
public void setTitle(final String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -128,9 +131,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel description.
|
* Returns the channel description.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel description, <b>null</b> if none.
|
* @return the channel description, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
|
@ -139,9 +142,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel description.
|
* Sets the channel description.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param description the channel description to set, <b>null</b> if none.
|
* @param description the channel description to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setDescription(final String description) {
|
public void setDescription(final String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
@ -150,9 +153,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel link.
|
* Returns the channel link.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel link, <b>null</b> if none.
|
* @return the channel link, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getLink() {
|
public String getLink() {
|
||||||
return link;
|
return link;
|
||||||
|
@ -161,9 +164,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel link.
|
* Sets the channel link.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param link the channel link to set, <b>null</b> if none.
|
* @param link the channel link to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setLink(final String link) {
|
public void setLink(final String link) {
|
||||||
this.link = link;
|
this.link = link;
|
||||||
|
@ -172,7 +175,7 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel uri.
|
* Returns the channel uri.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel uri, <b>null</b> if none.
|
* @return the channel uri, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public String getUri() {
|
public String getUri() {
|
||||||
|
@ -182,7 +185,7 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel uri.
|
* Sets the channel uri.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the channel uri, <b>null</b> if none.
|
* @param uri the channel uri, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public void setUri(final String uri) {
|
public void setUri(final String uri) {
|
||||||
|
@ -192,9 +195,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel image.
|
* Returns the channel image.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel image, <b>null</b> if none.
|
* @return the channel image, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Image getImage() {
|
public Image getImage() {
|
||||||
return image;
|
return image;
|
||||||
|
@ -203,9 +206,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel image.
|
* Sets the channel image.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param image the channel image to set, <b>null</b> if none.
|
* @param image the channel image to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setImage(final Image image) {
|
public void setImage(final Image image) {
|
||||||
this.image = image;
|
this.image = image;
|
||||||
|
@ -214,24 +217,21 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel items.
|
* Returns the channel items.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Item elements with the channel items, an empty list if none.
|
* @return a list of Item elements with the channel items, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Item> getItems() {
|
public List<Item> getItems() {
|
||||||
if (items == null) {
|
return items = Lists.createWhenNull(items);
|
||||||
items = new ArrayList<Item>();
|
|
||||||
}
|
|
||||||
return items;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the channel items.
|
* Sets the channel items.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param items the list of Item elements with the channel items to set, an empty list or
|
* @param items the list of Item elements with the channel items to set, an empty list or
|
||||||
* <b>null</b> if none.
|
* <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setItems(final List<Item> items) {
|
public void setItems(final List<Item> items) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
|
@ -240,9 +240,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel text input.
|
* Returns the channel text input.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel text input, <b>null</b> if none.
|
* @return the channel text input, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public TextInput getTextInput() {
|
public TextInput getTextInput() {
|
||||||
return textInput;
|
return textInput;
|
||||||
|
@ -251,9 +251,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel text input.
|
* Sets the channel text input.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param textInput the channel text input to set, <b>null</b> if none.
|
* @param textInput the channel text input to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setTextInput(final TextInput textInput) {
|
public void setTextInput(final TextInput textInput) {
|
||||||
this.textInput = textInput;
|
this.textInput = textInput;
|
||||||
|
@ -262,9 +262,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel language.
|
* Returns the channel language.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel language, <b>null</b> if none.
|
* @return the channel language, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getLanguage() {
|
public String getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
|
@ -273,9 +273,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel language.
|
* Sets the channel language.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param language the channel language to set, <b>null</b> if none.
|
* @param language the channel language to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setLanguage(final String language) {
|
public void setLanguage(final String language) {
|
||||||
this.language = language;
|
this.language = language;
|
||||||
|
@ -284,9 +284,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel rating.
|
* Returns the channel rating.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel rating, <b>null</b> if none.
|
* @return the channel rating, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getRating() {
|
public String getRating() {
|
||||||
return rating;
|
return rating;
|
||||||
|
@ -295,9 +295,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel rating.
|
* Sets the channel rating.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param rating the channel rating to set, <b>null</b> if none.
|
* @param rating the channel rating to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setRating(final String rating) {
|
public void setRating(final String rating) {
|
||||||
this.rating = rating;
|
this.rating = rating;
|
||||||
|
@ -306,9 +306,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel copyright.
|
* Returns the channel copyright.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel copyright, <b>null</b> if none.
|
* @return the channel copyright, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getCopyright() {
|
public String getCopyright() {
|
||||||
return copyright;
|
return copyright;
|
||||||
|
@ -317,9 +317,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel copyright.
|
* Sets the channel copyright.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param copyright the channel copyright to set, <b>null</b> if none.
|
* @param copyright the channel copyright to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setCopyright(final String copyright) {
|
public void setCopyright(final String copyright) {
|
||||||
this.copyright = copyright;
|
this.copyright = copyright;
|
||||||
|
@ -328,69 +328,53 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel publishing date.
|
* Returns the channel publishing date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel publishing date, <b>null</b> if none.
|
* @return the channel publishing date, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Date getPubDate() {
|
public Date getPubDate() {
|
||||||
if (pubDate == null) {
|
return Dates.copy(pubDate);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Date(pubDate.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the channel publishing date.
|
* Sets the channel publishing date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param pubDate the channel publishing date to set, <b>null</b> if none.
|
* @param pubDate the channel publishing date to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setPubDate(final Date pubDate) {
|
public void setPubDate(final Date pubDate) {
|
||||||
if (pubDate == null) {
|
this.pubDate = Dates.copy(pubDate);
|
||||||
this.pubDate = null;
|
|
||||||
} else {
|
|
||||||
this.pubDate = new Date(pubDate.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the channel last build date.
|
* Returns the channel last build date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel last build date, <b>null</b> if none.
|
* @return the channel last build date, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Date getLastBuildDate() {
|
public Date getLastBuildDate() {
|
||||||
if (lastBuildDate == null) {
|
return Dates.copy(lastBuildDate);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Date(lastBuildDate.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the channel last build date.
|
* Sets the channel last build date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param lastBuildDate the channel last build date to set, <b>null</b> if none.
|
* @param lastBuildDate the channel last build date to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setLastBuildDate(final Date lastBuildDate) {
|
public void setLastBuildDate(final Date lastBuildDate) {
|
||||||
if (lastBuildDate == null) {
|
this.lastBuildDate = Dates.copy(lastBuildDate);
|
||||||
this.lastBuildDate = null;
|
|
||||||
} else {
|
|
||||||
this.lastBuildDate = new Date(lastBuildDate.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the channel docs.
|
* Returns the channel docs.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel docs, <b>null</b> if none.
|
* @return the channel docs, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getDocs() {
|
public String getDocs() {
|
||||||
return docs;
|
return docs;
|
||||||
|
@ -399,9 +383,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel docs.
|
* Sets the channel docs.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param docs the channel docs to set, <b>null</b> if none.
|
* @param docs the channel docs to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setDocs(final String docs) {
|
public void setDocs(final String docs) {
|
||||||
this.docs = docs;
|
this.docs = docs;
|
||||||
|
@ -410,9 +394,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel managing editor.
|
* Returns the channel managing editor.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel managing editor, <b>null</b> if none.
|
* @return the channel managing editor, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getManagingEditor() {
|
public String getManagingEditor() {
|
||||||
return managingEditor;
|
return managingEditor;
|
||||||
|
@ -421,9 +405,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel managing editor.
|
* Sets the channel managing editor.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param managingEditor the channel managing editor to set, <b>null</b> if none.
|
* @param managingEditor the channel managing editor to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setManagingEditor(final String managingEditor) {
|
public void setManagingEditor(final String managingEditor) {
|
||||||
this.managingEditor = managingEditor;
|
this.managingEditor = managingEditor;
|
||||||
|
@ -432,9 +416,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel web master.
|
* Returns the channel web master.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel web master, <b>null</b> if none.
|
* @return the channel web master, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getWebMaster() {
|
public String getWebMaster() {
|
||||||
return webMaster;
|
return webMaster;
|
||||||
|
@ -443,9 +427,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel web master.
|
* Sets the channel web master.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param webMaster the channel web master to set, <b>null</b> if none.
|
* @param webMaster the channel web master to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setWebMaster(final String webMaster) {
|
public void setWebMaster(final String webMaster) {
|
||||||
this.webMaster = webMaster;
|
this.webMaster = webMaster;
|
||||||
|
@ -454,25 +438,21 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel skip hours.
|
* Returns the channel skip hours.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Integer elements with the channel skip hours, an empty list if none.
|
* @return a list of Integer elements with the channel skip hours, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Integer> getSkipHours() {
|
public List<Integer> getSkipHours() {
|
||||||
if (skipHours != null) {
|
return Lists.createWhenNull(skipHours);
|
||||||
return skipHours;
|
|
||||||
} else {
|
|
||||||
return new ArrayList<Integer>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the channel skip hours.
|
* Sets the channel skip hours.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param skipHours the list of Integer elements with the channel skip hours to set, an empty
|
* @param skipHours the list of Integer elements with the channel skip hours to set, an empty
|
||||||
* list or <b>null</b> if none.
|
* list or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setSkipHours(final List<Integer> skipHours) {
|
public void setSkipHours(final List<Integer> skipHours) {
|
||||||
if (skipHours != null) {
|
if (skipHours != null) {
|
||||||
|
@ -494,25 +474,21 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel skip days.
|
* Returns the channel skip days.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Day elements with the channel skip days, an empty list if none.
|
* @return a list of Day elements with the channel skip days, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<String> getSkipDays() {
|
public List<String> getSkipDays() {
|
||||||
if (skipDays != null) {
|
return Lists.createWhenNull(skipDays);
|
||||||
return skipDays;
|
|
||||||
} else {
|
|
||||||
return new ArrayList<String>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the channel skip days.
|
* Sets the channel skip days.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param skipDays the list of Day elements with the channel skip days to set, an empty list or
|
* @param skipDays the list of Day elements with the channel skip days to set, an empty list or
|
||||||
* <b>null</b> if none.
|
* <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setSkipDays(final List<String> skipDays) {
|
public void setSkipDays(final List<String> skipDays) {
|
||||||
if (skipDays != null) {
|
if (skipDays != null) {
|
||||||
|
@ -535,9 +511,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel cloud.
|
* Returns the channel cloud.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel cloud, <b>null</b> if none.
|
* @return the channel cloud, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Cloud getCloud() {
|
public Cloud getCloud() {
|
||||||
return cloud;
|
return cloud;
|
||||||
|
@ -546,9 +522,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel cloud.
|
* Sets the channel cloud.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param cloud the channel cloud to set, <b>null</b> if none.
|
* @param cloud the channel cloud to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setCloud(final Cloud cloud) {
|
public void setCloud(final Cloud cloud) {
|
||||||
this.cloud = cloud;
|
this.cloud = cloud;
|
||||||
|
@ -557,24 +533,21 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel categories.
|
* Returns the channel categories.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Category elements with the channel categories, an empty list if none.
|
* @return a list of Category elements with the channel categories, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Category> getCategories() {
|
public List<Category> getCategories() {
|
||||||
if (categories == null) {
|
return categories = Lists.createWhenNull(categories);
|
||||||
categories = new ArrayList<Category>();
|
|
||||||
}
|
|
||||||
return categories;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the channel categories.
|
* Sets the channel categories.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param categories the list of Category elements with the channel categories to set, an empty
|
* @param categories the list of Category elements with the channel categories to set, an empty
|
||||||
* list or <b>null</b> if none.
|
* list or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setCategories(final List<Category> categories) {
|
public void setCategories(final List<Category> categories) {
|
||||||
this.categories = categories;
|
this.categories = categories;
|
||||||
|
@ -583,9 +556,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel generator.
|
* Returns the channel generator.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel generator, <b>null</b> if none.
|
* @return the channel generator, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getGenerator() {
|
public String getGenerator() {
|
||||||
return generator;
|
return generator;
|
||||||
|
@ -594,9 +567,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel generator.
|
* Sets the channel generator.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param generator the channel generator to set, <b>null</b> if none.
|
* @param generator the channel generator to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setGenerator(final String generator) {
|
public void setGenerator(final String generator) {
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
|
@ -605,9 +578,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel time to live.
|
* Returns the channel time to live.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the channel time to live, <b>null</b> if none.
|
* @return the channel time to live, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public int getTtl() {
|
public int getTtl() {
|
||||||
return ttl;
|
return ttl;
|
||||||
|
@ -616,9 +589,9 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the channel time to live.
|
* Sets the channel time to live.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param ttl the channel time to live to set, <b>null</b> if none.
|
* @param ttl the channel time to live to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setTtl(final int ttl) {
|
public void setTtl(final int ttl) {
|
||||||
this.ttl = ttl;
|
this.ttl = ttl;
|
||||||
|
@ -627,25 +600,22 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the channel modules.
|
* Returns the channel modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of ModuleImpl elements with the channel modules, an empty list if none.
|
* @return a list of ModuleImpl elements with the channel modules, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Module> getModules() {
|
public List<Module> getModules() {
|
||||||
if (modules == null) {
|
return modules = Lists.createWhenNull(modules);
|
||||||
modules = new ArrayList<Module>();
|
|
||||||
}
|
|
||||||
return modules;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the channel modules.
|
* Sets the channel modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param modules the list of ModuleImpl elements with the channel modules to set, an empty list
|
* @param modules the list of ModuleImpl elements with the channel modules to set, an empty list
|
||||||
* or <b>null</b> if none.
|
* or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModules(final List<Module> modules) {
|
public void setModules(final List<Module> modules) {
|
||||||
|
@ -655,7 +625,7 @@ public class Channel extends WireFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the module identified by a given URI.
|
* Returns the module identified by a given URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the URI of the ModuleImpl.
|
* @param uri the URI of the ModuleImpl.
|
||||||
* @return The module with the given URI, <b>null</b> if none.
|
* @return The module with the given URI, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,12 +18,13 @@
|
||||||
package com.sun.syndication.feed.rss;
|
package com.sun.syndication.feed.rss;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jdom2.Element;
|
import org.jdom2.Element;
|
||||||
|
|
||||||
|
import com.rometools.utils.Dates;
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.impl.ObjectBean;
|
import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
import com.sun.syndication.feed.module.Extendable;
|
import com.sun.syndication.feed.module.Extendable;
|
||||||
import com.sun.syndication.feed.module.Module;
|
import com.sun.syndication.feed.module.Module;
|
||||||
|
@ -37,13 +38,16 @@ import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
* For RSS1.0 it supports Dublin Core and Syndication modules. Note that those modules currently
|
* For RSS1.0 it supports Dublin Core and Syndication modules. Note that those modules currently
|
||||||
* support simple syntax format only.
|
* support simple syntax format only.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Item implements Cloneable, Serializable, Extendable {
|
public class Item implements Cloneable, Serializable, Extendable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3741763947754555947L;
|
private static final long serialVersionUID = 3741763947754555947L;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
private String link;
|
private String link;
|
||||||
private String uri;
|
private String uri;
|
||||||
|
@ -63,7 +67,7 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Item() {
|
public Item() {
|
||||||
objBean = new ObjectBean(this.getClass(), this);
|
objBean = new ObjectBean(this.getClass(), this);
|
||||||
|
@ -72,10 +76,10 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -86,10 +90,10 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -110,9 +114,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -122,9 +126,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -134,9 +138,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item title.
|
* Returns the item title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the item title, <b>null</b> if none.
|
* @return the item title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
|
@ -145,9 +149,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the item title.
|
* Sets the item title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param title the item title to set, <b>null</b> if none.
|
* @param title the item title to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setTitle(final String title) {
|
public void setTitle(final String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -156,9 +160,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item link.
|
* Returns the item link.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the item link, <b>null</b> if none.
|
* @return the item link, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getLink() {
|
public String getLink() {
|
||||||
return link;
|
return link;
|
||||||
|
@ -167,9 +171,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the item link.
|
* Sets the item link.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param link the item link to set, <b>null</b> if none.
|
* @param link the item link to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setLink(final String link) {
|
public void setLink(final String link) {
|
||||||
this.link = link;
|
this.link = link;
|
||||||
|
@ -178,7 +182,7 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item uri.
|
* Returns the item uri.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the item uri, <b>null</b> if none.
|
* @return the item uri, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public String getUri() {
|
public String getUri() {
|
||||||
|
@ -188,7 +192,7 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the item uri.
|
* Sets the item uri.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the item uri to set, <b>null</b> if none.
|
* @param uri the item uri to set, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
public void setUri(final String uri) {
|
public void setUri(final String uri) {
|
||||||
|
@ -198,9 +202,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item description.
|
* Returns the item description.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the item description, <b>null</b> if none.
|
* @return the item description, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Description getDescription() {
|
public Description getDescription() {
|
||||||
return description;
|
return description;
|
||||||
|
@ -209,9 +213,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the item description.
|
* Sets the item description.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param description the item description to set, <b>null</b> if none.
|
* @param description the item description to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setDescription(final Description description) {
|
public void setDescription(final Description description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
@ -220,9 +224,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item content.
|
* Returns the item content.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the item content, <b>null</b> if none.
|
* @return the item content, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Content getContent() {
|
public Content getContent() {
|
||||||
return content;
|
return content;
|
||||||
|
@ -231,9 +235,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the item content.
|
* Sets the item content.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param content the item content to set, <b>null</b> if none.
|
* @param content the item content to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setContent(final Content content) {
|
public void setContent(final Content content) {
|
||||||
this.content = content;
|
this.content = content;
|
||||||
|
@ -242,9 +246,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item source.
|
* Returns the item source.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the item source, <b>null</b> if none.
|
* @return the item source, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Source getSource() {
|
public Source getSource() {
|
||||||
return source;
|
return source;
|
||||||
|
@ -253,9 +257,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the item source.
|
* Sets the item source.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param source the item source to set, <b>null</b> if none.
|
* @param source the item source to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setSource(final Source source) {
|
public void setSource(final Source source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
|
@ -264,24 +268,21 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item enclosures.
|
* Returns the item enclosures.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Enclosure elements with the item enclosures, an empty list if none.
|
* @return a list of Enclosure elements with the item enclosures, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Enclosure> getEnclosures() {
|
public List<Enclosure> getEnclosures() {
|
||||||
if (enclosures == null) {
|
return enclosures = Lists.createWhenNull(enclosures);
|
||||||
enclosures = new ArrayList<Enclosure>();
|
|
||||||
}
|
|
||||||
return enclosures;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the item enclosures.
|
* Sets the item enclosures.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param enclosures the list of Enclosure elements with the item enclosures to set, an empty
|
* @param enclosures the list of Enclosure elements with the item enclosures to set, an empty
|
||||||
* list or <b>null</b> if none.
|
* list or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setEnclosures(final List<Enclosure> enclosures) {
|
public void setEnclosures(final List<Enclosure> enclosures) {
|
||||||
this.enclosures = enclosures;
|
this.enclosures = enclosures;
|
||||||
|
@ -290,24 +291,21 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item categories.
|
* Returns the item categories.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of Category elements with the item categories, an empty list if none.
|
* @return a list of Category elements with the item categories, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Category> getCategories() {
|
public List<Category> getCategories() {
|
||||||
if (categories == null) {
|
return categories = Lists.createWhenNull(categories);
|
||||||
categories = new ArrayList<Category>();
|
|
||||||
}
|
|
||||||
return categories;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the item categories.
|
* Sets the item categories.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param categories the list of Categories elements with the item categories to set, an empty
|
* @param categories the list of Categories elements with the item categories to set, an empty
|
||||||
* list or <b>null</b> if none.
|
* list or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setCategories(final List<Category> categories) {
|
public void setCategories(final List<Category> categories) {
|
||||||
this.categories = categories;
|
this.categories = categories;
|
||||||
|
@ -316,9 +314,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item GUID.
|
* Returns the item GUID.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the item GUID, <b>null</b> if none.
|
* @return the item GUID, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Guid getGuid() {
|
public Guid getGuid() {
|
||||||
return guid;
|
return guid;
|
||||||
|
@ -327,9 +325,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the item GUID.
|
* Sets the item GUID.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param guid the item GUID to set, <b>null</b> if none.
|
* @param guid the item GUID to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setGuid(final Guid guid) {
|
public void setGuid(final Guid guid) {
|
||||||
this.guid = guid;
|
this.guid = guid;
|
||||||
|
@ -338,9 +336,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item comments.
|
* Returns the item comments.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the item comments, <b>null</b> if none.
|
* @return the item comments, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getComments() {
|
public String getComments() {
|
||||||
return comments;
|
return comments;
|
||||||
|
@ -349,9 +347,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the item comments.
|
* Sets the item comments.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param comments the item comments to set, <b>null</b> if none.
|
* @param comments the item comments to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setComments(final String comments) {
|
public void setComments(final String comments) {
|
||||||
this.comments = comments;
|
this.comments = comments;
|
||||||
|
@ -360,9 +358,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item author.
|
* Returns the item author.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the item author, <b>null</b> if none.
|
* @return the item author, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getAuthor() {
|
public String getAuthor() {
|
||||||
return author;
|
return author;
|
||||||
|
@ -371,9 +369,9 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Sets the item author.
|
* Sets the item author.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param author the item author to set, <b>null</b> if none.
|
* @param author the item author to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setAuthor(final String author) {
|
public void setAuthor(final String author) {
|
||||||
this.author = author;
|
this.author = author;
|
||||||
|
@ -382,25 +380,22 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item modules.
|
* Returns the item modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of ModuleImpl elements with the item modules, an empty list if none.
|
* @return a list of ModuleImpl elements with the item modules, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Module> getModules() {
|
public List<Module> getModules() {
|
||||||
if (modules == null) {
|
return modules = Lists.createWhenNull(modules);
|
||||||
modules = new ArrayList<Module>();
|
|
||||||
}
|
|
||||||
return modules;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the item modules.
|
* Sets the item modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param modules the list of ModuleImpl elements with the item modules to set, an empty list or
|
* @param modules the list of ModuleImpl elements with the item modules to set, an empty list or
|
||||||
* <b>null</b> if none.
|
* <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModules(final List<Module> modules) {
|
public void setModules(final List<Module> modules) {
|
||||||
|
@ -410,7 +405,7 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the module identified by a given URI.
|
* Returns the module identified by a given URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the URI of the ModuleImpl.
|
* @param uri the URI of the ModuleImpl.
|
||||||
* @return The module with the given URI, <b>null</b> if none.
|
* @return The module with the given URI, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
@ -422,83 +417,64 @@ public class Item implements Cloneable, Serializable, Extendable {
|
||||||
/**
|
/**
|
||||||
* Returns the item publishing date.
|
* Returns the item publishing date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the item publishing date, <b>null</b> if none.
|
* @return the item publishing date, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Date getPubDate() {
|
public Date getPubDate() {
|
||||||
if (pubDate == null) {
|
return Dates.copy(pubDate);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Date(pubDate.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the item publishing date.
|
* Sets the item publishing date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param pubDate the item publishing date to set, <b>null</b> if none.
|
* @param pubDate the item publishing date to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setPubDate(final Date pubDate) {
|
public void setPubDate(final Date pubDate) {
|
||||||
if (pubDate == null) {
|
this.pubDate = Dates.copy(pubDate);
|
||||||
this.pubDate = null;
|
|
||||||
} else {
|
|
||||||
this.pubDate = new Date(pubDate.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the item expiration date.
|
* Returns the item expiration date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the item expiration date, <b>null</b> if none.
|
* @return the item expiration date, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Date getExpirationDate() {
|
public Date getExpirationDate() {
|
||||||
if (expirationDate == null) {
|
return Dates.copy(expirationDate);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Date(expirationDate.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the item expiration date.
|
* Sets the item expiration date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param expirationDate the item expiration date to set, <b>null</b> if none.
|
* @param expirationDate the item expiration date to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setExpirationDate(final Date expirationDate) {
|
public void setExpirationDate(final Date expirationDate) {
|
||||||
if (expirationDate == null) {
|
this.expirationDate = Dates.copy(expirationDate);
|
||||||
this.expirationDate = null;
|
|
||||||
} else {
|
|
||||||
this.expirationDate = new Date(expirationDate.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns foreign markup found at item level.
|
* Returns foreign markup found at item level.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Opaque object to discourage use
|
* @return Opaque object to discourage use
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Element> getForeignMarkup() {
|
public List<Element> getForeignMarkup() {
|
||||||
if (foreignMarkup == null) {
|
return foreignMarkup = Lists.createWhenNull(foreignMarkup);
|
||||||
foreignMarkup = new ArrayList<Element>();
|
|
||||||
}
|
|
||||||
return foreignMarkup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets foreign markup found at item level.
|
* Sets foreign markup found at item level.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param foreignMarkup Opaque object to discourage use
|
* @param foreignMarkup Opaque object to discourage use
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setForeignMarkup(final List<Element> foreignMarkup) {
|
public void setForeignMarkup(final List<Element> foreignMarkup) {
|
||||||
this.foreignMarkup = foreignMarkup;
|
this.foreignMarkup = foreignMarkup;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2004 Sun Microsystems, Inc.
|
* Copyright 2004 Sun Microsystems, Inc.
|
||||||
* Copyright 2011 ROME Team
|
* Copyright 2011 ROME Team
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
|
@ -18,11 +18,8 @@
|
||||||
package com.sun.syndication.feed.synd;
|
package com.sun.syndication.feed.synd;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.AbstractList;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.sun.syndication.feed.CopyFrom;
|
import com.sun.syndication.feed.CopyFrom;
|
||||||
|
@ -34,20 +31,32 @@ import com.sun.syndication.feed.module.DCSubjectImpl;
|
||||||
/**
|
/**
|
||||||
* Bean for categories of SyndFeedImpl feeds and entries.
|
* Bean for categories of SyndFeedImpl feeds and entries.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SyndCategoryImpl implements Serializable, SyndCategory {
|
public class SyndCategoryImpl implements Serializable, SyndCategory {
|
||||||
|
|
||||||
private static final long serialVersionUID = -2151815243404151131L;
|
private static final long serialVersionUID = -2151815243404151131L;
|
||||||
|
|
||||||
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
private final DCSubject subject;
|
private final DCSubject subject;
|
||||||
|
|
||||||
|
static {
|
||||||
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
|
basePropInterfaceMap.put("name", String.class);
|
||||||
|
basePropInterfaceMap.put("taxonomyUri", String.class);
|
||||||
|
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = Collections.emptyMap();
|
||||||
|
COPY_FROM_HELPER = new CopyFromHelper(SyndCategory.class, basePropInterfaceMap, basePropClassImplMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For implementations extending SyndContentImpl to be able to use the ObjectBean functionality
|
* For implementations extending SyndContentImpl to be able to use the ObjectBean functionality
|
||||||
* with extended interfaces.
|
* with extended interfaces.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param subject the DC subject to wrap.
|
* @param subject the DC subject to wrap.
|
||||||
*/
|
*/
|
||||||
SyndCategoryImpl(final DCSubject subject) {
|
SyndCategoryImpl(final DCSubject subject) {
|
||||||
|
@ -58,10 +67,10 @@ public class SyndCategoryImpl implements Serializable, SyndCategory {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -72,10 +81,10 @@ public class SyndCategoryImpl implements Serializable, SyndCategory {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -90,9 +99,9 @@ public class SyndCategoryImpl implements Serializable, SyndCategory {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -102,9 +111,9 @@ public class SyndCategoryImpl implements Serializable, SyndCategory {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -114,9 +123,9 @@ public class SyndCategoryImpl implements Serializable, SyndCategory {
|
||||||
/**
|
/**
|
||||||
* Package private constructor, used by SyndCategoryListFacade.
|
* Package private constructor, used by SyndCategoryListFacade.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the DC subject being wrapped.
|
* @return the DC subject being wrapped.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
DCSubject getSubject() {
|
DCSubject getSubject() {
|
||||||
return subject;
|
return subject;
|
||||||
|
@ -125,7 +134,7 @@ public class SyndCategoryImpl implements Serializable, SyndCategory {
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public SyndCategoryImpl() {
|
public SyndCategoryImpl() {
|
||||||
this(new DCSubjectImpl());
|
this(new DCSubjectImpl());
|
||||||
|
@ -134,9 +143,9 @@ public class SyndCategoryImpl implements Serializable, SyndCategory {
|
||||||
/**
|
/**
|
||||||
* Returns the category name.
|
* Returns the category name.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the category name, <b>null</b> if none.
|
* @return the category name, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -146,9 +155,9 @@ public class SyndCategoryImpl implements Serializable, SyndCategory {
|
||||||
/**
|
/**
|
||||||
* Sets the category name.
|
* Sets the category name.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param name the category name to set, <b>null</b> if none.
|
* @param name the category name to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setName(final String name) {
|
public void setName(final String name) {
|
||||||
|
@ -158,9 +167,9 @@ public class SyndCategoryImpl implements Serializable, SyndCategory {
|
||||||
/**
|
/**
|
||||||
* Returns the category taxonomy URI.
|
* Returns the category taxonomy URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the category taxonomy URI, <b>null</b> if none.
|
* @return the category taxonomy URI, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getTaxonomyUri() {
|
public String getTaxonomyUri() {
|
||||||
|
@ -170,9 +179,9 @@ public class SyndCategoryImpl implements Serializable, SyndCategory {
|
||||||
/**
|
/**
|
||||||
* Sets the category taxonomy URI.
|
* Sets the category taxonomy URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param taxonomyUri the category taxonomy URI to set, <b>null</b> if none.
|
* @param taxonomyUri the category taxonomy URI to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setTaxonomyUri(final String taxonomyUri) {
|
public void setTaxonomyUri(final String taxonomyUri) {
|
||||||
|
@ -189,168 +198,4 @@ public class SyndCategoryImpl implements Serializable, SyndCategory {
|
||||||
COPY_FROM_HELPER.copy(this, obj);
|
COPY_FROM_HELPER.copy(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
|
||||||
|
|
||||||
static {
|
|
||||||
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
|
||||||
basePropInterfaceMap.put("name", String.class);
|
|
||||||
basePropInterfaceMap.put("taxonomyUri", String.class);
|
|
||||||
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = Collections.emptyMap();
|
|
||||||
COPY_FROM_HELPER = new CopyFromHelper(SyndCategory.class, basePropInterfaceMap, basePropClassImplMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List implementation for SyndCategoryImpl elements. To be directly used by the SyndFeedImpl and
|
|
||||||
* SyndEntryImpl classes only.
|
|
||||||
* <p>
|
|
||||||
* It acts as a facade on top of the DCSubjectImpl elements of the underlying list and remains in
|
|
||||||
* synch with it. It is possible to work on either list, the categories one or the subjects one and
|
|
||||||
* they remain in synch.
|
|
||||||
* <p>
|
|
||||||
* This is necessary because the SyndFeedImpl categories are just a convenience to access the
|
|
||||||
* DublinCore subjects.
|
|
||||||
* <P>
|
|
||||||
* All this mess to avoid making DCSubjectImpl implement SyndCategory (which it would be odd).
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @author Alejandro Abdelnur
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class SyndCategoryListFacade extends AbstractList<SyndCategory> {
|
|
||||||
private final List<DCSubject> subjects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor. Creates and empty list.
|
|
||||||
*/
|
|
||||||
public SyndCategoryListFacade() {
|
|
||||||
this(new ArrayList<DCSubject>());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a facade list of categories on top the given subject list.
|
|
||||||
* <P>
|
|
||||||
*
|
|
||||||
* @param subjects the list of subjects to create the facade.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public SyndCategoryListFacade(final List<DCSubject> subjects) {
|
|
||||||
this.subjects = subjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the category by index.
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @param index the index position to retrieve the category.
|
|
||||||
* @return the SyndCategoryImpl in position index, <b>null</b> if none.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public SyndCategory get(final int index) {
|
|
||||||
return new SyndCategoryImpl(subjects.get(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the size of the list.
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @return the size of the list.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
return subjects.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a category in an existing position in the list.
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @param index position to set the category.
|
|
||||||
* @param obj the SyndCategoryImpl object to set.
|
|
||||||
* @return the SyndCategoryImpl object that is being replaced, <b>null</b> if none.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public SyndCategory set(final int index, final SyndCategory obj) {
|
|
||||||
final SyndCategoryImpl sCat = (SyndCategoryImpl) obj;
|
|
||||||
DCSubject subject;
|
|
||||||
if (sCat != null) {
|
|
||||||
subject = sCat.getSubject();
|
|
||||||
} else {
|
|
||||||
subject = null;
|
|
||||||
}
|
|
||||||
subject = subjects.set(index, subject);
|
|
||||||
if (subject != null) {
|
|
||||||
return new SyndCategoryImpl(subject);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a category to the list.
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @param index position to add the category.
|
|
||||||
* @param obj the SyndCategoryImpl object to add.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void add(final int index, final SyndCategory obj) {
|
|
||||||
final SyndCategoryImpl sCat = (SyndCategoryImpl) obj;
|
|
||||||
DCSubject subject;
|
|
||||||
if (sCat != null) {
|
|
||||||
subject = sCat.getSubject();
|
|
||||||
} else {
|
|
||||||
subject = null;
|
|
||||||
}
|
|
||||||
subjects.add(index, subject);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a category element from a specific position.
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @param index position to remove the category from.
|
|
||||||
* @return the SyndCategoryImpl being removed from position index, <b>null</b> if none.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public SyndCategory remove(final int index) {
|
|
||||||
final DCSubject subject = subjects.remove(index);
|
|
||||||
if (subject != null) {
|
|
||||||
return new SyndCategoryImpl(subject);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list with the DCSubject elements of the SyndCategoryImpl list facade. To be used by
|
|
||||||
* the SyndFeedImpl class only.
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @param cList the list with SyndCategoryImpl elements to convert to subject list.
|
|
||||||
* @return a list with DCSubject elements corresponding to the categories in the given list.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static List<DCSubject> convertElementsSyndCategoryToSubject(final List<SyndCategory> cList) {
|
|
||||||
List<DCSubject> sList = null;
|
|
||||||
if (cList != null) {
|
|
||||||
sList = new ArrayList<DCSubject>();
|
|
||||||
for (int i = 0; i < cList.size(); i++) {
|
|
||||||
final SyndCategoryImpl sCat = (SyndCategoryImpl) cList.get(i);
|
|
||||||
DCSubject subject = null;
|
|
||||||
if (sCat != null) {
|
|
||||||
subject = sCat.getSubject();
|
|
||||||
}
|
|
||||||
sList.add(subject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sList;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,162 @@
|
||||||
|
package com.sun.syndication.feed.synd;
|
||||||
|
|
||||||
|
import java.util.AbstractList;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.sun.syndication.feed.module.DCSubject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List implementation for SyndCategoryImpl elements. To be directly used by the SyndFeedImpl and
|
||||||
|
* SyndEntryImpl classes only.
|
||||||
|
* <p>
|
||||||
|
* It acts as a facade on top of the DCSubjectImpl elements of the underlying list and remains in
|
||||||
|
* synch with it. It is possible to work on either list, the categories one or the subjects one and
|
||||||
|
* they remain in synch.
|
||||||
|
* <p>
|
||||||
|
* This is necessary because the SyndFeedImpl categories are just a convenience to access the
|
||||||
|
* DublinCore subjects.
|
||||||
|
* <P>
|
||||||
|
* All this mess to avoid making DCSubjectImpl implement SyndCategory (which it would be odd).
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @author Alejandro Abdelnur
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class SyndCategoryListFacade extends AbstractList<SyndCategory> {
|
||||||
|
|
||||||
|
private final List<DCSubject> subjects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor. Creates and empty list.
|
||||||
|
*/
|
||||||
|
public SyndCategoryListFacade() {
|
||||||
|
this(new ArrayList<DCSubject>());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a facade list of categories on top the given subject list.
|
||||||
|
* <P>
|
||||||
|
*
|
||||||
|
* @param subjects the list of subjects to create the facade.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public SyndCategoryListFacade(final List<DCSubject> subjects) {
|
||||||
|
this.subjects = subjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the category by index.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @param index the index position to retrieve the category.
|
||||||
|
* @return the SyndCategoryImpl in position index, <b>null</b> if none.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SyndCategory get(final int index) {
|
||||||
|
return new SyndCategoryImpl(subjects.get(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of the list.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @return the size of the list.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return subjects.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a category in an existing position in the list.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @param index position to set the category.
|
||||||
|
* @param obj the SyndCategoryImpl object to set.
|
||||||
|
* @return the SyndCategoryImpl object that is being replaced, <b>null</b> if none.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SyndCategory set(final int index, final SyndCategory obj) {
|
||||||
|
final SyndCategoryImpl sCat = (SyndCategoryImpl) obj;
|
||||||
|
DCSubject subject;
|
||||||
|
if (sCat != null) {
|
||||||
|
subject = sCat.getSubject();
|
||||||
|
} else {
|
||||||
|
subject = null;
|
||||||
|
}
|
||||||
|
subject = subjects.set(index, subject);
|
||||||
|
if (subject != null) {
|
||||||
|
return new SyndCategoryImpl(subject);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a category to the list.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @param index position to add the category.
|
||||||
|
* @param obj the SyndCategoryImpl object to add.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void add(final int index, final SyndCategory obj) {
|
||||||
|
final SyndCategoryImpl sCat = (SyndCategoryImpl) obj;
|
||||||
|
DCSubject subject;
|
||||||
|
if (sCat != null) {
|
||||||
|
subject = sCat.getSubject();
|
||||||
|
} else {
|
||||||
|
subject = null;
|
||||||
|
}
|
||||||
|
subjects.add(index, subject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a category element from a specific position.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @param index position to remove the category from.
|
||||||
|
* @return the SyndCategoryImpl being removed from position index, <b>null</b> if none.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SyndCategory remove(final int index) {
|
||||||
|
final DCSubject subject = subjects.remove(index);
|
||||||
|
if (subject != null) {
|
||||||
|
return new SyndCategoryImpl(subject);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list with the DCSubject elements of the SyndCategoryImpl list facade. To be used by
|
||||||
|
* the SyndFeedImpl class only.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @param cList the list with SyndCategoryImpl elements to convert to subject list.
|
||||||
|
* @return a list with DCSubject elements corresponding to the categories in the given list.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static List<DCSubject> convertElementsSyndCategoryToSubject(final List<SyndCategory> cList) {
|
||||||
|
List<DCSubject> sList = null;
|
||||||
|
if (cList != null) {
|
||||||
|
sList = new ArrayList<DCSubject>();
|
||||||
|
for (int i = 0; i < cList.size(); i++) {
|
||||||
|
final SyndCategoryImpl sCat = (SyndCategoryImpl) cList.get(i);
|
||||||
|
DCSubject subject = null;
|
||||||
|
if (sCat != null) {
|
||||||
|
subject = sCat.getSubject();
|
||||||
|
}
|
||||||
|
sList.add(subject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -28,21 +28,36 @@ import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
/**
|
/**
|
||||||
* Bean for content of SyndFeedImpl entries.
|
* Bean for content of SyndFeedImpl entries.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SyndContentImpl implements Serializable, SyndContent {
|
public class SyndContentImpl implements Serializable, SyndContent {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8831050456661121113L;
|
private static final long serialVersionUID = -8831050456661121113L;
|
||||||
|
|
||||||
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
private String value;
|
private String value;
|
||||||
private String mode;
|
private String mode;
|
||||||
|
|
||||||
|
static {
|
||||||
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
|
basePropInterfaceMap.put("type", String.class);
|
||||||
|
basePropInterfaceMap.put("value", String.class);
|
||||||
|
|
||||||
|
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom>, Class<?>> emptyMap();
|
||||||
|
|
||||||
|
COPY_FROM_HELPER = new CopyFromHelper(SyndContent.class, basePropInterfaceMap, basePropClassImplMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public SyndContentImpl() {
|
public SyndContentImpl() {
|
||||||
objBean = new ObjectBean(SyndContent.class, this);
|
objBean = new ObjectBean(SyndContent.class, this);
|
||||||
|
@ -51,10 +66,10 @@ public class SyndContentImpl implements Serializable, SyndContent {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -65,10 +80,10 @@ public class SyndContentImpl implements Serializable, SyndContent {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -80,9 +95,9 @@ public class SyndContentImpl implements Serializable, SyndContent {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -92,9 +107,9 @@ public class SyndContentImpl implements Serializable, SyndContent {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -106,9 +121,9 @@ public class SyndContentImpl implements Serializable, SyndContent {
|
||||||
* <p>
|
* <p>
|
||||||
* When used for the description of an entry, if <b>null</b> 'text/plain' must be assumed.
|
* When used for the description of an entry, if <b>null</b> 'text/plain' must be assumed.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the content type, <b>null</b> if none.
|
* @return the content type, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
@ -120,9 +135,9 @@ public class SyndContentImpl implements Serializable, SyndContent {
|
||||||
* <p>
|
* <p>
|
||||||
* When used for the description of an entry, if <b>null</b> 'text/plain' must be assumed.
|
* When used for the description of an entry, if <b>null</b> 'text/plain' must be assumed.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param type the content type to set, <b>null</b> if none.
|
* @param type the content type to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setType(final String type) {
|
public void setType(final String type) {
|
||||||
|
@ -131,9 +146,9 @@ public class SyndContentImpl implements Serializable, SyndContent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the content mode.
|
* Returns the content mode.
|
||||||
*
|
*
|
||||||
* @return the content mode, <b>null</b> if none.
|
* @return the content mode, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getMode() {
|
public String getMode() {
|
||||||
|
@ -142,9 +157,9 @@ public class SyndContentImpl implements Serializable, SyndContent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the content mode.
|
* Sets the content mode.
|
||||||
*
|
*
|
||||||
* @param mode the content mode to set, <b>null</b> if none.
|
* @param mode the content mode to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setMode(final String mode) {
|
public void setMode(final String mode) {
|
||||||
|
@ -154,9 +169,9 @@ public class SyndContentImpl implements Serializable, SyndContent {
|
||||||
/**
|
/**
|
||||||
* Returns the content value.
|
* Returns the content value.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the content value, <b>null</b> if none.
|
* @return the content value, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
|
@ -166,9 +181,9 @@ public class SyndContentImpl implements Serializable, SyndContent {
|
||||||
/**
|
/**
|
||||||
* Sets the content value.
|
* Sets the content value.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param value the content value to set, <b>null</b> if none.
|
* @param value the content value to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setValue(final String value) {
|
public void setValue(final String value) {
|
||||||
|
@ -185,16 +200,4 @@ public class SyndContentImpl implements Serializable, SyndContent {
|
||||||
COPY_FROM_HELPER.copy(this, obj);
|
COPY_FROM_HELPER.copy(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
|
||||||
|
|
||||||
static {
|
|
||||||
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
|
||||||
basePropInterfaceMap.put("type", String.class);
|
|
||||||
basePropInterfaceMap.put("value", String.class);
|
|
||||||
|
|
||||||
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom>, Class<?>> emptyMap();
|
|
||||||
|
|
||||||
COPY_FROM_HELPER = new CopyFromHelper(SyndContent.class, basePropInterfaceMap, basePropClassImplMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,16 +13,32 @@ import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*/
|
*/
|
||||||
public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5813049622142257411L;
|
private static final long serialVersionUID = -5813049622142257411L;
|
||||||
|
|
||||||
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
|
|
||||||
private String url;
|
private String url;
|
||||||
private String type;
|
private String type;
|
||||||
private long length;
|
private long length;
|
||||||
|
|
||||||
|
static {
|
||||||
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
|
basePropInterfaceMap.put("url", String.class);
|
||||||
|
basePropInterfaceMap.put("type", String.class);
|
||||||
|
basePropInterfaceMap.put("length", Long.TYPE);
|
||||||
|
|
||||||
|
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom>, Class<?>> emptyMap();
|
||||||
|
|
||||||
|
COPY_FROM_HELPER = new CopyFromHelper(SyndEnclosure.class, basePropInterfaceMap, basePropClassImplMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public SyndEnclosureImpl() {
|
public SyndEnclosureImpl() {
|
||||||
objBean = new ObjectBean(SyndEnclosure.class, this);
|
objBean = new ObjectBean(SyndEnclosure.class, this);
|
||||||
|
@ -31,10 +47,10 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -45,10 +61,10 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -60,9 +76,9 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -72,9 +88,9 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -84,7 +100,7 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
/**
|
/**
|
||||||
* Returns the enclosure URL.
|
* Returns the enclosure URL.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @return the enclosure URL, <b>null</b> if none.
|
* @return the enclosure URL, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,7 +111,7 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
/**
|
/**
|
||||||
* Sets the enclosure URL.
|
* Sets the enclosure URL.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @param url the enclosure URL to set, <b>null</b> if none.
|
* @param url the enclosure URL to set, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -106,7 +122,7 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
/**
|
/**
|
||||||
* Returns the enclosure length.
|
* Returns the enclosure length.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @return the enclosure length, <b>null</b> if none.
|
* @return the enclosure length, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,7 +133,7 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
/**
|
/**
|
||||||
* Sets the enclosure length.
|
* Sets the enclosure length.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @param length the enclosure length to set, <b>null</b> if none.
|
* @param length the enclosure length to set, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -128,7 +144,7 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
/**
|
/**
|
||||||
* Returns the enclosure type.
|
* Returns the enclosure type.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @return the enclosure type, <b>null</b> if none.
|
* @return the enclosure type, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -139,7 +155,7 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
/**
|
/**
|
||||||
* Sets the enclosure type.
|
* Sets the enclosure type.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @param type the enclosure type to set, <b>null</b> if none.
|
* @param type the enclosure type to set, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -157,17 +173,4 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
COPY_FROM_HELPER.copy(this, obj);
|
COPY_FROM_HELPER.copy(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
|
||||||
|
|
||||||
static {
|
|
||||||
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
|
||||||
basePropInterfaceMap.put("url", String.class);
|
|
||||||
basePropInterfaceMap.put("type", String.class);
|
|
||||||
basePropInterfaceMap.put("length", Long.TYPE);
|
|
||||||
|
|
||||||
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom>, Class<?>> emptyMap();
|
|
||||||
|
|
||||||
COPY_FROM_HELPER = new CopyFromHelper(SyndEnclosure.class, basePropInterfaceMap, basePropClassImplMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,9 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jdom2.Element;
|
import org.jdom2.Element;
|
||||||
|
|
||||||
|
import com.rometools.utils.Dates;
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
|
import com.rometools.utils.Strings;
|
||||||
import com.sun.syndication.feed.CopyFrom;
|
import com.sun.syndication.feed.CopyFrom;
|
||||||
import com.sun.syndication.feed.impl.CopyFromHelper;
|
import com.sun.syndication.feed.impl.CopyFromHelper;
|
||||||
import com.sun.syndication.feed.impl.ObjectBean;
|
import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
|
@ -42,13 +45,18 @@ import com.sun.syndication.feed.synd.impl.URINormalizer;
|
||||||
/**
|
/**
|
||||||
* Bean for entries of SyndFeedImpl feeds.
|
* Bean for entries of SyndFeedImpl feeds.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SyndEntryImpl implements Serializable, SyndEntry {
|
public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1944144041409866698L;
|
private static final long serialVersionUID = 1944144041409866698L;
|
||||||
|
|
||||||
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
|
|
||||||
private String uri;
|
private String uri;
|
||||||
private String link;
|
private String link;
|
||||||
private String comments;
|
private String comments;
|
||||||
|
@ -63,8 +71,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
private List<SyndPerson> contributors;
|
private List<SyndPerson> contributors;
|
||||||
private SyndFeed source;
|
private SyndFeed source;
|
||||||
private List<Element> foreignMarkup;
|
private List<Element> foreignMarkup;
|
||||||
private Object wireEntry; // com.sun.syndication.feed.atom.Entry or
|
|
||||||
// com.sun.syndication.feed.rss.Item
|
// com.sun.syndication.feed.atom.Entry or com.sun.syndication.feed.rss.Item
|
||||||
|
private Object wireEntry;
|
||||||
|
|
||||||
// ISSUE: some converters assume this is never null
|
// ISSUE: some converters assume this is never null
|
||||||
private List<SyndCategory> categories = new ArrayList<SyndCategory>();
|
private List<SyndCategory> categories = new ArrayList<SyndCategory>();
|
||||||
|
@ -80,19 +89,41 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
public static final Set<String> CONVENIENCE_PROPERTIES = Collections.unmodifiableSet(IGNORE_PROPERTIES);
|
public static final Set<String> CONVENIENCE_PROPERTIES = Collections.unmodifiableSet(IGNORE_PROPERTIES);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
IGNORE_PROPERTIES.add("publishedDate");
|
IGNORE_PROPERTIES.add("publishedDate");
|
||||||
IGNORE_PROPERTIES.add("author");
|
IGNORE_PROPERTIES.add("author");
|
||||||
|
|
||||||
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
|
basePropInterfaceMap.put("uri", String.class);
|
||||||
|
basePropInterfaceMap.put("title", String.class);
|
||||||
|
basePropInterfaceMap.put("link", String.class);
|
||||||
|
basePropInterfaceMap.put("uri", String.class);
|
||||||
|
basePropInterfaceMap.put("description", SyndContent.class);
|
||||||
|
basePropInterfaceMap.put("contents", SyndContent.class);
|
||||||
|
basePropInterfaceMap.put("enclosures", SyndEnclosure.class);
|
||||||
|
basePropInterfaceMap.put("modules", Module.class);
|
||||||
|
basePropInterfaceMap.put("categories", SyndCategory.class);
|
||||||
|
|
||||||
|
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = new HashMap<Class<? extends CopyFrom>, Class<?>>();
|
||||||
|
basePropClassImplMap.put(SyndContent.class, SyndContentImpl.class);
|
||||||
|
basePropClassImplMap.put(SyndEnclosure.class, SyndEnclosureImpl.class);
|
||||||
|
basePropClassImplMap.put(SyndCategory.class, SyndCategoryImpl.class);
|
||||||
|
basePropClassImplMap.put(DCModule.class, DCModuleImpl.class);
|
||||||
|
basePropClassImplMap.put(SyModule.class, SyModuleImpl.class);
|
||||||
|
|
||||||
|
COPY_FROM_HELPER = new CopyFromHelper(SyndEntry.class, basePropInterfaceMap, basePropClassImplMap);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For implementations extending SyndEntryImpl to be able to use the ObjectBean functionality
|
* For implementations extending SyndEntryImpl to be able to use the ObjectBean functionality
|
||||||
* with extended interfaces.
|
* with extended interfaces.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param beanClass
|
* @param beanClass
|
||||||
* @param convenienceProperties set containing the convenience properties of the SyndEntryImpl
|
* @param convenienceProperties set containing the convenience properties of the SyndEntryImpl
|
||||||
* (the are ignored during cloning, check CloneableBean for details).
|
* (the are ignored during cloning, check CloneableBean for details).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected SyndEntryImpl(final Class<?> beanClass, final Set<String> convenienceProperties) {
|
protected SyndEntryImpl(final Class<?> beanClass, final Set<String> convenienceProperties) {
|
||||||
objBean = new ObjectBean(beanClass, this, convenienceProperties);
|
objBean = new ObjectBean(beanClass, this, convenienceProperties);
|
||||||
|
@ -101,7 +132,7 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public SyndEntryImpl() {
|
public SyndEntryImpl() {
|
||||||
this(SyndEntry.class, IGNORE_PROPERTIES);
|
this(SyndEntry.class, IGNORE_PROPERTIES);
|
||||||
|
@ -110,10 +141,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -124,10 +155,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -154,9 +185,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -166,9 +197,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -185,9 +216,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
* <p>
|
* <p>
|
||||||
* The returned URI is a normalized URI as specified in RFC 2396bis.
|
* The returned URI is a normalized URI as specified in RFC 2396bis.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry URI, <b>null</b> if none.
|
* @return the entry URI, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUri() {
|
public String getUri() {
|
||||||
|
@ -202,9 +233,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
* href="http://wiki.java.net/bin/edit/Javawsxml/Rome04URIMapping">Feed and entry URI
|
* href="http://wiki.java.net/bin/edit/Javawsxml/Rome04URIMapping">Feed and entry URI
|
||||||
* mapping</a>.
|
* mapping</a>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the entry URI to set, <b>null</b> if none.
|
* @param uri the entry URI to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setUri(final String uri) {
|
public void setUri(final String uri) {
|
||||||
|
@ -214,9 +245,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Returns the entry title.
|
* Returns the entry title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry title, <b>null</b> if none.
|
* @return the entry title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
|
@ -229,9 +260,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Sets the entry title.
|
* Sets the entry title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param title the entry title to set, <b>null</b> if none.
|
* @param title the entry title to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setTitle(final String title) {
|
public void setTitle(final String title) {
|
||||||
|
@ -244,9 +275,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Returns the entry title as a text construct.
|
* Returns the entry title as a text construct.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry title, <b>null</b> if none.
|
* @return the entry title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SyndContent getTitleEx() {
|
public SyndContent getTitleEx() {
|
||||||
|
@ -256,9 +287,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Sets the entry title as a text construct.
|
* Sets the entry title as a text construct.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param title the entry title to set, <b>null</b> if none.
|
* @param title the entry title to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setTitleEx(final SyndContent title) {
|
public void setTitleEx(final SyndContent title) {
|
||||||
|
@ -268,9 +299,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Returns the entry link.
|
* Returns the entry link.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry link, <b>null</b> if none.
|
* @return the entry link, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getLink() {
|
public String getLink() {
|
||||||
|
@ -280,9 +311,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Sets the entry link.
|
* Sets the entry link.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param link the entry link to set, <b>null</b> if none.
|
* @param link the entry link to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setLink(final String link) {
|
public void setLink(final String link) {
|
||||||
|
@ -292,9 +323,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Returns the entry description.
|
* Returns the entry description.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry description, <b>null</b> if none.
|
* @return the entry description, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SyndContent getDescription() {
|
public SyndContent getDescription() {
|
||||||
|
@ -304,9 +335,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Sets the entry description.
|
* Sets the entry description.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param description the entry description to set, <b>null</b> if none.
|
* @param description the entry description to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setDescription(final SyndContent description) {
|
public void setDescription(final SyndContent description) {
|
||||||
|
@ -316,25 +347,22 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Returns the entry contents.
|
* Returns the entry contents.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of SyndContentImpl elements with the entry contents, an empty list if none.
|
* @return a list of SyndContentImpl elements with the entry contents, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SyndContent> getContents() {
|
public List<SyndContent> getContents() {
|
||||||
if (contents == null) {
|
return contents = Lists.createWhenNull(contents);
|
||||||
contents = new ArrayList<SyndContent>();
|
|
||||||
}
|
|
||||||
return contents;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the entry contents.
|
* Sets the entry contents.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param contents the list of SyndContentImpl elements with the entry contents to set, an empty
|
* @param contents the list of SyndContentImpl elements with the entry contents to set, an empty
|
||||||
* list or <b>null</b> if none.
|
* list or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setContents(final List<SyndContent> contents) {
|
public void setContents(final List<SyndContent> contents) {
|
||||||
|
@ -344,25 +372,22 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Returns the entry enclosures.
|
* Returns the entry enclosures.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of SyndEnclosure elements with the entry enclosures, an empty list if none.
|
* @return a list of SyndEnclosure elements with the entry enclosures, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SyndEnclosure> getEnclosures() {
|
public List<SyndEnclosure> getEnclosures() {
|
||||||
if (enclosures == null) {
|
return enclosures = Lists.createWhenNull(enclosures);
|
||||||
enclosures = new ArrayList<SyndEnclosure>();
|
|
||||||
}
|
|
||||||
return enclosures;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the entry enclosures.
|
* Sets the entry enclosures.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param enclosures the list of SyndEnclosure elements with the entry enclosures to set, an
|
* @param enclosures the list of SyndEnclosure elements with the entry enclosures to set, an
|
||||||
* empty list or <b>null</b> if none.
|
* empty list or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setEnclosures(final List<SyndEnclosure> enclosures) {
|
public void setEnclosures(final List<SyndEnclosure> enclosures) {
|
||||||
|
@ -374,9 +399,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module date.
|
* This method is a convenience method, it maps to the Dublin Core module date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry published date, <b>null</b> if none.
|
* @return the entry published date, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Date getPublishedDate() {
|
public Date getPublishedDate() {
|
||||||
|
@ -388,9 +413,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module date.
|
* This method is a convenience method, it maps to the Dublin Core module date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param publishedDate the entry published date to set, <b>null</b> if none.
|
* @param publishedDate the entry published date to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setPublishedDate(final Date publishedDate) {
|
public void setPublishedDate(final Date publishedDate) {
|
||||||
|
@ -400,9 +425,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Returns the entry categories.
|
* Returns the entry categories.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of SyndCategoryImpl elements with the entry categories, an empty list if none.
|
* @return a list of SyndCategoryImpl elements with the entry categories, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SyndCategory> getCategories() {
|
public List<SyndCategory> getCategories() {
|
||||||
|
@ -414,10 +439,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module subjects.
|
* This method is a convenience method, it maps to the Dublin Core module subjects.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param categories the list of SyndCategoryImpl elements with the entry categories to set, an
|
* @param categories the list of SyndCategoryImpl elements with the entry categories to set, an
|
||||||
* empty list or <b>null</b> if none.
|
* empty list or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setCategories(final List<SyndCategory> categories) {
|
public void setCategories(final List<SyndCategory> categories) {
|
||||||
|
@ -427,15 +452,13 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Returns the entry modules.
|
* Returns the entry modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of ModuleImpl elements with the entry modules, an empty list if none.
|
* @return a list of ModuleImpl elements with the entry modules, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Module> getModules() {
|
public List<Module> getModules() {
|
||||||
if (modules == null) {
|
modules = Lists.createWhenNull(modules);
|
||||||
modules = new ArrayList<Module>();
|
|
||||||
}
|
|
||||||
if (ModuleUtils.getModule(modules, DCModule.URI) == null) {
|
if (ModuleUtils.getModule(modules, DCModule.URI) == null) {
|
||||||
modules.add(new DCModuleImpl());
|
modules.add(new DCModuleImpl());
|
||||||
}
|
}
|
||||||
|
@ -445,10 +468,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Sets the entry modules.
|
* Sets the entry modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param modules the list of ModuleImpl elements with the entry modules to set, an empty list
|
* @param modules the list of ModuleImpl elements with the entry modules to set, an empty list
|
||||||
* or <b>null</b> if none.
|
* or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModules(final List<Module> modules) {
|
public void setModules(final List<Module> modules) {
|
||||||
|
@ -458,7 +481,7 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Returns the module identified by a given URI.
|
* Returns the module identified by a given URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the URI of the ModuleImpl.
|
* @param uri the URI of the ModuleImpl.
|
||||||
* @return The module with the given URI, <b>null</b> if none.
|
* @return The module with the given URI, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
@ -469,9 +492,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Dublin Core module of the feed.
|
* Returns the Dublin Core module of the feed.
|
||||||
*
|
*
|
||||||
* @return the DC module, it's never <b>null</b>
|
* @return the DC module, it's never <b>null</b>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private DCModule getDCModule() {
|
private DCModule getDCModule() {
|
||||||
return (DCModule) getModule(DCModule.URI);
|
return (DCModule) getModule(DCModule.URI);
|
||||||
|
@ -487,48 +510,21 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
COPY_FROM_HELPER.copy(this, obj);
|
COPY_FROM_HELPER.copy(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
|
||||||
|
|
||||||
static {
|
|
||||||
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
|
||||||
basePropInterfaceMap.put("uri", String.class);
|
|
||||||
basePropInterfaceMap.put("title", String.class);
|
|
||||||
basePropInterfaceMap.put("link", String.class);
|
|
||||||
basePropInterfaceMap.put("uri", String.class);
|
|
||||||
basePropInterfaceMap.put("description", SyndContent.class);
|
|
||||||
basePropInterfaceMap.put("contents", SyndContent.class);
|
|
||||||
basePropInterfaceMap.put("enclosures", SyndEnclosure.class);
|
|
||||||
basePropInterfaceMap.put("modules", Module.class);
|
|
||||||
basePropInterfaceMap.put("categories", SyndCategory.class);
|
|
||||||
|
|
||||||
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = new HashMap<Class<? extends CopyFrom>, Class<?>>();
|
|
||||||
basePropClassImplMap.put(SyndContent.class, SyndContentImpl.class);
|
|
||||||
basePropClassImplMap.put(SyndEnclosure.class, SyndEnclosureImpl.class);
|
|
||||||
basePropClassImplMap.put(SyndCategory.class, SyndCategoryImpl.class);
|
|
||||||
basePropClassImplMap.put(DCModule.class, DCModuleImpl.class);
|
|
||||||
basePropClassImplMap.put(SyModule.class, SyModuleImpl.class);
|
|
||||||
|
|
||||||
COPY_FROM_HELPER = new CopyFromHelper(SyndEntry.class, basePropInterfaceMap, basePropClassImplMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the links
|
* Returns the links
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the links.
|
* @return Returns the links.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SyndLink> getLinks() {
|
public List<SyndLink> getLinks() {
|
||||||
if (links == null) {
|
return links = Lists.createWhenNull(links);
|
||||||
links = new ArrayList<SyndLink>();
|
|
||||||
}
|
|
||||||
return links;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the links
|
* Set the links
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param links The links to set.
|
* @param links The links to set.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -539,22 +535,18 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Returns the updatedDate
|
* Returns the updatedDate
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the updatedDate.
|
* @return Returns the updatedDate.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Date getUpdatedDate() {
|
public Date getUpdatedDate() {
|
||||||
if (updatedDate == null) {
|
return Dates.copy(updatedDate);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Date(updatedDate.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the updatedDate
|
* Set the updatedDate
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param updatedDate The updatedDate to set.
|
* @param updatedDate The updatedDate to set.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -564,16 +556,9 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SyndPerson> getAuthors() {
|
public List<SyndPerson> getAuthors() {
|
||||||
if (authors == null) {
|
return authors = Lists.createWhenNull(authors);
|
||||||
authors = new ArrayList<SyndPerson>();
|
|
||||||
}
|
|
||||||
return authors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see com.sun.syndication.feed.synd.SyndEntry#setAuthors(java.util.List)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setAuthors(final List<SyndPerson> authors) {
|
public void setAuthors(final List<SyndPerson> authors) {
|
||||||
this.authors = authors;
|
this.authors = authors;
|
||||||
|
@ -584,26 +569,29 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module creator.
|
* This method is a convenience method, it maps to the Dublin Core module creator.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the entry author, <b>null</b> if none.
|
* @return the entry author, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getAuthor() {
|
public String getAuthor() {
|
||||||
|
|
||||||
String author;
|
String author;
|
||||||
|
|
||||||
// Start out looking for one or more authors in authors. For non-Atom
|
// Start out looking for one or more authors in authors. For non-Atom
|
||||||
// feeds, authors may actually be null.
|
// feeds, authors may actually be null.
|
||||||
if (authors != null && !authors.isEmpty()) {
|
if (Lists.isNotEmpty(authors)) {
|
||||||
author = authors.get(0).getName();
|
author = authors.get(0).getName();
|
||||||
} else {
|
} else {
|
||||||
author = getDCModule().getCreator();
|
author = getDCModule().getCreator();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (author == null) {
|
if (author == null) {
|
||||||
author = "";
|
author = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return author;
|
return author;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -611,28 +599,24 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module creator.
|
* This method is a convenience method, it maps to the Dublin Core module creator.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param author the entry author to set, <b>null</b> if none.
|
* @param author the entry author to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setAuthor(final String author) {
|
public void setAuthor(final String author) {
|
||||||
// Get the DCModule so that we can check to see if "creator" is already
|
// Get the DCModule so that we can check to see if "creator" is already set.
|
||||||
// set.
|
|
||||||
final DCModule dcModule = getDCModule();
|
final DCModule dcModule = getDCModule();
|
||||||
final String currentValue = dcModule.getCreator();
|
final String currentValue = dcModule.getCreator();
|
||||||
|
|
||||||
if (currentValue == null || currentValue.length() == 0) {
|
if (Strings.isEmpty(currentValue)) {
|
||||||
getDCModule().setCreator(author);
|
getDCModule().setCreator(author);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SyndPerson> getContributors() {
|
public List<SyndPerson> getContributors() {
|
||||||
if (contributors == null) {
|
return contributors = Lists.createWhenNull(contributors);
|
||||||
contributors = new ArrayList<SyndPerson>();
|
|
||||||
}
|
|
||||||
return contributors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -653,42 +637,33 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
/**
|
/**
|
||||||
* Returns foreign markup found at channel level.
|
* Returns foreign markup found at channel level.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return list of JDOM nodes containing channel-level foreign markup, an empty list if none.
|
* @return list of JDOM nodes containing channel-level foreign markup, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Element> getForeignMarkup() {
|
public List<Element> getForeignMarkup() {
|
||||||
if (foreignMarkup == null) {
|
return foreignMarkup = Lists.createWhenNull(foreignMarkup);
|
||||||
foreignMarkup = new ArrayList<Element>();
|
|
||||||
}
|
|
||||||
return foreignMarkup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets foreign markup found at channel level.
|
* Sets foreign markup found at channel level.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param foreignMarkup list of JDOM nodes containing channel-level foreign markup, an empty
|
* @param foreignMarkup list of JDOM nodes containing channel-level foreign markup, an empty
|
||||||
* list if none.
|
* list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setForeignMarkup(final List<Element> foreignMarkup) {
|
public void setForeignMarkup(final List<Element> foreignMarkup) {
|
||||||
this.foreignMarkup = foreignMarkup;
|
this.foreignMarkup = foreignMarkup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getComments() {
|
public String getComments() {
|
||||||
return comments;
|
return comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setComments(final String comments) {
|
public void setComments(final String comments) {
|
||||||
this.comments = comments;
|
this.comments = comments;
|
||||||
|
@ -705,11 +680,13 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SyndLink findRelatedLink(final String relation) {
|
public SyndLink findRelatedLink(final String relation) {
|
||||||
for (final SyndLink l : getLinks()) {
|
final List<SyndLink> syndLinks = getLinks();
|
||||||
if (relation.equals(l.getRel())) {
|
for (final SyndLink syndLink : syndLinks) {
|
||||||
return l;
|
if (relation.equals(syndLink.getRel())) {
|
||||||
|
return syndLink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package com.sun.syndication.feed.synd;
|
package com.sun.syndication.feed.synd;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -28,6 +27,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jdom2.Element;
|
import org.jdom2.Element;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.CopyFrom;
|
import com.sun.syndication.feed.CopyFrom;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.impl.CopyFromHelper;
|
import com.sun.syndication.feed.impl.CopyFromHelper;
|
||||||
|
@ -47,13 +47,16 @@ import com.sun.syndication.feed.synd.impl.URINormalizer;
|
||||||
* It handles all RSS versions, Atom 0.3 and Atom 1.0, it normalizes all info, it may lose
|
* It handles all RSS versions, Atom 0.3 and Atom 1.0, it normalizes all info, it may lose
|
||||||
* information.
|
* information.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SyndFeedImpl implements Serializable, SyndFeed {
|
public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
|
|
||||||
private static final long serialVersionUID = -2529165503200548045L;
|
private static final long serialVersionUID = -2529165503200548045L;
|
||||||
|
|
||||||
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
|
|
||||||
private String encoding;
|
private String encoding;
|
||||||
|
@ -92,17 +95,40 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
public static final Set<String> CONVENIENCE_PROPERTIES = Collections.unmodifiableSet(IGNORE_PROPERTIES);
|
public static final Set<String> CONVENIENCE_PROPERTIES = Collections.unmodifiableSet(IGNORE_PROPERTIES);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
IGNORE_PROPERTIES.add("publishedDate");
|
IGNORE_PROPERTIES.add("publishedDate");
|
||||||
IGNORE_PROPERTIES.add("author");
|
IGNORE_PROPERTIES.add("author");
|
||||||
IGNORE_PROPERTIES.add("copyright");
|
IGNORE_PROPERTIES.add("copyright");
|
||||||
IGNORE_PROPERTIES.add("categories");
|
IGNORE_PROPERTIES.add("categories");
|
||||||
IGNORE_PROPERTIES.add("language");
|
IGNORE_PROPERTIES.add("language");
|
||||||
|
|
||||||
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
|
basePropInterfaceMap.put("feedType", String.class);
|
||||||
|
basePropInterfaceMap.put("encoding", String.class);
|
||||||
|
basePropInterfaceMap.put("uri", String.class);
|
||||||
|
basePropInterfaceMap.put("title", String.class);
|
||||||
|
basePropInterfaceMap.put("link", String.class);
|
||||||
|
basePropInterfaceMap.put("description", String.class);
|
||||||
|
basePropInterfaceMap.put("image", SyndImage.class);
|
||||||
|
basePropInterfaceMap.put("entries", SyndEntry.class);
|
||||||
|
basePropInterfaceMap.put("modules", Module.class);
|
||||||
|
basePropInterfaceMap.put("categories", SyndCategory.class);
|
||||||
|
|
||||||
|
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = new HashMap<Class<? extends CopyFrom>, Class<?>>();
|
||||||
|
basePropClassImplMap.put(SyndEntry.class, SyndEntryImpl.class);
|
||||||
|
basePropClassImplMap.put(SyndImage.class, SyndImageImpl.class);
|
||||||
|
basePropClassImplMap.put(SyndCategory.class, SyndCategoryImpl.class);
|
||||||
|
basePropClassImplMap.put(DCModule.class, DCModuleImpl.class);
|
||||||
|
basePropClassImplMap.put(SyModule.class, SyModuleImpl.class);
|
||||||
|
|
||||||
|
COPY_FROM_HELPER = new CopyFromHelper(SyndFeed.class, basePropInterfaceMap, basePropClassImplMap);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the real feed types the SyndFeedImpl supports when converting from and to.
|
* Returns the real feed types the SyndFeedImpl supports when converting from and to.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the real feed type supported.
|
* @return the real feed type supported.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,11 +140,11 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* For implementations extending SyndFeedImpl to be able to use the ObjectBean functionality
|
* For implementations extending SyndFeedImpl to be able to use the ObjectBean functionality
|
||||||
* with extended interfaces.
|
* with extended interfaces.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param beanClass
|
* @param beanClass
|
||||||
* @param convenienceProperties set containing the convenience properties of the SyndEntryImpl
|
* @param convenienceProperties set containing the convenience properties of the SyndEntryImpl
|
||||||
* (the are ignored during cloning, check CloneableBean for details).
|
* (the are ignored during cloning, check CloneableBean for details).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected SyndFeedImpl(final Class<?> beanClass, final Set<String> convenienceProperties) {
|
protected SyndFeedImpl(final Class<?> beanClass, final Set<String> convenienceProperties) {
|
||||||
objBean = new ObjectBean(beanClass, this, convenienceProperties);
|
objBean = new ObjectBean(beanClass, this, convenienceProperties);
|
||||||
|
@ -127,7 +153,7 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public SyndFeedImpl() {
|
public SyndFeedImpl() {
|
||||||
this(null);
|
this(null);
|
||||||
|
@ -137,9 +163,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* Creates a SyndFeedImpl and populates all its properties out of the given RSS Channel or Atom
|
* Creates a SyndFeedImpl and populates all its properties out of the given RSS Channel or Atom
|
||||||
* Feed properties.
|
* Feed properties.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param feed the RSS Channel or the Atom Feed to populate the properties from.
|
* @param feed the RSS Channel or the Atom Feed to populate the properties from.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public SyndFeedImpl(final WireFeed feed) {
|
public SyndFeedImpl(final WireFeed feed) {
|
||||||
this(feed, false);
|
this(feed, false);
|
||||||
|
@ -149,7 +175,7 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* Creates a SyndFeedImpl and populates all its properties out of the given RSS Channel or Atom
|
* Creates a SyndFeedImpl and populates all its properties out of the given RSS Channel or Atom
|
||||||
* Feed properties, while optionally preserving the WireFeed for access via the
|
* Feed properties, while optionally preserving the WireFeed for access via the
|
||||||
* orignalWireFeed() method.
|
* orignalWireFeed() method.
|
||||||
*
|
*
|
||||||
* @param feed
|
* @param feed
|
||||||
* @param preserveWireFeed
|
* @param preserveWireFeed
|
||||||
*/
|
*/
|
||||||
|
@ -175,10 +201,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -189,10 +215,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -212,9 +238,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -224,9 +250,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -238,9 +264,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* <p>
|
* <p>
|
||||||
* The feed type of the created WireFeed is taken from the SyndFeedImpl feedType property.
|
* The feed type of the created WireFeed is taken from the SyndFeedImpl feedType property.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the real feed.
|
* @return the real feed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public WireFeed createWireFeed() {
|
public WireFeed createWireFeed() {
|
||||||
|
@ -250,21 +276,25 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Creates a real feed containing the information of the SyndFeedImpl.
|
* Creates a real feed containing the information of the SyndFeedImpl.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param feedType the feed type for the WireFeed to be created.
|
* @param feedType the feed type for the WireFeed to be created.
|
||||||
* @return the real feed.
|
* @return the real feed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public WireFeed createWireFeed(final String feedType) {
|
public WireFeed createWireFeed(final String feedType) {
|
||||||
|
|
||||||
if (feedType == null) {
|
if (feedType == null) {
|
||||||
throw new IllegalArgumentException("Feed type cannot be null");
|
throw new IllegalArgumentException("Feed type cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
final Converter converter = CONVERTERS.getConverter(feedType);
|
final Converter converter = CONVERTERS.getConverter(feedType);
|
||||||
if (converter == null) {
|
if (converter == null) {
|
||||||
throw new IllegalArgumentException("Invalid feed type [" + feedType + "]");
|
throw new IllegalArgumentException("Invalid feed type [" + feedType + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
return converter.createRealFeed(this);
|
return converter.createRealFeed(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,9 +303,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* Note: The wire feed returned here will NOT contain any modifications done on this SyndFeed
|
* Note: The wire feed returned here will NOT contain any modifications done on this SyndFeed
|
||||||
* since it was created. That is in contrast to the createWireFeed method, which will reflect
|
* since it was created. That is in contrast to the createWireFeed method, which will reflect
|
||||||
* the current state of the SyndFeed
|
* the current state of the SyndFeed
|
||||||
*
|
*
|
||||||
* @return The WireFeed this was created from, or null
|
* @return The WireFeed this was created from, or null
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public WireFeed originalWireFeed() {
|
public WireFeed originalWireFeed() {
|
||||||
|
@ -285,9 +315,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the wire feed type the feed had/will-have when coverted from/to a WireFeed.
|
* Returns the wire feed type the feed had/will-have when coverted from/to a WireFeed.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed type, <b>null</b> if none.
|
* @return the feed type, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getFeedType() {
|
public String getFeedType() {
|
||||||
|
@ -297,9 +327,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the wire feed type the feed will-have when coverted to a WireFeed.
|
* Sets the wire feed type the feed will-have when coverted to a WireFeed.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param feedType the feed type to set, <b>null</b> if none.
|
* @param feedType the feed type to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setFeedType(final String feedType) {
|
public void setFeedType(final String feedType) {
|
||||||
|
@ -309,9 +339,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the charset encoding of a the feed. This is not set by Rome parsers.
|
* Returns the charset encoding of a the feed. This is not set by Rome parsers.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the charset encoding of the feed.
|
* @return the charset encoding of the feed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getEncoding() {
|
public String getEncoding() {
|
||||||
|
@ -321,9 +351,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the charset encoding of a the feed. This is not set by Rome parsers.
|
* Sets the charset encoding of a the feed. This is not set by Rome parsers.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param encoding the charset encoding of the feed.
|
* @param encoding the charset encoding of the feed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setEncoding(final String encoding) {
|
public void setEncoding(final String encoding) {
|
||||||
|
@ -350,9 +380,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* be treated as distinct entities. In the RSS 1.0 case the URI must be a valid RDF URI
|
* be treated as distinct entities. In the RSS 1.0 case the URI must be a valid RDF URI
|
||||||
* reference.
|
* reference.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed URI, <b>null</b> if none.
|
* @return the feed URI, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUri() {
|
public String getUri() {
|
||||||
|
@ -377,9 +407,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* be treated as distinct entities. In the RSS 1.0 case the URI must be a valid RDF URI
|
* be treated as distinct entities. In the RSS 1.0 case the URI must be a valid RDF URI
|
||||||
* reference.
|
* reference.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the feed URI to set, <b>null</b> if none.
|
* @param uri the feed URI to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setUri(final String uri) {
|
public void setUri(final String uri) {
|
||||||
|
@ -389,9 +419,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed title.
|
* Returns the feed title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed title, <b>null</b> if none.
|
* @return the feed title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
|
@ -404,9 +434,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed title.
|
* Sets the feed title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param title the feed title to set, <b>null</b> if none.
|
* @param title the feed title to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setTitle(final String title) {
|
public void setTitle(final String title) {
|
||||||
|
@ -419,9 +449,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed title as a text construct.
|
* Returns the feed title as a text construct.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed title, <b>null</b> if none.
|
* @return the feed title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SyndContent getTitleEx() {
|
public SyndContent getTitleEx() {
|
||||||
|
@ -431,9 +461,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed title as a text construct.
|
* Sets the feed title as a text construct.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param title the feed title to set, <b>null</b> if none.
|
* @param title the feed title to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setTitleEx(final SyndContent title) {
|
public void setTitleEx(final SyndContent title) {
|
||||||
|
@ -453,9 +483,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* be treated as distinct entities. In the RSS 1.0 case the URI must be a valid RDF URI
|
* be treated as distinct entities. In the RSS 1.0 case the URI must be a valid RDF URI
|
||||||
* reference.
|
* reference.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed link, <b>null</b> if none.
|
* @return the feed link, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getLink() {
|
public String getLink() {
|
||||||
|
@ -475,9 +505,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* be treated as distinct entities. In the RSS 1.0 case the URI must be a valid RDF URI
|
* be treated as distinct entities. In the RSS 1.0 case the URI must be a valid RDF URI
|
||||||
* reference.
|
* reference.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param link the feed link to set, <b>null</b> if none.
|
* @param link the feed link to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setLink(final String link) {
|
public void setLink(final String link) {
|
||||||
|
@ -487,9 +517,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed description.
|
* Returns the feed description.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed description, <b>null</b> if none.
|
* @return the feed description, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
@ -502,9 +532,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed description.
|
* Sets the feed description.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param description the feed description to set, <b>null</b> if none.
|
* @param description the feed description to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setDescription(final String description) {
|
public void setDescription(final String description) {
|
||||||
|
@ -517,9 +547,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed description as a text construct.
|
* Returns the feed description as a text construct.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed description, <b>null</b> if none.
|
* @return the feed description, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SyndContent getDescriptionEx() {
|
public SyndContent getDescriptionEx() {
|
||||||
|
@ -529,9 +559,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed description as a text construct.
|
* Sets the feed description as a text construct.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param description the feed description to set, <b>null</b> if none.
|
* @param description the feed description to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setDescriptionEx(final SyndContent description) {
|
public void setDescriptionEx(final SyndContent description) {
|
||||||
|
@ -543,9 +573,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module date.
|
* This method is a convenience method, it maps to the Dublin Core module date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed published date, <b>null</b> if none.
|
* @return the feed published date, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Date getPublishedDate() {
|
public Date getPublishedDate() {
|
||||||
|
@ -557,9 +587,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module date.
|
* This method is a convenience method, it maps to the Dublin Core module date.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param publishedDate the feed published date to set, <b>null</b> if none.
|
* @param publishedDate the feed published date to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setPublishedDate(final Date publishedDate) {
|
public void setPublishedDate(final Date publishedDate) {
|
||||||
|
@ -571,9 +601,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module rights.
|
* This method is a convenience method, it maps to the Dublin Core module rights.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed copyright, <b>null</b> if none.
|
* @return the feed copyright, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getCopyright() {
|
public String getCopyright() {
|
||||||
|
@ -585,9 +615,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module rights.
|
* This method is a convenience method, it maps to the Dublin Core module rights.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param copyright the feed copyright to set, <b>null</b> if none.
|
* @param copyright the feed copyright to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setCopyright(final String copyright) {
|
public void setCopyright(final String copyright) {
|
||||||
|
@ -597,9 +627,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed image.
|
* Returns the feed image.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed image, <b>null</b> if none.
|
* @return the feed image, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SyndImage getImage() {
|
public SyndImage getImage() {
|
||||||
|
@ -609,9 +639,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed image.
|
* Sets the feed image.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param image the feed image to set, <b>null</b> if none.
|
* @param image the feed image to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setImage(final SyndImage image) {
|
public void setImage(final SyndImage image) {
|
||||||
|
@ -623,9 +653,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module subjects.
|
* This method is a convenience method, it maps to the Dublin Core module subjects.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of SyndCategoryImpl elements with the feed categories, an empty list if none.
|
* @return a list of SyndCategoryImpl elements with the feed categories, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SyndCategory> getCategories() {
|
public List<SyndCategory> getCategories() {
|
||||||
|
@ -637,10 +667,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module subjects.
|
* This method is a convenience method, it maps to the Dublin Core module subjects.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param categories the list of SyndCategoryImpl elements with the feed categories to set, an
|
* @param categories the list of SyndCategoryImpl elements with the feed categories to set, an
|
||||||
* empty list or <b>null</b> if none.
|
* empty list or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setCategories(final List<SyndCategory> categories) {
|
public void setCategories(final List<SyndCategory> categories) {
|
||||||
|
@ -650,25 +680,22 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed entries.
|
* Returns the feed entries.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of SyndEntryImpl elements with the feed entries, an empty list if none.
|
* @return a list of SyndEntryImpl elements with the feed entries, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SyndEntry> getEntries() {
|
public List<SyndEntry> getEntries() {
|
||||||
if (entries == null) {
|
return entries = Lists.createWhenNull(entries);
|
||||||
entries = new ArrayList<SyndEntry>();
|
|
||||||
}
|
|
||||||
return entries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the feed entries.
|
* Sets the feed entries.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param entries the list of SyndEntryImpl elements with the feed entries to set, an empty list
|
* @param entries the list of SyndEntryImpl elements with the feed entries to set, an empty list
|
||||||
* or <b>null</b> if none.
|
* or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setEntries(final List<SyndEntry> entries) {
|
public void setEntries(final List<SyndEntry> entries) {
|
||||||
|
@ -680,9 +707,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module language.
|
* This method is a convenience method, it maps to the Dublin Core module language.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed language, <b>null</b> if none.
|
* @return the feed language, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getLanguage() {
|
public String getLanguage() {
|
||||||
|
@ -694,9 +721,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module language.
|
* This method is a convenience method, it maps to the Dublin Core module language.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param language the feed language to set, <b>null</b> if none.
|
* @param language the feed language to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setLanguage(final String language) {
|
public void setLanguage(final String language) {
|
||||||
|
@ -706,15 +733,13 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the feed modules.
|
* Returns the feed modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of ModuleImpl elements with the feed modules, an empty list if none.
|
* @return a list of ModuleImpl elements with the feed modules, an empty list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Module> getModules() {
|
public List<Module> getModules() {
|
||||||
if (modules == null) {
|
modules = Lists.createWhenNull(modules);
|
||||||
modules = new ArrayList<Module>();
|
|
||||||
}
|
|
||||||
if (ModuleUtils.getModule(modules, DCModule.URI) == null) {
|
if (ModuleUtils.getModule(modules, DCModule.URI) == null) {
|
||||||
modules.add(new DCModuleImpl());
|
modules.add(new DCModuleImpl());
|
||||||
}
|
}
|
||||||
|
@ -724,10 +749,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Sets the feed modules.
|
* Sets the feed modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param modules the list of ModuleImpl elements with the feed modules to set, an empty list or
|
* @param modules the list of ModuleImpl elements with the feed modules to set, an empty list or
|
||||||
* <b>null</b> if none.
|
* <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModules(final List<Module> modules) {
|
public void setModules(final List<Module> modules) {
|
||||||
|
@ -737,7 +762,7 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Returns the module identified by a given URI.
|
* Returns the module identified by a given URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the URI of the ModuleImpl.
|
* @param uri the URI of the ModuleImpl.
|
||||||
* @return The module with the given URI, <b>null</b> if none.
|
* @return The module with the given URI, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
@ -748,9 +773,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Dublin Core module of the feed.
|
* Returns the Dublin Core module of the feed.
|
||||||
*
|
*
|
||||||
* @return the DC module, it's never <b>null</b>
|
* @return the DC module, it's never <b>null</b>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private DCModule getDCModule() {
|
private DCModule getDCModule() {
|
||||||
return (DCModule) getModule(DCModule.URI);
|
return (DCModule) getModule(DCModule.URI);
|
||||||
|
@ -766,51 +791,21 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
COPY_FROM_HELPER.copy(this, obj);
|
COPY_FROM_HELPER.copy(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO We need to find out how to refactor this one in a nice reusable way.
|
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
|
||||||
|
|
||||||
static {
|
|
||||||
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
|
||||||
basePropInterfaceMap.put("feedType", String.class);
|
|
||||||
basePropInterfaceMap.put("encoding", String.class);
|
|
||||||
basePropInterfaceMap.put("uri", String.class);
|
|
||||||
basePropInterfaceMap.put("title", String.class);
|
|
||||||
basePropInterfaceMap.put("link", String.class);
|
|
||||||
basePropInterfaceMap.put("description", String.class);
|
|
||||||
basePropInterfaceMap.put("image", SyndImage.class);
|
|
||||||
basePropInterfaceMap.put("entries", SyndEntry.class);
|
|
||||||
basePropInterfaceMap.put("modules", Module.class);
|
|
||||||
basePropInterfaceMap.put("categories", SyndCategory.class);
|
|
||||||
|
|
||||||
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = new HashMap<Class<? extends CopyFrom>, Class<?>>();
|
|
||||||
basePropClassImplMap.put(SyndEntry.class, SyndEntryImpl.class);
|
|
||||||
basePropClassImplMap.put(SyndImage.class, SyndImageImpl.class);
|
|
||||||
basePropClassImplMap.put(SyndCategory.class, SyndCategoryImpl.class);
|
|
||||||
basePropClassImplMap.put(DCModule.class, DCModuleImpl.class);
|
|
||||||
basePropClassImplMap.put(SyModule.class, SyModuleImpl.class);
|
|
||||||
|
|
||||||
COPY_FROM_HELPER = new CopyFromHelper(SyndFeed.class, basePropInterfaceMap, basePropClassImplMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the links
|
* Returns the links
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Returns the links.
|
* @return Returns the links.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SyndLink> getLinks() {
|
public List<SyndLink> getLinks() {
|
||||||
if (links == null) {
|
return links = Lists.createWhenNull(links);
|
||||||
links = new ArrayList<SyndLink>();
|
|
||||||
}
|
|
||||||
return links;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the links
|
* Set the links
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param links The links to set.
|
* @param links The links to set.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -820,10 +815,7 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SyndPerson> getAuthors() {
|
public List<SyndPerson> getAuthors() {
|
||||||
if (authors == null) {
|
return authors = Lists.createWhenNull(authors);
|
||||||
authors = new ArrayList<SyndPerson>();
|
|
||||||
}
|
|
||||||
return authors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -836,9 +828,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module creator.
|
* This method is a convenience method, it maps to the Dublin Core module creator.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the feed author, <b>null</b> if none.
|
* @return the feed author, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getAuthor() {
|
public String getAuthor() {
|
||||||
|
@ -850,9 +842,9 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
* <p>
|
* <p>
|
||||||
* This method is a convenience method, it maps to the Dublin Core module creator.
|
* This method is a convenience method, it maps to the Dublin Core module creator.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param author the feed author to set, <b>null</b> if none.
|
* @param author the feed author to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setAuthor(final String author) {
|
public void setAuthor(final String author) {
|
||||||
|
@ -861,10 +853,7 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SyndPerson> getContributors() {
|
public List<SyndPerson> getContributors() {
|
||||||
if (contributors == null) {
|
return contributors = Lists.createWhenNull(contributors);
|
||||||
contributors = new ArrayList<SyndPerson>();
|
|
||||||
}
|
|
||||||
return contributors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -875,24 +864,21 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
/**
|
/**
|
||||||
* Returns foreign markup found at channel level.
|
* Returns foreign markup found at channel level.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return Opaque object to discourage use
|
* @return Opaque object to discourage use
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Element> getForeignMarkup() {
|
public List<Element> getForeignMarkup() {
|
||||||
if (foreignMarkup == null) {
|
return foreignMarkup = Lists.createWhenNull(foreignMarkup);
|
||||||
foreignMarkup = new ArrayList<Element>();
|
|
||||||
}
|
|
||||||
return foreignMarkup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets foreign markup found at channel level.
|
* Sets foreign markup found at channel level.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param foreignMarkup Opaque object to discourage use
|
* @param foreignMarkup Opaque object to discourage use
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setForeignMarkup(final List<Element> foreignMarkup) {
|
public void setForeignMarkup(final List<Element> foreignMarkup) {
|
||||||
|
@ -904,83 +890,54 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
|
||||||
return preserveWireFeed;
|
return preserveWireFeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getDocs() {
|
public String getDocs() {
|
||||||
return docs;
|
return docs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setDocs(final String docs) {
|
public void setDocs(final String docs) {
|
||||||
this.docs = docs;
|
this.docs = docs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getGenerator() {
|
public String getGenerator() {
|
||||||
return generator;
|
return generator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setGenerator(final String generator) {
|
public void setGenerator(final String generator) {
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getManagingEditor() {
|
public String getManagingEditor() {
|
||||||
return managingEditor;
|
return managingEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setManagingEditor(final String managingEditor) {
|
public void setManagingEditor(final String managingEditor) {
|
||||||
this.managingEditor = managingEditor;
|
this.managingEditor = managingEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getWebMaster() {
|
public String getWebMaster() {
|
||||||
return webMaster;
|
return webMaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setWebMaster(final String webMaster) {
|
public void setWebMaster(final String webMaster) {
|
||||||
this.webMaster = webMaster;
|
this.webMaster = webMaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getStyleSheet() {
|
public String getStyleSheet() {
|
||||||
return styleSheet;
|
return styleSheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setStyleSheet(final String styleSheet) {
|
public void setStyleSheet(final String styleSheet) {
|
||||||
this.styleSheet = styleSheet;
|
this.styleSheet = styleSheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,22 +28,39 @@ import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
/**
|
/**
|
||||||
* Bean for images of SyndFeedImpl feeds.
|
* Bean for images of SyndFeedImpl feeds.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SyndImageImpl implements Serializable, SyndImage {
|
public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 5078981553559513247L;
|
private static final long serialVersionUID = 5078981553559513247L;
|
||||||
|
|
||||||
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
private String url;
|
private String url;
|
||||||
private String link;
|
private String link;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
static {
|
||||||
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
|
basePropInterfaceMap.put("title", String.class);
|
||||||
|
basePropInterfaceMap.put("url", String.class);
|
||||||
|
basePropInterfaceMap.put("link", String.class);
|
||||||
|
basePropInterfaceMap.put("description", String.class);
|
||||||
|
|
||||||
|
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom>, Class<?>> emptyMap();
|
||||||
|
|
||||||
|
COPY_FROM_HELPER = new CopyFromHelper(SyndImage.class, basePropInterfaceMap, basePropClassImplMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. All properties are set to <b>null</b>.
|
* Default constructor. All properties are set to <b>null</b>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public SyndImageImpl() {
|
public SyndImageImpl() {
|
||||||
objBean = new ObjectBean(SyndImage.class, this);
|
objBean = new ObjectBean(SyndImage.class, this);
|
||||||
|
@ -52,10 +69,10 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -66,10 +83,10 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -81,9 +98,9 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -93,9 +110,9 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -105,9 +122,9 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
/**
|
/**
|
||||||
* Returns the image title.
|
* Returns the image title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the image title, <b>null</b> if none.
|
* @return the image title, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
|
@ -117,9 +134,9 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
/**
|
/**
|
||||||
* Sets the image title.
|
* Sets the image title.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param title the image title to set, <b>null</b> if none.
|
* @param title the image title to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setTitle(final String title) {
|
public void setTitle(final String title) {
|
||||||
|
@ -129,9 +146,9 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
/**
|
/**
|
||||||
* Returns the image URL.
|
* Returns the image URL.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the image URL, <b>null</b> if none.
|
* @return the image URL, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
|
@ -141,9 +158,9 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
/**
|
/**
|
||||||
* Sets the image URL.
|
* Sets the image URL.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param url the image URL to set, <b>null</b> if none.
|
* @param url the image URL to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setUrl(final String url) {
|
public void setUrl(final String url) {
|
||||||
|
@ -153,9 +170,9 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
/**
|
/**
|
||||||
* Returns the image link.
|
* Returns the image link.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the image link, <b>null</b> if none.
|
* @return the image link, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getLink() {
|
public String getLink() {
|
||||||
|
@ -165,9 +182,9 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
/**
|
/**
|
||||||
* Sets the image link.
|
* Sets the image link.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param link the image link to set, <b>null</b> if none.
|
* @param link the image link to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setLink(final String link) {
|
public void setLink(final String link) {
|
||||||
|
@ -177,9 +194,9 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
/**
|
/**
|
||||||
* Returns the image description.
|
* Returns the image description.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the image description, <b>null</b> if none.
|
* @return the image description, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
@ -189,9 +206,9 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
/**
|
/**
|
||||||
* Sets the image description.
|
* Sets the image description.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param description the image description to set, <b>null</b> if none.
|
* @param description the image description to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setDescription(final String description) {
|
public void setDescription(final String description) {
|
||||||
|
@ -208,18 +225,4 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
COPY_FROM_HELPER.copy(this, syndImage);
|
COPY_FROM_HELPER.copy(this, syndImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
|
||||||
|
|
||||||
static {
|
|
||||||
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
|
||||||
basePropInterfaceMap.put("title", String.class);
|
|
||||||
basePropInterfaceMap.put("url", String.class);
|
|
||||||
basePropInterfaceMap.put("link", String.class);
|
|
||||||
basePropInterfaceMap.put("description", String.class);
|
|
||||||
|
|
||||||
final Map<Class<? extends CopyFrom>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom>, Class<?>> emptyMap();
|
|
||||||
|
|
||||||
COPY_FROM_HELPER = new CopyFromHelper(SyndImage.class, basePropInterfaceMap, basePropClassImplMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
package com.sun.syndication.feed.synd;
|
package com.sun.syndication.feed.synd;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.impl.ObjectBean;
|
import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
import com.sun.syndication.feed.module.Module;
|
import com.sun.syndication.feed.module.Module;
|
||||||
import com.sun.syndication.feed.module.impl.ModuleUtils;
|
import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
|
@ -28,13 +28,16 @@ import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
/**
|
/**
|
||||||
* Bean for authors and contributors of SyndFeedImpl feeds and entries.
|
* Bean for authors and contributors of SyndFeedImpl feeds and entries.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Dave Johnson
|
* @author Dave Johnson
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SyndPersonImpl implements Serializable, SyndPerson {
|
public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
|
|
||||||
private static final long serialVersionUID = 8523373264589239335L;
|
private static final long serialVersionUID = 8523373264589239335L;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String uri;
|
private String uri;
|
||||||
private String email;
|
private String email;
|
||||||
|
@ -51,10 +54,10 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
/**
|
/**
|
||||||
* Creates a deep 'bean' clone of the object.
|
* Creates a deep 'bean' clone of the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a clone of the object.
|
* @return a clone of the object.
|
||||||
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
|
@ -65,10 +68,10 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
|
||||||
* method.
|
* method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param other he reference object with which to compare.
|
* @param other he reference object with which to compare.
|
||||||
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
* @return <b>true</b> if 'this' object is equal to the 'other' object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
|
@ -83,9 +86,9 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
* <p>
|
* <p>
|
||||||
* It follows the contract defined by the Object hashCode() method.
|
* It follows the contract defined by the Object hashCode() method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the hashcode of the bean object.
|
* @return the hashcode of the bean object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -95,9 +98,9 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
/**
|
/**
|
||||||
* Returns the String representation for the object.
|
* Returns the String representation for the object.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return String representation for the object.
|
* @return String representation for the object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -107,9 +110,9 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
/**
|
/**
|
||||||
* Returns the person name.
|
* Returns the person name.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the person name, <b>null</b> if none.
|
* @return the person name, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -119,9 +122,9 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
/**
|
/**
|
||||||
* Sets the category name.
|
* Sets the category name.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param name the category name to set, <b>null</b> if none.
|
* @param name the category name to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setName(final String name) {
|
public void setName(final String name) {
|
||||||
|
@ -131,9 +134,9 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
/**
|
/**
|
||||||
* Returns the person's e-mail address.
|
* Returns the person's e-mail address.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the person's e-mail address, <b>null</b> if none.
|
* @return the person's e-mail address, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
|
@ -143,9 +146,9 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
/**
|
/**
|
||||||
* Sets the person's e-mail address.
|
* Sets the person's e-mail address.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param email The person's e-mail address to set, <b>null</b> if none.
|
* @param email The person's e-mail address to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setEmail(final String email) {
|
public void setEmail(final String email) {
|
||||||
|
@ -155,9 +158,9 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
/**
|
/**
|
||||||
* Returns the person's URI.
|
* Returns the person's URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return the person's URI, <b>null</b> if none.
|
* @return the person's URI, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUri() {
|
public String getUri() {
|
||||||
|
@ -167,9 +170,9 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
/**
|
/**
|
||||||
* Sets the person's URI.
|
* Sets the person's URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the peron's URI to set, <b>null</b> if none.
|
* @param uri the peron's URI to set, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setUri(final String uri) {
|
public void setUri(final String uri) {
|
||||||
|
@ -179,24 +182,21 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
/**
|
/**
|
||||||
* Returns the person modules.
|
* Returns the person modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return a list of ModuleImpl elements with the person modules, an empty list if none.
|
* @return a list of ModuleImpl elements with the person modules, an empty list if none.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Module> getModules() {
|
public List<Module> getModules() {
|
||||||
if (modules == null) {
|
return modules = Lists.createWhenNull(modules);
|
||||||
modules = new ArrayList<Module>();
|
|
||||||
}
|
|
||||||
return modules;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the person modules.
|
* Sets the person modules.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param modules the list of ModuleImpl elements with the person modules to set, an empty list
|
* @param modules the list of ModuleImpl elements with the person modules to set, an empty list
|
||||||
* or <b>null</b> if none.
|
* or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModules(final List<Module> modules) {
|
public void setModules(final List<Module> modules) {
|
||||||
|
@ -206,7 +206,7 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
/**
|
/**
|
||||||
* Returns the module identified by a given URI.
|
* Returns the module identified by a given URI.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param uri the URI of the ModuleImpl.
|
* @param uri the URI of the ModuleImpl.
|
||||||
* @return The module with the given URI, <b>null</b> if none.
|
* @return The module with the given URI, <b>null</b> if none.
|
||||||
*/
|
*/
|
||||||
|
@ -214,4 +214,5 @@ public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
public Module getModule(final String uri) {
|
public Module getModule(final String uri) {
|
||||||
return ModuleUtils.getModule(getModules(), uri);
|
return ModuleUtils.getModule(getModules(), uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,11 @@ import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jdom2.Element;
|
||||||
|
|
||||||
|
import com.rometools.utils.Alternatives;
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
|
import com.rometools.utils.Strings;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.atom.Content;
|
import com.sun.syndication.feed.atom.Content;
|
||||||
import com.sun.syndication.feed.atom.Entry;
|
import com.sun.syndication.feed.atom.Entry;
|
||||||
|
@ -46,6 +51,7 @@ import com.sun.syndication.feed.synd.SyndPersonImpl;
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class ConverterForAtom03 implements Converter {
|
public class ConverterForAtom03 implements Converter {
|
||||||
|
|
||||||
private final String type;
|
private final String type;
|
||||||
|
|
||||||
public ConverterForAtom03() {
|
public ConverterForAtom03() {
|
||||||
|
@ -63,24 +69,29 @@ public class ConverterForAtom03 implements Converter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
||||||
|
|
||||||
final Feed aFeed = (Feed) feed;
|
final Feed aFeed = (Feed) feed;
|
||||||
|
|
||||||
syndFeed.setModules(ModuleUtils.cloneModules(aFeed.getModules()));
|
syndFeed.setModules(ModuleUtils.cloneModules(aFeed.getModules()));
|
||||||
|
|
||||||
if (!feed.getForeignMarkup().isEmpty()) {
|
final List<Element> foreignMarkup = feed.getForeignMarkup();
|
||||||
syndFeed.setForeignMarkup(feed.getForeignMarkup());
|
if (Lists.isNotEmpty(foreignMarkup)) {
|
||||||
|
syndFeed.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
syndFeed.setEncoding(aFeed.getEncoding());
|
syndFeed.setEncoding(aFeed.getEncoding());
|
||||||
syndFeed.setStyleSheet(aFeed.getStyleSheet());
|
syndFeed.setStyleSheet(aFeed.getStyleSheet());
|
||||||
|
|
||||||
if (aFeed.getLogo() != null) {
|
final String logo = aFeed.getLogo();
|
||||||
|
final String icon = aFeed.getIcon();
|
||||||
|
|
||||||
|
if (logo != null) {
|
||||||
final SyndImage image = new SyndImageImpl();
|
final SyndImage image = new SyndImageImpl();
|
||||||
image.setUrl(aFeed.getLogo());
|
image.setUrl(logo);
|
||||||
syndFeed.setImage(image);
|
syndFeed.setImage(image);
|
||||||
} else if (aFeed.getIcon() != null) {
|
} else if (icon != null) {
|
||||||
final SyndImage image = new SyndImageImpl();
|
final SyndImage image = new SyndImageImpl();
|
||||||
image.setUrl(aFeed.getIcon());
|
image.setUrl(icon);
|
||||||
syndFeed.setImage(image);
|
syndFeed.setImage(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,17 +100,19 @@ public class ConverterForAtom03 implements Converter {
|
||||||
syndFeed.setTitle(aFeed.getTitle());
|
syndFeed.setTitle(aFeed.getTitle());
|
||||||
|
|
||||||
// use first alternate links as THE link
|
// use first alternate links as THE link
|
||||||
if (aFeed.getAlternateLinks() != null && !aFeed.getAlternateLinks().isEmpty()) {
|
final List<Link> alternateLinks = aFeed.getAlternateLinks();
|
||||||
final Link theLink = aFeed.getAlternateLinks().get(0);
|
if (Lists.isNotEmpty(alternateLinks)) {
|
||||||
syndFeed.setLink(theLink.getHrefResolved());
|
final Link link = alternateLinks.get(0);
|
||||||
|
syndFeed.setLink(link.getHrefResolved());
|
||||||
}
|
}
|
||||||
// lump alternate and other links together
|
// lump alternate and other links together
|
||||||
final List<SyndLink> syndLinks = new ArrayList<SyndLink>();
|
final List<SyndLink> syndLinks = new ArrayList<SyndLink>();
|
||||||
if (aFeed.getAlternateLinks() != null && !aFeed.getAlternateLinks().isEmpty()) {
|
if (Lists.isNotEmpty(alternateLinks)) {
|
||||||
syndLinks.addAll(createSyndLinks(aFeed.getAlternateLinks()));
|
syndLinks.addAll(createSyndLinks(alternateLinks));
|
||||||
}
|
}
|
||||||
if (aFeed.getOtherLinks() != null && !aFeed.getOtherLinks().isEmpty()) {
|
final List<Link> otherLinks = aFeed.getOtherLinks();
|
||||||
syndLinks.addAll(createSyndLinks(aFeed.getOtherLinks()));
|
if (Lists.isNotEmpty(otherLinks)) {
|
||||||
|
syndLinks.addAll(createSyndLinks(otherLinks));
|
||||||
}
|
}
|
||||||
syndFeed.setLinks(syndLinks);
|
syndFeed.setLinks(syndLinks);
|
||||||
|
|
||||||
|
@ -109,7 +122,7 @@ public class ConverterForAtom03 implements Converter {
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Entry> aEntries = aFeed.getEntries();
|
final List<Entry> aEntries = aFeed.getEntries();
|
||||||
if (aEntries != null) {
|
if (Lists.isNotEmpty(aEntries)) {
|
||||||
syndFeed.setEntries(createSyndEntries(aEntries, syndFeed.isPreservingWireFeed()));
|
syndFeed.setEntries(createSyndEntries(aEntries, syndFeed.isPreservingWireFeed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +135,7 @@ public class ConverterForAtom03 implements Converter {
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> authors = aFeed.getAuthors();
|
final List<SyndPerson> authors = aFeed.getAuthors();
|
||||||
if (authors != null && !authors.isEmpty()) {
|
if (Lists.isNotEmpty(authors)) {
|
||||||
syndFeed.setAuthors(createSyndPersons(authors));
|
syndFeed.setAuthors(createSyndPersons(authors));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,16 +151,16 @@ public class ConverterForAtom03 implements Converter {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<SyndLink> createSyndLinks(final List<Link> aLinks) {
|
protected List<SyndLink> createSyndLinks(final List<Link> atomLinks) {
|
||||||
final ArrayList<SyndLink> sLinks = new ArrayList<SyndLink>();
|
final ArrayList<SyndLink> syndLinks = new ArrayList<SyndLink>();
|
||||||
for (final Link link2 : aLinks) {
|
for (final Link atomLink : atomLinks) {
|
||||||
final Link link = link2;
|
final Link link = atomLink;
|
||||||
if (!link.getRel().equals("enclosure")) {
|
if (!link.getRel().equals("enclosure")) {
|
||||||
final SyndLink sLink = createSyndLink(link);
|
final SyndLink syndLink = createSyndLink(link);
|
||||||
sLinks.add(sLink);
|
syndLinks.add(syndLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sLinks;
|
return syndLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SyndLink createSyndLink(final Link link) {
|
public SyndLink createSyndLink(final Link link) {
|
||||||
|
@ -161,38 +174,42 @@ public class ConverterForAtom03 implements Converter {
|
||||||
|
|
||||||
protected List<SyndEntry> createSyndEntries(final List<Entry> atomEntries, final boolean preserveWireItems) {
|
protected List<SyndEntry> createSyndEntries(final List<Entry> atomEntries, final boolean preserveWireItems) {
|
||||||
final List<SyndEntry> syndEntries = new ArrayList<SyndEntry>();
|
final List<SyndEntry> syndEntries = new ArrayList<SyndEntry>();
|
||||||
for (int i = 0; i < atomEntries.size(); i++) {
|
for (final Entry atomEntry : atomEntries) {
|
||||||
syndEntries.add(createSyndEntry(atomEntries.get(i), preserveWireItems));
|
syndEntries.add(createSyndEntry(atomEntry, preserveWireItems));
|
||||||
}
|
}
|
||||||
return syndEntries;
|
return syndEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SyndEntry createSyndEntry(final Entry entry, final boolean preserveWireItem) {
|
protected SyndEntry createSyndEntry(final Entry entry, final boolean preserveWireItem) {
|
||||||
|
|
||||||
final SyndEntryImpl syndEntry = new SyndEntryImpl();
|
final SyndEntryImpl syndEntry = new SyndEntryImpl();
|
||||||
|
|
||||||
if (preserveWireItem) {
|
if (preserveWireItem) {
|
||||||
syndEntry.setWireEntry(entry);
|
syndEntry.setWireEntry(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
syndEntry.setModules(ModuleUtils.cloneModules(entry.getModules()));
|
syndEntry.setModules(ModuleUtils.cloneModules(entry.getModules()));
|
||||||
|
|
||||||
if (!entry.getForeignMarkup().isEmpty()) {
|
final List<Element> foreignMarkup = entry.getForeignMarkup();
|
||||||
syndEntry.setForeignMarkup(entry.getForeignMarkup());
|
if (Lists.isNotEmpty(foreignMarkup)) {
|
||||||
|
syndEntry.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
syndEntry.setTitle(entry.getTitle());
|
syndEntry.setTitle(entry.getTitle());
|
||||||
|
|
||||||
// if there is exactly one alternate link, use that as THE link
|
// if there is exactly one alternate link, use that as THE link
|
||||||
if (entry.getAlternateLinks() != null && entry.getAlternateLinks().size() == 1) {
|
final List<Link> alternateLinks = entry.getAlternateLinks();
|
||||||
final Link theLink = entry.getAlternateLinks().get(0);
|
if (Lists.sizeIs(alternateLinks, 1)) {
|
||||||
|
final Link theLink = alternateLinks.get(0);
|
||||||
syndEntry.setLink(theLink.getHrefResolved());
|
syndEntry.setLink(theLink.getHrefResolved());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create synd enclosures from enclosure links
|
// Create synd enclosures from enclosure links
|
||||||
final List<SyndEnclosure> syndEnclosures = new ArrayList<SyndEnclosure>();
|
final List<SyndEnclosure> syndEnclosures = new ArrayList<SyndEnclosure>();
|
||||||
if (entry.getOtherLinks() != null && !entry.getOtherLinks().isEmpty()) {
|
final List<Link> otherLinks = entry.getOtherLinks();
|
||||||
final List<Link> oLinks = entry.getOtherLinks();
|
if (Lists.isNotEmpty(otherLinks)) {
|
||||||
for (final Link link : oLinks) {
|
for (final Link otherLink : otherLinks) {
|
||||||
final Link thisLink = link;
|
final Link thisLink = otherLink;
|
||||||
if ("enclosure".equals(thisLink.getRel())) {
|
if ("enclosure".equals(thisLink.getRel())) {
|
||||||
syndEnclosures.add(createSyndEnclosure(entry, thisLink));
|
syndEnclosures.add(createSyndEnclosure(entry, thisLink));
|
||||||
}
|
}
|
||||||
|
@ -202,63 +219,64 @@ public class ConverterForAtom03 implements Converter {
|
||||||
|
|
||||||
// lump alternate and other links together
|
// lump alternate and other links together
|
||||||
final List<SyndLink> syndLinks = new ArrayList<SyndLink>();
|
final List<SyndLink> syndLinks = new ArrayList<SyndLink>();
|
||||||
if (entry.getAlternateLinks() != null && !entry.getAlternateLinks().isEmpty()) {
|
|
||||||
syndLinks.addAll(createSyndLinks(entry.getAlternateLinks()));
|
if (Lists.isNotEmpty(alternateLinks)) {
|
||||||
|
syndLinks.addAll(createSyndLinks(alternateLinks));
|
||||||
}
|
}
|
||||||
if (entry.getOtherLinks() != null && !entry.getOtherLinks().isEmpty()) {
|
|
||||||
syndLinks.addAll(createSyndLinks(entry.getOtherLinks()));
|
if (Lists.isNotEmpty(otherLinks)) {
|
||||||
|
syndLinks.addAll(createSyndLinks(otherLinks));
|
||||||
}
|
}
|
||||||
|
|
||||||
syndEntry.setLinks(syndLinks);
|
syndEntry.setLinks(syndLinks);
|
||||||
|
|
||||||
final String id = entry.getId();
|
final String id = entry.getId();
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
syndEntry.setUri(entry.getId());
|
syndEntry.setUri(id);
|
||||||
} else {
|
} else {
|
||||||
syndEntry.setUri(syndEntry.getLink());
|
final String link = syndEntry.getLink();
|
||||||
|
syndEntry.setUri(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
Content content = entry.getSummary();
|
Content summary = entry.getSummary();
|
||||||
if (content == null) {
|
if (summary == null) {
|
||||||
final List<Content> contents = entry.getContents();
|
final List<Content> contents = entry.getContents();
|
||||||
if (contents != null && !contents.isEmpty()) {
|
if (Lists.isNotEmpty(contents)) {
|
||||||
content = contents.get(0);
|
summary = contents.get(0);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if (content != null) {
|
|
||||||
final SyndContent sContent = new SyndContentImpl();
|
final SyndContent sContent = new SyndContentImpl();
|
||||||
sContent.setType(content.getType());
|
sContent.setType(summary.getType());
|
||||||
sContent.setValue(content.getValue());
|
sContent.setValue(summary.getValue());
|
||||||
syndEntry.setDescription(sContent);
|
syndEntry.setDescription(sContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Content> contents = entry.getContents();
|
final List<Content> contents = entry.getContents();
|
||||||
if (!contents.isEmpty()) {
|
if (Lists.isNotEmpty(contents)) {
|
||||||
final List<SyndContent> sContents = new ArrayList<SyndContent>();
|
final List<SyndContent> sContents = new ArrayList<SyndContent>();
|
||||||
for (int i = 0; i < contents.size(); i++) {
|
for (final Content content : contents) {
|
||||||
content = contents.get(i);
|
|
||||||
final SyndContent sContent = new SyndContentImpl();
|
final SyndContent sContent = new SyndContentImpl();
|
||||||
sContent.setType(content.getType());
|
sContent.setType(content.getType());
|
||||||
sContent.setValue(content.getValue());
|
sContent.setValue(content.getValue());
|
||||||
sContent.setMode(content.getMode());
|
sContent.setMode(content.getMode());
|
||||||
sContents.add(sContent);
|
sContents.add(sContent);
|
||||||
|
|
||||||
}
|
}
|
||||||
syndEntry.setContents(sContents);
|
syndEntry.setContents(sContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> authors = entry.getAuthors();
|
final List<SyndPerson> authors = entry.getAuthors();
|
||||||
if (authors != null && !authors.isEmpty()) {
|
if (Lists.isNotEmpty(authors)) {
|
||||||
syndEntry.setAuthors(createSyndPersons(authors));
|
syndEntry.setAuthors(createSyndPersons(authors));
|
||||||
final SyndPerson person0 = syndEntry.getAuthors().get(0);
|
final SyndPerson firstPerson = syndEntry.getAuthors().get(0);
|
||||||
syndEntry.setAuthor(person0.getName());
|
syndEntry.setAuthor(firstPerson.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
Date date = entry.getModified();
|
Date date = entry.getModified();
|
||||||
if (date == null) {
|
if (date == null) {
|
||||||
date = entry.getIssued();
|
date = Alternatives.firstNotNull(entry.getIssued(), entry.getCreated());
|
||||||
if (date == null) {
|
|
||||||
date = entry.getCreated();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (date != null) {
|
if (date != null) {
|
||||||
syndEntry.setPublishedDate(date);
|
syndEntry.setPublishedDate(date);
|
||||||
}
|
}
|
||||||
|
@ -286,13 +304,16 @@ public class ConverterForAtom03 implements Converter {
|
||||||
|
|
||||||
final SyndContent sTitle = syndFeed.getTitleEx();
|
final SyndContent sTitle = syndFeed.getTitleEx();
|
||||||
if (sTitle != null) {
|
if (sTitle != null) {
|
||||||
|
|
||||||
final Content title = new Content();
|
final Content title = new Content();
|
||||||
if (sTitle.getType() != null) {
|
final String type = sTitle.getType();
|
||||||
title.setType(sTitle.getType());
|
if (type != null) {
|
||||||
|
title.setType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sTitle.getMode() != null) {
|
final String mode = sTitle.getMode();
|
||||||
title.setMode(sTitle.getMode());
|
if (mode != null) {
|
||||||
|
title.setMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
title.setValue(sTitle.getValue());
|
title.setValue(sTitle.getValue());
|
||||||
|
@ -302,12 +323,14 @@ public class ConverterForAtom03 implements Converter {
|
||||||
// separate SyndEntry's links collection into alternate and other links
|
// separate SyndEntry's links collection into alternate and other links
|
||||||
final List<Link> alternateLinks = new ArrayList<Link>();
|
final List<Link> alternateLinks = new ArrayList<Link>();
|
||||||
final List<Link> otherLinks = new ArrayList<Link>();
|
final List<Link> otherLinks = new ArrayList<Link>();
|
||||||
|
|
||||||
final List<SyndLink> slinks = syndFeed.getLinks();
|
final List<SyndLink> slinks = syndFeed.getLinks();
|
||||||
if (slinks != null) {
|
if (slinks != null) {
|
||||||
for (final SyndLink syndLink2 : slinks) {
|
for (final SyndLink syndLink2 : slinks) {
|
||||||
final SyndLink syndLink = syndLink2;
|
final SyndLink syndLink = syndLink2;
|
||||||
final Link link = createAtomLink(syndLink);
|
final Link link = createAtomLink(syndLink);
|
||||||
if (link.getRel() == null || "".equals(link.getRel().trim()) || "alternate".equals(link.getRel())) {
|
final String rel = link.getRel();
|
||||||
|
if (Strings.isBlank(rel) || "alternate".equals(rel)) {
|
||||||
alternateLinks.add(link);
|
alternateLinks.add(link);
|
||||||
} else {
|
} else {
|
||||||
otherLinks.add(link);
|
otherLinks.add(link);
|
||||||
|
@ -315,10 +338,11 @@ public class ConverterForAtom03 implements Converter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// no alternate link? then use THE link if there is one
|
// no alternate link? then use THE link if there is one
|
||||||
if (alternateLinks.isEmpty() && syndFeed.getLink() != null) {
|
final String sLink = syndFeed.getLink();
|
||||||
|
if (alternateLinks.isEmpty() && sLink != null) {
|
||||||
final Link link = new Link();
|
final Link link = new Link();
|
||||||
link.setRel("alternate");
|
link.setRel("alternate");
|
||||||
link.setHref(syndFeed.getLink());
|
link.setHref(sLink);
|
||||||
alternateLinks.add(link);
|
alternateLinks.add(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +363,7 @@ public class ConverterForAtom03 implements Converter {
|
||||||
aFeed.setLanguage(syndFeed.getLanguage());
|
aFeed.setLanguage(syndFeed.getLanguage());
|
||||||
|
|
||||||
final List<SyndPerson> authors = syndFeed.getAuthors();
|
final List<SyndPerson> authors = syndFeed.getAuthors();
|
||||||
if (authors != null && !authors.isEmpty()) {
|
if (Lists.isNotEmpty(authors)) {
|
||||||
aFeed.setAuthors(createAtomPersons(authors));
|
aFeed.setAuthors(createAtomPersons(authors));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,8 +408,8 @@ public class ConverterForAtom03 implements Converter {
|
||||||
|
|
||||||
protected List<Entry> createAtomEntries(final List<SyndEntry> syndEntries) {
|
protected List<Entry> createAtomEntries(final List<SyndEntry> syndEntries) {
|
||||||
final List<Entry> atomEntries = new ArrayList<Entry>();
|
final List<Entry> atomEntries = new ArrayList<Entry>();
|
||||||
for (int i = 0; i < syndEntries.size(); i++) {
|
for (final SyndEntry syndEntry : syndEntries) {
|
||||||
atomEntries.add(createAtomEntry(syndEntries.get(i)));
|
atomEntries.add(createAtomEntry(syndEntry));
|
||||||
}
|
}
|
||||||
return atomEntries;
|
return atomEntries;
|
||||||
}
|
}
|
||||||
|
@ -399,12 +423,14 @@ public class ConverterForAtom03 implements Converter {
|
||||||
final SyndContent sTitle = sEntry.getTitleEx();
|
final SyndContent sTitle = sEntry.getTitleEx();
|
||||||
if (sTitle != null) {
|
if (sTitle != null) {
|
||||||
final Content title = new Content();
|
final Content title = new Content();
|
||||||
if (sTitle.getType() != null) {
|
final String type = sTitle.getType();
|
||||||
title.setType(sTitle.getType());
|
if (type != null) {
|
||||||
|
title.setType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sTitle.getMode() != null) {
|
final String mode = sTitle.getMode();
|
||||||
title.setMode(sTitle.getMode());
|
if (mode != null) {
|
||||||
|
title.setMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
title.setValue(sTitle.getValue());
|
title.setValue(sTitle.getValue());
|
||||||
|
@ -414,12 +440,13 @@ public class ConverterForAtom03 implements Converter {
|
||||||
// separate SyndEntry's links collection into alternate and other links
|
// separate SyndEntry's links collection into alternate and other links
|
||||||
final List<Link> alternateLinks = new ArrayList<Link>();
|
final List<Link> alternateLinks = new ArrayList<Link>();
|
||||||
final List<Link> otherLinks = new ArrayList<Link>();
|
final List<Link> otherLinks = new ArrayList<Link>();
|
||||||
final List<SyndLink> slinks = sEntry.getLinks();
|
final List<SyndLink> syndLinks = sEntry.getLinks();
|
||||||
if (slinks != null) {
|
|
||||||
for (final SyndLink syndLink2 : slinks) {
|
if (syndLinks != null) {
|
||||||
final SyndLink syndLink = syndLink2;
|
for (final SyndLink syndLink : syndLinks) {
|
||||||
final Link link = createAtomLink(syndLink);
|
final Link link = createAtomLink(syndLink);
|
||||||
if (link.getRel() == null || "".equals(link.getRel().trim()) || "alternate".equals(link.getRel())) {
|
final String rel = link.getRel();
|
||||||
|
if (Strings.isBlank(rel) || "alternate".equals(rel)) {
|
||||||
alternateLinks.add(link);
|
alternateLinks.add(link);
|
||||||
} else {
|
} else {
|
||||||
otherLinks.add(link);
|
otherLinks.add(link);
|
||||||
|
@ -427,17 +454,17 @@ public class ConverterForAtom03 implements Converter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// no alternate link? then use THE link if there is one
|
// no alternate link? then use THE link if there is one
|
||||||
if (alternateLinks.isEmpty() && sEntry.getLink() != null) {
|
final String sLink = sEntry.getLink();
|
||||||
|
if (alternateLinks.isEmpty() && sLink != null) {
|
||||||
final Link link = new Link();
|
final Link link = new Link();
|
||||||
link.setRel("alternate");
|
link.setRel("alternate");
|
||||||
link.setHref(sEntry.getLink());
|
link.setHref(sLink);
|
||||||
alternateLinks.add(link);
|
alternateLinks.add(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndEnclosure> sEnclosures = sEntry.getEnclosures();
|
final List<SyndEnclosure> sEnclosures = sEntry.getEnclosures();
|
||||||
if (sEnclosures != null) {
|
if (sEnclosures != null) {
|
||||||
for (final SyndEnclosure syndEnclosure2 : sEnclosures) {
|
for (final SyndEnclosure syndEnclosure : sEnclosures) {
|
||||||
final SyndEnclosure syndEnclosure = syndEnclosure2;
|
|
||||||
final Link link = createAtomEnclosure(syndEnclosure);
|
final Link link = createAtomEnclosure(syndEnclosure);
|
||||||
otherLinks.add(link);
|
otherLinks.add(link);
|
||||||
}
|
}
|
||||||
|
@ -450,7 +477,7 @@ public class ConverterForAtom03 implements Converter {
|
||||||
aEntry.setOtherLinks(otherLinks);
|
aEntry.setOtherLinks(otherLinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
SyndContent sContent = sEntry.getDescription();
|
final SyndContent sContent = sEntry.getDescription();
|
||||||
if (sContent != null) {
|
if (sContent != null) {
|
||||||
final Content content = new Content();
|
final Content content = new Content();
|
||||||
content.setType(sContent.getType());
|
content.setType(sContent.getType());
|
||||||
|
@ -462,24 +489,23 @@ public class ConverterForAtom03 implements Converter {
|
||||||
final List<SyndContent> contents = sEntry.getContents();
|
final List<SyndContent> contents = sEntry.getContents();
|
||||||
if (!contents.isEmpty()) {
|
if (!contents.isEmpty()) {
|
||||||
final List<Content> aContents = new ArrayList<Content>();
|
final List<Content> aContents = new ArrayList<Content>();
|
||||||
for (int i = 0; i < contents.size(); i++) {
|
for (final SyndContent syndContent : contents) {
|
||||||
sContent = contents.get(i);
|
|
||||||
final Content content = new Content();
|
final Content content = new Content();
|
||||||
content.setType(sContent.getType());
|
content.setType(syndContent.getType());
|
||||||
content.setValue(sContent.getValue());
|
content.setValue(syndContent.getValue());
|
||||||
content.setMode(sContent.getMode());
|
content.setMode(syndContent.getMode());
|
||||||
aContents.add(content);
|
aContents.add(content);
|
||||||
|
|
||||||
}
|
}
|
||||||
aEntry.setContents(aContents);
|
aEntry.setContents(aContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> sAuthors = sEntry.getAuthors();
|
final List<SyndPerson> sAuthors = sEntry.getAuthors();
|
||||||
if (sAuthors != null && !sAuthors.isEmpty()) {
|
final String author = sEntry.getAuthor();
|
||||||
|
if (Lists.isNotEmpty(sAuthors)) {
|
||||||
aEntry.setAuthors(createAtomPersons(sAuthors));
|
aEntry.setAuthors(createAtomPersons(sAuthors));
|
||||||
} else if (sEntry.getAuthor() != null) {
|
} else if (author != null) {
|
||||||
final Person person = new Person();
|
final Person person = new Person();
|
||||||
person.setName(sEntry.getAuthor());
|
person.setName(author);
|
||||||
final List<SyndPerson> authors = new ArrayList<SyndPerson>();
|
final List<SyndPerson> authors = new ArrayList<SyndPerson>();
|
||||||
authors.add(person);
|
authors.add(person);
|
||||||
aEntry.setAuthors(authors);
|
aEntry.setAuthors(authors);
|
||||||
|
|
|
@ -20,6 +20,10 @@ import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jdom2.Element;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
|
import com.rometools.utils.Strings;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.atom.Category;
|
import com.sun.syndication.feed.atom.Category;
|
||||||
import com.sun.syndication.feed.atom.Content;
|
import com.sun.syndication.feed.atom.Content;
|
||||||
|
@ -48,6 +52,7 @@ import com.sun.syndication.feed.synd.SyndPerson;
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class ConverterForAtom10 implements Converter {
|
public class ConverterForAtom10 implements Converter {
|
||||||
|
|
||||||
private final String type;
|
private final String type;
|
||||||
|
|
||||||
public ConverterForAtom10() {
|
public ConverterForAtom10() {
|
||||||
|
@ -65,24 +70,29 @@ public class ConverterForAtom10 implements Converter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
||||||
|
|
||||||
final Feed aFeed = (Feed) feed;
|
final Feed aFeed = (Feed) feed;
|
||||||
|
|
||||||
syndFeed.setModules(ModuleUtils.cloneModules(aFeed.getModules()));
|
syndFeed.setModules(ModuleUtils.cloneModules(aFeed.getModules()));
|
||||||
|
|
||||||
if (!feed.getForeignMarkup().isEmpty()) {
|
final List<Element> foreignMarkup = feed.getForeignMarkup();
|
||||||
syndFeed.setForeignMarkup(feed.getForeignMarkup());
|
if (!foreignMarkup.isEmpty()) {
|
||||||
|
syndFeed.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
syndFeed.setEncoding(aFeed.getEncoding());
|
syndFeed.setEncoding(aFeed.getEncoding());
|
||||||
syndFeed.setStyleSheet(aFeed.getStyleSheet());
|
syndFeed.setStyleSheet(aFeed.getStyleSheet());
|
||||||
|
|
||||||
if (aFeed.getLogo() != null) {
|
final String logo = aFeed.getLogo();
|
||||||
|
final String icon = aFeed.getIcon();
|
||||||
|
|
||||||
|
if (logo != null) {
|
||||||
final SyndImage image = new SyndImageImpl();
|
final SyndImage image = new SyndImageImpl();
|
||||||
image.setUrl(aFeed.getLogo());
|
image.setUrl(logo);
|
||||||
syndFeed.setImage(image);
|
syndFeed.setImage(image);
|
||||||
} else if (aFeed.getIcon() != null) {
|
} else if (icon != null) {
|
||||||
final SyndImage image = new SyndImageImpl();
|
final SyndImage image = new SyndImageImpl();
|
||||||
image.setUrl(aFeed.getIcon());
|
image.setUrl(icon);
|
||||||
syndFeed.setImage(image);
|
syndFeed.setImage(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,18 +115,24 @@ public class ConverterForAtom10 implements Converter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// use first alternate links as THE link
|
// use first alternate links as THE link
|
||||||
if (aFeed.getAlternateLinks() != null && !aFeed.getAlternateLinks().isEmpty()) {
|
final List<Link> alternateLinks = aFeed.getAlternateLinks();
|
||||||
final Link theLink = aFeed.getAlternateLinks().get(0);
|
if (Lists.isNotEmpty(alternateLinks)) {
|
||||||
|
final Link theLink = alternateLinks.get(0);
|
||||||
syndFeed.setLink(theLink.getHrefResolved());
|
syndFeed.setLink(theLink.getHrefResolved());
|
||||||
}
|
}
|
||||||
|
|
||||||
// lump alternate and other links together
|
// lump alternate and other links together
|
||||||
final List<SyndLink> syndLinks = new ArrayList<SyndLink>();
|
final List<SyndLink> syndLinks = new ArrayList<SyndLink>();
|
||||||
if (aFeed.getAlternateLinks() != null && !aFeed.getAlternateLinks().isEmpty()) {
|
|
||||||
syndLinks.addAll(createSyndLinks(aFeed.getAlternateLinks()));
|
if (Lists.isNotEmpty(alternateLinks)) {
|
||||||
|
syndLinks.addAll(createSyndLinks(alternateLinks));
|
||||||
}
|
}
|
||||||
if (aFeed.getOtherLinks() != null && !aFeed.getOtherLinks().isEmpty()) {
|
|
||||||
syndLinks.addAll(createSyndLinks(aFeed.getOtherLinks()));
|
final List<Link> otherLinks = aFeed.getOtherLinks();
|
||||||
|
if (Lists.isNotEmpty(otherLinks)) {
|
||||||
|
syndLinks.addAll(createSyndLinks(otherLinks));
|
||||||
}
|
}
|
||||||
|
|
||||||
syndFeed.setLinks(syndLinks);
|
syndFeed.setLinks(syndLinks);
|
||||||
|
|
||||||
final List<Entry> aEntries = aFeed.getEntries();
|
final List<Entry> aEntries = aFeed.getEntries();
|
||||||
|
@ -128,12 +144,12 @@ public class ConverterForAtom10 implements Converter {
|
||||||
// over DC equivalent info.
|
// over DC equivalent info.
|
||||||
|
|
||||||
final List<SyndPerson> authors = aFeed.getAuthors();
|
final List<SyndPerson> authors = aFeed.getAuthors();
|
||||||
if (authors != null && !authors.isEmpty()) {
|
if (Lists.isNotEmpty(authors)) {
|
||||||
syndFeed.setAuthors(ConverterForAtom03.createSyndPersons(authors));
|
syndFeed.setAuthors(ConverterForAtom03.createSyndPersons(authors));
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> contributors = aFeed.getContributors();
|
final List<SyndPerson> contributors = aFeed.getContributors();
|
||||||
if (contributors != null && !contributors.isEmpty()) {
|
if (Lists.isNotEmpty(contributors)) {
|
||||||
syndFeed.setContributors(ConverterForAtom03.createSyndPersons(contributors));
|
syndFeed.setContributors(ConverterForAtom03.createSyndPersons(contributors));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,20 +165,19 @@ public class ConverterForAtom10 implements Converter {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<SyndLink> createSyndLinks(final List<Link> aLinks) {
|
protected List<SyndLink> createSyndLinks(final List<Link> atomLinks) {
|
||||||
final ArrayList<SyndLink> sLinks = new ArrayList<SyndLink>();
|
final ArrayList<SyndLink> syndLinks = new ArrayList<SyndLink>();
|
||||||
for (final Link link2 : aLinks) {
|
for (final Link atomLink : atomLinks) {
|
||||||
final Link link = link2;
|
final SyndLink syndLink = createSyndLink(atomLink);
|
||||||
final SyndLink sLink = createSyndLink(link);
|
syndLinks.add(syndLink);
|
||||||
sLinks.add(sLink);
|
|
||||||
}
|
}
|
||||||
return sLinks;
|
return syndLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<SyndEntry> createSyndEntries(final Feed feed, final List<Entry> atomEntries, final boolean preserveWireItems) {
|
protected List<SyndEntry> createSyndEntries(final Feed feed, final List<Entry> atomEntries, final boolean preserveWireItems) {
|
||||||
final List<SyndEntry> syndEntries = new ArrayList<SyndEntry>();
|
final List<SyndEntry> syndEntries = new ArrayList<SyndEntry>();
|
||||||
for (int i = 0; i < atomEntries.size(); i++) {
|
for (final Entry atomEntry : atomEntries) {
|
||||||
syndEntries.add(createSyndEntry(feed, atomEntries.get(i), preserveWireItems));
|
syndEntries.add(createSyndEntry(feed, atomEntry, preserveWireItems));
|
||||||
}
|
}
|
||||||
return syndEntries;
|
return syndEntries;
|
||||||
}
|
}
|
||||||
|
@ -174,8 +189,9 @@ public class ConverterForAtom10 implements Converter {
|
||||||
}
|
}
|
||||||
syndEntry.setModules(ModuleUtils.cloneModules(entry.getModules()));
|
syndEntry.setModules(ModuleUtils.cloneModules(entry.getModules()));
|
||||||
|
|
||||||
if (!entry.getForeignMarkup().isEmpty()) {
|
final List<Element> foreignMarkup = entry.getForeignMarkup();
|
||||||
syndEntry.setForeignMarkup(entry.getForeignMarkup());
|
if (!foreignMarkup.isEmpty()) {
|
||||||
|
syndEntry.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Content eTitle = entry.getTitleEx();
|
final Content eTitle = entry.getTitleEx();
|
||||||
|
@ -189,24 +205,23 @@ public class ConverterForAtom10 implements Converter {
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Content> contents = entry.getContents();
|
final List<Content> contents = entry.getContents();
|
||||||
if (contents != null && !contents.isEmpty()) {
|
if (Lists.isNotEmpty(contents)) {
|
||||||
final List<SyndContent> sContents = new ArrayList<SyndContent>();
|
final List<SyndContent> sContents = new ArrayList<SyndContent>();
|
||||||
for (final Content content2 : contents) {
|
for (final Content content : contents) {
|
||||||
final Content content = content2;
|
|
||||||
sContents.add(createSyndContent(content));
|
sContents.add(createSyndContent(content));
|
||||||
}
|
}
|
||||||
syndEntry.setContents(sContents);
|
syndEntry.setContents(sContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> authors = entry.getAuthors();
|
final List<SyndPerson> authors = entry.getAuthors();
|
||||||
if (authors != null && !authors.isEmpty()) {
|
if (Lists.isNotEmpty(authors)) {
|
||||||
syndEntry.setAuthors(ConverterForAtom03.createSyndPersons(authors));
|
syndEntry.setAuthors(ConverterForAtom03.createSyndPersons(authors));
|
||||||
final SyndPerson person0 = syndEntry.getAuthors().get(0);
|
final SyndPerson person0 = syndEntry.getAuthors().get(0);
|
||||||
syndEntry.setAuthor(person0.getName());
|
syndEntry.setAuthor(person0.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> contributors = entry.getContributors();
|
final List<SyndPerson> contributors = entry.getContributors();
|
||||||
if (contributors != null && !contributors.isEmpty()) {
|
if (Lists.isNotEmpty(contributors)) {
|
||||||
syndEntry.setContributors(ConverterForAtom03.createSyndPersons(contributors));
|
syndEntry.setContributors(ConverterForAtom03.createSyndPersons(contributors));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,10 +239,9 @@ public class ConverterForAtom10 implements Converter {
|
||||||
if (categories != null) {
|
if (categories != null) {
|
||||||
final List<SyndCategory> syndCategories = new ArrayList<SyndCategory>();
|
final List<SyndCategory> syndCategories = new ArrayList<SyndCategory>();
|
||||||
for (final Category category : categories) {
|
for (final Category category : categories) {
|
||||||
final Category c = category;
|
|
||||||
final SyndCategory syndCategory = new SyndCategoryImpl();
|
final SyndCategory syndCategory = new SyndCategoryImpl();
|
||||||
syndCategory.setName(c.getTerm());
|
syndCategory.setName(category.getTerm());
|
||||||
syndCategory.setTaxonomyUri(c.getSchemeResolved());
|
syndCategory.setTaxonomyUri(category.getSchemeResolved());
|
||||||
// TODO: categories MAY have labels
|
// TODO: categories MAY have labels
|
||||||
// syndCategory.setLabel(c.getLabel());
|
// syndCategory.setLabel(c.getLabel());
|
||||||
syndCategories.add(syndCategory);
|
syndCategories.add(syndCategory);
|
||||||
|
@ -236,19 +250,20 @@ public class ConverterForAtom10 implements Converter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// use first alternate link as THE link
|
// use first alternate link as THE link
|
||||||
if (entry.getAlternateLinks() != null && !entry.getAlternateLinks().isEmpty()) {
|
final List<Link> alternateLinks = entry.getAlternateLinks();
|
||||||
final Link theLink = entry.getAlternateLinks().get(0);
|
if (Lists.isNotEmpty(alternateLinks)) {
|
||||||
|
final Link theLink = alternateLinks.get(0);
|
||||||
syndEntry.setLink(theLink.getHrefResolved());
|
syndEntry.setLink(theLink.getHrefResolved());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create synd enclosures from enclosure links
|
// Create synd enclosures from enclosure links
|
||||||
final List<SyndEnclosure> syndEnclosures = new ArrayList<SyndEnclosure>();
|
final List<SyndEnclosure> syndEnclosures = new ArrayList<SyndEnclosure>();
|
||||||
if (entry.getOtherLinks() != null && !entry.getOtherLinks().isEmpty()) {
|
final List<Link> otherLinks = entry.getOtherLinks();
|
||||||
final List<Link> oLinks = entry.getOtherLinks();
|
if (Lists.isNotEmpty(otherLinks)) {
|
||||||
|
final List<Link> oLinks = otherLinks;
|
||||||
for (final Link link : oLinks) {
|
for (final Link link : oLinks) {
|
||||||
final Link thisLink = link;
|
if ("enclosure".equals(link.getRel())) {
|
||||||
if ("enclosure".equals(thisLink.getRel())) {
|
syndEnclosures.add(createSyndEnclosure(feed, entry, link));
|
||||||
syndEnclosures.add(createSyndEnclosure(feed, entry, thisLink));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,11 +271,11 @@ public class ConverterForAtom10 implements Converter {
|
||||||
|
|
||||||
// lump alternate and other links together
|
// lump alternate and other links together
|
||||||
final List<SyndLink> syndLinks = new ArrayList<SyndLink>();
|
final List<SyndLink> syndLinks = new ArrayList<SyndLink>();
|
||||||
if (entry.getAlternateLinks() != null && !entry.getAlternateLinks().isEmpty()) {
|
if (Lists.isNotEmpty(alternateLinks)) {
|
||||||
syndLinks.addAll(createSyndLinks(entry.getAlternateLinks()));
|
syndLinks.addAll(createSyndLinks(alternateLinks));
|
||||||
}
|
}
|
||||||
if (entry.getOtherLinks() != null && !entry.getOtherLinks().isEmpty()) {
|
if (Lists.isNotEmpty(otherLinks)) {
|
||||||
syndLinks.addAll(createSyndLinks(entry.getOtherLinks()));
|
syndLinks.addAll(createSyndLinks(otherLinks));
|
||||||
}
|
}
|
||||||
syndEntry.setLinks(syndLinks);
|
syndEntry.setLinks(syndLinks);
|
||||||
|
|
||||||
|
@ -352,10 +367,10 @@ public class ConverterForAtom10 implements Converter {
|
||||||
final List<Link> otherLinks = new ArrayList<Link>();
|
final List<Link> otherLinks = new ArrayList<Link>();
|
||||||
final List<SyndLink> slinks = syndFeed.getLinks();
|
final List<SyndLink> slinks = syndFeed.getLinks();
|
||||||
if (slinks != null) {
|
if (slinks != null) {
|
||||||
for (final SyndLink syndLink2 : slinks) {
|
for (final SyndLink syndLink : slinks) {
|
||||||
final SyndLink syndLink = syndLink2;
|
|
||||||
final Link link = createAtomLink(syndLink);
|
final Link link = createAtomLink(syndLink);
|
||||||
if (link.getRel() == null || "".equals(link.getRel().trim()) || "alternate".equals(link.getRel())) {
|
final String rel = link.getRel();
|
||||||
|
if (Strings.isBlank(rel) || "alternate".equals(rel)) {
|
||||||
alternateLinks.add(link);
|
alternateLinks.add(link);
|
||||||
} else {
|
} else {
|
||||||
otherLinks.add(link);
|
otherLinks.add(link);
|
||||||
|
@ -379,8 +394,7 @@ public class ConverterForAtom10 implements Converter {
|
||||||
final List<SyndCategory> sCats = syndFeed.getCategories();
|
final List<SyndCategory> sCats = syndFeed.getCategories();
|
||||||
final List<Category> aCats = new ArrayList<Category>();
|
final List<Category> aCats = new ArrayList<Category>();
|
||||||
if (sCats != null) {
|
if (sCats != null) {
|
||||||
for (final SyndCategory syndCategory : sCats) {
|
for (final SyndCategory sCat : sCats) {
|
||||||
final SyndCategory sCat = syndCategory;
|
|
||||||
final Category aCat = new Category();
|
final Category aCat = new Category();
|
||||||
aCat.setTerm(sCat.getName());
|
aCat.setTerm(sCat.getName());
|
||||||
// TODO: aCat.setLabel(sCat.getLabel());
|
// TODO: aCat.setLabel(sCat.getLabel());
|
||||||
|
@ -393,12 +407,12 @@ public class ConverterForAtom10 implements Converter {
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> authors = syndFeed.getAuthors();
|
final List<SyndPerson> authors = syndFeed.getAuthors();
|
||||||
if (authors != null && !authors.isEmpty()) {
|
if (Lists.isNotEmpty(authors)) {
|
||||||
aFeed.setAuthors(ConverterForAtom03.createAtomPersons(authors));
|
aFeed.setAuthors(ConverterForAtom03.createAtomPersons(authors));
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> contributors = syndFeed.getContributors();
|
final List<SyndPerson> contributors = syndFeed.getContributors();
|
||||||
if (contributors != null && !contributors.isEmpty()) {
|
if (Lists.isNotEmpty(contributors)) {
|
||||||
aFeed.setContributors(ConverterForAtom03.createAtomPersons(contributors));
|
aFeed.setContributors(ConverterForAtom03.createAtomPersons(contributors));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,10 +425,13 @@ public class ConverterForAtom10 implements Converter {
|
||||||
aFeed.setEntries(createAtomEntries(sEntries));
|
aFeed.setEntries(createAtomEntries(sEntries));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!syndFeed.getForeignMarkup().isEmpty()) {
|
final List<Element> foreignMarkup = syndFeed.getForeignMarkup();
|
||||||
aFeed.setForeignMarkup(syndFeed.getForeignMarkup());
|
if (!foreignMarkup.isEmpty()) {
|
||||||
|
aFeed.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
return aFeed;
|
return aFeed;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SyndContent createSyndContent(final Content content) {
|
protected SyndContent createSyndContent(final Content content) {
|
||||||
|
@ -426,8 +443,8 @@ public class ConverterForAtom10 implements Converter {
|
||||||
|
|
||||||
protected List<Entry> createAtomEntries(final List<SyndEntry> syndEntries) {
|
protected List<Entry> createAtomEntries(final List<SyndEntry> syndEntries) {
|
||||||
final List<Entry> atomEntries = new ArrayList<Entry>();
|
final List<Entry> atomEntries = new ArrayList<Entry>();
|
||||||
for (int i = 0; i < syndEntries.size(); i++) {
|
for (final SyndEntry syndEntry : syndEntries) {
|
||||||
atomEntries.add(createAtomEntry(syndEntries.get(i)));
|
atomEntries.add(createAtomEntry(syndEntry));
|
||||||
}
|
}
|
||||||
return atomEntries;
|
return atomEntries;
|
||||||
}
|
}
|
||||||
|
@ -441,14 +458,16 @@ public class ConverterForAtom10 implements Converter {
|
||||||
|
|
||||||
protected List<Content> createAtomContents(final List<SyndContent> syndContents) {
|
protected List<Content> createAtomContents(final List<SyndContent> syndContents) {
|
||||||
final List<Content> atomContents = new ArrayList<Content>();
|
final List<Content> atomContents = new ArrayList<Content>();
|
||||||
for (int i = 0; i < syndContents.size(); i++) {
|
for (final SyndContent syndContent : syndContents) {
|
||||||
atomContents.add(createAtomContent(syndContents.get(i)));
|
atomContents.add(createAtomContent(syndContent));
|
||||||
}
|
}
|
||||||
return atomContents;
|
return atomContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Entry createAtomEntry(final SyndEntry sEntry) {
|
protected Entry createAtomEntry(final SyndEntry sEntry) {
|
||||||
|
|
||||||
final Entry aEntry = new Entry();
|
final Entry aEntry = new Entry();
|
||||||
|
|
||||||
aEntry.setModules(ModuleUtils.cloneModules(sEntry.getModules()));
|
aEntry.setModules(ModuleUtils.cloneModules(sEntry.getModules()));
|
||||||
|
|
||||||
aEntry.setId(sEntry.getUri());
|
aEntry.setId(sEntry.getUri());
|
||||||
|
@ -472,26 +491,31 @@ public class ConverterForAtom10 implements Converter {
|
||||||
// separate SyndEntry's links collection into alternate and other links
|
// separate SyndEntry's links collection into alternate and other links
|
||||||
final List<Link> alternateLinks = new ArrayList<Link>();
|
final List<Link> alternateLinks = new ArrayList<Link>();
|
||||||
final List<Link> otherLinks = new ArrayList<Link>();
|
final List<Link> otherLinks = new ArrayList<Link>();
|
||||||
|
boolean linkRelEnclosureExists = false;
|
||||||
|
|
||||||
final List<SyndLink> slinks = sEntry.getLinks();
|
final List<SyndLink> slinks = sEntry.getLinks();
|
||||||
final List<SyndEnclosure> enclosures = sEntry.getEnclosures();
|
final List<SyndEnclosure> enclosures = sEntry.getEnclosures();
|
||||||
boolean linkRelEnclosureExists = false;
|
|
||||||
if (slinks != null) {
|
if (slinks != null) {
|
||||||
for (final SyndLink syndLink2 : slinks) {
|
for (final SyndLink syndLink : slinks) {
|
||||||
final SyndLink syndLink = syndLink2;
|
|
||||||
final Link link = createAtomLink(syndLink);
|
final Link link = createAtomLink(syndLink);
|
||||||
// Set this flag if there's a link of rel = enclosure so that
|
// Set this flag if there's a link of rel = enclosure so that
|
||||||
// enclosures won't be duplicated when pulled from
|
// enclosures won't be duplicated when pulled from
|
||||||
// SyndEntry.getEnclosures()
|
// SyndEntry.getEnclosures()
|
||||||
if (syndLink.getRel() != null && "enclosure".equals(syndLink.getRel())) {
|
final String sRel = syndLink.getRel();
|
||||||
|
if (sRel != null && "enclosure".equals(sRel)) {
|
||||||
linkRelEnclosureExists = true;
|
linkRelEnclosureExists = true;
|
||||||
}
|
}
|
||||||
if (link.getRel() == null || "".equals(link.getRel().trim()) || "alternate".equals(syndLink.getRel())) {
|
|
||||||
|
final String lRel = link.getRel();
|
||||||
|
if (Strings.isBlank(lRel) || "alternate".equals(sRel)) {
|
||||||
alternateLinks.add(link);
|
alternateLinks.add(link);
|
||||||
} else {
|
} else {
|
||||||
otherLinks.add(link);
|
otherLinks.add(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// no alternate link? then use THE link if there is one
|
// no alternate link? then use THE link if there is one
|
||||||
if (alternateLinks.isEmpty() && sEntry.getLink() != null) {
|
if (alternateLinks.isEmpty() && sEntry.getLink() != null) {
|
||||||
final Link link = new Link();
|
final Link link = new Link();
|
||||||
|
@ -499,6 +523,7 @@ public class ConverterForAtom10 implements Converter {
|
||||||
link.setHref(sEntry.getLink());
|
link.setHref(sEntry.getLink());
|
||||||
alternateLinks.add(link);
|
alternateLinks.add(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add SyndEnclosures as links with rel="enclosure" ONLY if
|
// add SyndEnclosures as links with rel="enclosure" ONLY if
|
||||||
// there are no SyndEntry.getLinks() with rel="enclosure"
|
// there are no SyndEntry.getLinks() with rel="enclosure"
|
||||||
if (enclosures != null && linkRelEnclosureExists == false) {
|
if (enclosures != null && linkRelEnclosureExists == false) {
|
||||||
|
@ -508,9 +533,11 @@ public class ConverterForAtom10 implements Converter {
|
||||||
otherLinks.add(link);
|
otherLinks.add(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alternateLinks.isEmpty()) {
|
if (!alternateLinks.isEmpty()) {
|
||||||
aEntry.setAlternateLinks(alternateLinks);
|
aEntry.setAlternateLinks(alternateLinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!otherLinks.isEmpty()) {
|
if (!otherLinks.isEmpty()) {
|
||||||
aEntry.setOtherLinks(otherLinks);
|
aEntry.setOtherLinks(otherLinks);
|
||||||
}
|
}
|
||||||
|
@ -518,8 +545,7 @@ public class ConverterForAtom10 implements Converter {
|
||||||
final List<SyndCategory> sCats = sEntry.getCategories();
|
final List<SyndCategory> sCats = sEntry.getCategories();
|
||||||
final List<Category> aCats = new ArrayList<Category>();
|
final List<Category> aCats = new ArrayList<Category>();
|
||||||
if (sCats != null) {
|
if (sCats != null) {
|
||||||
for (final SyndCategory syndCategory : sCats) {
|
for (final SyndCategory sCat : sCats) {
|
||||||
final SyndCategory sCat = syndCategory;
|
|
||||||
final Category aCat = new Category();
|
final Category aCat = new Category();
|
||||||
aCat.setTerm(sCat.getName());
|
aCat.setTerm(sCat.getName());
|
||||||
// TODO: aCat.setLabel(sCat.getLabel());
|
// TODO: aCat.setLabel(sCat.getLabel());
|
||||||
|
@ -527,6 +553,7 @@ public class ConverterForAtom10 implements Converter {
|
||||||
aCats.add(aCat);
|
aCats.add(aCat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aCats.isEmpty()) {
|
if (!aCats.isEmpty()) {
|
||||||
aEntry.setCategories(aCats);
|
aEntry.setCategories(aCats);
|
||||||
}
|
}
|
||||||
|
@ -535,18 +562,19 @@ public class ConverterForAtom10 implements Converter {
|
||||||
aEntry.setContents(createAtomContents(syndContents));
|
aEntry.setContents(createAtomContents(syndContents));
|
||||||
|
|
||||||
List<SyndPerson> authors = sEntry.getAuthors();
|
List<SyndPerson> authors = sEntry.getAuthors();
|
||||||
if (authors != null && !authors.isEmpty()) {
|
final String author = sEntry.getAuthor();
|
||||||
|
if (Lists.isNotEmpty(authors)) {
|
||||||
aEntry.setAuthors(ConverterForAtom03.createAtomPersons(authors));
|
aEntry.setAuthors(ConverterForAtom03.createAtomPersons(authors));
|
||||||
} else if (sEntry.getAuthor() != null) {
|
} else if (author != null) {
|
||||||
final Person person = new Person();
|
final Person person = new Person();
|
||||||
person.setName(sEntry.getAuthor());
|
person.setName(author);
|
||||||
authors = new ArrayList<SyndPerson>();
|
authors = new ArrayList<SyndPerson>();
|
||||||
authors.add(person);
|
authors.add(person);
|
||||||
aEntry.setAuthors(authors);
|
aEntry.setAuthors(authors);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> contributors = sEntry.getContributors();
|
final List<SyndPerson> contributors = sEntry.getContributors();
|
||||||
if (contributors != null && !contributors.isEmpty()) {
|
if (Lists.isNotEmpty(contributors)) {
|
||||||
aEntry.setContributors(ConverterForAtom03.createAtomPersons(contributors));
|
aEntry.setContributors(ConverterForAtom03.createAtomPersons(contributors));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,8 +589,9 @@ public class ConverterForAtom10 implements Converter {
|
||||||
aEntry.setUpdated(sEntry.getPublishedDate());
|
aEntry.setUpdated(sEntry.getPublishedDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sEntry.getForeignMarkup().isEmpty()) {
|
final List<Element> foreignMarkup = sEntry.getForeignMarkup();
|
||||||
aEntry.setForeignMarkup(sEntry.getForeignMarkup());
|
if (!foreignMarkup.isEmpty()) {
|
||||||
|
aEntry.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
final SyndFeed sSource = sEntry.getSource();
|
final SyndFeed sSource = sEntry.getSource();
|
||||||
|
|
|
@ -19,6 +19,8 @@ package com.sun.syndication.feed.synd.impl;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jdom2.Element;
|
||||||
|
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.module.impl.ModuleUtils;
|
import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
import com.sun.syndication.feed.rss.Channel;
|
import com.sun.syndication.feed.rss.Channel;
|
||||||
|
@ -32,6 +34,7 @@ import com.sun.syndication.feed.synd.SyndFeed;
|
||||||
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
import com.sun.syndication.feed.synd.SyndFeedImpl;
|
||||||
import com.sun.syndication.feed.synd.SyndImage;
|
import com.sun.syndication.feed.synd.SyndImage;
|
||||||
import com.sun.syndication.feed.synd.SyndImageImpl;
|
import com.sun.syndication.feed.synd.SyndImageImpl;
|
||||||
|
import com.sun.syndication.feed.synd.SyndLink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -53,13 +56,20 @@ public class ConverterForRSS090 implements Converter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
||||||
|
|
||||||
syndFeed.setModules(ModuleUtils.cloneModules(feed.getModules()));
|
syndFeed.setModules(ModuleUtils.cloneModules(feed.getModules()));
|
||||||
if (!feed.getForeignMarkup().isEmpty()) {
|
|
||||||
syndFeed.setForeignMarkup(feed.getForeignMarkup());
|
final List<Element> foreignMarkup = feed.getForeignMarkup();
|
||||||
|
if (!foreignMarkup.isEmpty()) {
|
||||||
|
syndFeed.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
syndFeed.setStyleSheet(feed.getStyleSheet());
|
syndFeed.setStyleSheet(feed.getStyleSheet());
|
||||||
|
|
||||||
syndFeed.setEncoding(feed.getEncoding());
|
syndFeed.setEncoding(feed.getEncoding());
|
||||||
|
|
||||||
final Channel channel = (Channel) feed;
|
final Channel channel = (Channel) feed;
|
||||||
|
|
||||||
syndFeed.setTitle(channel.getTitle());
|
syndFeed.setTitle(channel.getTitle());
|
||||||
syndFeed.setLink(channel.getLink());
|
syndFeed.setLink(channel.getLink());
|
||||||
syndFeed.setDescription(channel.getDescription());
|
syndFeed.setDescription(channel.getDescription());
|
||||||
|
@ -85,22 +95,25 @@ public class ConverterForRSS090 implements Converter {
|
||||||
|
|
||||||
protected List<SyndEntry> createSyndEntries(final List<Item> rssItems, final boolean preserveWireItems) {
|
protected List<SyndEntry> createSyndEntries(final List<Item> rssItems, final boolean preserveWireItems) {
|
||||||
final List<SyndEntry> syndEntries = new ArrayList<SyndEntry>();
|
final List<SyndEntry> syndEntries = new ArrayList<SyndEntry>();
|
||||||
for (int i = 0; i < rssItems.size(); i++) {
|
for (final Item item : rssItems) {
|
||||||
syndEntries.add(createSyndEntry(rssItems.get(i), preserveWireItems));
|
syndEntries.add(createSyndEntry(item, preserveWireItems));
|
||||||
}
|
}
|
||||||
return syndEntries;
|
return syndEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
|
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
|
||||||
|
|
||||||
final SyndEntryImpl syndEntry = new SyndEntryImpl();
|
final SyndEntryImpl syndEntry = new SyndEntryImpl();
|
||||||
|
|
||||||
if (preserveWireItem) {
|
if (preserveWireItem) {
|
||||||
syndEntry.setWireEntry(item);
|
syndEntry.setWireEntry(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
syndEntry.setModules(ModuleUtils.cloneModules(item.getModules()));
|
syndEntry.setModules(ModuleUtils.cloneModules(item.getModules()));
|
||||||
|
|
||||||
if (!item.getForeignMarkup().isEmpty()) {
|
final List<Element> foreignMarkup = item.getForeignMarkup();
|
||||||
syndEntry.setForeignMarkup(item.getForeignMarkup());
|
if (!foreignMarkup.isEmpty()) {
|
||||||
|
syndEntry.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
syndEntry.setUri(item.getUri());
|
syndEntry.setUri(item.getUri());
|
||||||
|
@ -134,12 +147,16 @@ public class ConverterForRSS090 implements Converter {
|
||||||
channel.setEncoding(syndFeed.getEncoding());
|
channel.setEncoding(syndFeed.getEncoding());
|
||||||
|
|
||||||
channel.setTitle(syndFeed.getTitle());
|
channel.setTitle(syndFeed.getTitle());
|
||||||
if (syndFeed.getLink() != null) {
|
final String link = syndFeed.getLink();
|
||||||
channel.setLink(syndFeed.getLink());
|
final List<SyndLink> links = syndFeed.getLinks();
|
||||||
} else if (!syndFeed.getLinks().isEmpty()) {
|
if (link != null) {
|
||||||
channel.setLink(syndFeed.getLinks().get(0).getHref());
|
channel.setLink(link);
|
||||||
|
} else if (!links.isEmpty()) {
|
||||||
|
channel.setLink(links.get(0).getHref());
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.setDescription(syndFeed.getDescription());
|
channel.setDescription(syndFeed.getDescription());
|
||||||
|
|
||||||
final SyndImage sImage = syndFeed.getImage();
|
final SyndImage sImage = syndFeed.getImage();
|
||||||
if (sImage != null) {
|
if (sImage != null) {
|
||||||
channel.setImage(createRSSImage(sImage));
|
channel.setImage(createRSSImage(sImage));
|
||||||
|
@ -150,9 +167,11 @@ public class ConverterForRSS090 implements Converter {
|
||||||
channel.setItems(createRSSItems(sEntries));
|
channel.setItems(createRSSItems(sEntries));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!syndFeed.getForeignMarkup().isEmpty()) {
|
final List<Element> foreignMarkup = syndFeed.getForeignMarkup();
|
||||||
channel.setForeignMarkup(syndFeed.getForeignMarkup());
|
if (!foreignMarkup.isEmpty()) {
|
||||||
|
channel.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,22 +185,29 @@ public class ConverterForRSS090 implements Converter {
|
||||||
|
|
||||||
protected List<Item> createRSSItems(final List<SyndEntry> sEntries) {
|
protected List<Item> createRSSItems(final List<SyndEntry> sEntries) {
|
||||||
final List<Item> list = new ArrayList<Item>();
|
final List<Item> list = new ArrayList<Item>();
|
||||||
for (int i = 0; i < sEntries.size(); i++) {
|
for (final SyndEntry syndEntry : sEntries) {
|
||||||
list.add(createRSSItem(sEntries.get(i)));
|
list.add(createRSSItem(syndEntry));
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Item createRSSItem(final SyndEntry sEntry) {
|
protected Item createRSSItem(final SyndEntry sEntry) {
|
||||||
|
|
||||||
final Item item = new Item();
|
final Item item = new Item();
|
||||||
|
|
||||||
item.setModules(ModuleUtils.cloneModules(sEntry.getModules()));
|
item.setModules(ModuleUtils.cloneModules(sEntry.getModules()));
|
||||||
|
|
||||||
item.setTitle(sEntry.getTitle());
|
item.setTitle(sEntry.getTitle());
|
||||||
|
|
||||||
item.setLink(sEntry.getLink());
|
item.setLink(sEntry.getLink());
|
||||||
if (!sEntry.getForeignMarkup().isEmpty()) {
|
|
||||||
item.setForeignMarkup(sEntry.getForeignMarkup());
|
final List<Element> foreignMarkup = sEntry.getForeignMarkup();
|
||||||
|
if (!foreignMarkup.isEmpty()) {
|
||||||
|
item.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
item.setSource(createSource(sEntry.getSource()));
|
item.setSource(createSource(sEntry.getSource()));
|
||||||
|
|
||||||
final String uri = sEntry.getUri();
|
final String uri = sEntry.getUri();
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
item.setUri(uri);
|
item.setUri(uri);
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.module.DCModule;
|
import com.sun.syndication.feed.module.DCModule;
|
||||||
import com.sun.syndication.feed.rss.Channel;
|
import com.sun.syndication.feed.rss.Channel;
|
||||||
|
@ -36,9 +37,8 @@ import com.sun.syndication.feed.synd.SyndFeed;
|
||||||
import com.sun.syndication.feed.synd.SyndImage;
|
import com.sun.syndication.feed.synd.SyndImage;
|
||||||
import com.sun.syndication.feed.synd.SyndPerson;
|
import com.sun.syndication.feed.synd.SyndPerson;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class ConverterForRSS091Userland extends ConverterForRSS090 {
|
public class ConverterForRSS091Userland extends ConverterForRSS090 {
|
||||||
|
|
||||||
public ConverterForRSS091Userland() {
|
public ConverterForRSS091Userland() {
|
||||||
this("rss_0.91U");
|
this("rss_0.91U");
|
||||||
}
|
}
|
||||||
|
@ -49,13 +49,21 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
||||||
|
|
||||||
final Channel channel = (Channel) feed;
|
final Channel channel = (Channel) feed;
|
||||||
|
|
||||||
super.copyInto(channel, syndFeed);
|
super.copyInto(channel, syndFeed);
|
||||||
|
|
||||||
syndFeed.setLanguage(channel.getLanguage()); // c
|
syndFeed.setLanguage(channel.getLanguage()); // c
|
||||||
|
|
||||||
syndFeed.setCopyright(channel.getCopyright()); // c
|
syndFeed.setCopyright(channel.getCopyright()); // c
|
||||||
|
|
||||||
syndFeed.setDocs(channel.getDocs());
|
syndFeed.setDocs(channel.getDocs());
|
||||||
|
|
||||||
syndFeed.setManagingEditor(channel.getManagingEditor());
|
syndFeed.setManagingEditor(channel.getManagingEditor());
|
||||||
|
|
||||||
syndFeed.setWebMaster(channel.getWebMaster());
|
syndFeed.setWebMaster(channel.getWebMaster());
|
||||||
|
|
||||||
syndFeed.setGenerator(channel.getGenerator());
|
syndFeed.setGenerator(channel.getGenerator());
|
||||||
|
|
||||||
final Date pubDate = channel.getPubDate();
|
final Date pubDate = channel.getPubDate();
|
||||||
|
@ -69,12 +77,12 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
|
||||||
final String author = channel.getManagingEditor();
|
final String author = channel.getManagingEditor();
|
||||||
|
|
||||||
if (author != null) {
|
if (author != null) {
|
||||||
|
|
||||||
final List<String> creators = ((DCModule) syndFeed.getModule(DCModule.URI)).getCreators();
|
final List<String> creators = ((DCModule) syndFeed.getModule(DCModule.URI)).getCreators();
|
||||||
|
|
||||||
if (!creators.contains(author)) {
|
if (!creators.contains(author)) {
|
||||||
final Set<String> s = new LinkedHashSet<String>(); // using a set to
|
// using a set to remove duplicates
|
||||||
// remove
|
final Set<String> s = new LinkedHashSet<String>();
|
||||||
// duplicates
|
|
||||||
s.addAll(creators); // DC creators
|
s.addAll(creators); // DC creators
|
||||||
s.add(author); // feed native author
|
s.add(author); // feed native author
|
||||||
creators.clear();
|
creators.clear();
|
||||||
|
@ -87,7 +95,6 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
|
||||||
final Description desc = new Description();
|
final Description desc = new Description();
|
||||||
desc.setValue(sContent.getValue());
|
desc.setValue(sContent.getValue());
|
||||||
desc.setType(sContent.getType());
|
desc.setType(sContent.getType());
|
||||||
|
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +102,6 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
|
||||||
protected Image createRSSImage(final SyndImage sImage) {
|
protected Image createRSSImage(final SyndImage sImage) {
|
||||||
final Image image = super.createRSSImage(sImage);
|
final Image image = super.createRSSImage(sImage);
|
||||||
image.setDescription(sImage.getDescription());
|
image.setDescription(sImage.getDescription());
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,8 +110,11 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
|
||||||
// synd.description -> rss.description
|
// synd.description -> rss.description
|
||||||
@Override
|
@Override
|
||||||
protected Item createRSSItem(final SyndEntry sEntry) {
|
protected Item createRSSItem(final SyndEntry sEntry) {
|
||||||
|
|
||||||
final Item item = super.createRSSItem(sEntry);
|
final Item item = super.createRSSItem(sEntry);
|
||||||
|
|
||||||
item.setComments(sEntry.getComments());
|
item.setComments(sEntry.getComments());
|
||||||
|
|
||||||
final SyndContent sContent = sEntry.getDescription();
|
final SyndContent sContent = sEntry.getDescription();
|
||||||
|
|
||||||
if (sContent != null) {
|
if (sContent != null) {
|
||||||
|
@ -114,7 +123,7 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
|
||||||
|
|
||||||
final List<SyndContent> contents = sEntry.getContents();
|
final List<SyndContent> contents = sEntry.getContents();
|
||||||
|
|
||||||
if (contents != null && !contents.isEmpty()) {
|
if (Lists.isNotEmpty(contents)) {
|
||||||
final SyndContent syndContent = contents.get(0);
|
final SyndContent syndContent = contents.get(0);
|
||||||
final Content cont = new Content();
|
final Content cont = new Content();
|
||||||
cont.setValue(syndContent.getValue());
|
cont.setValue(syndContent.getValue());
|
||||||
|
@ -136,8 +145,9 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
|
||||||
channel.setWebMaster(syndFeed.getWebMaster());
|
channel.setWebMaster(syndFeed.getWebMaster());
|
||||||
channel.setGenerator(syndFeed.getGenerator());
|
channel.setGenerator(syndFeed.getGenerator());
|
||||||
|
|
||||||
if (syndFeed.getAuthors() != null && !syndFeed.getAuthors().isEmpty()) {
|
final List<SyndPerson> authors = syndFeed.getAuthors();
|
||||||
final SyndPerson author = syndFeed.getAuthors().get(0);
|
if (Lists.isNotEmpty(authors)) {
|
||||||
|
final SyndPerson author = authors.get(0);
|
||||||
channel.setManagingEditor(author.getName());
|
channel.setManagingEditor(author.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,8 +159,11 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
|
||||||
// rss.description -> synd.description
|
// rss.description -> synd.description
|
||||||
@Override
|
@Override
|
||||||
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
|
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
|
||||||
|
|
||||||
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
|
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
|
||||||
|
|
||||||
final Description desc = item.getDescription();
|
final Description desc = item.getDescription();
|
||||||
|
|
||||||
syndEntry.setComments(item.getComments());
|
syndEntry.setComments(item.getComments());
|
||||||
|
|
||||||
if (desc != null) {
|
if (desc != null) {
|
||||||
|
@ -179,7 +192,7 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 {
|
||||||
protected SyndImage createSyndImage(final Image rssImage) {
|
protected SyndImage createSyndImage(final Image rssImage) {
|
||||||
final SyndImage syndImage = super.createSyndImage(rssImage);
|
final SyndImage syndImage = super.createSyndImage(rssImage);
|
||||||
syndImage.setDescription(rssImage.getDescription());
|
syndImage.setDescription(rssImage.getDescription());
|
||||||
|
|
||||||
return syndImage;
|
return syndImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,40 +44,38 @@ public class ConverterForRSS092 extends ConverterForRSS091Userland {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
|
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
|
||||||
|
|
||||||
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
|
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
|
||||||
|
|
||||||
final List<Category> cats = item.getCategories();
|
final List<Category> cats = item.getCategories();
|
||||||
|
|
||||||
if (!cats.isEmpty()) {
|
if (!cats.isEmpty()) {
|
||||||
final Set<SyndCategory> s = new LinkedHashSet<SyndCategory>(); // using
|
|
||||||
// a
|
// using a set to remove duplicates and use a LinkedHashSet to try to retain the
|
||||||
// set to
|
// document order
|
||||||
// remove
|
final Set<SyndCategory> s = new LinkedHashSet<SyndCategory>();
|
||||||
// duplicates
|
|
||||||
// and use
|
// feed native categories (as syndcat)
|
||||||
// a
|
s.addAll(createSyndCategories(cats));
|
||||||
// LinkedHashSet
|
|
||||||
// to try
|
// DC subjects (as syndcat)
|
||||||
// to
|
s.addAll(syndEntry.getCategories());
|
||||||
// retain
|
|
||||||
// the
|
|
||||||
// document
|
|
||||||
// order
|
|
||||||
s.addAll(createSyndCategories(cats)); // feed native categories
|
|
||||||
// (as
|
|
||||||
// syndcat)
|
|
||||||
s.addAll(syndEntry.getCategories()); // DC subjects (as syndcat)
|
|
||||||
syndEntry.setCategories(new ArrayList<SyndCategory>(s)); // c
|
syndEntry.setCategories(new ArrayList<SyndCategory>(s)); // c
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Enclosure> enclosures = item.getEnclosures();
|
final List<Enclosure> enclosures = item.getEnclosures();
|
||||||
if (!enclosures.isEmpty()) {
|
if (!enclosures.isEmpty()) {
|
||||||
syndEntry.setEnclosures(createSyndEnclosures(enclosures));
|
syndEntry.setEnclosures(createSyndEnclosures(enclosures));
|
||||||
}
|
}
|
||||||
|
|
||||||
return syndEntry;
|
return syndEntry;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<SyndCategory> createSyndCategories(final List<Category> rssCats) {
|
protected List<SyndCategory> createSyndCategories(final List<Category> rssCats) {
|
||||||
final List<SyndCategory> syndCats = new ArrayList<SyndCategory>();
|
final List<SyndCategory> syndCats = new ArrayList<SyndCategory>();
|
||||||
for (int i = 0; i < rssCats.size(); i++) {
|
for (final Category rssCat : rssCats) {
|
||||||
final Category rssCat = rssCats.get(i);
|
|
||||||
final SyndCategory sCat = new SyndCategoryImpl();
|
final SyndCategory sCat = new SyndCategoryImpl();
|
||||||
sCat.setTaxonomyUri(rssCat.getDomain());
|
sCat.setTaxonomyUri(rssCat.getDomain());
|
||||||
sCat.setName(rssCat.getValue());
|
sCat.setName(rssCat.getValue());
|
||||||
|
@ -88,8 +86,7 @@ public class ConverterForRSS092 extends ConverterForRSS091Userland {
|
||||||
|
|
||||||
protected List<SyndEnclosure> createSyndEnclosures(final List<Enclosure> enclosures) {
|
protected List<SyndEnclosure> createSyndEnclosures(final List<Enclosure> enclosures) {
|
||||||
final List<SyndEnclosure> sEnclosures = new ArrayList<SyndEnclosure>();
|
final List<SyndEnclosure> sEnclosures = new ArrayList<SyndEnclosure>();
|
||||||
for (int i = 0; i < enclosures.size(); i++) {
|
for (final Enclosure enc : enclosures) {
|
||||||
final Enclosure enc = enclosures.get(i);
|
|
||||||
final SyndEnclosure sEnc = new SyndEnclosureImpl();
|
final SyndEnclosure sEnc = new SyndEnclosureImpl();
|
||||||
sEnc.setUrl(enc.getUrl());
|
sEnc.setUrl(enc.getUrl());
|
||||||
sEnc.setType(enc.getType());
|
sEnc.setType(enc.getType());
|
||||||
|
@ -101,23 +98,26 @@ public class ConverterForRSS092 extends ConverterForRSS091Userland {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Item createRSSItem(final SyndEntry sEntry) {
|
protected Item createRSSItem(final SyndEntry sEntry) {
|
||||||
|
|
||||||
final Item item = super.createRSSItem(sEntry);
|
final Item item = super.createRSSItem(sEntry);
|
||||||
|
|
||||||
final List<SyndCategory> sCats = sEntry.getCategories(); // c
|
final List<SyndCategory> sCats = sEntry.getCategories(); // c
|
||||||
if (!sCats.isEmpty()) {
|
if (!sCats.isEmpty()) {
|
||||||
item.setCategories(createRSSCategories(sCats));
|
item.setCategories(createRSSCategories(sCats));
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndEnclosure> sEnclosures = sEntry.getEnclosures();
|
final List<SyndEnclosure> sEnclosures = sEntry.getEnclosures();
|
||||||
if (!sEnclosures.isEmpty()) {
|
if (!sEnclosures.isEmpty()) {
|
||||||
item.setEnclosures(createEnclosures(sEnclosures));
|
item.setEnclosures(createEnclosures(sEnclosures));
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Category> createRSSCategories(final List<SyndCategory> sCats) {
|
protected List<Category> createRSSCategories(final List<SyndCategory> sCats) {
|
||||||
final List<Category> cats = new ArrayList<Category>();
|
final List<Category> cats = new ArrayList<Category>();
|
||||||
for (int i = 0; i < sCats.size(); i++) {
|
for (final SyndCategory sCat : sCats) {
|
||||||
final SyndCategory sCat = sCats.get(i);
|
|
||||||
final Category cat = new Category();
|
final Category cat = new Category();
|
||||||
cat.setDomain(sCat.getTaxonomyUri());
|
cat.setDomain(sCat.getTaxonomyUri());
|
||||||
cat.setValue(sCat.getName());
|
cat.setValue(sCat.getName());
|
||||||
|
@ -128,8 +128,7 @@ public class ConverterForRSS092 extends ConverterForRSS091Userland {
|
||||||
|
|
||||||
protected List<Enclosure> createEnclosures(final List<SyndEnclosure> sEnclosures) {
|
protected List<Enclosure> createEnclosures(final List<SyndEnclosure> sEnclosures) {
|
||||||
final List<Enclosure> enclosures = new ArrayList<Enclosure>();
|
final List<Enclosure> enclosures = new ArrayList<Enclosure>();
|
||||||
for (int i = 0; i < sEnclosures.size(); i++) {
|
for (final SyndEnclosure sEnc : sEnclosures) {
|
||||||
final SyndEnclosure sEnc = sEnclosures.get(i);
|
|
||||||
final Enclosure enc = new Enclosure();
|
final Enclosure enc = new Enclosure();
|
||||||
enc.setUrl(sEnc.getUrl());
|
enc.setUrl(sEnc.getUrl());
|
||||||
enc.setType(sEnc.getType());
|
enc.setType(sEnc.getType());
|
||||||
|
|
|
@ -21,8 +21,6 @@ import java.util.Date;
|
||||||
import com.sun.syndication.feed.rss.Item;
|
import com.sun.syndication.feed.rss.Item;
|
||||||
import com.sun.syndication.feed.synd.SyndEntry;
|
import com.sun.syndication.feed.synd.SyndEntry;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class ConverterForRSS093 extends ConverterForRSS092 {
|
public class ConverterForRSS093 extends ConverterForRSS092 {
|
||||||
|
|
||||||
public ConverterForRSS093() {
|
public ConverterForRSS093() {
|
||||||
|
@ -35,11 +33,15 @@ public class ConverterForRSS093 extends ConverterForRSS092 {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
|
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
|
||||||
|
|
||||||
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
|
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
|
||||||
|
|
||||||
final Date pubDate = item.getPubDate();
|
final Date pubDate = item.getPubDate();
|
||||||
if (pubDate != null && syndEntry.getPublishedDate() == null) {
|
final Date publishedDate = syndEntry.getPublishedDate();
|
||||||
|
if (pubDate != null && publishedDate == null) {
|
||||||
syndEntry.setPublishedDate(pubDate); // c
|
syndEntry.setPublishedDate(pubDate); // c
|
||||||
}
|
}
|
||||||
|
|
||||||
return syndEntry;
|
return syndEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.module.DCModule;
|
import com.sun.syndication.feed.module.DCModule;
|
||||||
import com.sun.syndication.feed.rss.Category;
|
import com.sun.syndication.feed.rss.Category;
|
||||||
|
@ -34,8 +35,6 @@ import com.sun.syndication.feed.synd.SyndLink;
|
||||||
import com.sun.syndication.feed.synd.SyndLinkImpl;
|
import com.sun.syndication.feed.synd.SyndLinkImpl;
|
||||||
import com.sun.syndication.feed.synd.SyndPerson;
|
import com.sun.syndication.feed.synd.SyndPerson;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class ConverterForRSS094 extends ConverterForRSS093 {
|
public class ConverterForRSS094 extends ConverterForRSS093 {
|
||||||
|
|
||||||
public ConverterForRSS094() {
|
public ConverterForRSS094() {
|
||||||
|
@ -48,24 +47,32 @@ public class ConverterForRSS094 extends ConverterForRSS093 {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
||||||
|
|
||||||
final Channel channel = (Channel) feed;
|
final Channel channel = (Channel) feed;
|
||||||
|
|
||||||
super.copyInto(channel, syndFeed);
|
super.copyInto(channel, syndFeed);
|
||||||
|
|
||||||
final List<Category> cats = channel.getCategories(); // c
|
final List<Category> cats = channel.getCategories(); // c
|
||||||
if (!cats.isEmpty()) {
|
if (!cats.isEmpty()) {
|
||||||
final Set<SyndCategory> s = new LinkedHashSet<SyndCategory>(); // using a
|
|
||||||
// set to
|
// using a set to remove duplicates
|
||||||
// remove
|
final Set<SyndCategory> s = new LinkedHashSet<SyndCategory>();
|
||||||
// duplicates
|
|
||||||
s.addAll(createSyndCategories(cats)); // feed native categories
|
// feed native categories (as syndcat)
|
||||||
// (as
|
s.addAll(createSyndCategories(cats));
|
||||||
// syndcat)
|
|
||||||
s.addAll(syndFeed.getCategories()); // DC subjects (as syndcat)
|
// DC subjects (as syndcat)
|
||||||
|
s.addAll(syndFeed.getCategories());
|
||||||
|
|
||||||
syndFeed.setCategories(new ArrayList<SyndCategory>(s));
|
syndFeed.setCategories(new ArrayList<SyndCategory>(s));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
|
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
|
||||||
|
|
||||||
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
|
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
|
||||||
|
|
||||||
// adding native feed author to DC creators list
|
// adding native feed author to DC creators list
|
||||||
|
@ -73,32 +80,42 @@ public class ConverterForRSS094 extends ConverterForRSS093 {
|
||||||
if (author != null) {
|
if (author != null) {
|
||||||
final List<String> creators = ((DCModule) syndEntry.getModule(DCModule.URI)).getCreators();
|
final List<String> creators = ((DCModule) syndEntry.getModule(DCModule.URI)).getCreators();
|
||||||
if (!creators.contains(author)) {
|
if (!creators.contains(author)) {
|
||||||
final Set<String> s = new LinkedHashSet<String>(); // using a set to
|
|
||||||
// remove
|
// using a set to remove duplicates
|
||||||
// duplicates
|
final Set<String> s = new LinkedHashSet<String>();
|
||||||
s.addAll(creators); // DC creators
|
|
||||||
s.add(author); // feed native author
|
// DC creators
|
||||||
|
s.addAll(creators);
|
||||||
|
|
||||||
|
// feed native author
|
||||||
|
s.add(author);
|
||||||
|
|
||||||
creators.clear();
|
creators.clear();
|
||||||
creators.addAll(s);
|
creators.addAll(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Guid guid = item.getGuid();
|
final Guid guid = item.getGuid();
|
||||||
|
final String itemLink = item.getLink();
|
||||||
if (guid != null) {
|
if (guid != null) {
|
||||||
syndEntry.setUri(guid.getValue());
|
final String guidValue = guid.getValue();
|
||||||
if (item.getLink() == null && guid.isPermaLink()) {
|
syndEntry.setUri(guidValue);
|
||||||
syndEntry.setLink(guid.getValue());
|
if (itemLink == null && guid.isPermaLink()) {
|
||||||
|
syndEntry.setLink(guidValue);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
syndEntry.setUri(item.getLink());
|
syndEntry.setUri(itemLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getComments() != null) {
|
if (item.getComments() != null) {
|
||||||
final SyndLinkImpl comments = new SyndLinkImpl();
|
final SyndLinkImpl comments = new SyndLinkImpl();
|
||||||
comments.setRel("comments");
|
comments.setRel("comments");
|
||||||
comments.setHref(item.getComments());
|
comments.setHref(item.getComments());
|
||||||
comments.setType("text/html");
|
comments.setType("text/html");
|
||||||
}
|
}
|
||||||
|
|
||||||
return syndEntry;
|
return syndEntry;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,32 +130,36 @@ public class ConverterForRSS094 extends ConverterForRSS093 {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Item createRSSItem(final SyndEntry sEntry) {
|
protected Item createRSSItem(final SyndEntry sEntry) {
|
||||||
|
|
||||||
final Item item = super.createRSSItem(sEntry);
|
final Item item = super.createRSSItem(sEntry);
|
||||||
if (sEntry.getAuthors() != null && !sEntry.getAuthors().isEmpty()) {
|
|
||||||
final SyndPerson author = sEntry.getAuthors().get(0);
|
final List<SyndPerson> authors = sEntry.getAuthors();
|
||||||
|
if (Lists.isNotEmpty(authors)) {
|
||||||
|
final SyndPerson author = authors.get(0);
|
||||||
item.setAuthor(author.getEmail());
|
item.setAuthor(author.getEmail());
|
||||||
}
|
}
|
||||||
|
|
||||||
Guid guid = null;
|
Guid guid = null;
|
||||||
final String uri = sEntry.getUri();
|
final String uri = sEntry.getUri();
|
||||||
|
final String link = sEntry.getLink();
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
guid = new Guid();
|
guid = new Guid();
|
||||||
guid.setPermaLink(false);
|
guid.setPermaLink(false);
|
||||||
guid.setValue(uri);
|
guid.setValue(uri);
|
||||||
} else {
|
} else if (link != null) {
|
||||||
final String link = sEntry.getLink();
|
guid = new Guid();
|
||||||
if (link != null) {
|
guid.setPermaLink(true);
|
||||||
guid = new Guid();
|
guid.setValue(link);
|
||||||
guid.setPermaLink(true);
|
|
||||||
guid.setValue(link);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
item.setGuid(guid);
|
item.setGuid(guid);
|
||||||
|
|
||||||
final SyndLink comments = sEntry.findRelatedLink("comments");
|
final SyndLink comments = sEntry.findRelatedLink("comments");
|
||||||
if (comments != null && (comments.getType() == null || comments.getType().endsWith("html"))) {
|
if (comments != null && (comments.getType() == null || comments.getType().endsWith("html"))) {
|
||||||
item.setComments(comments.getHref());
|
item.setComments(comments.getHref());
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ package com.sun.syndication.feed.synd.impl;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.rss.Channel;
|
import com.sun.syndication.feed.rss.Channel;
|
||||||
import com.sun.syndication.feed.rss.Content;
|
import com.sun.syndication.feed.rss.Content;
|
||||||
|
@ -29,8 +30,6 @@ import com.sun.syndication.feed.synd.SyndContentImpl;
|
||||||
import com.sun.syndication.feed.synd.SyndEntry;
|
import com.sun.syndication.feed.synd.SyndEntry;
|
||||||
import com.sun.syndication.feed.synd.SyndFeed;
|
import com.sun.syndication.feed.synd.SyndFeed;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class ConverterForRSS10 extends ConverterForRSS090 {
|
public class ConverterForRSS10 extends ConverterForRSS090 {
|
||||||
|
|
||||||
public ConverterForRSS10() {
|
public ConverterForRSS10() {
|
||||||
|
@ -43,13 +42,18 @@ public class ConverterForRSS10 extends ConverterForRSS090 {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
||||||
|
|
||||||
final Channel channel = (Channel) feed;
|
final Channel channel = (Channel) feed;
|
||||||
|
|
||||||
super.copyInto(channel, syndFeed);
|
super.copyInto(channel, syndFeed);
|
||||||
if (channel.getUri() != null) {
|
|
||||||
syndFeed.setUri(channel.getUri());
|
final String uri = channel.getUri();
|
||||||
|
if (uri != null) {
|
||||||
|
syndFeed.setUri(uri);
|
||||||
} else {
|
} else {
|
||||||
// if URI is not set use the value for link
|
// if URI is not set use the value for link
|
||||||
syndFeed.setUri(channel.getLink());
|
final String link = channel.getLink();
|
||||||
|
syndFeed.setUri(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +63,7 @@ public class ConverterForRSS10 extends ConverterForRSS090 {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
|
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
|
||||||
|
|
||||||
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
|
final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
|
||||||
|
|
||||||
final Description desc = item.getDescription();
|
final Description desc = item.getDescription();
|
||||||
|
@ -68,27 +73,36 @@ public class ConverterForRSS10 extends ConverterForRSS090 {
|
||||||
descContent.setValue(desc.getValue());
|
descContent.setValue(desc.getValue());
|
||||||
syndEntry.setDescription(descContent);
|
syndEntry.setDescription(descContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Content cont = item.getContent();
|
final Content cont = item.getContent();
|
||||||
if (cont != null) {
|
if (cont != null) {
|
||||||
|
|
||||||
final SyndContent contContent = new SyndContentImpl();
|
final SyndContent contContent = new SyndContentImpl();
|
||||||
contContent.setType(cont.getType());
|
contContent.setType(cont.getType());
|
||||||
contContent.setValue(cont.getValue());
|
contContent.setValue(cont.getValue());
|
||||||
|
|
||||||
final List<SyndContent> contents = new ArrayList<SyndContent>();
|
final List<SyndContent> contents = new ArrayList<SyndContent>();
|
||||||
contents.add(contContent);
|
contents.add(contContent);
|
||||||
syndEntry.setContents(contents);
|
syndEntry.setContents(contents);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return syndEntry;
|
return syndEntry;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WireFeed createRealFeed(final String type, final SyndFeed syndFeed) {
|
protected WireFeed createRealFeed(final String type, final SyndFeed syndFeed) {
|
||||||
|
|
||||||
final Channel channel = (Channel) super.createRealFeed(type, syndFeed);
|
final Channel channel = (Channel) super.createRealFeed(type, syndFeed);
|
||||||
if (syndFeed.getUri() != null) {
|
|
||||||
channel.setUri(syndFeed.getUri());
|
final String uri = syndFeed.getUri();
|
||||||
|
if (uri != null) {
|
||||||
|
channel.setUri(uri);
|
||||||
} else {
|
} else {
|
||||||
// if URI is not set use the value for link
|
// if URI is not set use the value for link
|
||||||
channel.setUri(syndFeed.getLink());
|
final String link = syndFeed.getLink();
|
||||||
|
channel.setUri(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
return channel;
|
return channel;
|
||||||
|
@ -100,14 +114,16 @@ public class ConverterForRSS10 extends ConverterForRSS090 {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Item createRSSItem(final SyndEntry sEntry) {
|
protected Item createRSSItem(final SyndEntry sEntry) {
|
||||||
|
|
||||||
final Item item = super.createRSSItem(sEntry);
|
final Item item = super.createRSSItem(sEntry);
|
||||||
|
|
||||||
final SyndContent desc = sEntry.getDescription();
|
final SyndContent desc = sEntry.getDescription();
|
||||||
if (desc != null) {
|
if (desc != null) {
|
||||||
item.setDescription(createItemDescription(desc));
|
item.setDescription(createItemDescription(desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndContent> contents = sEntry.getContents();
|
final List<SyndContent> contents = sEntry.getContents();
|
||||||
if (contents != null && !contents.isEmpty()) {
|
if (Lists.isNotEmpty(contents)) {
|
||||||
item.setContent(createItemContent(contents.get(0)));
|
item.setContent(createItemContent(contents.get(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package com.sun.syndication.feed.synd.impl;
|
package com.sun.syndication.feed.synd.impl;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class ConverterForRSS20 extends ConverterForRSS094 {
|
public class ConverterForRSS20 extends ConverterForRSS094 {
|
||||||
|
|
||||||
public ConverterForRSS20() {
|
public ConverterForRSS20() {
|
||||||
|
|
|
@ -19,10 +19,9 @@ package com.sun.syndication.io;
|
||||||
/**
|
/**
|
||||||
* Exception thrown by WireFeedInput, WireFeedOutput, WireFeedParser and WireFeedGenerator instances
|
* Exception thrown by WireFeedInput, WireFeedOutput, WireFeedParser and WireFeedGenerator instances
|
||||||
* if they can not parse or generate a feed.
|
* if they can not parse or generate a feed.
|
||||||
* <p>
|
*
|
||||||
*
|
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FeedException extends Exception {
|
public class FeedException extends Exception {
|
||||||
|
|
||||||
|
@ -30,10 +29,9 @@ public class FeedException extends Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a FeedException with a message.
|
* Creates a FeedException with a message.
|
||||||
* <p>
|
*
|
||||||
*
|
|
||||||
* @param msg exception message.
|
* @param msg exception message.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public FeedException(final String msg) {
|
public FeedException(final String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
|
@ -41,11 +39,10 @@ public class FeedException extends Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a FeedException with a message and a root cause exception.
|
* Creates a FeedException with a message and a root cause exception.
|
||||||
* <p>
|
*
|
||||||
*
|
|
||||||
* @param msg exception message.
|
* @param msg exception message.
|
||||||
* @param rootCause root cause exception.
|
* @param rootCause root cause exception.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public FeedException(final String msg, final Throwable rootCause) {
|
public FeedException(final String msg, final Throwable rootCause) {
|
||||||
super(msg, rootCause);
|
super(msg, rootCause);
|
||||||
|
|
|
@ -20,10 +20,9 @@ import org.jdom2.input.JDOMParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown by WireFeedInput instance if it can not parse a feed.
|
* Exception thrown by WireFeedInput instance if it can not parse a feed.
|
||||||
* <p>
|
*
|
||||||
*
|
|
||||||
* @author Elaine Chien
|
* @author Elaine Chien
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ParsingFeedException extends FeedException {
|
public class ParsingFeedException extends FeedException {
|
||||||
|
|
||||||
|
@ -31,10 +30,9 @@ public class ParsingFeedException extends FeedException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a FeedException with a message.
|
* Creates a FeedException with a message.
|
||||||
* <p>
|
*
|
||||||
*
|
|
||||||
* @param msg exception message.
|
* @param msg exception message.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public ParsingFeedException(final String msg) {
|
public ParsingFeedException(final String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
|
@ -42,11 +40,10 @@ public class ParsingFeedException extends FeedException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a FeedException with a message and a root cause exception.
|
* Creates a FeedException with a message and a root cause exception.
|
||||||
* <p>
|
*
|
||||||
*
|
|
||||||
* @param msg exception message.
|
* @param msg exception message.
|
||||||
* @param rootCause root cause exception.
|
* @param rootCause root cause exception.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public ParsingFeedException(final String msg, final Throwable rootCause) {
|
public ParsingFeedException(final String msg, final Throwable rootCause) {
|
||||||
super(msg, rootCause);
|
super(msg, rootCause);
|
||||||
|
@ -57,7 +54,7 @@ public class ParsingFeedException extends FeedException {
|
||||||
* <p>
|
* <p>
|
||||||
* The first line in the document is line 1.
|
* The first line in the document is line 1.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @return an integer representing the line number, or -1 if the information is not available.
|
* @return an integer representing the line number, or -1 if the information is not available.
|
||||||
*/
|
*/
|
||||||
public int getLineNumber() {
|
public int getLineNumber() {
|
||||||
|
@ -73,7 +70,7 @@ public class ParsingFeedException extends FeedException {
|
||||||
* <p>
|
* <p>
|
||||||
* The first column in a line is position 1.
|
* The first column in a line is position 1.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @return an integer representing the column number, or -1 if the information is not available.
|
* @return an integer representing the column number, or -1 if the information is not available.
|
||||||
*/
|
*/
|
||||||
public int getColumnNumber() {
|
public int getColumnNumber() {
|
||||||
|
|
|
@ -30,21 +30,13 @@ import com.sun.syndication.feed.synd.SyndFeed;
|
||||||
* <p>
|
* <p>
|
||||||
* It delegates to a WireFeedOutput to generate all feed types.
|
* It delegates to a WireFeedOutput to generate all feed types.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SyndFeedOutput {
|
public class SyndFeedOutput {
|
||||||
private final WireFeedOutput feedOutput;
|
|
||||||
|
|
||||||
/**
|
private final WireFeedOutput feedOutput = new WireFeedOutput();
|
||||||
* Creates a SyndFeedOutput instance.
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public SyndFeedOutput() {
|
|
||||||
feedOutput = new WireFeedOutput();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a String with the XML representation for the given SyndFeedImpl.
|
* Creates a String with the XML representation for the given SyndFeedImpl.
|
||||||
|
@ -53,12 +45,12 @@ public class SyndFeedOutput {
|
||||||
* the responsibility of the developer to ensure that if the String is written to a character
|
* the responsibility of the developer to ensure that if the String is written to a character
|
||||||
* stream the stream charset is the same as the feed encoding property.
|
* stream the stream charset is the same as the feed encoding property.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param feed Abstract feed to create XML representation from. The type of the SyndFeedImpl
|
* @param feed Abstract feed to create XML representation from. The type of the SyndFeedImpl
|
||||||
* must match the type given to the FeedOuptut constructor.
|
* must match the type given to the FeedOuptut constructor.
|
||||||
* @return a String with the XML representation for the given SyndFeedImpl.
|
* @return a String with the XML representation for the given SyndFeedImpl.
|
||||||
* @throws FeedException thrown if the XML representation for the feed could not be created.
|
* @throws FeedException thrown if the XML representation for the feed could not be created.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String outputString(final SyndFeed feed) throws FeedException {
|
public String outputString(final SyndFeed feed) throws FeedException {
|
||||||
return feedOutput.outputString(feed.createWireFeed());
|
return feedOutput.outputString(feed.createWireFeed());
|
||||||
|
@ -71,13 +63,13 @@ public class SyndFeedOutput {
|
||||||
* the responsibility of the developer to ensure that if the String is written to a character
|
* the responsibility of the developer to ensure that if the String is written to a character
|
||||||
* stream the stream charset is the same as the feed encoding property.
|
* stream the stream charset is the same as the feed encoding property.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param feed Abstract feed to create XML representation from. The type of the SyndFeedImpl
|
* @param feed Abstract feed to create XML representation from. The type of the SyndFeedImpl
|
||||||
* must match the type given to the FeedOuptut constructor.
|
* must match the type given to the FeedOuptut constructor.
|
||||||
* @param prettyPrint pretty-print XML (true) oder collapsed
|
* @param prettyPrint pretty-print XML (true) oder collapsed
|
||||||
* @return a String with the XML representation for the given SyndFeedImpl.
|
* @return a String with the XML representation for the given SyndFeedImpl.
|
||||||
* @throws FeedException thrown if the XML representation for the feed could not be created.
|
* @throws FeedException thrown if the XML representation for the feed could not be created.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String outputString(final SyndFeed feed, final boolean prettyPrint) throws FeedException {
|
public String outputString(final SyndFeed feed, final boolean prettyPrint) throws FeedException {
|
||||||
return feedOutput.outputString(feed.createWireFeed(), prettyPrint);
|
return feedOutput.outputString(feed.createWireFeed(), prettyPrint);
|
||||||
|
@ -91,13 +83,13 @@ public class SyndFeedOutput {
|
||||||
* responsibility of the developer to ensure the feed encoding is set to the platform charset
|
* responsibility of the developer to ensure the feed encoding is set to the platform charset
|
||||||
* encoding.
|
* encoding.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param feed Abstract feed to create XML representation from. The type of the SyndFeedImpl
|
* @param feed Abstract feed to create XML representation from. The type of the SyndFeedImpl
|
||||||
* must match the type given to the FeedOuptut constructor.
|
* must match the type given to the FeedOuptut constructor.
|
||||||
* @param file the file where to write the XML representation for the given SyndFeedImpl.
|
* @param file the file where to write the XML representation for the given SyndFeedImpl.
|
||||||
* @throws IOException thrown if there was some problem writing to the File.
|
* @throws IOException thrown if there was some problem writing to the File.
|
||||||
* @throws FeedException thrown if the XML representation for the feed could not be created.
|
* @throws FeedException thrown if the XML representation for the feed could not be created.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void output(final SyndFeed feed, final File file) throws IOException, FeedException {
|
public void output(final SyndFeed feed, final File file) throws IOException, FeedException {
|
||||||
feedOutput.output(feed.createWireFeed(), file);
|
feedOutput.output(feed.createWireFeed(), file);
|
||||||
|
@ -111,14 +103,14 @@ public class SyndFeedOutput {
|
||||||
* responsibility of the developer to ensure the feed encoding is set to the platform charset
|
* responsibility of the developer to ensure the feed encoding is set to the platform charset
|
||||||
* encoding.
|
* encoding.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param feed Abstract feed to create XML representation from. The type of the SyndFeedImpl
|
* @param feed Abstract feed to create XML representation from. The type of the SyndFeedImpl
|
||||||
* must match the type given to the FeedOuptut constructor.
|
* must match the type given to the FeedOuptut constructor.
|
||||||
* @param prettyPrint pretty-print XML (true) oder collapsed
|
* @param prettyPrint pretty-print XML (true) oder collapsed
|
||||||
* @param file the file where to write the XML representation for the given SyndFeedImpl.
|
* @param file the file where to write the XML representation for the given SyndFeedImpl.
|
||||||
* @throws IOException thrown if there was some problem writing to the File.
|
* @throws IOException thrown if there was some problem writing to the File.
|
||||||
* @throws FeedException thrown if the XML representation for the feed could not be created.
|
* @throws FeedException thrown if the XML representation for the feed could not be created.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void output(final SyndFeed feed, final File file, final boolean prettyPrint) throws IOException, FeedException {
|
public void output(final SyndFeed feed, final File file, final boolean prettyPrint) throws IOException, FeedException {
|
||||||
feedOutput.output(feed.createWireFeed(), file, prettyPrint);
|
feedOutput.output(feed.createWireFeed(), file, prettyPrint);
|
||||||
|
@ -131,13 +123,13 @@ public class SyndFeedOutput {
|
||||||
* the responsibility of the developer to ensure that if the String is written to a character
|
* the responsibility of the developer to ensure that if the String is written to a character
|
||||||
* stream the stream charset is the same as the feed encoding property.
|
* stream the stream charset is the same as the feed encoding property.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param feed Abstract feed to create XML representation from. The type of the SyndFeedImpl
|
* @param feed Abstract feed to create XML representation from. The type of the SyndFeedImpl
|
||||||
* must match the type given to the FeedOuptut constructor.
|
* must match the type given to the FeedOuptut constructor.
|
||||||
* @param writer Writer to write the XML representation for the given SyndFeedImpl.
|
* @param writer Writer to write the XML representation for the given SyndFeedImpl.
|
||||||
* @throws IOException thrown if there was some problem writing to the Writer.
|
* @throws IOException thrown if there was some problem writing to the Writer.
|
||||||
* @throws FeedException thrown if the XML representation for the feed could not be created.
|
* @throws FeedException thrown if the XML representation for the feed could not be created.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void output(final SyndFeed feed, final Writer writer) throws IOException, FeedException {
|
public void output(final SyndFeed feed, final Writer writer) throws IOException, FeedException {
|
||||||
feedOutput.output(feed.createWireFeed(), writer);
|
feedOutput.output(feed.createWireFeed(), writer);
|
||||||
|
@ -150,14 +142,14 @@ public class SyndFeedOutput {
|
||||||
* the responsibility of the developer to ensure that if the String is written to a character
|
* the responsibility of the developer to ensure that if the String is written to a character
|
||||||
* stream the stream charset is the same as the feed encoding property.
|
* stream the stream charset is the same as the feed encoding property.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param feed Abstract feed to create XML representation from. The type of the SyndFeedImpl
|
* @param feed Abstract feed to create XML representation from. The type of the SyndFeedImpl
|
||||||
* must match the type given to the FeedOuptut constructor.
|
* must match the type given to the FeedOuptut constructor.
|
||||||
* @param prettyPrint pretty-print XML (true) oder collapsed
|
* @param prettyPrint pretty-print XML (true) oder collapsed
|
||||||
* @param writer Writer to write the XML representation for the given SyndFeedImpl.
|
* @param writer Writer to write the XML representation for the given SyndFeedImpl.
|
||||||
* @throws IOException thrown if there was some problem writing to the Writer.
|
* @throws IOException thrown if there was some problem writing to the Writer.
|
||||||
* @throws FeedException thrown if the XML representation for the feed could not be created.
|
* @throws FeedException thrown if the XML representation for the feed could not be created.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void output(final SyndFeed feed, final Writer writer, final boolean prettyPrint) throws IOException, FeedException {
|
public void output(final SyndFeed feed, final Writer writer, final boolean prettyPrint) throws IOException, FeedException {
|
||||||
feedOutput.output(feed.createWireFeed(), writer, prettyPrint);
|
feedOutput.output(feed.createWireFeed(), writer, prettyPrint);
|
||||||
|
@ -168,12 +160,12 @@ public class SyndFeedOutput {
|
||||||
* <p>
|
* <p>
|
||||||
* This method does not use the feed encoding property.
|
* This method does not use the feed encoding property.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param feed Abstract feed to create W3C DOM document from. The type of the SyndFeedImpl must
|
* @param feed Abstract feed to create W3C DOM document from. The type of the SyndFeedImpl must
|
||||||
* match the type given to the FeedOuptut constructor.
|
* match the type given to the FeedOuptut constructor.
|
||||||
* @return the W3C DOM document for the given SyndFeedImpl.
|
* @return the W3C DOM document for the given SyndFeedImpl.
|
||||||
* @throws FeedException thrown if the W3C DOM document for the feed could not be created.
|
* @throws FeedException thrown if the W3C DOM document for the feed could not be created.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public org.w3c.dom.Document outputW3CDom(final SyndFeed feed) throws FeedException {
|
public org.w3c.dom.Document outputW3CDom(final SyndFeed feed) throws FeedException {
|
||||||
return feedOutput.outputW3CDom(feed.createWireFeed());
|
return feedOutput.outputW3CDom(feed.createWireFeed());
|
||||||
|
@ -184,12 +176,12 @@ public class SyndFeedOutput {
|
||||||
* <p>
|
* <p>
|
||||||
* This method does not use the feed encoding property.
|
* This method does not use the feed encoding property.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param feed Abstract feed to create JDOM document from. The type of the SyndFeedImpl must
|
* @param feed Abstract feed to create JDOM document from. The type of the SyndFeedImpl must
|
||||||
* match the type given to the FeedOuptut constructor.
|
* match the type given to the FeedOuptut constructor.
|
||||||
* @return the JDOM document for the given SyndFeedImpl.
|
* @return the JDOM document for the given SyndFeedImpl.
|
||||||
* @throws FeedException thrown if the JDOM document for the feed could not be created.
|
* @throws FeedException thrown if the JDOM document for the feed could not be created.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Document outputJDom(final SyndFeed feed) throws FeedException {
|
public Document outputJDom(final SyndFeed feed) throws FeedException {
|
||||||
return feedOutput.outputJDom(feed.createWireFeed());
|
return feedOutput.outputJDom(feed.createWireFeed());
|
||||||
|
|
|
@ -52,14 +52,22 @@ import com.sun.syndication.io.impl.XmlFixerReader;
|
||||||
* <p>
|
* <p>
|
||||||
* The WireFeedInput useds liberal parsers.
|
* The WireFeedInput useds liberal parsers.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class WireFeedInput {
|
public class WireFeedInput {
|
||||||
|
|
||||||
|
private static final InputSource EMPTY_INPUTSOURCE = new InputSource(new ByteArrayInputStream(new byte[0]));
|
||||||
|
private static final EntityResolver RESOLVER = new EmptyEntityResolver();
|
||||||
|
|
||||||
private static Map<ClassLoader, FeedParsers> clMap = new WeakHashMap<ClassLoader, FeedParsers>();
|
private static Map<ClassLoader, FeedParsers> clMap = new WeakHashMap<ClassLoader, FeedParsers>();
|
||||||
|
|
||||||
|
private final boolean validate;
|
||||||
|
private final Locale locale;
|
||||||
|
|
||||||
|
private boolean xmlHealerOn;
|
||||||
|
|
||||||
private static FeedParsers getFeedParsers() {
|
private static FeedParsers getFeedParsers() {
|
||||||
synchronized (WireFeedInput.class) {
|
synchronized (WireFeedInput.class) {
|
||||||
final ClassLoader classLoader = ConfigurableClassLoader.INSTANCE.getClassLoader();
|
final ClassLoader classLoader = ConfigurableClassLoader.INSTANCE.getClassLoader();
|
||||||
|
@ -72,9 +80,6 @@ public class WireFeedInput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final InputSource EMPTY_INPUTSOURCE = new InputSource(new ByteArrayInputStream(new byte[0]));
|
|
||||||
private static final EntityResolver RESOLVER = new EmptyEntityResolver();
|
|
||||||
|
|
||||||
private static class EmptyEntityResolver implements EntityResolver {
|
private static class EmptyEntityResolver implements EntityResolver {
|
||||||
@Override
|
@Override
|
||||||
public InputSource resolveEntity(final String publicId, final String systemId) {
|
public InputSource resolveEntity(final String publicId, final String systemId) {
|
||||||
|
@ -85,19 +90,14 @@ public class WireFeedInput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final boolean validate;
|
|
||||||
|
|
||||||
private boolean xmlHealerOn;
|
|
||||||
private final Locale locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of supported input feed types.
|
* Returns the list of supported input feed types.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @see WireFeed for details on the format of these strings.
|
* @see WireFeed for details on the format of these strings.
|
||||||
* <p>
|
* <p>
|
||||||
* @return a list of String elements with the supported input feed types.
|
* @return a list of String elements with the supported input feed types.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static List<String> getSupportedFeedTypes() {
|
public static List<String> getSupportedFeedTypes() {
|
||||||
return getFeedParsers().getSupportedFeedTypes();
|
return getFeedParsers().getSupportedFeedTypes();
|
||||||
|
@ -106,7 +106,7 @@ public class WireFeedInput {
|
||||||
/**
|
/**
|
||||||
* Creates a WireFeedInput instance with input validation turned off.
|
* Creates a WireFeedInput instance with input validation turned off.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public WireFeedInput() {
|
public WireFeedInput() {
|
||||||
this(false, Locale.US);
|
this(false, Locale.US);
|
||||||
|
@ -115,10 +115,10 @@ public class WireFeedInput {
|
||||||
/**
|
/**
|
||||||
* Creates a WireFeedInput instance.
|
* Creates a WireFeedInput instance.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param validate indicates if the input should be validated. NOT IMPLEMENTED YET (validation
|
* @param validate indicates if the input should be validated. NOT IMPLEMENTED YET (validation
|
||||||
* does not happen)
|
* does not happen)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public WireFeedInput(final boolean validate, final Locale locale) {
|
public WireFeedInput(final boolean validate, final Locale locale) {
|
||||||
this.validate = false; // TODO FIX THIS THINGY
|
this.validate = false; // TODO FIX THIS THINGY
|
||||||
|
@ -137,9 +137,9 @@ public class WireFeedInput {
|
||||||
* <p>
|
* <p>
|
||||||
* By default is TRUE.
|
* By default is TRUE.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param heals TRUE enables stream healing, FALSE disables it.
|
* @param heals TRUE enables stream healing, FALSE disables it.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setXmlHealerOn(final boolean heals) {
|
public void setXmlHealerOn(final boolean heals) {
|
||||||
xmlHealerOn = heals;
|
xmlHealerOn = heals;
|
||||||
|
@ -156,9 +156,9 @@ public class WireFeedInput {
|
||||||
* <p>
|
* <p>
|
||||||
* By default is TRUE.
|
* By default is TRUE.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @return TRUE if healing is enabled, FALSE if not.
|
* @return TRUE if healing is enabled, FALSE if not.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public boolean getXmlHealerOn() {
|
public boolean getXmlHealerOn() {
|
||||||
return xmlHealerOn;
|
return xmlHealerOn;
|
||||||
|
@ -169,7 +169,7 @@ public class WireFeedInput {
|
||||||
* <p>
|
* <p>
|
||||||
* NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
|
* NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param file file to read to create the WireFeed.
|
* @param file file to read to create the WireFeed.
|
||||||
* @return the WireFeed read from the file.
|
* @return the WireFeed read from the file.
|
||||||
* @throws FileNotFoundException thrown if the file could not be found.
|
* @throws FileNotFoundException thrown if the file could not be found.
|
||||||
|
@ -177,7 +177,7 @@ public class WireFeedInput {
|
||||||
* @throws IllegalArgumentException thrown if feed type could not be understood by any of the
|
* @throws IllegalArgumentException thrown if feed type could not be understood by any of the
|
||||||
* underlying parsers.
|
* underlying parsers.
|
||||||
* @throws FeedException if the feed could not be parsed
|
* @throws FeedException if the feed could not be parsed
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public WireFeed build(final File file) throws FileNotFoundException, IOException, IllegalArgumentException, FeedException {
|
public WireFeed build(final File file) throws FileNotFoundException, IOException, IllegalArgumentException, FeedException {
|
||||||
WireFeed feed;
|
WireFeed feed;
|
||||||
|
@ -195,13 +195,13 @@ public class WireFeedInput {
|
||||||
* <p>
|
* <p>
|
||||||
* NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
|
* NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param reader Reader to read to create the WireFeed.
|
* @param reader Reader to read to create the WireFeed.
|
||||||
* @return the WireFeed read from the Reader.
|
* @return the WireFeed read from the Reader.
|
||||||
* @throws IllegalArgumentException thrown if feed type could not be understood by any of the
|
* @throws IllegalArgumentException thrown if feed type could not be understood by any of the
|
||||||
* underlying parsers.
|
* underlying parsers.
|
||||||
* @throws FeedException if the feed could not be parsed
|
* @throws FeedException if the feed could not be parsed
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public WireFeed build(Reader reader) throws IllegalArgumentException, FeedException {
|
public WireFeed build(Reader reader) throws IllegalArgumentException, FeedException {
|
||||||
final SAXBuilder saxBuilder = createSAXBuilder();
|
final SAXBuilder saxBuilder = createSAXBuilder();
|
||||||
|
@ -225,13 +225,13 @@ public class WireFeedInput {
|
||||||
* <p>
|
* <p>
|
||||||
* NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
|
* NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param is W3C SAX InputSource to read to create the WireFeed.
|
* @param is W3C SAX InputSource to read to create the WireFeed.
|
||||||
* @return the WireFeed read from the W3C SAX InputSource.
|
* @return the WireFeed read from the W3C SAX InputSource.
|
||||||
* @throws IllegalArgumentException thrown if feed type could not be understood by any of the
|
* @throws IllegalArgumentException thrown if feed type could not be understood by any of the
|
||||||
* underlying parsers.
|
* underlying parsers.
|
||||||
* @throws FeedException if the feed could not be parsed
|
* @throws FeedException if the feed could not be parsed
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public WireFeed build(final InputSource is) throws IllegalArgumentException, FeedException {
|
public WireFeed build(final InputSource is) throws IllegalArgumentException, FeedException {
|
||||||
final SAXBuilder saxBuilder = createSAXBuilder();
|
final SAXBuilder saxBuilder = createSAXBuilder();
|
||||||
|
@ -252,13 +252,13 @@ public class WireFeedInput {
|
||||||
* <p>
|
* <p>
|
||||||
* NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
|
* NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param document W3C DOM document to read to create the WireFeed.
|
* @param document W3C DOM document to read to create the WireFeed.
|
||||||
* @return the WireFeed read from the W3C DOM document.
|
* @return the WireFeed read from the W3C DOM document.
|
||||||
* @throws IllegalArgumentException thrown if feed type could not be understood by any of the
|
* @throws IllegalArgumentException thrown if feed type could not be understood by any of the
|
||||||
* underlying parsers.
|
* underlying parsers.
|
||||||
* @throws FeedException if the feed could not be parsed
|
* @throws FeedException if the feed could not be parsed
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public WireFeed build(final org.w3c.dom.Document document) throws IllegalArgumentException, FeedException {
|
public WireFeed build(final org.w3c.dom.Document document) throws IllegalArgumentException, FeedException {
|
||||||
final DOMBuilder domBuilder = new DOMBuilder();
|
final DOMBuilder domBuilder = new DOMBuilder();
|
||||||
|
@ -277,13 +277,13 @@ public class WireFeedInput {
|
||||||
* <p>
|
* <p>
|
||||||
* NOTE: All other build methods delegate to this method.
|
* NOTE: All other build methods delegate to this method.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param document JDOM document to read to create the WireFeed.
|
* @param document JDOM document to read to create the WireFeed.
|
||||||
* @return the WireFeed read from the JDOM document.
|
* @return the WireFeed read from the JDOM document.
|
||||||
* @throws IllegalArgumentException thrown if feed type could not be understood by any of the
|
* @throws IllegalArgumentException thrown if feed type could not be understood by any of the
|
||||||
* underlying parsers.
|
* underlying parsers.
|
||||||
* @throws FeedException if the feed could not be parsed
|
* @throws FeedException if the feed could not be parsed
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public WireFeed build(final Document document) throws IllegalArgumentException, FeedException {
|
public WireFeed build(final Document document) throws IllegalArgumentException, FeedException {
|
||||||
final WireFeedParser parser = getFeedParsers().getParserFor(document);
|
final WireFeedParser parser = getFeedParsers().getParserFor(document);
|
||||||
|
@ -295,7 +295,7 @@ public class WireFeedInput {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and sets up a org.jdom2.input.SAXBuilder for parsing.
|
* Creates and sets up a org.jdom2.input.SAXBuilder for parsing.
|
||||||
*
|
*
|
||||||
* @return a new org.jdom2.input.SAXBuilder object
|
* @return a new org.jdom2.input.SAXBuilder object
|
||||||
*/
|
*/
|
||||||
protected SAXBuilder createSAXBuilder() {
|
protected SAXBuilder createSAXBuilder() {
|
||||||
|
@ -357,4 +357,5 @@ public class WireFeedInput {
|
||||||
saxBuilder.setExpandEntities(false);
|
saxBuilder.setExpandEntities(false);
|
||||||
return saxBuilder;
|
return saxBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package com.sun.syndication.io.impl;
|
package com.sun.syndication.io.impl;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ import org.jdom2.Element;
|
||||||
import org.jdom2.Namespace;
|
import org.jdom2.Namespace;
|
||||||
import org.jdom2.input.SAXBuilder;
|
import org.jdom2.input.SAXBuilder;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.atom.Content;
|
import com.sun.syndication.feed.atom.Content;
|
||||||
import com.sun.syndication.feed.atom.Entry;
|
import com.sun.syndication.feed.atom.Entry;
|
||||||
|
@ -44,6 +46,7 @@ import com.sun.syndication.io.FeedException;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Atom03Generator extends BaseWireFeedGenerator {
|
public class Atom03Generator extends BaseWireFeedGenerator {
|
||||||
|
|
||||||
private static final String ATOM_03_URI = "http://purl.org/atom/ns#";
|
private static final String ATOM_03_URI = "http://purl.org/atom/ns#";
|
||||||
private static final Namespace ATOM_NS = Namespace.getNamespace(ATOM_03_URI);
|
private static final Namespace ATOM_NS = Namespace.getNamespace(ATOM_03_URI);
|
||||||
|
|
||||||
|
@ -102,9 +105,9 @@ public class Atom03Generator extends BaseWireFeedGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addEntries(final Feed feed, final Element parent) throws FeedException {
|
protected void addEntries(final Feed feed, final Element parent) throws FeedException {
|
||||||
final List<Entry> items = feed.getEntries();
|
final List<Entry> entries = feed.getEntries();
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (final Entry entry : entries) {
|
||||||
addEntry(items.get(i), parent);
|
addEntry(entry, parent);
|
||||||
}
|
}
|
||||||
checkEntriesConstraints(parent);
|
checkEntriesConstraints(parent);
|
||||||
}
|
}
|
||||||
|
@ -118,129 +121,151 @@ public class Atom03Generator extends BaseWireFeedGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void populateFeedHeader(final Feed feed, final Element eFeed) throws FeedException {
|
protected void populateFeedHeader(final Feed feed, final Element eFeed) throws FeedException {
|
||||||
if (feed.getTitleEx() != null) {
|
|
||||||
|
final Content titleEx = feed.getTitleEx();
|
||||||
|
if (titleEx != null) {
|
||||||
final Element titleElement = new Element("title", getFeedNamespace());
|
final Element titleElement = new Element("title", getFeedNamespace());
|
||||||
fillContentElement(titleElement, feed.getTitleEx());
|
fillContentElement(titleElement, titleEx);
|
||||||
eFeed.addContent(titleElement);
|
eFeed.addContent(titleElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Link> links = feed.getAlternateLinks();
|
List<Link> links = feed.getAlternateLinks();
|
||||||
for (int i = 0; i < links.size(); i++) {
|
for (final Link link : links) {
|
||||||
eFeed.addContent(generateLinkElement(links.get(i)));
|
eFeed.addContent(generateLinkElement(link));
|
||||||
}
|
}
|
||||||
|
|
||||||
links = feed.getOtherLinks();
|
links = feed.getOtherLinks();
|
||||||
for (int i = 0; i < links.size(); i++) {
|
for (final Link link : links) {
|
||||||
eFeed.addContent(generateLinkElement(links.get(i)));
|
eFeed.addContent(generateLinkElement(link));
|
||||||
}
|
}
|
||||||
if (feed.getAuthors() != null && !feed.getAuthors().isEmpty()) {
|
|
||||||
|
final List<SyndPerson> authors = feed.getAuthors();
|
||||||
|
if (Lists.isNotEmpty(authors)) {
|
||||||
final Element authorElement = new Element("author", getFeedNamespace());
|
final Element authorElement = new Element("author", getFeedNamespace());
|
||||||
fillPersonElement(authorElement, feed.getAuthors().get(0));
|
fillPersonElement(authorElement, authors.get(0));
|
||||||
eFeed.addContent(authorElement);
|
eFeed.addContent(authorElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> contributors = feed.getContributors();
|
final List<SyndPerson> contributors = feed.getContributors();
|
||||||
for (int i = 0; i < contributors.size(); i++) {
|
for (final SyndPerson contributor : contributors) {
|
||||||
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
||||||
fillPersonElement(contributorElement, contributors.get(i));
|
fillPersonElement(contributorElement, contributor);
|
||||||
eFeed.addContent(contributorElement);
|
eFeed.addContent(contributorElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getTagline() != null) {
|
final Content tagline = feed.getTagline();
|
||||||
|
if (tagline != null) {
|
||||||
final Element taglineElement = new Element("tagline", getFeedNamespace());
|
final Element taglineElement = new Element("tagline", getFeedNamespace());
|
||||||
fillContentElement(taglineElement, feed.getTagline());
|
fillContentElement(taglineElement, tagline);
|
||||||
eFeed.addContent(taglineElement);
|
eFeed.addContent(taglineElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getId() != null) {
|
final String id = feed.getId();
|
||||||
eFeed.addContent(generateSimpleElement("id", feed.getId()));
|
if (id != null) {
|
||||||
|
eFeed.addContent(generateSimpleElement("id", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getGenerator() != null) {
|
final Generator generator = feed.getGenerator();
|
||||||
eFeed.addContent(generateGeneratorElement(feed.getGenerator()));
|
if (generator != null) {
|
||||||
|
eFeed.addContent(generateGeneratorElement(generator));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getCopyright() != null) {
|
final String copyright = feed.getCopyright();
|
||||||
eFeed.addContent(generateSimpleElement("copyright", feed.getCopyright()));
|
if (copyright != null) {
|
||||||
|
eFeed.addContent(generateSimpleElement("copyright", copyright));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getInfo() != null) {
|
final Content info = feed.getInfo();
|
||||||
|
if (info != null) {
|
||||||
final Element infoElement = new Element("info", getFeedNamespace());
|
final Element infoElement = new Element("info", getFeedNamespace());
|
||||||
fillContentElement(infoElement, feed.getInfo());
|
fillContentElement(infoElement, info);
|
||||||
eFeed.addContent(infoElement);
|
eFeed.addContent(infoElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getModified() != null) {
|
final Date modified = feed.getModified();
|
||||||
|
if (modified != null) {
|
||||||
final Element modifiedElement = new Element("modified", getFeedNamespace());
|
final Element modifiedElement = new Element("modified", getFeedNamespace());
|
||||||
modifiedElement.addContent(DateParser.formatW3CDateTime(feed.getModified(), Locale.US));
|
modifiedElement.addContent(DateParser.formatW3CDateTime(modified, Locale.US));
|
||||||
eFeed.addContent(modifiedElement);
|
eFeed.addContent(modifiedElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void populateEntry(final Entry entry, final Element eEntry) throws FeedException {
|
protected void populateEntry(final Entry entry, final Element eEntry) throws FeedException {
|
||||||
if (entry.getTitleEx() != null) {
|
|
||||||
|
final Content titleEx = entry.getTitleEx();
|
||||||
|
if (titleEx != null) {
|
||||||
final Element titleElement = new Element("title", getFeedNamespace());
|
final Element titleElement = new Element("title", getFeedNamespace());
|
||||||
fillContentElement(titleElement, entry.getTitleEx());
|
fillContentElement(titleElement, titleEx);
|
||||||
eEntry.addContent(titleElement);
|
eEntry.addContent(titleElement);
|
||||||
}
|
}
|
||||||
List<Link> links = entry.getAlternateLinks();
|
|
||||||
for (int i = 0; i < links.size(); i++) {
|
final List<Link> alternateLinks = entry.getAlternateLinks();
|
||||||
eEntry.addContent(generateLinkElement(links.get(i)));
|
for (final Link link : alternateLinks) {
|
||||||
|
eEntry.addContent(generateLinkElement(link));
|
||||||
}
|
}
|
||||||
|
|
||||||
links = entry.getOtherLinks();
|
final List<Link> otherLinks = entry.getOtherLinks();
|
||||||
for (int i = 0; i < links.size(); i++) {
|
for (final Link link : otherLinks) {
|
||||||
eEntry.addContent(generateLinkElement(links.get(i)));
|
eEntry.addContent(generateLinkElement(link));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getAuthors() != null && !entry.getAuthors().isEmpty()) {
|
final List<SyndPerson> authors = entry.getAuthors();
|
||||||
|
if (Lists.isNotEmpty(authors)) {
|
||||||
final Element authorElement = new Element("author", getFeedNamespace());
|
final Element authorElement = new Element("author", getFeedNamespace());
|
||||||
fillPersonElement(authorElement, entry.getAuthors().get(0));
|
fillPersonElement(authorElement, authors.get(0));
|
||||||
eEntry.addContent(authorElement);
|
eEntry.addContent(authorElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> contributors = entry.getContributors();
|
final List<SyndPerson> contributors = entry.getContributors();
|
||||||
for (int i = 0; i < contributors.size(); i++) {
|
for (final SyndPerson contributor : contributors) {
|
||||||
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
||||||
fillPersonElement(contributorElement, contributors.get(i));
|
fillPersonElement(contributorElement, contributor);
|
||||||
eEntry.addContent(contributorElement);
|
eEntry.addContent(contributorElement);
|
||||||
}
|
}
|
||||||
if (entry.getId() != null) {
|
|
||||||
eEntry.addContent(generateSimpleElement("id", entry.getId()));
|
final String id = entry.getId();
|
||||||
|
if (id != null) {
|
||||||
|
eEntry.addContent(generateSimpleElement("id", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getModified() != null) {
|
final Date modified = entry.getModified();
|
||||||
|
if (modified != null) {
|
||||||
final Element modifiedElement = new Element("modified", getFeedNamespace());
|
final Element modifiedElement = new Element("modified", getFeedNamespace());
|
||||||
modifiedElement.addContent(DateParser.formatW3CDateTime(entry.getModified(), Locale.US));
|
modifiedElement.addContent(DateParser.formatW3CDateTime(modified, Locale.US));
|
||||||
eEntry.addContent(modifiedElement);
|
eEntry.addContent(modifiedElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getIssued() != null) {
|
final Date issued = entry.getIssued();
|
||||||
|
if (issued != null) {
|
||||||
final Element issuedElement = new Element("issued", getFeedNamespace());
|
final Element issuedElement = new Element("issued", getFeedNamespace());
|
||||||
issuedElement.addContent(DateParser.formatW3CDateTime(entry.getIssued(), Locale.US));
|
issuedElement.addContent(DateParser.formatW3CDateTime(issued, Locale.US));
|
||||||
eEntry.addContent(issuedElement);
|
eEntry.addContent(issuedElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getCreated() != null) {
|
final Date created = entry.getCreated();
|
||||||
|
if (created != null) {
|
||||||
final Element createdElement = new Element("created", getFeedNamespace());
|
final Element createdElement = new Element("created", getFeedNamespace());
|
||||||
createdElement.addContent(DateParser.formatW3CDateTime(entry.getCreated(), Locale.US));
|
createdElement.addContent(DateParser.formatW3CDateTime(created, Locale.US));
|
||||||
eEntry.addContent(createdElement);
|
eEntry.addContent(createdElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getSummary() != null) {
|
final Content summary = entry.getSummary();
|
||||||
|
if (summary != null) {
|
||||||
final Element summaryElement = new Element("summary", getFeedNamespace());
|
final Element summaryElement = new Element("summary", getFeedNamespace());
|
||||||
fillContentElement(summaryElement, entry.getSummary());
|
fillContentElement(summaryElement, summary);
|
||||||
eEntry.addContent(summaryElement);
|
eEntry.addContent(summaryElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Content> contents = entry.getContents();
|
final List<Content> contents = entry.getContents();
|
||||||
for (int i = 0; i < contents.size(); i++) {
|
for (final Content content : contents) {
|
||||||
final Element contentElement = new Element("content", getFeedNamespace());
|
final Element contentElement = new Element("content", getFeedNamespace());
|
||||||
fillContentElement(contentElement, contents.get(i));
|
fillContentElement(contentElement, content);
|
||||||
eEntry.addContent(contentElement);
|
eEntry.addContent(contentElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
generateForeignMarkup(eEntry, entry.getForeignMarkup());
|
generateForeignMarkup(eEntry, entry.getForeignMarkup());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkFeedHeaderConstraints(final Element eFeed) throws FeedException {
|
protected void checkFeedHeaderConstraints(final Element eFeed) throws FeedException {
|
||||||
|
@ -253,75 +278,98 @@ public class Atom03Generator extends BaseWireFeedGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateLinkElement(final Link link) {
|
protected Element generateLinkElement(final Link link) {
|
||||||
|
|
||||||
final Element linkElement = new Element("link", getFeedNamespace());
|
final Element linkElement = new Element("link", getFeedNamespace());
|
||||||
|
|
||||||
if (link.getRel() != null) {
|
final String rel = link.getRel();
|
||||||
final Attribute relAttribute = new Attribute("rel", link.getRel().toString());
|
if (rel != null) {
|
||||||
|
final Attribute relAttribute = new Attribute("rel", rel.toString());
|
||||||
linkElement.setAttribute(relAttribute);
|
linkElement.setAttribute(relAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link.getType() != null) {
|
final String type = link.getType();
|
||||||
final Attribute typeAttribute = new Attribute("type", link.getType());
|
if (type != null) {
|
||||||
|
final Attribute typeAttribute = new Attribute("type", type);
|
||||||
linkElement.setAttribute(typeAttribute);
|
linkElement.setAttribute(typeAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link.getHref() != null) {
|
final String href = link.getHref();
|
||||||
final Attribute hrefAttribute = new Attribute("href", link.getHref());
|
if (href != null) {
|
||||||
|
final Attribute hrefAttribute = new Attribute("href", href);
|
||||||
linkElement.setAttribute(hrefAttribute);
|
linkElement.setAttribute(hrefAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
return linkElement;
|
return linkElement;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fillPersonElement(final Element element, final SyndPerson person) {
|
protected void fillPersonElement(final Element element, final SyndPerson person) {
|
||||||
if (person.getName() != null) {
|
|
||||||
element.addContent(generateSimpleElement("name", person.getName()));
|
final String name = person.getName();
|
||||||
}
|
if (name != null) {
|
||||||
if (person.getUri() != null) {
|
element.addContent(generateSimpleElement("name", name));
|
||||||
element.addContent(generateSimpleElement("url", person.getUri()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (person.getEmail() != null) {
|
final String uri = person.getUri();
|
||||||
element.addContent(generateSimpleElement("email", person.getEmail()));
|
if (uri != null) {
|
||||||
|
element.addContent(generateSimpleElement("url", uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String email = person.getEmail();
|
||||||
|
if (email != null) {
|
||||||
|
element.addContent(generateSimpleElement("email", email));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateTagLineElement(final Content tagline) {
|
protected Element generateTagLineElement(final Content tagline) {
|
||||||
|
|
||||||
final Element taglineElement = new Element("tagline", getFeedNamespace());
|
final Element taglineElement = new Element("tagline", getFeedNamespace());
|
||||||
|
|
||||||
if (tagline.getType() != null) {
|
final String type = tagline.getType();
|
||||||
final Attribute typeAttribute = new Attribute("type", tagline.getType());
|
if (type != null) {
|
||||||
|
final Attribute typeAttribute = new Attribute("type", type);
|
||||||
taglineElement.setAttribute(typeAttribute);
|
taglineElement.setAttribute(typeAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tagline.getValue() != null) {
|
final String value = tagline.getValue();
|
||||||
taglineElement.addContent(tagline.getValue());
|
if (value != null) {
|
||||||
|
taglineElement.addContent(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return taglineElement;
|
return taglineElement;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fillContentElement(final Element contentElement, final Content content) throws FeedException {
|
protected void fillContentElement(final Element contentElement, final Content content) throws FeedException {
|
||||||
|
|
||||||
if (content.getType() != null) {
|
final String type = content.getType();
|
||||||
final Attribute typeAttribute = new Attribute("type", content.getType());
|
if (type != null) {
|
||||||
|
final Attribute typeAttribute = new Attribute("type", type);
|
||||||
contentElement.setAttribute(typeAttribute);
|
contentElement.setAttribute(typeAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String mode = content.getMode();
|
final String mode = content.getMode();
|
||||||
if (mode != null) {
|
if (mode != null) {
|
||||||
final Attribute modeAttribute = new Attribute("mode", content.getMode().toString());
|
final Attribute modeAttribute = new Attribute("mode", mode.toString());
|
||||||
contentElement.setAttribute(modeAttribute);
|
contentElement.setAttribute(modeAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content.getValue() != null) {
|
final String value = content.getValue();
|
||||||
|
if (value != null) {
|
||||||
|
|
||||||
if (mode == null || mode.equals(Content.ESCAPED)) {
|
if (mode == null || mode.equals(Content.ESCAPED)) {
|
||||||
contentElement.addContent(content.getValue());
|
|
||||||
|
contentElement.addContent(value);
|
||||||
|
|
||||||
} else if (mode.equals(Content.BASE64)) {
|
} else if (mode.equals(Content.BASE64)) {
|
||||||
contentElement.addContent(Base64.encode(content.getValue()));
|
|
||||||
|
contentElement.addContent(Base64.encode(value));
|
||||||
|
|
||||||
} else if (mode.equals(Content.XML)) {
|
} else if (mode.equals(Content.XML)) {
|
||||||
|
|
||||||
final StringBuffer tmpDocString = new StringBuffer("<tmpdoc>");
|
final StringBuffer tmpDocString = new StringBuffer("<tmpdoc>");
|
||||||
tmpDocString.append(content.getValue());
|
tmpDocString.append(value);
|
||||||
tmpDocString.append("</tmpdoc>");
|
tmpDocString.append("</tmpdoc>");
|
||||||
final StringReader tmpDocReader = new StringReader(tmpDocString.toString());
|
final StringReader tmpDocReader = new StringReader(tmpDocString.toString());
|
||||||
Document tmpDoc;
|
Document tmpDoc;
|
||||||
|
@ -336,24 +384,29 @@ public class Atom03Generator extends BaseWireFeedGenerator {
|
||||||
final List<org.jdom2.Content> children = tmpDoc.getRootElement().removeContent();
|
final List<org.jdom2.Content> children = tmpDoc.getRootElement().removeContent();
|
||||||
contentElement.addContent(children);
|
contentElement.addContent(children);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateGeneratorElement(final Generator generator) {
|
protected Element generateGeneratorElement(final Generator generator) {
|
||||||
|
|
||||||
final Element generatorElement = new Element("generator", getFeedNamespace());
|
final Element generatorElement = new Element("generator", getFeedNamespace());
|
||||||
|
|
||||||
if (generator.getUrl() != null) {
|
final String url = generator.getUrl();
|
||||||
final Attribute urlAttribute = new Attribute("url", generator.getUrl());
|
if (url != null) {
|
||||||
|
final Attribute urlAttribute = new Attribute("url", url);
|
||||||
generatorElement.setAttribute(urlAttribute);
|
generatorElement.setAttribute(urlAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (generator.getVersion() != null) {
|
final String version = generator.getVersion();
|
||||||
final Attribute versionAttribute = new Attribute("version", generator.getVersion());
|
if (version != null) {
|
||||||
|
final Attribute versionAttribute = new Attribute("version", version);
|
||||||
generatorElement.setAttribute(versionAttribute);
|
generatorElement.setAttribute(versionAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (generator.getValue() != null) {
|
final String value = generator.getValue();
|
||||||
generatorElement.addContent(generator.getValue());
|
if (value != null) {
|
||||||
|
generatorElement.addContent(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return generatorElement;
|
return generatorElement;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.jdom2.Element;
|
||||||
import org.jdom2.Namespace;
|
import org.jdom2.Namespace;
|
||||||
import org.jdom2.output.XMLOutputter;
|
import org.jdom2.output.XMLOutputter;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.atom.Content;
|
import com.sun.syndication.feed.atom.Content;
|
||||||
import com.sun.syndication.feed.atom.Entry;
|
import com.sun.syndication.feed.atom.Entry;
|
||||||
|
@ -35,9 +36,8 @@ import com.sun.syndication.feed.atom.Person;
|
||||||
import com.sun.syndication.feed.synd.SyndPerson;
|
import com.sun.syndication.feed.synd.SyndPerson;
|
||||||
import com.sun.syndication.io.FeedException;
|
import com.sun.syndication.io.FeedException;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class Atom03Parser extends BaseWireFeedParser {
|
public class Atom03Parser extends BaseWireFeedParser {
|
||||||
|
|
||||||
private static final String ATOM_03_URI = "http://purl.org/atom/ns#";
|
private static final String ATOM_03_URI = "http://purl.org/atom/ns#";
|
||||||
private static final Namespace ATOM_03_NS = Namespace.getNamespace(ATOM_03_URI);
|
private static final Namespace ATOM_03_NS = Namespace.getNamespace(ATOM_03_URI);
|
||||||
|
|
||||||
|
@ -62,125 +62,137 @@ public class Atom03Parser extends BaseWireFeedParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WireFeed parse(final Document document, final boolean validate, final Locale locale) throws IllegalArgumentException, FeedException {
|
public WireFeed parse(final Document document, final boolean validate, final Locale locale) throws IllegalArgumentException, FeedException {
|
||||||
|
|
||||||
if (validate) {
|
if (validate) {
|
||||||
validateFeed(document);
|
validateFeed(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Element rssRoot = document.getRootElement();
|
final Element rssRoot = document.getRootElement();
|
||||||
|
|
||||||
return parseFeed(rssRoot, locale);
|
return parseFeed(rssRoot, locale);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void validateFeed(final Document document) throws FeedException {
|
protected void validateFeed(final Document document) throws FeedException {
|
||||||
// TBD
|
// TODO here we have to validate the Feed against a schema or whatever not sure how to do it
|
||||||
// here we have to validate the Feed against a schema or whatever
|
// one posibility would be to produce an ouput and attempt to parse it again with validation
|
||||||
// not sure how to do it
|
// turned on. otherwise will have to check the document elements by hand.
|
||||||
// one posibility would be to produce an ouput and attempt to parse it
|
|
||||||
// again
|
|
||||||
// with validation turned on.
|
|
||||||
// otherwise will have to check the document elements by hand.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WireFeed parseFeed(final Element eFeed, final Locale locale) {
|
protected WireFeed parseFeed(final Element eFeed, final Locale locale) {
|
||||||
|
|
||||||
final Feed feed = new Feed(getType());
|
final String type = getType();
|
||||||
feed.setStyleSheet(getStyleSheet(eFeed.getDocument()));
|
final Document document = eFeed.getDocument();
|
||||||
|
final String styleSheet = getStyleSheet(document);
|
||||||
|
|
||||||
Element e = eFeed.getChild("title", getAtomNamespace());
|
final Feed feed = new Feed(type);
|
||||||
if (e != null) {
|
feed.setStyleSheet(styleSheet);
|
||||||
feed.setTitleEx(parseContent(e));
|
|
||||||
|
final Element title = eFeed.getChild("title", getAtomNamespace());
|
||||||
|
if (title != null) {
|
||||||
|
feed.setTitleEx(parseContent(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Element> eList = eFeed.getChildren("link", getAtomNamespace());
|
final List<Element> links = eFeed.getChildren("link", getAtomNamespace());
|
||||||
feed.setAlternateLinks(parseAlternateLinks(eList));
|
feed.setAlternateLinks(parseAlternateLinks(links));
|
||||||
feed.setOtherLinks(parseOtherLinks(eList));
|
feed.setOtherLinks(parseOtherLinks(links));
|
||||||
|
|
||||||
e = eFeed.getChild("author", getAtomNamespace());
|
final Element author = eFeed.getChild("author", getAtomNamespace());
|
||||||
if (e != null) {
|
if (author != null) {
|
||||||
final List<SyndPerson> authors = new ArrayList<SyndPerson>();
|
final List<SyndPerson> authors = new ArrayList<SyndPerson>();
|
||||||
authors.add(parsePerson(e));
|
authors.add(parsePerson(author));
|
||||||
feed.setAuthors(authors);
|
feed.setAuthors(authors);
|
||||||
}
|
}
|
||||||
|
|
||||||
eList = eFeed.getChildren("contributor", getAtomNamespace());
|
final List<Element> contributors = eFeed.getChildren("contributor", getAtomNamespace());
|
||||||
if (!eList.isEmpty()) {
|
if (!contributors.isEmpty()) {
|
||||||
feed.setContributors(parsePersons(eList));
|
feed.setContributors(parsePersons(contributors));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("tagline", getAtomNamespace());
|
final Element tagline = eFeed.getChild("tagline", getAtomNamespace());
|
||||||
if (e != null) {
|
if (tagline != null) {
|
||||||
feed.setTagline(parseContent(e));
|
feed.setTagline(parseContent(tagline));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("id", getAtomNamespace());
|
final Element id = eFeed.getChild("id", getAtomNamespace());
|
||||||
if (e != null) {
|
if (id != null) {
|
||||||
feed.setId(e.getText());
|
feed.setId(id.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("generator", getAtomNamespace());
|
final Element generator = eFeed.getChild("generator", getAtomNamespace());
|
||||||
if (e != null) {
|
if (generator != null) {
|
||||||
final Generator gen = new Generator();
|
final Generator gen = new Generator();
|
||||||
gen.setValue(e.getText());
|
gen.setValue(generator.getText());
|
||||||
String att = getAttributeValue(e, "url");
|
String att = getAttributeValue(generator, "url");
|
||||||
if (att != null) {
|
if (att != null) {
|
||||||
gen.setUrl(att);
|
gen.setUrl(att);
|
||||||
}
|
}
|
||||||
att = getAttributeValue(e, "version");
|
att = getAttributeValue(generator, "version");
|
||||||
if (att != null) {
|
if (att != null) {
|
||||||
gen.setVersion(att);
|
gen.setVersion(att);
|
||||||
}
|
}
|
||||||
feed.setGenerator(gen);
|
feed.setGenerator(gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("copyright", getAtomNamespace());
|
final Element copyright = eFeed.getChild("copyright", getAtomNamespace());
|
||||||
if (e != null) {
|
if (copyright != null) {
|
||||||
feed.setCopyright(e.getText());
|
feed.setCopyright(copyright.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("info", getAtomNamespace());
|
final Element info = eFeed.getChild("info", getAtomNamespace());
|
||||||
if (e != null) {
|
if (info != null) {
|
||||||
feed.setInfo(parseContent(e));
|
feed.setInfo(parseContent(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("modified", getAtomNamespace());
|
final Element modified = eFeed.getChild("modified", getAtomNamespace());
|
||||||
if (e != null) {
|
if (modified != null) {
|
||||||
feed.setModified(DateParser.parseDate(e.getText(), locale));
|
feed.setModified(DateParser.parseDate(modified.getText(), locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
feed.setModules(parseFeedModules(eFeed, locale));
|
feed.setModules(parseFeedModules(eFeed, locale));
|
||||||
|
|
||||||
eList = eFeed.getChildren("entry", getAtomNamespace());
|
final List<Element> entries = eFeed.getChildren("entry", getAtomNamespace());
|
||||||
if (!eList.isEmpty()) {
|
if (!entries.isEmpty()) {
|
||||||
feed.setEntries(parseEntries(eList, locale));
|
feed.setEntries(parseEntries(entries, locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Element> foreignMarkup = extractForeignMarkup(eFeed, feed, getAtomNamespace());
|
final List<Element> foreignMarkup = extractForeignMarkup(eFeed, feed, getAtomNamespace());
|
||||||
if (!foreignMarkup.isEmpty()) {
|
if (!foreignMarkup.isEmpty()) {
|
||||||
feed.setForeignMarkup(foreignMarkup);
|
feed.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
return feed;
|
return feed;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Link parseLink(final Element eLink) {
|
private Link parseLink(final Element eLink) {
|
||||||
|
|
||||||
final Link link = new Link();
|
final Link link = new Link();
|
||||||
String att = getAttributeValue(eLink, "rel");
|
|
||||||
if (att != null) {
|
final String rel = getAttributeValue(eLink, "rel");
|
||||||
link.setRel(att);
|
if (rel != null) {
|
||||||
|
link.setRel(rel);
|
||||||
}
|
}
|
||||||
att = getAttributeValue(eLink, "type");
|
|
||||||
if (att != null) {
|
final String type = getAttributeValue(eLink, "type");
|
||||||
link.setType(att);
|
if (type != null) {
|
||||||
|
link.setType(type);
|
||||||
}
|
}
|
||||||
att = getAttributeValue(eLink, "href");
|
|
||||||
if (att != null) {
|
final String href = getAttributeValue(eLink, "href");
|
||||||
link.setHref(att);
|
if (href != null) {
|
||||||
|
link.setHref(href);
|
||||||
}
|
}
|
||||||
|
|
||||||
return link;
|
return link;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List(Elements) -> List(Link)
|
|
||||||
private List<Link> parseLinks(final List<Element> eLinks, final boolean alternate) {
|
private List<Link> parseLinks(final List<Element> eLinks, final boolean alternate) {
|
||||||
|
|
||||||
final List<Link> links = new ArrayList<Link>();
|
final List<Link> links = new ArrayList<Link>();
|
||||||
for (int i = 0; i < eLinks.size(); i++) {
|
|
||||||
final Element eLink = eLinks.get(i);
|
for (final Element eLink : eLinks) {
|
||||||
final String rel = getAttributeValue(eLink, "rel");
|
final String rel = getAttributeValue(eLink, "rel");
|
||||||
if (alternate) {
|
if (alternate) {
|
||||||
if ("alternate".equals(rel)) {
|
if ("alternate".equals(rel)) {
|
||||||
|
@ -192,11 +204,9 @@ public class Atom03Parser extends BaseWireFeedParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!links.isEmpty()) {
|
|
||||||
return links;
|
return Lists.emptyToNull(links);
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List(Elements) -> List(Link)
|
// List(Elements) -> List(Link)
|
||||||
|
@ -210,51 +220,67 @@ public class Atom03Parser extends BaseWireFeedParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Person parsePerson(final Element ePerson) {
|
private Person parsePerson(final Element ePerson) {
|
||||||
|
|
||||||
final Person person = new Person();
|
final Person person = new Person();
|
||||||
Element e = ePerson.getChild("name", getAtomNamespace());
|
|
||||||
if (e != null) {
|
final Element name = ePerson.getChild("name", getAtomNamespace());
|
||||||
person.setName(e.getText());
|
|
||||||
|
if (name != null) {
|
||||||
|
person.setName(name.getText());
|
||||||
}
|
}
|
||||||
e = ePerson.getChild("url", getAtomNamespace());
|
|
||||||
if (e != null) {
|
final Element url = ePerson.getChild("url", getAtomNamespace());
|
||||||
person.setUrl(e.getText());
|
if (url != null) {
|
||||||
|
person.setUrl(url.getText());
|
||||||
}
|
}
|
||||||
e = ePerson.getChild("email", getAtomNamespace());
|
|
||||||
if (e != null) {
|
final Element email = ePerson.getChild("email", getAtomNamespace());
|
||||||
person.setEmail(e.getText());
|
if (email != null) {
|
||||||
|
person.setEmail(email.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
return person;
|
return person;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List(Elements) -> List(Persons)
|
// List(Elements) -> List(Persons)
|
||||||
private List<SyndPerson> parsePersons(final List<Element> ePersons) {
|
private List<SyndPerson> parsePersons(final List<Element> ePersons) {
|
||||||
|
|
||||||
final List<SyndPerson> persons = new ArrayList<SyndPerson>();
|
final List<SyndPerson> persons = new ArrayList<SyndPerson>();
|
||||||
for (int i = 0; i < ePersons.size(); i++) {
|
|
||||||
persons.add(parsePerson(ePersons.get(i)));
|
for (final Element person : ePersons) {
|
||||||
}
|
persons.add(parsePerson(person));
|
||||||
if (!persons.isEmpty()) {
|
|
||||||
return persons;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Lists.emptyToNull(persons);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Content parseContent(final Element e) {
|
private Content parseContent(final Element e) {
|
||||||
|
|
||||||
String value = null;
|
String value = null;
|
||||||
|
|
||||||
String type = getAttributeValue(e, "type");
|
String type = getAttributeValue(e, "type");
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
type = "text/plain";
|
type = "text/plain";
|
||||||
}
|
}
|
||||||
|
|
||||||
String mode = getAttributeValue(e, "mode");
|
String mode = getAttributeValue(e, "mode");
|
||||||
if (mode == null) {
|
if (mode == null) {
|
||||||
mode = Content.XML; // default to xml content
|
mode = Content.XML; // default to xml content
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode.equals(Content.ESCAPED)) {
|
if (mode.equals(Content.ESCAPED)) {
|
||||||
|
|
||||||
// do nothing XML Parser took care of this
|
// do nothing XML Parser took care of this
|
||||||
value = e.getText();
|
value = e.getText();
|
||||||
|
|
||||||
} else if (mode.equals(Content.BASE64)) {
|
} else if (mode.equals(Content.BASE64)) {
|
||||||
|
|
||||||
value = Base64.decode(e.getText());
|
value = Base64.decode(e.getText());
|
||||||
|
|
||||||
} else if (mode.equals(Content.XML)) {
|
} else if (mode.equals(Content.XML)) {
|
||||||
|
|
||||||
final XMLOutputter outputter = new XMLOutputter();
|
final XMLOutputter outputter = new XMLOutputter();
|
||||||
final List<org.jdom2.Content> contents = e.getContent();
|
final List<org.jdom2.Content> contents = e.getContent();
|
||||||
for (final org.jdom2.Content content : contents) {
|
for (final org.jdom2.Content content : contents) {
|
||||||
|
@ -267,6 +293,7 @@ public class Atom03Parser extends BaseWireFeedParser {
|
||||||
|
|
||||||
}
|
}
|
||||||
value = outputter.outputString(contents);
|
value = outputter.outputString(contents);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final Content content = new Content();
|
final Content content = new Content();
|
||||||
|
@ -278,71 +305,71 @@ public class Atom03Parser extends BaseWireFeedParser {
|
||||||
|
|
||||||
// List(Elements) -> List(Entries)
|
// List(Elements) -> List(Entries)
|
||||||
private List<Entry> parseEntries(final List<Element> eEntries, final Locale locale) {
|
private List<Entry> parseEntries(final List<Element> eEntries, final Locale locale) {
|
||||||
|
|
||||||
final List<Entry> entries = new ArrayList<Entry>();
|
final List<Entry> entries = new ArrayList<Entry>();
|
||||||
for (int i = 0; i < eEntries.size(); i++) {
|
for (final Element entry : eEntries) {
|
||||||
entries.add(parseEntry(eEntries.get(i), locale));
|
entries.add(parseEntry(entry, locale));
|
||||||
}
|
|
||||||
if (!entries.isEmpty()) {
|
|
||||||
return entries;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Lists.emptyToNull(entries);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Entry parseEntry(final Element eEntry, final Locale locale) {
|
private Entry parseEntry(final Element eEntry, final Locale locale) {
|
||||||
|
|
||||||
final Entry entry = new Entry();
|
final Entry entry = new Entry();
|
||||||
|
|
||||||
Element e = eEntry.getChild("title", getAtomNamespace());
|
final Element title = eEntry.getChild("title", getAtomNamespace());
|
||||||
if (e != null) {
|
if (title != null) {
|
||||||
entry.setTitleEx(parseContent(e));
|
entry.setTitleEx(parseContent(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Element> eList = eEntry.getChildren("link", getAtomNamespace());
|
final List<Element> links = eEntry.getChildren("link", getAtomNamespace());
|
||||||
entry.setAlternateLinks(parseAlternateLinks(eList));
|
entry.setAlternateLinks(parseAlternateLinks(links));
|
||||||
entry.setOtherLinks(parseOtherLinks(eList));
|
entry.setOtherLinks(parseOtherLinks(links));
|
||||||
|
|
||||||
e = eEntry.getChild("author", getAtomNamespace());
|
final Element author = eEntry.getChild("author", getAtomNamespace());
|
||||||
if (e != null) {
|
if (author != null) {
|
||||||
final List<SyndPerson> authors = new ArrayList<SyndPerson>();
|
final List<SyndPerson> authors = new ArrayList<SyndPerson>();
|
||||||
authors.add(parsePerson(e));
|
authors.add(parsePerson(author));
|
||||||
entry.setAuthors(authors);
|
entry.setAuthors(authors);
|
||||||
}
|
}
|
||||||
|
|
||||||
eList = eEntry.getChildren("contributor", getAtomNamespace());
|
final List<Element> contributors = eEntry.getChildren("contributor", getAtomNamespace());
|
||||||
if (!eList.isEmpty()) {
|
if (!contributors.isEmpty()) {
|
||||||
entry.setContributors(parsePersons(eList));
|
entry.setContributors(parsePersons(contributors));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eEntry.getChild("id", getAtomNamespace());
|
final Element id = eEntry.getChild("id", getAtomNamespace());
|
||||||
if (e != null) {
|
if (id != null) {
|
||||||
entry.setId(e.getText());
|
entry.setId(id.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eEntry.getChild("modified", getAtomNamespace());
|
final Element modified = eEntry.getChild("modified", getAtomNamespace());
|
||||||
if (e != null) {
|
if (modified != null) {
|
||||||
entry.setModified(DateParser.parseDate(e.getText(), locale));
|
entry.setModified(DateParser.parseDate(modified.getText(), locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eEntry.getChild("issued", getAtomNamespace());
|
final Element issued = eEntry.getChild("issued", getAtomNamespace());
|
||||||
if (e != null) {
|
if (issued != null) {
|
||||||
entry.setIssued(DateParser.parseDate(e.getText(), locale));
|
entry.setIssued(DateParser.parseDate(issued.getText(), locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eEntry.getChild("created", getAtomNamespace());
|
final Element created = eEntry.getChild("created", getAtomNamespace());
|
||||||
if (e != null) {
|
if (created != null) {
|
||||||
entry.setCreated(DateParser.parseDate(e.getText(), locale));
|
entry.setCreated(DateParser.parseDate(created.getText(), locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eEntry.getChild("summary", getAtomNamespace());
|
final Element summary = eEntry.getChild("summary", getAtomNamespace());
|
||||||
if (e != null) {
|
if (summary != null) {
|
||||||
entry.setSummary(parseContent(e));
|
entry.setSummary(parseContent(summary));
|
||||||
}
|
}
|
||||||
|
|
||||||
eList = eEntry.getChildren("content", getAtomNamespace());
|
final List<Element> contents = eEntry.getChildren("content", getAtomNamespace());
|
||||||
if (!eList.isEmpty()) {
|
if (!contents.isEmpty()) {
|
||||||
final List<Content> content = new ArrayList<Content>();
|
final List<Content> content = new ArrayList<Content>();
|
||||||
for (int i = 0; i < eList.size(); i++) {
|
for (final Element eContent : contents) {
|
||||||
content.add(parseContent(eList.get(i)));
|
content.add(parseContent(eContent));
|
||||||
}
|
}
|
||||||
entry.setContents(content);
|
entry.setContents(content);
|
||||||
}
|
}
|
||||||
|
@ -353,7 +380,9 @@ public class Atom03Parser extends BaseWireFeedParser {
|
||||||
if (!foreignMarkup.isEmpty()) {
|
if (!foreignMarkup.isEmpty()) {
|
||||||
entry.setForeignMarkup(foreignMarkup);
|
entry.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ import org.jdom2.Namespace;
|
||||||
import org.jdom2.input.SAXBuilder;
|
import org.jdom2.input.SAXBuilder;
|
||||||
import org.jdom2.output.XMLOutputter;
|
import org.jdom2.output.XMLOutputter;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.atom.Category;
|
import com.sun.syndication.feed.atom.Category;
|
||||||
import com.sun.syndication.feed.atom.Content;
|
import com.sun.syndication.feed.atom.Content;
|
||||||
|
@ -49,8 +51,8 @@ import com.sun.syndication.io.WireFeedOutput;
|
||||||
* @author Dave Johnson (updated for Atom 1.0)
|
* @author Dave Johnson (updated for Atom 1.0)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Atom10Generator extends BaseWireFeedGenerator {
|
public class Atom10Generator extends BaseWireFeedGenerator {
|
||||||
|
|
||||||
private static final String ATOM_10_URI = "http://www.w3.org/2005/Atom";
|
private static final String ATOM_10_URI = "http://www.w3.org/2005/Atom";
|
||||||
private static final Namespace ATOM_NS = Namespace.getNamespace(ATOM_10_URI);
|
private static final Namespace ATOM_NS = Namespace.getNamespace(ATOM_10_URI);
|
||||||
|
|
||||||
|
@ -87,15 +89,23 @@ public class Atom10Generator extends BaseWireFeedGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element createRootElement(final Feed feed) {
|
protected Element createRootElement(final Feed feed) {
|
||||||
|
|
||||||
final Element root = new Element("feed", getFeedNamespace());
|
final Element root = new Element("feed", getFeedNamespace());
|
||||||
|
|
||||||
root.addNamespaceDeclaration(getFeedNamespace());
|
root.addNamespaceDeclaration(getFeedNamespace());
|
||||||
|
|
||||||
// Attribute version = new Attribute("version", getVersion());
|
// Attribute version = new Attribute("version", getVersion());
|
||||||
// root.setAttribute(version);
|
// root.setAttribute(version);
|
||||||
if (feed.getXmlBase() != null) {
|
|
||||||
root.setAttribute("base", feed.getXmlBase(), Namespace.XML_NAMESPACE);
|
final String xmlBase = feed.getXmlBase();
|
||||||
|
if (xmlBase != null) {
|
||||||
|
root.setAttribute("base", xmlBase, Namespace.XML_NAMESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
generateModuleNamespaceDefs(root);
|
generateModuleNamespaceDefs(root);
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void populateFeed(final Feed feed, final Element parent) throws FeedException {
|
protected void populateFeed(final Feed feed, final Element parent) throws FeedException {
|
||||||
|
@ -113,41 +123,49 @@ public class Atom10Generator extends BaseWireFeedGenerator {
|
||||||
|
|
||||||
protected void addEntries(final Feed feed, final Element parent) throws FeedException {
|
protected void addEntries(final Feed feed, final Element parent) throws FeedException {
|
||||||
final List<Entry> items = feed.getEntries();
|
final List<Entry> items = feed.getEntries();
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (final Entry entry : items) {
|
||||||
addEntry(items.get(i), parent);
|
addEntry(entry, parent);
|
||||||
}
|
}
|
||||||
checkEntriesConstraints(parent);
|
checkEntriesConstraints(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addEntry(final Entry entry, final Element parent) throws FeedException {
|
protected void addEntry(final Entry entry, final Element parent) throws FeedException {
|
||||||
|
|
||||||
final Element eEntry = new Element("entry", getFeedNamespace());
|
final Element eEntry = new Element("entry", getFeedNamespace());
|
||||||
if (entry.getXmlBase() != null) {
|
|
||||||
eEntry.setAttribute("base", entry.getXmlBase(), Namespace.XML_NAMESPACE);
|
final String xmlBase = entry.getXmlBase();
|
||||||
|
if (xmlBase != null) {
|
||||||
|
eEntry.setAttribute("base", xmlBase, Namespace.XML_NAMESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
populateEntry(entry, eEntry);
|
populateEntry(entry, eEntry);
|
||||||
generateForeignMarkup(eEntry, entry.getForeignMarkup());
|
generateForeignMarkup(eEntry, entry.getForeignMarkup());
|
||||||
checkEntryConstraints(eEntry);
|
checkEntryConstraints(eEntry);
|
||||||
generateItemModules(entry.getModules(), eEntry);
|
generateItemModules(entry.getModules(), eEntry);
|
||||||
parent.addContent(eEntry);
|
parent.addContent(eEntry);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void populateFeedHeader(final Feed feed, final Element eFeed) throws FeedException {
|
protected void populateFeedHeader(final Feed feed, final Element eFeed) throws FeedException {
|
||||||
if (feed.getTitleEx() != null) {
|
|
||||||
|
final Content titleEx = feed.getTitleEx();
|
||||||
|
if (titleEx != null) {
|
||||||
final Element titleElement = new Element("title", getFeedNamespace());
|
final Element titleElement = new Element("title", getFeedNamespace());
|
||||||
fillContentElement(titleElement, feed.getTitleEx());
|
fillContentElement(titleElement, titleEx);
|
||||||
eFeed.addContent(titleElement);
|
eFeed.addContent(titleElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Link> links = feed.getAlternateLinks();
|
final List<Link> alternateLinks = feed.getAlternateLinks();
|
||||||
if (links != null) {
|
if (alternateLinks != null) {
|
||||||
for (int i = 0; i < links.size(); i++) {
|
for (final Link link : alternateLinks) {
|
||||||
eFeed.addContent(generateLinkElement(links.get(i)));
|
eFeed.addContent(generateLinkElement(link));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
links = feed.getOtherLinks();
|
|
||||||
if (links != null) {
|
final List<Link> otherLinks = feed.getOtherLinks();
|
||||||
for (int j = 0; j < links.size(); j++) {
|
if (otherLinks != null) {
|
||||||
eFeed.addContent(generateLinkElement(links.get(j)));
|
for (final Link link : otherLinks) {
|
||||||
|
eFeed.addContent(generateLinkElement(link));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,133 +177,153 @@ public class Atom10Generator extends BaseWireFeedGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> authors = feed.getAuthors();
|
final List<SyndPerson> authors = feed.getAuthors();
|
||||||
if (authors != null && !authors.isEmpty()) {
|
if (Lists.isNotEmpty(authors)) {
|
||||||
for (int i = 0; i < authors.size(); i++) {
|
for (final SyndPerson author : authors) {
|
||||||
final Element authorElement = new Element("author", getFeedNamespace());
|
final Element authorElement = new Element("author", getFeedNamespace());
|
||||||
fillPersonElement(authorElement, feed.getAuthors().get(i));
|
fillPersonElement(authorElement, author);
|
||||||
eFeed.addContent(authorElement);
|
eFeed.addContent(authorElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> contributors = feed.getContributors();
|
final List<SyndPerson> contributors = feed.getContributors();
|
||||||
if (contributors != null && !contributors.isEmpty()) {
|
if (Lists.isNotEmpty(contributors)) {
|
||||||
for (int i = 0; i < contributors.size(); i++) {
|
for (final SyndPerson contributor : contributors) {
|
||||||
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
||||||
fillPersonElement(contributorElement, contributors.get(i));
|
fillPersonElement(contributorElement, contributor);
|
||||||
eFeed.addContent(contributorElement);
|
eFeed.addContent(contributorElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getSubtitle() != null) {
|
final Content subtitle = feed.getSubtitle();
|
||||||
|
if (subtitle != null) {
|
||||||
final Element subtitleElement = new Element("subtitle", getFeedNamespace());
|
final Element subtitleElement = new Element("subtitle", getFeedNamespace());
|
||||||
fillContentElement(subtitleElement, feed.getSubtitle());
|
fillContentElement(subtitleElement, subtitle);
|
||||||
eFeed.addContent(subtitleElement);
|
eFeed.addContent(subtitleElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getId() != null) {
|
final String id = feed.getId();
|
||||||
eFeed.addContent(generateSimpleElement("id", feed.getId()));
|
if (id != null) {
|
||||||
|
eFeed.addContent(generateSimpleElement("id", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getGenerator() != null) {
|
final Generator generator = feed.getGenerator();
|
||||||
eFeed.addContent(generateGeneratorElement(feed.getGenerator()));
|
if (generator != null) {
|
||||||
|
eFeed.addContent(generateGeneratorElement(generator));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getRights() != null) {
|
final String rights = feed.getRights();
|
||||||
eFeed.addContent(generateSimpleElement("rights", feed.getRights()));
|
if (rights != null) {
|
||||||
|
eFeed.addContent(generateSimpleElement("rights", rights));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getIcon() != null) {
|
final String icon = feed.getIcon();
|
||||||
eFeed.addContent(generateSimpleElement("icon", feed.getIcon()));
|
if (icon != null) {
|
||||||
|
eFeed.addContent(generateSimpleElement("icon", icon));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getLogo() != null) {
|
final String logo = feed.getLogo();
|
||||||
eFeed.addContent(generateSimpleElement("logo", feed.getLogo()));
|
if (logo != null) {
|
||||||
|
eFeed.addContent(generateSimpleElement("logo", logo));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed.getUpdated() != null) {
|
final Date updated = feed.getUpdated();
|
||||||
|
if (updated != null) {
|
||||||
final Element updatedElement = new Element("updated", getFeedNamespace());
|
final Element updatedElement = new Element("updated", getFeedNamespace());
|
||||||
updatedElement.addContent(DateParser.formatW3CDateTime(feed.getUpdated(), Locale.US));
|
updatedElement.addContent(DateParser.formatW3CDateTime(updated, Locale.US));
|
||||||
eFeed.addContent(updatedElement);
|
eFeed.addContent(updatedElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void populateEntry(final Entry entry, final Element eEntry) throws FeedException {
|
protected void populateEntry(final Entry entry, final Element eEntry) throws FeedException {
|
||||||
if (entry.getTitleEx() != null) {
|
|
||||||
|
final Content titleEx = entry.getTitleEx();
|
||||||
|
if (titleEx != null) {
|
||||||
final Element titleElement = new Element("title", getFeedNamespace());
|
final Element titleElement = new Element("title", getFeedNamespace());
|
||||||
fillContentElement(titleElement, entry.getTitleEx());
|
fillContentElement(titleElement, titleEx);
|
||||||
eEntry.addContent(titleElement);
|
eEntry.addContent(titleElement);
|
||||||
}
|
}
|
||||||
List<Link> links = entry.getAlternateLinks();
|
|
||||||
if (links != null) {
|
final List<Link> alternateLinks = entry.getAlternateLinks();
|
||||||
for (int i = 0; i < links.size(); i++) {
|
if (alternateLinks != null) {
|
||||||
eEntry.addContent(generateLinkElement(links.get(i)));
|
for (final Link link : alternateLinks) {
|
||||||
|
eEntry.addContent(generateLinkElement(link));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
links = entry.getOtherLinks();
|
|
||||||
if (links != null) {
|
final List<Link> otherLinks = entry.getOtherLinks();
|
||||||
for (int i = 0; i < links.size(); i++) {
|
if (otherLinks != null) {
|
||||||
eEntry.addContent(generateLinkElement(links.get(i)));
|
for (final Link link : otherLinks) {
|
||||||
|
eEntry.addContent(generateLinkElement(link));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Category> cats = entry.getCategories();
|
final List<Category> cats = entry.getCategories();
|
||||||
if (cats != null) {
|
if (cats != null) {
|
||||||
for (int i = 0; i < cats.size(); i++) {
|
for (final Category category : cats) {
|
||||||
eEntry.addContent(generateCategoryElement(cats.get(i)));
|
eEntry.addContent(generateCategoryElement(category));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> authors = entry.getAuthors();
|
final List<SyndPerson> authors = entry.getAuthors();
|
||||||
if (authors != null && !authors.isEmpty()) {
|
if (Lists.isNotEmpty(authors)) {
|
||||||
for (int i = 0; i < authors.size(); i++) {
|
for (final SyndPerson author : authors) {
|
||||||
final Element authorElement = new Element("author", getFeedNamespace());
|
final Element authorElement = new Element("author", getFeedNamespace());
|
||||||
fillPersonElement(authorElement, entry.getAuthors().get(i));
|
fillPersonElement(authorElement, author);
|
||||||
eEntry.addContent(authorElement);
|
eEntry.addContent(authorElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SyndPerson> contributors = entry.getContributors();
|
final List<SyndPerson> contributors = entry.getContributors();
|
||||||
if (contributors != null && !contributors.isEmpty()) {
|
if (Lists.isNotEmpty(contributors)) {
|
||||||
for (int i = 0; i < contributors.size(); i++) {
|
for (final SyndPerson contributor : contributors) {
|
||||||
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
||||||
fillPersonElement(contributorElement, contributors.get(i));
|
fillPersonElement(contributorElement, contributor);
|
||||||
eEntry.addContent(contributorElement);
|
eEntry.addContent(contributorElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entry.getId() != null) {
|
|
||||||
eEntry.addContent(generateSimpleElement("id", entry.getId()));
|
final String id = entry.getId();
|
||||||
|
if (id != null) {
|
||||||
|
eEntry.addContent(generateSimpleElement("id", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getUpdated() != null) {
|
final Date updated = entry.getUpdated();
|
||||||
|
if (updated != null) {
|
||||||
final Element updatedElement = new Element("updated", getFeedNamespace());
|
final Element updatedElement = new Element("updated", getFeedNamespace());
|
||||||
updatedElement.addContent(DateParser.formatW3CDateTime(entry.getUpdated(), Locale.US));
|
updatedElement.addContent(DateParser.formatW3CDateTime(updated, Locale.US));
|
||||||
eEntry.addContent(updatedElement);
|
eEntry.addContent(updatedElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getPublished() != null) {
|
final Date published = entry.getPublished();
|
||||||
|
if (published != null) {
|
||||||
final Element publishedElement = new Element("published", getFeedNamespace());
|
final Element publishedElement = new Element("published", getFeedNamespace());
|
||||||
publishedElement.addContent(DateParser.formatW3CDateTime(entry.getPublished(), Locale.US));
|
publishedElement.addContent(DateParser.formatW3CDateTime(published, Locale.US));
|
||||||
eEntry.addContent(publishedElement);
|
eEntry.addContent(publishedElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getContents() != null && !entry.getContents().isEmpty()) {
|
final List<Content> contents = entry.getContents();
|
||||||
|
if (Lists.isNotEmpty(contents)) {
|
||||||
final Element contentElement = new Element("content", getFeedNamespace());
|
final Element contentElement = new Element("content", getFeedNamespace());
|
||||||
final Content content = entry.getContents().get(0);
|
final Content content = contents.get(0);
|
||||||
fillContentElement(contentElement, content);
|
fillContentElement(contentElement, content);
|
||||||
eEntry.addContent(contentElement);
|
eEntry.addContent(contentElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getSummary() != null) {
|
final Content summary = entry.getSummary();
|
||||||
|
if (summary != null) {
|
||||||
final Element summaryElement = new Element("summary", getFeedNamespace());
|
final Element summaryElement = new Element("summary", getFeedNamespace());
|
||||||
fillContentElement(summaryElement, entry.getSummary());
|
fillContentElement(summaryElement, summary);
|
||||||
eEntry.addContent(summaryElement);
|
eEntry.addContent(summaryElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getSource() != null) {
|
final Feed source = entry.getSource();
|
||||||
|
if (source != null) {
|
||||||
final Element sourceElement = new Element("source", getFeedNamespace());
|
final Element sourceElement = new Element("source", getFeedNamespace());
|
||||||
populateFeedHeader(entry.getSource(), sourceElement);
|
populateFeedHeader(source, sourceElement);
|
||||||
eEntry.addContent(sourceElement);
|
eEntry.addContent(sourceElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkFeedHeaderConstraints(final Element eFeed) throws FeedException {
|
protected void checkFeedHeaderConstraints(final Element eFeed) throws FeedException {
|
||||||
|
@ -298,90 +336,122 @@ public class Atom10Generator extends BaseWireFeedGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateCategoryElement(final Category cat) {
|
protected Element generateCategoryElement(final Category cat) {
|
||||||
final Element catElement = new Element("category", getFeedNamespace());
|
|
||||||
|
|
||||||
if (cat.getTerm() != null) {
|
final Namespace namespace = getFeedNamespace();
|
||||||
final Attribute termAttribute = new Attribute("term", cat.getTerm());
|
final Element catElement = new Element("category", namespace);
|
||||||
|
|
||||||
|
final String term = cat.getTerm();
|
||||||
|
if (term != null) {
|
||||||
|
final Attribute termAttribute = new Attribute("term", term);
|
||||||
catElement.setAttribute(termAttribute);
|
catElement.setAttribute(termAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cat.getLabel() != null) {
|
final String label = cat.getLabel();
|
||||||
final Attribute labelAttribute = new Attribute("label", cat.getLabel());
|
if (label != null) {
|
||||||
|
final Attribute labelAttribute = new Attribute("label", label);
|
||||||
catElement.setAttribute(labelAttribute);
|
catElement.setAttribute(labelAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cat.getScheme() != null) {
|
final String scheme = cat.getScheme();
|
||||||
final Attribute schemeAttribute = new Attribute("scheme", cat.getScheme());
|
if (scheme != null) {
|
||||||
|
final Attribute schemeAttribute = new Attribute("scheme", scheme);
|
||||||
catElement.setAttribute(schemeAttribute);
|
catElement.setAttribute(schemeAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
return catElement;
|
return catElement;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateLinkElement(final Link link) {
|
protected Element generateLinkElement(final Link link) {
|
||||||
final Element linkElement = new Element("link", getFeedNamespace());
|
|
||||||
|
|
||||||
if (link.getRel() != null) {
|
final Namespace namespace = getFeedNamespace();
|
||||||
final Attribute relAttribute = new Attribute("rel", link.getRel());
|
final Element linkElement = new Element("link", namespace);
|
||||||
|
|
||||||
|
final String rel = link.getRel();
|
||||||
|
if (rel != null) {
|
||||||
|
final Attribute relAttribute = new Attribute("rel", rel);
|
||||||
linkElement.setAttribute(relAttribute);
|
linkElement.setAttribute(relAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link.getType() != null) {
|
final String type = link.getType();
|
||||||
final Attribute typeAttribute = new Attribute("type", link.getType());
|
if (type != null) {
|
||||||
|
final Attribute typeAttribute = new Attribute("type", type);
|
||||||
linkElement.setAttribute(typeAttribute);
|
linkElement.setAttribute(typeAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link.getHref() != null) {
|
final String href = link.getHref();
|
||||||
final Attribute hrefAttribute = new Attribute("href", link.getHref());
|
if (href != null) {
|
||||||
|
final Attribute hrefAttribute = new Attribute("href", href);
|
||||||
linkElement.setAttribute(hrefAttribute);
|
linkElement.setAttribute(hrefAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link.getHreflang() != null) {
|
final String hreflang = link.getHreflang();
|
||||||
final Attribute hreflangAttribute = new Attribute("hreflang", link.getHreflang());
|
if (hreflang != null) {
|
||||||
|
final Attribute hreflangAttribute = new Attribute("hreflang", hreflang);
|
||||||
linkElement.setAttribute(hreflangAttribute);
|
linkElement.setAttribute(hreflangAttribute);
|
||||||
}
|
}
|
||||||
if (link.getTitle() != null) {
|
|
||||||
final Attribute title = new Attribute("title", link.getTitle());
|
final String linkTitle = link.getTitle();
|
||||||
|
if (linkTitle != null) {
|
||||||
|
final Attribute title = new Attribute("title", linkTitle);
|
||||||
linkElement.setAttribute(title);
|
linkElement.setAttribute(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link.getLength() != 0) {
|
if (link.getLength() != 0) {
|
||||||
final Attribute lenght = new Attribute("length", Long.toString(link.getLength()));
|
final Attribute lenght = new Attribute("length", Long.toString(link.getLength()));
|
||||||
linkElement.setAttribute(lenght);
|
linkElement.setAttribute(lenght);
|
||||||
}
|
}
|
||||||
|
|
||||||
return linkElement;
|
return linkElement;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fillPersonElement(final Element element, final SyndPerson person) {
|
protected void fillPersonElement(final Element element, final SyndPerson person) {
|
||||||
if (person.getName() != null) {
|
|
||||||
element.addContent(generateSimpleElement("name", person.getName()));
|
final String name = person.getName();
|
||||||
}
|
if (name != null) {
|
||||||
if (person.getUri() != null) {
|
element.addContent(generateSimpleElement("name", name));
|
||||||
element.addContent(generateSimpleElement("uri", person.getUri()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (person.getEmail() != null) {
|
final String uri = person.getUri();
|
||||||
element.addContent(generateSimpleElement("email", person.getEmail()));
|
if (uri != null) {
|
||||||
|
element.addContent(generateSimpleElement("uri", uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String email = person.getEmail();
|
||||||
|
if (email != null) {
|
||||||
|
element.addContent(generateSimpleElement("email", email));
|
||||||
|
}
|
||||||
|
|
||||||
generatePersonModules(person.getModules(), element);
|
generatePersonModules(person.getModules(), element);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateTagLineElement(final Content tagline) {
|
protected Element generateTagLineElement(final Content tagline) {
|
||||||
|
|
||||||
final Element taglineElement = new Element("subtitle", getFeedNamespace());
|
final Element taglineElement = new Element("subtitle", getFeedNamespace());
|
||||||
|
|
||||||
if (tagline.getType() != null) {
|
final String type = tagline.getType();
|
||||||
final Attribute typeAttribute = new Attribute("type", tagline.getType());
|
if (type != null) {
|
||||||
|
final Attribute typeAttribute = new Attribute("type", type);
|
||||||
taglineElement.setAttribute(typeAttribute);
|
taglineElement.setAttribute(typeAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tagline.getValue() != null) {
|
final String value = tagline.getValue();
|
||||||
taglineElement.addContent(tagline.getValue());
|
if (value != null) {
|
||||||
|
taglineElement.addContent(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return taglineElement;
|
return taglineElement;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fillContentElement(final Element contentElement, final Content content) throws FeedException {
|
protected void fillContentElement(final Element contentElement, final Content content) throws FeedException {
|
||||||
|
|
||||||
final String type = content.getType();
|
final String type = content.getType();
|
||||||
|
|
||||||
String atomType = type;
|
String atomType = type;
|
||||||
|
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
// Fix for issue #39 "Atom 1.0 Text Types Not Set Correctly"
|
// Fix for issue #39 "Atom 1.0 Text Types Not Set Correctly"
|
||||||
// we're not sure who set this value, so ensure Atom types are used
|
// we're not sure who set this value, so ensure Atom types are used
|
||||||
|
@ -396,16 +466,20 @@ public class Atom10Generator extends BaseWireFeedGenerator {
|
||||||
final Attribute typeAttribute = new Attribute("type", atomType);
|
final Attribute typeAttribute = new Attribute("type", atomType);
|
||||||
contentElement.setAttribute(typeAttribute);
|
contentElement.setAttribute(typeAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String href = content.getSrc();
|
final String href = content.getSrc();
|
||||||
if (href != null) {
|
if (href != null) {
|
||||||
final Attribute srcAttribute = new Attribute("src", href);
|
final Attribute srcAttribute = new Attribute("src", href);
|
||||||
contentElement.setAttribute(srcAttribute);
|
contentElement.setAttribute(srcAttribute);
|
||||||
}
|
}
|
||||||
if (content.getValue() != null) {
|
|
||||||
|
final String value = content.getValue();
|
||||||
|
if (value != null) {
|
||||||
|
|
||||||
if (atomType != null && (atomType.equals(Content.XHTML) || atomType.indexOf("/xml") != -1 || atomType.indexOf("+xml") != -1)) {
|
if (atomType != null && (atomType.equals(Content.XHTML) || atomType.indexOf("/xml") != -1 || atomType.indexOf("+xml") != -1)) {
|
||||||
|
|
||||||
final StringBuffer tmpDocString = new StringBuffer("<tmpdoc>");
|
final StringBuffer tmpDocString = new StringBuffer("<tmpdoc>");
|
||||||
tmpDocString.append(content.getValue());
|
tmpDocString.append(value);
|
||||||
tmpDocString.append("</tmpdoc>");
|
tmpDocString.append("</tmpdoc>");
|
||||||
final StringReader tmpDocReader = new StringReader(tmpDocString.toString());
|
final StringReader tmpDocReader = new StringReader(tmpDocString.toString());
|
||||||
Document tmpDoc;
|
Document tmpDoc;
|
||||||
|
@ -417,29 +491,37 @@ public class Atom10Generator extends BaseWireFeedGenerator {
|
||||||
}
|
}
|
||||||
final List<org.jdom2.Content> children = tmpDoc.getRootElement().removeContent();
|
final List<org.jdom2.Content> children = tmpDoc.getRootElement().removeContent();
|
||||||
contentElement.addContent(children);
|
contentElement.addContent(children);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// must be type html, text or some other non-XML format
|
// must be type html, text or some other non-XML format
|
||||||
// JDOM will escape property for XML
|
// JDOM will escape property for XML
|
||||||
contentElement.addContent(content.getValue());
|
contentElement.addContent(value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateGeneratorElement(final Generator generator) {
|
protected Element generateGeneratorElement(final Generator generator) {
|
||||||
|
|
||||||
final Element generatorElement = new Element("generator", getFeedNamespace());
|
final Element generatorElement = new Element("generator", getFeedNamespace());
|
||||||
|
|
||||||
if (generator.getUrl() != null) {
|
final String url = generator.getUrl();
|
||||||
final Attribute urlAttribute = new Attribute("uri", generator.getUrl());
|
if (url != null) {
|
||||||
|
final Attribute urlAttribute = new Attribute("uri", url);
|
||||||
generatorElement.setAttribute(urlAttribute);
|
generatorElement.setAttribute(urlAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (generator.getVersion() != null) {
|
final String version2 = generator.getVersion();
|
||||||
final Attribute versionAttribute = new Attribute("version", generator.getVersion());
|
if (version2 != null) {
|
||||||
|
final Attribute versionAttribute = new Attribute("version", version2);
|
||||||
generatorElement.setAttribute(versionAttribute);
|
generatorElement.setAttribute(versionAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (generator.getValue() != null) {
|
final String value = generator.getValue();
|
||||||
generatorElement.addContent(generator.getValue());
|
if (value != null) {
|
||||||
|
generatorElement.addContent(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return generatorElement;
|
return generatorElement;
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.jdom2.Parent;
|
||||||
import org.jdom2.input.SAXBuilder;
|
import org.jdom2.input.SAXBuilder;
|
||||||
import org.jdom2.output.XMLOutputter;
|
import org.jdom2.output.XMLOutputter;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.WireFeed;
|
import com.sun.syndication.feed.WireFeed;
|
||||||
import com.sun.syndication.feed.atom.Category;
|
import com.sun.syndication.feed.atom.Category;
|
||||||
import com.sun.syndication.feed.atom.Content;
|
import com.sun.syndication.feed.atom.Content;
|
||||||
|
@ -52,6 +53,7 @@ import com.sun.syndication.io.WireFeedOutput;
|
||||||
* @author Dave Johnson
|
* @author Dave Johnson
|
||||||
*/
|
*/
|
||||||
public class Atom10Parser extends BaseWireFeedParser {
|
public class Atom10Parser extends BaseWireFeedParser {
|
||||||
|
|
||||||
private static final String ATOM_10_URI = "http://www.w3.org/2005/Atom";
|
private static final String ATOM_10_URI = "http://www.w3.org/2005/Atom";
|
||||||
private static final Namespace ATOM_10_NS = Namespace.getNamespace(ATOM_10_URI);
|
private static final Namespace ATOM_10_NS = Namespace.getNamespace(ATOM_10_URI);
|
||||||
|
|
||||||
|
@ -94,13 +96,9 @@ public class Atom10Parser extends BaseWireFeedParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void validateFeed(final Document document) throws FeedException {
|
protected void validateFeed(final Document document) throws FeedException {
|
||||||
// TBD
|
// TBD here we have to validate the Feed against a schema or whatever not sure how to do it
|
||||||
// here we have to validate the Feed against a schema or whatever
|
// one posibility would be to produce an ouput and attempt to parse it again with validation
|
||||||
// not sure how to do it
|
// turned on. otherwise will have to check the document elements by hand.
|
||||||
// one posibility would be to produce an ouput and attempt to parse it
|
|
||||||
// again
|
|
||||||
// with validation turned on.
|
|
||||||
// otherwise will have to check the document elements by hand.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WireFeed parseFeed(final Element eFeed, final Locale locale) throws FeedException {
|
protected WireFeed parseFeed(final Element eFeed, final Locale locale) throws FeedException {
|
||||||
|
@ -135,203 +133,225 @@ public class Atom10Parser extends BaseWireFeedParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Feed parseFeedMetadata(final String baseURI, final Element eFeed, final Locale locale) {
|
private Feed parseFeedMetadata(final String baseURI, final Element eFeed, final Locale locale) {
|
||||||
|
|
||||||
final com.sun.syndication.feed.atom.Feed feed = new com.sun.syndication.feed.atom.Feed(getType());
|
final com.sun.syndication.feed.atom.Feed feed = new com.sun.syndication.feed.atom.Feed(getType());
|
||||||
|
|
||||||
Element e = eFeed.getChild("title", getAtomNamespace());
|
final Element title = eFeed.getChild("title", getAtomNamespace());
|
||||||
if (e != null) {
|
if (title != null) {
|
||||||
final Content c = new Content();
|
final Content c = new Content();
|
||||||
c.setValue(parseTextConstructToString(e));
|
c.setValue(parseTextConstructToString(title));
|
||||||
c.setType(getAttributeValue(e, "type"));
|
c.setType(getAttributeValue(title, "type"));
|
||||||
feed.setTitleEx(c);
|
feed.setTitleEx(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Element> eList = eFeed.getChildren("link", getAtomNamespace());
|
final List<Element> links = eFeed.getChildren("link", getAtomNamespace());
|
||||||
feed.setAlternateLinks(parseAlternateLinks(feed, null, baseURI, eList));
|
feed.setAlternateLinks(parseAlternateLinks(feed, null, baseURI, links));
|
||||||
feed.setOtherLinks(parseOtherLinks(feed, null, baseURI, eList));
|
feed.setOtherLinks(parseOtherLinks(feed, null, baseURI, links));
|
||||||
|
|
||||||
final List<Element> cList = eFeed.getChildren("category", getAtomNamespace());
|
final List<Element> categories = eFeed.getChildren("category", getAtomNamespace());
|
||||||
feed.setCategories(parseCategories(baseURI, cList));
|
feed.setCategories(parseCategories(baseURI, categories));
|
||||||
|
|
||||||
eList = eFeed.getChildren("author", getAtomNamespace());
|
final List<Element> authors = eFeed.getChildren("author", getAtomNamespace());
|
||||||
if (!eList.isEmpty()) {
|
if (!authors.isEmpty()) {
|
||||||
feed.setAuthors(parsePersons(baseURI, eList, locale));
|
feed.setAuthors(parsePersons(baseURI, authors, locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
eList = eFeed.getChildren("contributor", getAtomNamespace());
|
final List<Element> contributors = eFeed.getChildren("contributor", getAtomNamespace());
|
||||||
if (!eList.isEmpty()) {
|
if (!contributors.isEmpty()) {
|
||||||
feed.setContributors(parsePersons(baseURI, eList, locale));
|
feed.setContributors(parsePersons(baseURI, contributors, locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("subtitle", getAtomNamespace());
|
final Element subtitle = eFeed.getChild("subtitle", getAtomNamespace());
|
||||||
if (e != null) {
|
if (subtitle != null) {
|
||||||
final Content subtitle = new Content();
|
final Content content = new Content();
|
||||||
subtitle.setValue(parseTextConstructToString(e));
|
content.setValue(parseTextConstructToString(subtitle));
|
||||||
subtitle.setType(getAttributeValue(e, "type"));
|
content.setType(getAttributeValue(subtitle, "type"));
|
||||||
feed.setSubtitle(subtitle);
|
feed.setSubtitle(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("id", getAtomNamespace());
|
final Element id = eFeed.getChild("id", getAtomNamespace());
|
||||||
if (e != null) {
|
if (id != null) {
|
||||||
feed.setId(e.getText());
|
feed.setId(id.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("generator", getAtomNamespace());
|
final Element generator = eFeed.getChild("generator", getAtomNamespace());
|
||||||
if (e != null) {
|
if (generator != null) {
|
||||||
|
|
||||||
final Generator gen = new Generator();
|
final Generator gen = new Generator();
|
||||||
gen.setValue(e.getText());
|
gen.setValue(generator.getText());
|
||||||
String att = getAttributeValue(e, "uri");
|
|
||||||
if (att != null) {
|
final String uri = getAttributeValue(generator, "uri");
|
||||||
gen.setUrl(att);
|
if (uri != null) {
|
||||||
|
gen.setUrl(uri);
|
||||||
}
|
}
|
||||||
att = getAttributeValue(e, "version");
|
|
||||||
if (att != null) {
|
final String version = getAttributeValue(generator, "version");
|
||||||
gen.setVersion(att);
|
if (version != null) {
|
||||||
|
gen.setVersion(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
feed.setGenerator(gen);
|
feed.setGenerator(gen);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("rights", getAtomNamespace());
|
final Element rights = eFeed.getChild("rights", getAtomNamespace());
|
||||||
if (e != null) {
|
if (rights != null) {
|
||||||
feed.setRights(parseTextConstructToString(e));
|
feed.setRights(parseTextConstructToString(rights));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("icon", getAtomNamespace());
|
final Element icon = eFeed.getChild("icon", getAtomNamespace());
|
||||||
if (e != null) {
|
if (icon != null) {
|
||||||
feed.setIcon(e.getText());
|
feed.setIcon(icon.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("logo", getAtomNamespace());
|
final Element logo = eFeed.getChild("logo", getAtomNamespace());
|
||||||
if (e != null) {
|
if (logo != null) {
|
||||||
feed.setLogo(e.getText());
|
feed.setLogo(logo.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eFeed.getChild("updated", getAtomNamespace());
|
final Element updated = eFeed.getChild("updated", getAtomNamespace());
|
||||||
if (e != null) {
|
if (updated != null) {
|
||||||
feed.setUpdated(DateParser.parseDate(e.getText(), locale));
|
feed.setUpdated(DateParser.parseDate(updated.getText(), locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
return feed;
|
return feed;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Link parseLink(final Feed feed, final Entry entry, final String baseURI, final Element eLink) {
|
private Link parseLink(final Feed feed, final Entry entry, final String baseURI, final Element eLink) {
|
||||||
|
|
||||||
final Link link = new Link();
|
final Link link = new Link();
|
||||||
String att = getAttributeValue(eLink, "rel");
|
|
||||||
if (att != null) {
|
final String rel = getAttributeValue(eLink, "rel");
|
||||||
link.setRel(att);
|
if (rel != null) {
|
||||||
|
link.setRel(rel);
|
||||||
}
|
}
|
||||||
att = getAttributeValue(eLink, "type");
|
|
||||||
if (att != null) {
|
final String type = getAttributeValue(eLink, "type");
|
||||||
link.setType(att);
|
if (type != null) {
|
||||||
|
link.setType(type);
|
||||||
}
|
}
|
||||||
att = getAttributeValue(eLink, "href");
|
|
||||||
if (att != null) {
|
final String href = getAttributeValue(eLink, "href");
|
||||||
link.setHref(att);
|
if (href != null) {
|
||||||
if (isRelativeURI(att)) {
|
link.setHref(href);
|
||||||
link.setHrefResolved(resolveURI(baseURI, eLink, att));
|
if (isRelativeURI(href)) {
|
||||||
|
link.setHrefResolved(resolveURI(baseURI, eLink, href));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
att = getAttributeValue(eLink, "title");
|
|
||||||
if (att != null) {
|
final String title = getAttributeValue(eLink, "title");
|
||||||
link.setTitle(att);
|
if (title != null) {
|
||||||
|
link.setTitle(title);
|
||||||
}
|
}
|
||||||
att = getAttributeValue(eLink, "hreflang");
|
|
||||||
if (att != null) {
|
final String hrefLang = getAttributeValue(eLink, "hreflang");
|
||||||
link.setHreflang(att);
|
if (hrefLang != null) {
|
||||||
|
link.setHreflang(hrefLang);
|
||||||
}
|
}
|
||||||
att = getAttributeValue(eLink, "length");
|
|
||||||
if (att != null) {
|
final String length = getAttributeValue(eLink, "length");
|
||||||
final Long val = NumberParser.parseLong(att);
|
if (length != null) {
|
||||||
|
final Long val = NumberParser.parseLong(length);
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
link.setLength(val.longValue());
|
link.setLength(val.longValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return link;
|
return link;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List(Elements) -> List(Link)
|
// List(Elements) -> List(Link)
|
||||||
private List<Link> parseAlternateLinks(final Feed feed, final Entry entry, final String baseURI, final List<Element> eLinks) {
|
private List<Link> parseAlternateLinks(final Feed feed, final Entry entry, final String baseURI, final List<Element> eLinks) {
|
||||||
|
|
||||||
final List<Link> links = new ArrayList<Link>();
|
final List<Link> links = new ArrayList<Link>();
|
||||||
for (int i = 0; i < eLinks.size(); i++) {
|
for (final Element eLink : eLinks) {
|
||||||
final Element eLink = eLinks.get(i);
|
|
||||||
final Link link = parseLink(feed, entry, baseURI, eLink);
|
final Link link = parseLink(feed, entry, baseURI, eLink);
|
||||||
if (link.getRel() == null || "".equals(link.getRel().trim()) || "alternate".equals(link.getRel())) {
|
if (link.getRel() == null || "".equals(link.getRel().trim()) || "alternate".equals(link.getRel())) {
|
||||||
links.add(link);
|
links.add(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!links.isEmpty()) {
|
|
||||||
return links;
|
return Lists.emptyToNull(links);
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Link> parseOtherLinks(final Feed feed, final Entry entry, final String baseURI, final List<Element> eLinks) {
|
private List<Link> parseOtherLinks(final Feed feed, final Entry entry, final String baseURI, final List<Element> eLinks) {
|
||||||
|
|
||||||
final List<Link> links = new ArrayList<Link>();
|
final List<Link> links = new ArrayList<Link>();
|
||||||
for (int i = 0; i < eLinks.size(); i++) {
|
for (final Element eLink : eLinks) {
|
||||||
final Element eLink = eLinks.get(i);
|
|
||||||
final Link link = parseLink(feed, entry, baseURI, eLink);
|
final Link link = parseLink(feed, entry, baseURI, eLink);
|
||||||
if (!"alternate".equals(link.getRel())) {
|
if (!"alternate".equals(link.getRel())) {
|
||||||
links.add(link);
|
links.add(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!links.isEmpty()) {
|
|
||||||
return links;
|
return Lists.emptyToNull(links);
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Person parsePerson(final String baseURI, final Element ePerson, final Locale locale) {
|
private Person parsePerson(final String baseURI, final Element ePerson, final Locale locale) {
|
||||||
|
|
||||||
final Person person = new Person();
|
final Person person = new Person();
|
||||||
Element e = ePerson.getChild("name", getAtomNamespace());
|
|
||||||
if (e != null) {
|
final Element name = ePerson.getChild("name", getAtomNamespace());
|
||||||
person.setName(e.getText());
|
if (name != null) {
|
||||||
|
person.setName(name.getText());
|
||||||
}
|
}
|
||||||
e = ePerson.getChild("uri", getAtomNamespace());
|
|
||||||
if (e != null) {
|
final Element uri = ePerson.getChild("uri", getAtomNamespace());
|
||||||
person.setUri(e.getText());
|
if (uri != null) {
|
||||||
if (isRelativeURI(e.getText())) {
|
person.setUri(uri.getText());
|
||||||
person.setUriResolved(resolveURI(baseURI, ePerson, e.getText()));
|
if (isRelativeURI(uri.getText())) {
|
||||||
|
person.setUriResolved(resolveURI(baseURI, ePerson, uri.getText()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e = ePerson.getChild("email", getAtomNamespace());
|
|
||||||
if (e != null) {
|
final Element email = ePerson.getChild("email", getAtomNamespace());
|
||||||
person.setEmail(e.getText());
|
if (email != null) {
|
||||||
|
person.setEmail(email.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
person.setModules(parsePersonModules(ePerson, locale));
|
person.setModules(parsePersonModules(ePerson, locale));
|
||||||
|
|
||||||
return person;
|
return person;
|
||||||
}
|
}
|
||||||
|
|
||||||
// List(Elements) -> List(Persons)
|
// List(Elements) -> List(Persons)
|
||||||
private List<SyndPerson> parsePersons(final String baseURI, final List<Element> ePersons, final Locale locale) {
|
private List<SyndPerson> parsePersons(final String baseURI, final List<Element> ePersons, final Locale locale) {
|
||||||
|
|
||||||
final List<SyndPerson> persons = new ArrayList<SyndPerson>();
|
final List<SyndPerson> persons = new ArrayList<SyndPerson>();
|
||||||
for (int i = 0; i < ePersons.size(); i++) {
|
for (final Element ePerson : ePersons) {
|
||||||
persons.add(parsePerson(baseURI, ePersons.get(i), locale));
|
persons.add(parsePerson(baseURI, ePerson, locale));
|
||||||
}
|
|
||||||
if (!persons.isEmpty()) {
|
|
||||||
return persons;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Lists.emptyToNull(persons);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Content parseContent(final Element e) {
|
private Content parseContent(final Element e) {
|
||||||
|
|
||||||
final String value = parseTextConstructToString(e);
|
final String value = parseTextConstructToString(e);
|
||||||
final String src = getAttributeValue(e, "src");
|
final String src = getAttributeValue(e, "src");
|
||||||
final String type = getAttributeValue(e, "type");
|
final String type = getAttributeValue(e, "type");
|
||||||
|
|
||||||
final Content content = new Content();
|
final Content content = new Content();
|
||||||
content.setSrc(src);
|
content.setSrc(src);
|
||||||
content.setType(type);
|
content.setType(type);
|
||||||
content.setValue(value);
|
content.setValue(value);
|
||||||
return content;
|
return content;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String parseTextConstructToString(final Element e) {
|
private String parseTextConstructToString(final Element e) {
|
||||||
String value = null;
|
|
||||||
String type = getAttributeValue(e, "type");
|
String type = getAttributeValue(e, "type");
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
type = Content.TEXT;
|
type = Content.TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String value = null;
|
||||||
if (type.equals(Content.XHTML) || type.indexOf("/xml") != -1 || type.indexOf("+xml") != -1) {
|
if (type.equals(Content.XHTML) || type.indexOf("/xml") != -1 || type.indexOf("+xml") != -1) {
|
||||||
// XHTML content needs special handling
|
// XHTML content needs special handling
|
||||||
final XMLOutputter outputter = new XMLOutputter();
|
final XMLOutputter outputter = new XMLOutputter();
|
||||||
|
@ -349,23 +369,25 @@ public class Atom10Parser extends BaseWireFeedParser {
|
||||||
// Everything else comes in verbatim
|
// Everything else comes in verbatim
|
||||||
value = e.getText();
|
value = e.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List(Elements) -> List(Entries)
|
// List(Elements) -> List(Entries)
|
||||||
protected List<Entry> parseEntries(final Feed feed, final String baseURI, final List<Element> eEntries, final Locale locale) {
|
protected List<Entry> parseEntries(final Feed feed, final String baseURI, final List<Element> eEntries, final Locale locale) {
|
||||||
|
|
||||||
final List<Entry> entries = new ArrayList<Entry>();
|
final List<Entry> entries = new ArrayList<Entry>();
|
||||||
for (int i = 0; i < eEntries.size(); i++) {
|
for (final Element entry : eEntries) {
|
||||||
entries.add(this.parseEntry(feed, eEntries.get(i), baseURI, locale));
|
entries.add(this.parseEntry(feed, entry, baseURI, locale));
|
||||||
}
|
|
||||||
if (!entries.isEmpty()) {
|
|
||||||
return entries;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Lists.emptyToNull(entries);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Entry parseEntry(final Feed feed, final Element eEntry, final String baseURI, final Locale locale) {
|
protected Entry parseEntry(final Feed feed, final Element eEntry, final String baseURI, final Locale locale) {
|
||||||
|
|
||||||
final Entry entry = new Entry();
|
final Entry entry = new Entry();
|
||||||
|
|
||||||
final String xmlBase = eEntry.getAttributeValue("base", Namespace.XML_NAMESPACE);
|
final String xmlBase = eEntry.getAttributeValue("base", Namespace.XML_NAMESPACE);
|
||||||
|
@ -373,67 +395,67 @@ public class Atom10Parser extends BaseWireFeedParser {
|
||||||
entry.setXmlBase(xmlBase);
|
entry.setXmlBase(xmlBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
Element e = eEntry.getChild("title", getAtomNamespace());
|
final Element title = eEntry.getChild("title", getAtomNamespace());
|
||||||
if (e != null) {
|
if (title != null) {
|
||||||
final Content c = new Content();
|
final Content c = new Content();
|
||||||
c.setValue(parseTextConstructToString(e));
|
c.setValue(parseTextConstructToString(title));
|
||||||
c.setType(getAttributeValue(e, "type"));
|
c.setType(getAttributeValue(title, "type"));
|
||||||
entry.setTitleEx(c);
|
entry.setTitleEx(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Element> eList = eEntry.getChildren("link", getAtomNamespace());
|
final List<Element> links = eEntry.getChildren("link", getAtomNamespace());
|
||||||
entry.setAlternateLinks(parseAlternateLinks(feed, entry, baseURI, eList));
|
entry.setAlternateLinks(parseAlternateLinks(feed, entry, baseURI, links));
|
||||||
entry.setOtherLinks(parseOtherLinks(feed, entry, baseURI, eList));
|
entry.setOtherLinks(parseOtherLinks(feed, entry, baseURI, links));
|
||||||
|
|
||||||
eList = eEntry.getChildren("author", getAtomNamespace());
|
final List<Element> authors = eEntry.getChildren("author", getAtomNamespace());
|
||||||
if (!eList.isEmpty()) {
|
if (!authors.isEmpty()) {
|
||||||
entry.setAuthors(parsePersons(baseURI, eList, locale));
|
entry.setAuthors(parsePersons(baseURI, authors, locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
eList = eEntry.getChildren("contributor", getAtomNamespace());
|
final List<Element> contributors = eEntry.getChildren("contributor", getAtomNamespace());
|
||||||
if (!eList.isEmpty()) {
|
if (!contributors.isEmpty()) {
|
||||||
entry.setContributors(parsePersons(baseURI, eList, locale));
|
entry.setContributors(parsePersons(baseURI, contributors, locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eEntry.getChild("id", getAtomNamespace());
|
final Element id = eEntry.getChild("id", getAtomNamespace());
|
||||||
if (e != null) {
|
if (id != null) {
|
||||||
entry.setId(e.getText());
|
entry.setId(id.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eEntry.getChild("updated", getAtomNamespace());
|
final Element updated = eEntry.getChild("updated", getAtomNamespace());
|
||||||
if (e != null) {
|
if (updated != null) {
|
||||||
entry.setUpdated(DateParser.parseDate(e.getText(), locale));
|
entry.setUpdated(DateParser.parseDate(updated.getText(), locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eEntry.getChild("published", getAtomNamespace());
|
final Element published = eEntry.getChild("published", getAtomNamespace());
|
||||||
if (e != null) {
|
if (published != null) {
|
||||||
entry.setPublished(DateParser.parseDate(e.getText(), locale));
|
entry.setPublished(DateParser.parseDate(published.getText(), locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eEntry.getChild("summary", getAtomNamespace());
|
final Element summary = eEntry.getChild("summary", getAtomNamespace());
|
||||||
if (e != null) {
|
if (summary != null) {
|
||||||
entry.setSummary(parseContent(e));
|
entry.setSummary(parseContent(summary));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eEntry.getChild("content", getAtomNamespace());
|
final Element content = eEntry.getChild("content", getAtomNamespace());
|
||||||
if (e != null) {
|
if (content != null) {
|
||||||
final List<Content> contents = new ArrayList<Content>();
|
final List<Content> contents = new ArrayList<Content>();
|
||||||
contents.add(parseContent(e));
|
contents.add(parseContent(content));
|
||||||
entry.setContents(contents);
|
entry.setContents(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eEntry.getChild("rights", getAtomNamespace());
|
final Element rights = eEntry.getChild("rights", getAtomNamespace());
|
||||||
if (e != null) {
|
if (rights != null) {
|
||||||
entry.setRights(e.getText());
|
entry.setRights(rights.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Element> cList = eEntry.getChildren("category", getAtomNamespace());
|
final List<Element> categories = eEntry.getChildren("category", getAtomNamespace());
|
||||||
entry.setCategories(parseCategories(baseURI, cList));
|
entry.setCategories(parseCategories(baseURI, categories));
|
||||||
|
|
||||||
// TODO: SHOULD handle Atom entry source element
|
// TODO: SHOULD handle Atom entry source element
|
||||||
e = eEntry.getChild("source", getAtomNamespace());
|
final Element source = eEntry.getChild("source", getAtomNamespace());
|
||||||
if (e != null) {
|
if (source != null) {
|
||||||
entry.setSource(parseFeedMetadata(baseURI, e, locale));
|
entry.setSource(parseFeedMetadata(baseURI, source, locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.setModules(parseItemModules(eEntry, locale));
|
entry.setModules(parseItemModules(eEntry, locale));
|
||||||
|
@ -442,39 +464,43 @@ public class Atom10Parser extends BaseWireFeedParser {
|
||||||
if (!foreignMarkup.isEmpty()) {
|
if (!foreignMarkup.isEmpty()) {
|
||||||
entry.setForeignMarkup(foreignMarkup);
|
entry.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Category> parseCategories(final String baseURI, final List<Element> eCategories) {
|
private List<Category> parseCategories(final String baseURI, final List<Element> eCategories) {
|
||||||
|
|
||||||
final List<Category> cats = new ArrayList<Category>();
|
final List<Category> cats = new ArrayList<Category>();
|
||||||
for (int i = 0; i < eCategories.size(); i++) {
|
for (final Element eCategory : eCategories) {
|
||||||
final Element eCategory = eCategories.get(i);
|
|
||||||
cats.add(parseCategory(baseURI, eCategory));
|
cats.add(parseCategory(baseURI, eCategory));
|
||||||
}
|
}
|
||||||
if (!cats.isEmpty()) {
|
|
||||||
return cats;
|
return Lists.emptyToNull(cats);
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Category parseCategory(final String baseURI, final Element eCategory) {
|
private Category parseCategory(final String baseURI, final Element eCategory) {
|
||||||
|
|
||||||
final Category category = new Category();
|
final Category category = new Category();
|
||||||
String att = getAttributeValue(eCategory, "term");
|
|
||||||
if (att != null) {
|
final String term = getAttributeValue(eCategory, "term");
|
||||||
category.setTerm(att);
|
if (term != null) {
|
||||||
|
category.setTerm(term);
|
||||||
}
|
}
|
||||||
att = getAttributeValue(eCategory, "scheme");
|
|
||||||
if (att != null) {
|
final String scheme = getAttributeValue(eCategory, "scheme");
|
||||||
category.setScheme(att);
|
if (scheme != null) {
|
||||||
if (isRelativeURI(att)) {
|
category.setScheme(scheme);
|
||||||
category.setSchemeResolved(resolveURI(baseURI, eCategory, att));
|
if (isRelativeURI(scheme)) {
|
||||||
|
category.setSchemeResolved(resolveURI(baseURI, eCategory, scheme));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
att = getAttributeValue(eCategory, "label");
|
|
||||||
if (att != null) {
|
final String label = getAttributeValue(eCategory, "label");
|
||||||
category.setLabel(att);
|
if (label != null) {
|
||||||
|
category.setLabel(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
return category;
|
return category;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -506,10 +532,13 @@ public class Atom10Parser extends BaseWireFeedParser {
|
||||||
* @param url URL to be resolved
|
* @param url URL to be resolved
|
||||||
*/
|
*/
|
||||||
public static String resolveURI(final String baseURI, final Parent parent, String url) {
|
public static String resolveURI(final String baseURI, final Parent parent, String url) {
|
||||||
|
|
||||||
if (!resolveURIs) {
|
if (!resolveURIs) {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRelativeURI(url)) {
|
if (isRelativeURI(url)) {
|
||||||
|
|
||||||
if (".".equals(url) || "./".equals(url)) {
|
if (".".equals(url) || "./".equals(url)) {
|
||||||
url = "";
|
url = "";
|
||||||
}
|
}
|
||||||
|
@ -560,7 +589,9 @@ public class Atom10Parser extends BaseWireFeedParser {
|
||||||
return formURI(baseURI, url);
|
return formURI(baseURI, url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -658,7 +689,8 @@ public class Atom10Parser extends BaseWireFeedParser {
|
||||||
* Parse entry from reader.
|
* Parse entry from reader.
|
||||||
*/
|
*/
|
||||||
public static Entry parseEntry(final Reader rd, final String baseURI, final Locale locale) throws JDOMException, IOException, IllegalArgumentException,
|
public static Entry parseEntry(final Reader rd, final String baseURI, final Locale locale) throws JDOMException, IOException, IllegalArgumentException,
|
||||||
FeedException {
|
FeedException {
|
||||||
|
|
||||||
// Parse entry into JDOM tree
|
// Parse entry into JDOM tree
|
||||||
final SAXBuilder builder = new SAXBuilder();
|
final SAXBuilder builder = new SAXBuilder();
|
||||||
final Document entryDoc = builder.build(rd);
|
final Document entryDoc = builder.build(rd);
|
||||||
|
@ -681,4 +713,5 @@ public class Atom10Parser extends BaseWireFeedParser {
|
||||||
final Feed parsedFeed = (Feed) input.build(feedDoc);
|
final Feed parsedFeed = (Feed) input.build(feedDoc);
|
||||||
return parsedFeed.getEntries().get(0);
|
return parsedFeed.getEntries().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,25 +122,28 @@ public abstract class BaseWireFeedGenerator implements WireFeedGenerator {
|
||||||
// ConcurrentModificationException
|
// ConcurrentModificationException
|
||||||
// below
|
// below
|
||||||
|
|
||||||
for (int i = 0; i < additionalNamespaces.size(); i++) {
|
for (final Namespace ns : additionalNamespaces) {
|
||||||
final Namespace ns = additionalNamespaces.get(i);
|
|
||||||
final String prefix = ns.getPrefix();
|
final String prefix = ns.getPrefix();
|
||||||
if (prefix != null && prefix.length() > 0 && !usedPrefixes.contains(prefix)) {
|
if (prefix != null && prefix.length() > 0 && !usedPrefixes.contains(prefix)) {
|
||||||
root.removeNamespaceDeclaration(ns);
|
root.removeNamespaceDeclaration(ns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void collectUsedPrefixes(final Element el, final Set<String> collector) {
|
private static void collectUsedPrefixes(final Element el, final Set<String> collector) {
|
||||||
|
|
||||||
final String prefix = el.getNamespacePrefix();
|
final String prefix = el.getNamespacePrefix();
|
||||||
if (prefix != null && prefix.length() > 0 && !collector.contains(prefix)) {
|
if (prefix != null && prefix.length() > 0 && !collector.contains(prefix)) {
|
||||||
collector.add(prefix);
|
collector.add(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Element> kids = el.getChildren();
|
final List<Element> kids = el.getChildren();
|
||||||
for (int i = 0; i < kids.size(); i++) {
|
for (final Element kid : kids) {
|
||||||
collectUsedPrefixes(kids.get(i), collector); // recursion
|
// recursion- worth it
|
||||||
// - worth it
|
collectUsedPrefixes(kid, collector);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,9 @@ import com.sun.syndication.io.ModuleGenerator;
|
||||||
/**
|
/**
|
||||||
* Feed Generator for DublinCore Module.
|
* Feed Generator for DublinCore Module.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Elaine Chien
|
* @author Elaine Chien
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DCModuleGenerator implements ModuleGenerator {
|
public class DCModuleGenerator implements ModuleGenerator {
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class DCModuleGenerator implements ModuleGenerator {
|
||||||
* It is used by the the feed generators to add their namespace definition in the root element
|
* It is used by the the feed generators to add their namespace definition in the root element
|
||||||
* of the generated document (forward-missing of Java 5.0 Generics).
|
* of the generated document (forward-missing of Java 5.0 Generics).
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @return a set with all the URIs this module generator uses.
|
* @return a set with all the URIs this module generator uses.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,97 +94,137 @@ public class DCModuleGenerator implements ModuleGenerator {
|
||||||
/**
|
/**
|
||||||
* Populate an element tree with elements for a module.
|
* Populate an element tree with elements for a module.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param module the module to populate from.
|
* @param module the module to populate from.
|
||||||
* @param element the root element to attach child elements to.
|
* @param element the root element to attach child elements to.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void generate(final Module module, final Element element) {
|
public final void generate(final Module module, final Element element) {
|
||||||
|
|
||||||
final DCModule dcModule = (DCModule) module;
|
final DCModule dcModule = (DCModule) module;
|
||||||
|
|
||||||
if (dcModule.getTitle() != null) {
|
final String title = dcModule.getTitle();
|
||||||
|
if (title != null) {
|
||||||
element.addContent(generateSimpleElementList("title", dcModule.getTitles()));
|
element.addContent(generateSimpleElementList("title", dcModule.getTitles()));
|
||||||
}
|
}
|
||||||
if (dcModule.getCreator() != null) {
|
|
||||||
|
final String creator = dcModule.getCreator();
|
||||||
|
if (creator != null) {
|
||||||
element.addContent(generateSimpleElementList("creator", dcModule.getCreators()));
|
element.addContent(generateSimpleElementList("creator", dcModule.getCreators()));
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<DCSubject> subjects = dcModule.getSubjects();
|
final List<DCSubject> subjects = dcModule.getSubjects();
|
||||||
for (int i = 0; i < subjects.size(); i++) {
|
for (final DCSubject dcSubject : subjects) {
|
||||||
element.addContent(generateSubjectElement(subjects.get(i)));
|
element.addContent(generateSubjectElement(dcSubject));
|
||||||
}
|
}
|
||||||
if (dcModule.getDescription() != null) {
|
|
||||||
|
final String description = dcModule.getDescription();
|
||||||
|
if (description != null) {
|
||||||
element.addContent(generateSimpleElementList("description", dcModule.getDescriptions()));
|
element.addContent(generateSimpleElementList("description", dcModule.getDescriptions()));
|
||||||
}
|
}
|
||||||
if (dcModule.getPublisher() != null) {
|
|
||||||
|
final String publisher = dcModule.getPublisher();
|
||||||
|
if (publisher != null) {
|
||||||
element.addContent(generateSimpleElementList("publisher", dcModule.getPublishers()));
|
element.addContent(generateSimpleElementList("publisher", dcModule.getPublishers()));
|
||||||
}
|
}
|
||||||
if (dcModule.getContributors() != null) {
|
|
||||||
element.addContent(generateSimpleElementList("contributor", dcModule.getContributors()));
|
final List<String> contributors = dcModule.getContributors();
|
||||||
|
if (contributors != null) {
|
||||||
|
element.addContent(generateSimpleElementList("contributor", contributors));
|
||||||
}
|
}
|
||||||
if (dcModule.getDate() != null) {
|
|
||||||
|
final Date dcDate = dcModule.getDate();
|
||||||
|
if (dcDate != null) {
|
||||||
for (final Date date : dcModule.getDates()) {
|
for (final Date date : dcModule.getDates()) {
|
||||||
element.addContent(generateSimpleElement("date", DateParser.formatW3CDateTime(date, Locale.US)));
|
element.addContent(generateSimpleElement("date", DateParser.formatW3CDateTime(date, Locale.US)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dcModule.getType() != null) {
|
|
||||||
|
final String type = dcModule.getType();
|
||||||
|
if (type != null) {
|
||||||
element.addContent(generateSimpleElementList("type", dcModule.getTypes()));
|
element.addContent(generateSimpleElementList("type", dcModule.getTypes()));
|
||||||
}
|
}
|
||||||
if (dcModule.getFormat() != null) {
|
|
||||||
|
final String format = dcModule.getFormat();
|
||||||
|
if (format != null) {
|
||||||
element.addContent(generateSimpleElementList("format", dcModule.getFormats()));
|
element.addContent(generateSimpleElementList("format", dcModule.getFormats()));
|
||||||
}
|
}
|
||||||
if (dcModule.getIdentifier() != null) {
|
|
||||||
|
final String identifier = dcModule.getIdentifier();
|
||||||
|
if (identifier != null) {
|
||||||
element.addContent(generateSimpleElementList("identifier", dcModule.getIdentifiers()));
|
element.addContent(generateSimpleElementList("identifier", dcModule.getIdentifiers()));
|
||||||
}
|
}
|
||||||
if (dcModule.getSource() != null) {
|
|
||||||
|
final String source = dcModule.getSource();
|
||||||
|
if (source != null) {
|
||||||
element.addContent(generateSimpleElementList("source", dcModule.getSources()));
|
element.addContent(generateSimpleElementList("source", dcModule.getSources()));
|
||||||
}
|
}
|
||||||
if (dcModule.getLanguage() != null) {
|
|
||||||
|
final String language = dcModule.getLanguage();
|
||||||
|
if (language != null) {
|
||||||
element.addContent(generateSimpleElementList("language", dcModule.getLanguages()));
|
element.addContent(generateSimpleElementList("language", dcModule.getLanguages()));
|
||||||
}
|
}
|
||||||
if (dcModule.getRelation() != null) {
|
|
||||||
|
final String relation = dcModule.getRelation();
|
||||||
|
if (relation != null) {
|
||||||
element.addContent(generateSimpleElementList("relation", dcModule.getRelations()));
|
element.addContent(generateSimpleElementList("relation", dcModule.getRelations()));
|
||||||
}
|
}
|
||||||
if (dcModule.getCoverage() != null) {
|
|
||||||
|
final String coverage = dcModule.getCoverage();
|
||||||
|
if (coverage != null) {
|
||||||
element.addContent(generateSimpleElementList("coverage", dcModule.getCoverages()));
|
element.addContent(generateSimpleElementList("coverage", dcModule.getCoverages()));
|
||||||
}
|
}
|
||||||
if (dcModule.getRights() != null) {
|
|
||||||
|
final String rights = dcModule.getRights();
|
||||||
|
if (rights != null) {
|
||||||
element.addContent(generateSimpleElementList("rights", dcModule.getRightsList()));
|
element.addContent(generateSimpleElementList("rights", dcModule.getRightsList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to generate an element for a subject.
|
* Utility method to generate an element for a subject.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param subject the subject to generate an element for.
|
* @param subject the subject to generate an element for.
|
||||||
* @return the element for the subject.
|
* @return the element for the subject.
|
||||||
*/
|
*/
|
||||||
protected final Element generateSubjectElement(final DCSubject subject) {
|
protected final Element generateSubjectElement(final DCSubject subject) {
|
||||||
|
|
||||||
final Element subjectElement = new Element("subject", getDCNamespace());
|
final Element subjectElement = new Element("subject", getDCNamespace());
|
||||||
|
|
||||||
if (subject.getTaxonomyUri() != null) {
|
final String taxonomyUri = subject.getTaxonomyUri();
|
||||||
final Element descriptionElement = new Element("Description", getRDFNamespace());
|
final String value = subject.getValue();
|
||||||
|
|
||||||
|
if (taxonomyUri != null) {
|
||||||
|
|
||||||
|
final Attribute resourceAttribute = new Attribute("resource", taxonomyUri, getRDFNamespace());
|
||||||
|
|
||||||
final Element topicElement = new Element("topic", getTaxonomyNamespace());
|
final Element topicElement = new Element("topic", getTaxonomyNamespace());
|
||||||
final Attribute resourceAttribute = new Attribute("resource", subject.getTaxonomyUri(), getRDFNamespace());
|
|
||||||
topicElement.setAttribute(resourceAttribute);
|
topicElement.setAttribute(resourceAttribute);
|
||||||
|
|
||||||
|
final Element descriptionElement = new Element("Description", getRDFNamespace());
|
||||||
descriptionElement.addContent(topicElement);
|
descriptionElement.addContent(topicElement);
|
||||||
|
|
||||||
if (subject.getValue() != null) {
|
if (value != null) {
|
||||||
final Element valueElement = new Element("value", getRDFNamespace());
|
final Element valueElement = new Element("value", getRDFNamespace());
|
||||||
valueElement.addContent(subject.getValue());
|
valueElement.addContent(value);
|
||||||
descriptionElement.addContent(valueElement);
|
descriptionElement.addContent(valueElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
subjectElement.addContent(descriptionElement);
|
subjectElement.addContent(descriptionElement);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
subjectElement.addContent(subject.getValue());
|
subjectElement.addContent(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return subjectElement;
|
return subjectElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to generate a single element containing a string.
|
* Utility method to generate a single element containing a string.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param name the name of the elment to generate.
|
* @param name the name of the elment to generate.
|
||||||
* @param value the value of the text in the element.
|
* @param value the value of the text in the element.
|
||||||
* @return the element generated.
|
* @return the element generated.
|
||||||
|
@ -192,24 +232,22 @@ public class DCModuleGenerator implements ModuleGenerator {
|
||||||
protected final Element generateSimpleElement(final String name, final String value) {
|
protected final Element generateSimpleElement(final String name, final String value) {
|
||||||
final Element element = new Element(name, getDCNamespace());
|
final Element element = new Element(name, getDCNamespace());
|
||||||
element.addContent(value);
|
element.addContent(value);
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to generate a list of simple elements.
|
* Utility method to generate a list of simple elements.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param name the name of the element list to generate.
|
* @param name the name of the element list to generate.
|
||||||
* @param value the list of values for the elements.
|
* @param values the list of values for the elements.
|
||||||
* @return a list of Elements created.
|
* @return a list of Elements created.
|
||||||
*/
|
*/
|
||||||
protected final List<Element> generateSimpleElementList(final String name, final List<String> value) {
|
protected final List<Element> generateSimpleElementList(final String name, final List<String> values) {
|
||||||
final List<Element> elements = new ArrayList<Element>();
|
final List<Element> elements = new ArrayList<Element>();
|
||||||
for (final String string : value) {
|
for (final String value : values) {
|
||||||
elements.add(generateSimpleElement(name, string));
|
elements.add(generateSimpleElement(name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,139 +64,163 @@ public class DCModuleParser implements ModuleParser {
|
||||||
/**
|
/**
|
||||||
* Parse an element tree and return the module found in it.
|
* Parse an element tree and return the module found in it.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param dcRoot the root element containing the module elements.
|
* @param dcRoot the root element containing the module elements.
|
||||||
* @param locale for date/time parsing
|
* @param locale for date/time parsing
|
||||||
* @return the module parsed from the element tree, <i>null</i> if none.
|
* @return the module parsed from the element tree, <i>null</i> if none.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Module parse(final Element dcRoot, final Locale locale) {
|
public Module parse(final Element dcRoot, final Locale locale) {
|
||||||
|
|
||||||
boolean foundSomething = false;
|
boolean foundSomething = false;
|
||||||
final DCModule dcm = new DCModuleImpl();
|
final DCModule dcm = new DCModuleImpl();
|
||||||
|
|
||||||
List<Element> eList = dcRoot.getChildren("title", getDCNamespace());
|
final List<Element> titles = dcRoot.getChildren("title", getDCNamespace());
|
||||||
if (!eList.isEmpty()) {
|
if (!titles.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setTitles(parseElementList(eList));
|
dcm.setTitles(parseElementList(titles));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("creator", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> creators = dcRoot.getChildren("creator", getDCNamespace());
|
||||||
|
if (!creators.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setCreators(parseElementList(eList));
|
dcm.setCreators(parseElementList(creators));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("subject", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> subjects = dcRoot.getChildren("subject", getDCNamespace());
|
||||||
|
if (!subjects.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setSubjects(parseSubjects(eList));
|
dcm.setSubjects(parseSubjects(subjects));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("description", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> descriptions = dcRoot.getChildren("description", getDCNamespace());
|
||||||
|
if (!descriptions.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setDescriptions(parseElementList(eList));
|
dcm.setDescriptions(parseElementList(descriptions));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("publisher", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> publishers = dcRoot.getChildren("publisher", getDCNamespace());
|
||||||
|
if (!publishers.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setPublishers(parseElementList(eList));
|
dcm.setPublishers(parseElementList(publishers));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("contributor", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> contributors = dcRoot.getChildren("contributor", getDCNamespace());
|
||||||
|
if (!contributors.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setContributors(parseElementList(eList));
|
dcm.setContributors(parseElementList(contributors));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("date", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> dates = dcRoot.getChildren("date", getDCNamespace());
|
||||||
|
if (!dates.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setDates(parseElementListDate(eList, locale));
|
dcm.setDates(parseElementListDate(dates, locale));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("type", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> types = dcRoot.getChildren("type", getDCNamespace());
|
||||||
|
if (!types.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setTypes(parseElementList(eList));
|
dcm.setTypes(parseElementList(types));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("format", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> formats = dcRoot.getChildren("format", getDCNamespace());
|
||||||
|
if (!formats.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setFormats(parseElementList(eList));
|
dcm.setFormats(parseElementList(formats));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("identifier", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> identifiers = dcRoot.getChildren("identifier", getDCNamespace());
|
||||||
|
if (!identifiers.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setIdentifiers(parseElementList(eList));
|
dcm.setIdentifiers(parseElementList(identifiers));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("source", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> sources = dcRoot.getChildren("source", getDCNamespace());
|
||||||
|
if (!sources.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setSources(parseElementList(eList));
|
dcm.setSources(parseElementList(sources));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("language", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> languages = dcRoot.getChildren("language", getDCNamespace());
|
||||||
|
if (!languages.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setLanguages(parseElementList(eList));
|
dcm.setLanguages(parseElementList(languages));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("relation", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> relations = dcRoot.getChildren("relation", getDCNamespace());
|
||||||
|
if (!relations.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setRelations(parseElementList(eList));
|
dcm.setRelations(parseElementList(relations));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("coverage", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> coverages = dcRoot.getChildren("coverage", getDCNamespace());
|
||||||
|
if (!coverages.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setCoverages(parseElementList(eList));
|
dcm.setCoverages(parseElementList(coverages));
|
||||||
}
|
}
|
||||||
eList = dcRoot.getChildren("rights", getDCNamespace());
|
|
||||||
if (!eList.isEmpty()) {
|
final List<Element> rights = dcRoot.getChildren("rights", getDCNamespace());
|
||||||
|
if (!rights.isEmpty()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
dcm.setRightsList(parseElementList(eList));
|
dcm.setRightsList(parseElementList(rights));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundSomething) {
|
if (foundSomething) {
|
||||||
return dcm;
|
return dcm;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to parse a taxonomy from an element.
|
* Utility method to parse a taxonomy from an element.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param desc the taxonomy description element.
|
* @param desc the taxonomy description element.
|
||||||
* @return the string contained in the resource of the element.
|
* @return the string contained in the resource of the element.
|
||||||
*/
|
*/
|
||||||
protected final String getTaxonomy(final Element desc) {
|
protected final String getTaxonomy(final Element desc) {
|
||||||
String d = null;
|
String taxonomy = null;
|
||||||
final Element taxo = desc.getChild("topic", getTaxonomyNamespace());
|
final Element topic = desc.getChild("topic", getTaxonomyNamespace());
|
||||||
if (taxo != null) {
|
if (topic != null) {
|
||||||
final Attribute a = taxo.getAttribute("resource", getRDFNamespace());
|
final Attribute resource = topic.getAttribute("resource", getRDFNamespace());
|
||||||
if (a != null) {
|
if (resource != null) {
|
||||||
d = a.getValue();
|
taxonomy = resource.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return d;
|
return taxonomy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to parse a list of subjects out of a list of elements.
|
* Utility method to parse a list of subjects out of a list of elements.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param eList the element list to parse.
|
* @param eList the element list to parse.
|
||||||
* @return a list of subjects parsed from the elements.
|
* @return a list of subjects parsed from the elements.
|
||||||
*/
|
*/
|
||||||
protected final List<DCSubject> parseSubjects(final List<Element> eList) {
|
protected final List<DCSubject> parseSubjects(final List<Element> eList) {
|
||||||
|
|
||||||
final List<DCSubject> subjects = new ArrayList<DCSubject>();
|
final List<DCSubject> subjects = new ArrayList<DCSubject>();
|
||||||
for (final Element element : eList) {
|
|
||||||
final Element eSubject = element;
|
for (final Element eSubject : eList) {
|
||||||
final Element eDesc = eSubject.getChild("Description", getRDFNamespace());
|
|
||||||
if (eDesc != null) {
|
final Element description = eSubject.getChild("Description", getRDFNamespace());
|
||||||
final String taxonomy = getTaxonomy(eDesc);
|
|
||||||
final List<Element> eValues = eDesc.getChildren("value", getRDFNamespace());
|
if (description != null) {
|
||||||
for (final Element element2 : eValues) {
|
|
||||||
final Element eValue = element2;
|
final String taxonomy = getTaxonomy(description);
|
||||||
|
|
||||||
|
final List<Element> values = description.getChildren("value", getRDFNamespace());
|
||||||
|
for (final Element value : values) {
|
||||||
|
|
||||||
final DCSubject subject = new DCSubjectImpl();
|
final DCSubject subject = new DCSubjectImpl();
|
||||||
subject.setTaxonomyUri(taxonomy);
|
subject.setTaxonomyUri(taxonomy);
|
||||||
subject.setValue(eValue.getText());
|
subject.setValue(value.getText());
|
||||||
subjects.add(subject);
|
subjects.add(subject);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
final DCSubject subject = new DCSubjectImpl();
|
final DCSubject subject = new DCSubjectImpl();
|
||||||
subject.setValue(eSubject.getText());
|
subject.setValue(eSubject.getText());
|
||||||
|
@ -210,34 +234,31 @@ public class DCModuleParser implements ModuleParser {
|
||||||
/**
|
/**
|
||||||
* Utility method to parse a list of strings out of a list of elements.
|
* Utility method to parse a list of strings out of a list of elements.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param eList the list of elements to parse.
|
* @param elements the list of elements to parse.
|
||||||
* @return the list of strings
|
* @return the list of strings
|
||||||
*/
|
*/
|
||||||
protected final List<String> parseElementList(final List<Element> eList) {
|
protected final List<String> parseElementList(final List<Element> elements) {
|
||||||
final List<String> values = new ArrayList<String>();
|
final List<String> values = new ArrayList<String>();
|
||||||
for (final Element element : eList) {
|
for (final Element element : elements) {
|
||||||
final Element e = element;
|
values.add(element.getText());
|
||||||
values.add(e.getText());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to parse a list of dates out of a list of elements.
|
* Utility method to parse a list of dates out of a list of elements.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param eList the list of elements to parse.
|
* @param elements the list of elements to parse.
|
||||||
* @return the list of dates.
|
* @return the list of dates.
|
||||||
*/
|
*/
|
||||||
protected final List<Date> parseElementListDate(final List<Element> eList, final Locale locale) {
|
protected final List<Date> parseElementListDate(final List<Element> elements, final Locale locale) {
|
||||||
final List<Date> values = new ArrayList<Date>();
|
final List<Date> values = new ArrayList<Date>();
|
||||||
for (final Element element : eList) {
|
for (final Element element : elements) {
|
||||||
final Element e = element;
|
values.add(DateParser.parseDate(element.getText(), locale));
|
||||||
values.add(DateParser.parseDate(e.getText(), locale));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,44 +31,34 @@ import java.util.TimeZone;
|
||||||
* It uses the JDK java.text.SimpleDateFormat class attemtping the parse using a mask for each one
|
* It uses the JDK java.text.SimpleDateFormat class attemtping the parse using a mask for each one
|
||||||
* of the possible formats.
|
* of the possible formats.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DateParser {
|
public class DateParser {
|
||||||
|
|
||||||
private static String[] ADDITIONAL_MASKS;
|
private static String[] ADDITIONAL_MASKS;
|
||||||
|
|
||||||
static {
|
// order is like this because the SimpleDateFormat.parse does not fail with exception if it can
|
||||||
ADDITIONAL_MASKS = PropertiesLoader.getPropertiesLoader().getTokenizedProperty("datetime.extra.masks", "|");
|
// parse a valid date out of a substring of the full string given the mask so we have to check
|
||||||
}
|
// the most complete format first, then it fails with exception
|
||||||
|
|
||||||
// order is like this because the SimpleDateFormat.parse does not fail with
|
|
||||||
// exception
|
|
||||||
// if it can parse a valid date out of a substring of the full string given
|
|
||||||
// the mask
|
|
||||||
// so we have to check the most complete format first, then it fails with
|
|
||||||
// exception
|
|
||||||
private static final String[] RFC822_MASKS = { "EEE, dd MMM yy HH:mm:ss z", "EEE, dd MMM yy HH:mm z", "dd MMM yy HH:mm:ss z", "dd MMM yy HH:mm z" };
|
private static final String[] RFC822_MASKS = { "EEE, dd MMM yy HH:mm:ss z", "EEE, dd MMM yy HH:mm z", "dd MMM yy HH:mm:ss z", "dd MMM yy HH:mm z" };
|
||||||
|
|
||||||
// order is like this because the SimpleDateFormat.parse does not fail with
|
// order is like this because the SimpleDateFormat.parse does not fail with exception if it can
|
||||||
// exception
|
// parse a valid date out of a substring of the full string given the mask so we have to check
|
||||||
// if it can parse a valid date out of a substring of the full string given
|
// the most complete format first, then it fails with exception
|
||||||
// the mask
|
|
||||||
// so we have to check the most complete format first, then it fails with
|
|
||||||
// exception
|
|
||||||
private static final String[] W3CDATETIME_MASKS = { "yyyy-MM-dd'T'HH:mm:ss.SSSz", "yyyy-MM-dd't'HH:mm:ss.SSSz", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
|
private static final String[] W3CDATETIME_MASKS = { "yyyy-MM-dd'T'HH:mm:ss.SSSz", "yyyy-MM-dd't'HH:mm:ss.SSSz", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
|
||||||
"yyyy-MM-dd't'HH:mm:ss.SSS'z'", "yyyy-MM-dd'T'HH:mm:ssz", "yyyy-MM-dd't'HH:mm:ssz", "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd't'HH:mm:ssZ",
|
"yyyy-MM-dd't'HH:mm:ss.SSS'z'", "yyyy-MM-dd'T'HH:mm:ssz", "yyyy-MM-dd't'HH:mm:ssz", "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd't'HH:mm:ssZ",
|
||||||
"yyyy-MM-dd'T'HH:mm:ss'Z'", "yyyy-MM-dd't'HH:mm:ss'z'", "yyyy-MM-dd'T'HH:mmz", // together
|
"yyyy-MM-dd'T'HH:mm:ss'Z'", "yyyy-MM-dd't'HH:mm:ss'z'", "yyyy-MM-dd'T'HH:mmz", // together
|
||||||
// with
|
// with
|
||||||
// logic
|
// logic
|
||||||
// in
|
// in
|
||||||
// the
|
// the
|
||||||
// parseW3CDateTime
|
// parseW3CDateTime
|
||||||
// they
|
// they
|
||||||
"yyyy-MM'T'HH:mmz", // handle W3C dates without time forcing them to
|
"yyyy-MM'T'HH:mmz", // handle W3C dates without time forcing them to
|
||||||
// be GMT
|
// be GMT
|
||||||
"yyyy'T'HH:mmz", "yyyy-MM-dd't'HH:mmz", "yyyy-MM-dd'T'HH:mm'Z'", "yyyy-MM-dd't'HH:mm'z'", "yyyy-MM-dd", "yyyy-MM", "yyyy" };
|
"yyyy'T'HH:mmz", "yyyy-MM-dd't'HH:mmz", "yyyy-MM-dd'T'HH:mm'Z'", "yyyy-MM-dd't'HH:mm'z'", "yyyy-MM-dd", "yyyy-MM", "yyyy" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The masks used to validate and parse the input to this Atom date. These are a lot more
|
* The masks used to validate and parse the input to this Atom date. These are a lot more
|
||||||
|
@ -77,14 +67,18 @@ public class DateParser {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static final String[] masks = { "yyyy-MM-dd'T'HH:mm:ss.SSSz", "yyyy-MM-dd't'HH:mm:ss.SSSz", // invalid
|
private static final String[] masks = { "yyyy-MM-dd'T'HH:mm:ss.SSSz", "yyyy-MM-dd't'HH:mm:ss.SSSz", // invalid
|
||||||
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd't'HH:mm:ss.SSS'z'", // invalid
|
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd't'HH:mm:ss.SSS'z'", // invalid
|
||||||
"yyyy-MM-dd'T'HH:mm:ssz", "yyyy-MM-dd't'HH:mm:ssz", // invalid
|
"yyyy-MM-dd'T'HH:mm:ssz", "yyyy-MM-dd't'HH:mm:ssz", // invalid
|
||||||
"yyyy-MM-dd'T'HH:mm:ss'Z'", "yyyy-MM-dd't'HH:mm:ss'z'", // invalid
|
"yyyy-MM-dd'T'HH:mm:ss'Z'", "yyyy-MM-dd't'HH:mm:ss'z'", // invalid
|
||||||
"yyyy-MM-dd'T'HH:mmz", // invalid
|
"yyyy-MM-dd'T'HH:mmz", // invalid
|
||||||
"yyyy-MM-dd't'HH:mmz", // invalid
|
"yyyy-MM-dd't'HH:mmz", // invalid
|
||||||
"yyyy-MM-dd'T'HH:mm'Z'", // invalid
|
"yyyy-MM-dd'T'HH:mm'Z'", // invalid
|
||||||
"yyyy-MM-dd't'HH:mm'z'", // invalid
|
"yyyy-MM-dd't'HH:mm'z'", // invalid
|
||||||
"yyyy-MM-dd", "yyyy-MM", "yyyy" };
|
"yyyy-MM-dd", "yyyy-MM", "yyyy" };
|
||||||
|
|
||||||
|
static {
|
||||||
|
ADDITIONAL_MASKS = PropertiesLoader.getPropertiesLoader().getTokenizedProperty("datetime.extra.masks", "|");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private constructor to avoid DateParser instances creation.
|
* Private constructor to avoid DateParser instances creation.
|
||||||
|
@ -97,12 +91,12 @@ public class DateParser {
|
||||||
* <p/>
|
* <p/>
|
||||||
* It uses the masks in order until one of them succedes or all fail.
|
* It uses the masks in order until one of them succedes or all fail.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @param masks array of masks to use for parsing the string
|
* @param masks array of masks to use for parsing the string
|
||||||
* @param sDate string to parse for a date.
|
* @param sDate string to parse for a date.
|
||||||
* @return the Date represented by the given string using one of the given masks. It returns
|
* @return the Date represented by the given string using one of the given masks. It returns
|
||||||
* <b>null</b> if it was not possible to parse the the string with any of the masks.
|
* <b>null</b> if it was not possible to parse the the string with any of the masks.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static Date parseUsingMask(final String[] masks, String sDate, final Locale locale) {
|
private static Date parseUsingMask(final String[] masks, String sDate, final Locale locale) {
|
||||||
if (sDate != null) {
|
if (sDate != null) {
|
||||||
|
@ -145,11 +139,11 @@ public class DateParser {
|
||||||
* <p/>
|
* <p/>
|
||||||
* Refer to the java.text.SimpleDateFormat javadocs for details on the format of each element.
|
* Refer to the java.text.SimpleDateFormat javadocs for details on the format of each element.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @param sDate string to parse for a date.
|
* @param sDate string to parse for a date.
|
||||||
* @return the Date represented by the given RFC822 string. It returns <b>null</b> if it was not
|
* @return the Date represented by the given RFC822 string. It returns <b>null</b> if it was not
|
||||||
* possible to parse the given string into a Date.
|
* possible to parse the given string into a Date.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static Date parseRFC822(String sDate, final Locale locale) {
|
public static Date parseRFC822(String sDate, final Locale locale) {
|
||||||
final int utIndex = sDate.indexOf(" UT");
|
final int utIndex = sDate.indexOf(" UT");
|
||||||
|
@ -175,16 +169,15 @@ public class DateParser {
|
||||||
* <p/>
|
* <p/>
|
||||||
* Refer to the java.text.SimpleDateFormat javadocs for details on the format of each element.
|
* Refer to the java.text.SimpleDateFormat javadocs for details on the format of each element.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @param sDate string to parse for a date.
|
* @param sDate string to parse for a date.
|
||||||
* @return the Date represented by the given W3C date-time string. It returns <b>null</b> if it
|
* @return the Date represented by the given W3C date-time string. It returns <b>null</b> if it
|
||||||
* was not possible to parse the given string into a Date.
|
* was not possible to parse the given string into a Date.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static Date parseW3CDateTime(String sDate, final Locale locale) {
|
public static Date parseW3CDateTime(String sDate, final Locale locale) {
|
||||||
// if sDate has time on it, it injects 'GTM' before de TZ displacement
|
// if sDate has time on it, it injects 'GTM' before de TZ displacement to allow the
|
||||||
// to
|
// SimpleDateFormat parser to parse it properly
|
||||||
// allow the SimpleDateFormat parser to parse it properly
|
|
||||||
final int tIndex = sDate.indexOf("T");
|
final int tIndex = sDate.indexOf("T");
|
||||||
if (tIndex > -1) {
|
if (tIndex > -1) {
|
||||||
if (sDate.endsWith("Z")) {
|
if (sDate.endsWith("Z")) {
|
||||||
|
@ -212,21 +205,21 @@ public class DateParser {
|
||||||
/**
|
/**
|
||||||
* Parses a Date out of a String with a date in W3C date-time format or in a RFC822 format.
|
* Parses a Date out of a String with a date in W3C date-time format or in a RFC822 format.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param sDate string to parse for a date.
|
* @param sDate string to parse for a date.
|
||||||
* @return the Date represented by the given W3C date-time string. It returns <b>null</b> if it
|
* @return the Date represented by the given W3C date-time string. It returns <b>null</b> if it
|
||||||
* was not possible to parse the given string into a Date.
|
* was not possible to parse the given string into a Date.
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
public static Date parseDate(final String sDate, final Locale locale) {
|
public static Date parseDate(final String sDate, final Locale locale) {
|
||||||
Date d = parseW3CDateTime(sDate, locale);
|
Date date = parseW3CDateTime(sDate, locale);
|
||||||
if (d == null) {
|
if (date == null) {
|
||||||
d = parseRFC822(sDate, locale);
|
date = parseRFC822(sDate, locale);
|
||||||
if (d == null && ADDITIONAL_MASKS.length > 0) {
|
if (date == null && ADDITIONAL_MASKS.length > 0) {
|
||||||
d = parseUsingMask(ADDITIONAL_MASKS, sDate, locale);
|
date = parseUsingMask(ADDITIONAL_MASKS, sDate, locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return d;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -234,11 +227,11 @@ public class DateParser {
|
||||||
* <p/>
|
* <p/>
|
||||||
* Refer to the java.text.SimpleDateFormat javadocs for details on the format of each element.
|
* Refer to the java.text.SimpleDateFormat javadocs for details on the format of each element.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @param date Date to parse
|
* @param date Date to parse
|
||||||
* @return the RFC822 represented by the given Date It returns <b>null</b> if it was not
|
* @return the RFC822 represented by the given Date It returns <b>null</b> if it was not
|
||||||
* possible to parse the date.
|
* possible to parse the date.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static String formatRFC822(final Date date, final Locale locale) {
|
public static String formatRFC822(final Date date, final Locale locale) {
|
||||||
final SimpleDateFormat dateFormater = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", locale);
|
final SimpleDateFormat dateFormater = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", locale);
|
||||||
|
@ -251,11 +244,11 @@ public class DateParser {
|
||||||
* <p/>
|
* <p/>
|
||||||
* Refer to the java.text.SimpleDateFormat javadocs for details on the format of each element.
|
* Refer to the java.text.SimpleDateFormat javadocs for details on the format of each element.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @param date Date to parse
|
* @param date Date to parse
|
||||||
* @return the W3C Date Time represented by the given Date It returns <b>null</b> if it was not
|
* @return the W3C Date Time represented by the given Date It returns <b>null</b> if it was not
|
||||||
* possible to parse the date.
|
* possible to parse the date.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static String formatW3CDateTime(final Date date, final Locale locale) {
|
public static String formatW3CDateTime(final Date date, final Locale locale) {
|
||||||
final SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", locale);
|
final SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", locale);
|
||||||
|
|
|
@ -34,22 +34,22 @@ import com.sun.syndication.io.WireFeedParser;
|
||||||
* Parsers for a specific type must extend this class and register in the parser list. (Right now
|
* Parsers for a specific type must extend this class and register in the parser list. (Right now
|
||||||
* registration is hardcoded in the WireFeedParser constructor).
|
* registration is hardcoded in the WireFeedParser constructor).
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FeedParsers extends PluginManager<WireFeedParser> {
|
public class FeedParsers extends PluginManager<WireFeedParser> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WireFeedParser.classes= [className] ...
|
* WireFeedParser.classes= [className] ...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static final String FEED_PARSERS_KEY = "WireFeedParser.classes";
|
public static final String FEED_PARSERS_KEY = "WireFeedParser.classes";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a parser instance.
|
* Creates a parser instance.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public FeedParsers() {
|
public FeedParsers() {
|
||||||
super(FEED_PARSERS_KEY);
|
super(FEED_PARSERS_KEY);
|
||||||
|
@ -62,22 +62,20 @@ public class FeedParsers extends PluginManager<WireFeedParser> {
|
||||||
/**
|
/**
|
||||||
* Finds the real parser type for the given document feed.
|
* Finds the real parser type for the given document feed.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param document document feed to find the parser for.
|
* @param document document feed to find the parser for.
|
||||||
* @return the parser for the given document or <b>null</b> if there is no parser for that
|
* @return the parser for the given document or <b>null</b> if there is no parser for that
|
||||||
* document.
|
* document.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public WireFeedParser getParserFor(final Document document) {
|
public WireFeedParser getParserFor(final Document document) {
|
||||||
final List<WireFeedParser> parsers = getPlugins();
|
final List<WireFeedParser> parsers = getPlugins();
|
||||||
WireFeedParser parser = null;
|
for (final WireFeedParser parser : parsers) {
|
||||||
for (int i = 0; parser == null && i < parsers.size(); i++) {
|
if (parser.isMyType(document)) {
|
||||||
parser = parsers.get(i);
|
return parser;
|
||||||
if (!parser.isMyType(document)) {
|
|
||||||
parser = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return parser;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,9 +27,8 @@ import org.jdom2.Namespace;
|
||||||
import com.sun.syndication.feed.module.Module;
|
import com.sun.syndication.feed.module.Module;
|
||||||
import com.sun.syndication.io.ModuleGenerator;
|
import com.sun.syndication.io.ModuleGenerator;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class ModuleGenerators extends PluginManager<ModuleGenerator> {
|
public class ModuleGenerators extends PluginManager<ModuleGenerator> {
|
||||||
|
|
||||||
private Set<Namespace> allNamespaces;
|
private Set<Namespace> allNamespaces;
|
||||||
|
|
||||||
public ModuleGenerators(final String propertyKey, final BaseWireFeedGenerator parentGenerator) {
|
public ModuleGenerators(final String propertyKey, final BaseWireFeedGenerator parentGenerator) {
|
||||||
|
@ -51,8 +50,7 @@ public class ModuleGenerators extends PluginManager<ModuleGenerator> {
|
||||||
|
|
||||||
public void generateModules(final List<Module> modules, final Element element) {
|
public void generateModules(final List<Module> modules, final Element element) {
|
||||||
final Map<String, ModuleGenerator> generators = getPluginMap();
|
final Map<String, ModuleGenerator> generators = getPluginMap();
|
||||||
for (int i = 0; i < modules.size(); i++) {
|
for (final Module module : modules) {
|
||||||
final Module module = modules.get(i);
|
|
||||||
final String namespaceUri = module.getUri();
|
final String namespaceUri = module.getUri();
|
||||||
final ModuleGenerator generator = generators.get(namespaceUri);
|
final ModuleGenerator generator = generators.get(namespaceUri);
|
||||||
if (generator != null) {
|
if (generator != null) {
|
||||||
|
@ -65,11 +63,12 @@ public class ModuleGenerators extends PluginManager<ModuleGenerator> {
|
||||||
if (allNamespaces == null) {
|
if (allNamespaces == null) {
|
||||||
allNamespaces = new HashSet<Namespace>();
|
allNamespaces = new HashSet<Namespace>();
|
||||||
final List<String> mUris = getModuleNamespaces();
|
final List<String> mUris = getModuleNamespaces();
|
||||||
for (int i = 0; i < mUris.size(); i++) {
|
for (final String mUri : mUris) {
|
||||||
final ModuleGenerator mGen = getGenerator(mUris.get(i));
|
final ModuleGenerator mGen = getGenerator(mUri);
|
||||||
allNamespaces.addAll(mGen.getNamespaces());
|
allNamespaces.addAll(mGen.getNamespaces());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return allNamespaces;
|
return allNamespaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
*/
|
*/
|
||||||
package com.sun.syndication.io.impl;
|
package com.sun.syndication.io.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.jdom2.Element;
|
import org.jdom2.Element;
|
||||||
import org.jdom2.Namespace;
|
import org.jdom2.Namespace;
|
||||||
|
|
||||||
|
import com.rometools.utils.Lists;
|
||||||
import com.sun.syndication.feed.module.Module;
|
import com.sun.syndication.feed.module.Module;
|
||||||
import com.sun.syndication.io.ModuleParser;
|
import com.sun.syndication.io.ModuleParser;
|
||||||
import com.sun.syndication.io.WireFeedParser;
|
import com.sun.syndication.io.WireFeedParser;
|
||||||
|
@ -30,6 +30,7 @@ import com.sun.syndication.io.WireFeedParser;
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class ModuleParsers extends PluginManager<ModuleParser> {
|
public class ModuleParsers extends PluginManager<ModuleParser> {
|
||||||
|
|
||||||
public ModuleParsers(final String propertyKey, final WireFeedParser parentParser) {
|
public ModuleParsers(final String propertyKey, final WireFeedParser parentParser) {
|
||||||
super(propertyKey, parentParser, null);
|
super(propertyKey, parentParser, null);
|
||||||
}
|
}
|
||||||
|
@ -46,16 +47,13 @@ public class ModuleParsers extends PluginManager<ModuleParser> {
|
||||||
public List<Module> parseModules(final Element root, final Locale locale) {
|
public List<Module> parseModules(final Element root, final Locale locale) {
|
||||||
final List<ModuleParser> parsers = getPlugins();
|
final List<ModuleParser> parsers = getPlugins();
|
||||||
List<Module> modules = null;
|
List<Module> modules = null;
|
||||||
for (int i = 0; i < parsers.size(); i++) {
|
for (final ModuleParser parser : parsers) {
|
||||||
final ModuleParser parser = parsers.get(i);
|
|
||||||
final String namespaceUri = parser.getNamespaceUri();
|
final String namespaceUri = parser.getNamespaceUri();
|
||||||
final Namespace namespace = Namespace.getNamespace(namespaceUri);
|
final Namespace namespace = Namespace.getNamespace(namespaceUri);
|
||||||
if (hasElementsFrom(root, namespace)) {
|
if (hasElementsFrom(root, namespace)) {
|
||||||
final Module module = parser.parse(root, locale);
|
final Module module = parser.parse(root, locale);
|
||||||
if (module != null) {
|
if (module != null) {
|
||||||
if (modules == null) {
|
modules = Lists.createWhenNull(modules);
|
||||||
modules = new ArrayList<Module>();
|
|
||||||
}
|
|
||||||
modules.add(module);
|
modules.add(module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,15 +63,14 @@ public class ModuleParsers extends PluginManager<ModuleParser> {
|
||||||
|
|
||||||
private boolean hasElementsFrom(final Element root, final Namespace namespace) {
|
private boolean hasElementsFrom(final Element root, final Namespace namespace) {
|
||||||
boolean hasElements = false;
|
boolean hasElements = false;
|
||||||
// boolean hasElements = namespace.equals(root.getNamespace());
|
for (final Element child : root.getChildren()) {
|
||||||
|
final Namespace childNamespace = child.getNamespace();
|
||||||
if (!hasElements) {
|
if (namespace.equals(childNamespace)) {
|
||||||
final List<Element> children = root.getChildren();
|
hasElements = true;
|
||||||
for (int i = 0; !hasElements && i < children.size(); i++) {
|
break;
|
||||||
final Element child = children.get(i);
|
|
||||||
hasElements = namespace.equals(child.getNamespace());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hasElements;
|
return hasElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,16 +37,17 @@ import com.sun.syndication.io.WireFeedParser;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class PluginManager<T> {
|
public abstract class PluginManager<T> {
|
||||||
|
|
||||||
private final String[] propertyValues;
|
private final String[] propertyValues;
|
||||||
private Map<String, T> pluginsMap;
|
|
||||||
private List<T> pluginsList;
|
|
||||||
private final List<String> keys;
|
private final List<String> keys;
|
||||||
private final WireFeedParser parentParser;
|
private final WireFeedParser parentParser;
|
||||||
private final WireFeedGenerator parentGenerator;
|
private final WireFeedGenerator parentGenerator;
|
||||||
|
|
||||||
|
private Map<String, T> pluginsMap;
|
||||||
|
private List<T> pluginsList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a PluginManager
|
* Creates a PluginManager
|
||||||
* <p>
|
|
||||||
*
|
*
|
||||||
* @param propertyKey property key defining the plugins classes
|
* @param propertyKey property key defining the plugins classes
|
||||||
*
|
*
|
||||||
|
@ -86,25 +87,32 @@ public abstract class PluginManager<T> {
|
||||||
// PRIVATE - LOADER PART
|
// PRIVATE - LOADER PART
|
||||||
|
|
||||||
private void loadPlugins() {
|
private void loadPlugins() {
|
||||||
|
|
||||||
final List<T> finalPluginsList = new ArrayList<T>();
|
final List<T> finalPluginsList = new ArrayList<T>();
|
||||||
pluginsList = new ArrayList<T>();
|
pluginsList = new ArrayList<T>();
|
||||||
pluginsMap = new HashMap<String, T>();
|
pluginsMap = new HashMap<String, T>();
|
||||||
String className = null;
|
String className = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Class<T>[] classes = getClasses();
|
final Class<T>[] classes = getClasses();
|
||||||
for (final Class<T> classe : classes) {
|
for (final Class<T> clazz : classes) {
|
||||||
className = classe.getName();
|
|
||||||
final T plugin = classe.newInstance();
|
className = clazz.getName();
|
||||||
|
final T plugin = clazz.newInstance();
|
||||||
|
|
||||||
if (plugin instanceof DelegatingModuleParser) {
|
if (plugin instanceof DelegatingModuleParser) {
|
||||||
((DelegatingModuleParser) plugin).setFeedParser(parentParser);
|
((DelegatingModuleParser) plugin).setFeedParser(parentParser);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin instanceof DelegatingModuleGenerator) {
|
if (plugin instanceof DelegatingModuleGenerator) {
|
||||||
((DelegatingModuleGenerator) plugin).setFeedGenerator(parentGenerator);
|
((DelegatingModuleGenerator) plugin).setFeedGenerator(parentGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginsMap.put(getKey(plugin), plugin);
|
pluginsMap.put(getKey(plugin), plugin);
|
||||||
|
|
||||||
// to preserve the order of definition in the rome.properties files
|
// to preserve the order of definition in the rome.properties files
|
||||||
pluginsList.add(plugin);
|
pluginsList.add(plugin);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final Collection<T> plugins = pluginsMap.values();
|
final Collection<T> plugins = pluginsMap.values();
|
||||||
|
@ -143,9 +151,13 @@ public abstract class PluginManager<T> {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Class<T>[] getClasses() throws ClassNotFoundException {
|
private Class<T>[] getClasses() throws ClassNotFoundException {
|
||||||
|
|
||||||
final ClassLoader classLoader = ConfigurableClassLoader.INSTANCE.getClassLoader();
|
final ClassLoader classLoader = ConfigurableClassLoader.INSTANCE.getClassLoader();
|
||||||
|
|
||||||
final List<Class<T>> classes = new ArrayList<Class<T>>();
|
final List<Class<T>> classes = new ArrayList<Class<T>>();
|
||||||
|
|
||||||
final boolean useLoadClass = Boolean.valueOf(System.getProperty("rome.pluginmanager.useloadclass", "false")).booleanValue();
|
final boolean useLoadClass = Boolean.valueOf(System.getProperty("rome.pluginmanager.useloadclass", "false")).booleanValue();
|
||||||
|
|
||||||
for (final String propertyValue : propertyValues) {
|
for (final String propertyValue : propertyValues) {
|
||||||
final Class<T> mClass;
|
final Class<T> mClass;
|
||||||
if (useLoadClass) {
|
if (useLoadClass) {
|
||||||
|
@ -155,6 +167,7 @@ public abstract class PluginManager<T> {
|
||||||
}
|
}
|
||||||
classes.add(mClass);
|
classes.add(mClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Class<T>[] array = new Class[classes.size()];
|
final Class<T>[] array = new Class[classes.size()];
|
||||||
classes.toArray(array);
|
classes.toArray(array);
|
||||||
return array;
|
return array;
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package com.sun.syndication.io.impl;
|
package com.sun.syndication.io.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -56,44 +55,40 @@ public class RSS090Parser extends BaseWireFeedParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMyType(final Document document) {
|
public boolean isMyType(final Document document) {
|
||||||
boolean ok = false;
|
|
||||||
|
|
||||||
final Element rssRoot = document.getRootElement();
|
final Element rssRoot = document.getRootElement();
|
||||||
final Namespace defaultNS = rssRoot.getNamespace();
|
final Namespace defaultNS = rssRoot.getNamespace();
|
||||||
final List<Namespace> additionalNSs = rssRoot.getAdditionalNamespaces();
|
final List<Namespace> additionalNSs = rssRoot.getAdditionalNamespaces();
|
||||||
|
|
||||||
ok = defaultNS != null && defaultNS.equals(getRDFNamespace());
|
boolean myType = false;
|
||||||
if (ok) {
|
if (defaultNS != null && defaultNS.equals(getRDFNamespace()) && additionalNSs != null) {
|
||||||
if (additionalNSs == null) {
|
for (final Namespace namespace : additionalNSs) {
|
||||||
ok = false;
|
if (getRSSNamespace().equals(namespace)) {
|
||||||
} else {
|
myType = true;
|
||||||
ok = false;
|
break;
|
||||||
for (int i = 0; !ok && i < additionalNSs.size(); i++) {
|
|
||||||
ok = getRSSNamespace().equals(additionalNSs.get(i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ok;
|
return myType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WireFeed parse(final Document document, final boolean validate, final Locale locale) throws IllegalArgumentException, FeedException {
|
public WireFeed parse(final Document document, final boolean validate, final Locale locale) throws IllegalArgumentException, FeedException {
|
||||||
|
|
||||||
if (validate) {
|
if (validate) {
|
||||||
validateFeed(document);
|
validateFeed(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Element rssRoot = document.getRootElement();
|
final Element rssRoot = document.getRootElement();
|
||||||
return parseChannel(rssRoot, locale);
|
return parseChannel(rssRoot, locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void validateFeed(final Document document) throws FeedException {
|
protected void validateFeed(final Document document) throws FeedException {
|
||||||
// TBD
|
// TODO here we have to validate the Feed against a schema or whatever not sure how to do it
|
||||||
// here we have to validate the Feed against a schema or whatever
|
// one posibility would be to inject our own schema for the feed (they don't exist out
|
||||||
// not sure how to do it
|
// there) to the document, produce an ouput and attempt to parse it again with validation
|
||||||
// one posibility would be to inject our own schema for the feed (they
|
// turned on. otherwise will have to check the document elements by hand.
|
||||||
// don't exist out there)
|
|
||||||
// to the document, produce an ouput and attempt to parse it again with
|
|
||||||
// validation turned on.
|
|
||||||
// otherwise will have to check the document elements by hand.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,41 +142,46 @@ public class RSS090Parser extends BaseWireFeedParser {
|
||||||
* @return the parsed Channel bean.
|
* @return the parsed Channel bean.
|
||||||
*/
|
*/
|
||||||
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
|
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
|
||||||
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
|
||||||
|
|
||||||
final Channel channel = new Channel(getType());
|
final Channel channel = new Channel(getType());
|
||||||
channel.setStyleSheet(getStyleSheet(rssRoot.getDocument()));
|
channel.setStyleSheet(getStyleSheet(rssRoot.getDocument()));
|
||||||
|
|
||||||
Element e = eChannel.getChild("title", getRSSNamespace());
|
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
||||||
if (e != null) {
|
|
||||||
channel.setTitle(e.getText());
|
final Element title = eChannel.getChild("title", getRSSNamespace());
|
||||||
|
if (title != null) {
|
||||||
|
channel.setTitle(title.getText());
|
||||||
}
|
}
|
||||||
e = eChannel.getChild("link", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element link = eChannel.getChild("link", getRSSNamespace());
|
||||||
channel.setLink(e.getText());
|
if (link != null) {
|
||||||
|
channel.setLink(link.getText());
|
||||||
}
|
}
|
||||||
e = eChannel.getChild("description", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element description = eChannel.getChild("description", getRSSNamespace());
|
||||||
channel.setDescription(e.getText());
|
if (description != null) {
|
||||||
|
channel.setDescription(description.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.setImage(parseImage(rssRoot));
|
channel.setImage(parseImage(rssRoot));
|
||||||
|
|
||||||
channel.setTextInput(parseTextInput(rssRoot));
|
channel.setTextInput(parseTextInput(rssRoot));
|
||||||
|
|
||||||
// Unfortunately Microsoft's SSE extension has a special case of
|
// Unfortunately Microsoft's SSE extension has a special case of effectively putting the
|
||||||
// effectively putting the sharing channel module inside the RSS tag
|
// sharing channel module inside the RSS tag and not inside the channel itself. So we also
|
||||||
// and not inside the channel itself. So we also need to look for
|
// need to look for channel modules from the root RSS element.
|
||||||
// channel modules from the root RSS element.
|
|
||||||
final List<Module> allFeedModules = new ArrayList<Module>();
|
final List<Module> allFeedModules = new ArrayList<Module>();
|
||||||
final List<Module> rootModules = parseFeedModules(rssRoot, locale);
|
final List<Module> rootModules = parseFeedModules(rssRoot, locale);
|
||||||
final List<Module> channelModules = parseFeedModules(eChannel, locale);
|
final List<Module> channelModules = parseFeedModules(eChannel, locale);
|
||||||
|
|
||||||
if (rootModules != null) {
|
if (rootModules != null) {
|
||||||
allFeedModules.addAll(rootModules);
|
allFeedModules.addAll(rootModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channelModules != null) {
|
if (channelModules != null) {
|
||||||
allFeedModules.addAll(channelModules);
|
allFeedModules.addAll(channelModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.setModules(allFeedModules);
|
channel.setModules(allFeedModules);
|
||||||
channel.setItems(parseItems(rssRoot, locale));
|
channel.setItems(parseItems(rssRoot, locale));
|
||||||
|
|
||||||
|
@ -189,7 +189,9 @@ public class RSS090Parser extends BaseWireFeedParser {
|
||||||
if (!foreignMarkup.isEmpty()) {
|
if (!foreignMarkup.isEmpty()) {
|
||||||
channel.setForeignMarkup(foreignMarkup);
|
channel.setForeignMarkup(foreignMarkup);
|
||||||
}
|
}
|
||||||
|
|
||||||
return channel;
|
return channel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -232,25 +234,33 @@ public class RSS090Parser extends BaseWireFeedParser {
|
||||||
* @return the parsed image bean.
|
* @return the parsed image bean.
|
||||||
*/
|
*/
|
||||||
protected Image parseImage(final Element rssRoot) {
|
protected Image parseImage(final Element rssRoot) {
|
||||||
|
|
||||||
Image image = null;
|
Image image = null;
|
||||||
|
|
||||||
final Element eImage = getImage(rssRoot);
|
final Element eImage = getImage(rssRoot);
|
||||||
if (eImage != null) {
|
if (eImage != null) {
|
||||||
|
|
||||||
image = new Image();
|
image = new Image();
|
||||||
|
|
||||||
Element e = eImage.getChild("title", getRSSNamespace());
|
final Element title = eImage.getChild("title", getRSSNamespace());
|
||||||
if (e != null) {
|
if (title != null) {
|
||||||
image.setTitle(e.getText());
|
image.setTitle(title.getText());
|
||||||
}
|
}
|
||||||
e = eImage.getChild("url", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element url = eImage.getChild("url", getRSSNamespace());
|
||||||
image.setUrl(e.getText());
|
if (url != null) {
|
||||||
|
image.setUrl(url.getText());
|
||||||
}
|
}
|
||||||
e = eImage.getChild("link", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element link = eImage.getChild("link", getRSSNamespace());
|
||||||
image.setLink(e.getText());
|
if (link != null) {
|
||||||
|
image.setLink(link.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -265,12 +275,9 @@ public class RSS090Parser extends BaseWireFeedParser {
|
||||||
* @return a list with all the parsed RSSItem beans.
|
* @return a list with all the parsed RSSItem beans.
|
||||||
*/
|
*/
|
||||||
protected List<Item> parseItems(final Element rssRoot, final Locale locale) {
|
protected List<Item> parseItems(final Element rssRoot, final Locale locale) {
|
||||||
final Collection<Element> eItems = getItems(rssRoot);
|
|
||||||
|
|
||||||
final List<Item> items = new ArrayList<Item>();
|
final List<Item> items = new ArrayList<Item>();
|
||||||
for (final Element element : eItems) {
|
for (final Element item : getItems(rssRoot)) {
|
||||||
final Element eItem = element;
|
items.add(parseItem(rssRoot, item, locale));
|
||||||
items.add(parseItem(rssRoot, eItem, locale));
|
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
@ -286,29 +293,32 @@ public class RSS090Parser extends BaseWireFeedParser {
|
||||||
* @return the parsed RSSItem bean.
|
* @return the parsed RSSItem bean.
|
||||||
*/
|
*/
|
||||||
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
|
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
|
||||||
|
|
||||||
final Item item = new Item();
|
final Item item = new Item();
|
||||||
Element e = eItem.getChild("title", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element title = eItem.getChild("title", getRSSNamespace());
|
||||||
item.setTitle(e.getText());
|
if (title != null) {
|
||||||
|
item.setTitle(title.getText());
|
||||||
}
|
}
|
||||||
e = eItem.getChild("link", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element link = eItem.getChild("link", getRSSNamespace());
|
||||||
item.setLink(e.getText());
|
if (link != null) {
|
||||||
item.setUri(e.getText());
|
item.setLink(link.getText());
|
||||||
|
item.setUri(link.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
item.setModules(parseItemModules(eItem, locale));
|
item.setModules(parseItemModules(eItem, locale));
|
||||||
|
|
||||||
final List<Element> foreignMarkup = extractForeignMarkup(eItem, item, getRSSNamespace());
|
final List<Element> foreignMarkup = extractForeignMarkup(eItem, item, getRSSNamespace());
|
||||||
// content:encoded elements are treated special, without a module, they
|
// content:encoded elements are treated special, without a module, they have to be removed
|
||||||
// have to be removed from the foreign
|
// from the foreign markup to avoid duplication in case of read/write. Note that this fix
|
||||||
// markup to avoid duplication in case of read/write. Note that this fix
|
// will break if a content module is used
|
||||||
// will break if a content module is
|
|
||||||
// used
|
|
||||||
final Iterator<Element> iterator = foreignMarkup.iterator();
|
final Iterator<Element> iterator = foreignMarkup.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
final Element element = iterator.next();
|
final Element element = iterator.next();
|
||||||
if (getContentNamespace().equals(element.getNamespace()) && element.getName().equals("encoded")) {
|
final Namespace eNamespace = element.getNamespace();
|
||||||
|
final String eName = element.getName();
|
||||||
|
if (getContentNamespace().equals(eNamespace) && eName.equals("encoded")) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,28 +340,38 @@ public class RSS090Parser extends BaseWireFeedParser {
|
||||||
* @return the parsed RSSTextInput bean.
|
* @return the parsed RSSTextInput bean.
|
||||||
*/
|
*/
|
||||||
protected TextInput parseTextInput(final Element rssRoot) {
|
protected TextInput parseTextInput(final Element rssRoot) {
|
||||||
|
|
||||||
TextInput textInput = null;
|
TextInput textInput = null;
|
||||||
|
|
||||||
final Element eTextInput = getTextInput(rssRoot);
|
final Element eTextInput = getTextInput(rssRoot);
|
||||||
if (eTextInput != null) {
|
if (eTextInput != null) {
|
||||||
|
|
||||||
textInput = new TextInput();
|
textInput = new TextInput();
|
||||||
Element e = eTextInput.getChild("title", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element title = eTextInput.getChild("title", getRSSNamespace());
|
||||||
textInput.setTitle(e.getText());
|
if (title != null) {
|
||||||
|
textInput.setTitle(title.getText());
|
||||||
}
|
}
|
||||||
e = eTextInput.getChild("description", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element description = eTextInput.getChild("description", getRSSNamespace());
|
||||||
textInput.setDescription(e.getText());
|
if (description != null) {
|
||||||
|
textInput.setDescription(description.getText());
|
||||||
}
|
}
|
||||||
e = eTextInput.getChild("name", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element name = eTextInput.getChild("name", getRSSNamespace());
|
||||||
textInput.setName(e.getText());
|
if (name != null) {
|
||||||
|
textInput.setName(name.getText());
|
||||||
}
|
}
|
||||||
e = eTextInput.getChild("link", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element link = eTextInput.getChild("link", getRSSNamespace());
|
||||||
textInput.setLink(e.getText());
|
if (link != null) {
|
||||||
|
textInput.setLink(link.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return textInput;
|
return textInput;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,6 @@ import org.jdom2.DocType;
|
||||||
import org.jdom2.Document;
|
import org.jdom2.Document;
|
||||||
import org.jdom2.Element;
|
import org.jdom2.Element;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class RSS091NetscapeParser extends RSS091UserlandParser {
|
public class RSS091NetscapeParser extends RSS091UserlandParser {
|
||||||
|
|
||||||
public RSS091NetscapeParser() {
|
public RSS091NetscapeParser() {
|
||||||
|
@ -39,27 +37,15 @@ public class RSS091NetscapeParser extends RSS091UserlandParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMyType(final Document document) {
|
public boolean isMyType(final Document document) {
|
||||||
boolean ok = false;
|
|
||||||
final Element rssRoot = document.getRootElement();
|
|
||||||
ok = rssRoot.getName().equals("rss");
|
|
||||||
if (ok) {
|
|
||||||
ok = false;
|
|
||||||
final Attribute version = rssRoot.getAttribute("version");
|
|
||||||
if (version != null) {
|
|
||||||
ok = version.getValue().equals(getRSSVersion());
|
|
||||||
if (ok) {
|
|
||||||
ok = false;
|
|
||||||
final DocType docType = document.getDocType();
|
|
||||||
|
|
||||||
if (docType != null) {
|
final Element rssRoot = document.getRootElement();
|
||||||
ok = ELEMENT_NAME.equals(docType.getElementName());
|
final String name = rssRoot.getName();
|
||||||
ok = ok && PUBLIC_ID.equals(docType.getPublicID());
|
final Attribute version = rssRoot.getAttribute("version");
|
||||||
ok = ok && SYSTEM_ID.equals(docType.getSystemID());
|
final DocType docType = document.getDocType();
|
||||||
}
|
|
||||||
}
|
return name.equals(ELEMENT_NAME) && version != null && version.getValue().equals(getRSSVersion()) && docType != null
|
||||||
}
|
&& ELEMENT_NAME.equals(docType.getElementName()) && PUBLIC_ID.equals(docType.getPublicID()) && SYSTEM_ID.equals(docType.getSystemID());
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.jdom2.Element;
|
||||||
import org.jdom2.Namespace;
|
import org.jdom2.Namespace;
|
||||||
|
|
||||||
import com.sun.syndication.feed.rss.Channel;
|
import com.sun.syndication.feed.rss.Channel;
|
||||||
|
import com.sun.syndication.feed.rss.Content;
|
||||||
import com.sun.syndication.feed.rss.Description;
|
import com.sun.syndication.feed.rss.Description;
|
||||||
import com.sun.syndication.feed.rss.Image;
|
import com.sun.syndication.feed.rss.Image;
|
||||||
import com.sun.syndication.feed.rss.Item;
|
import com.sun.syndication.feed.rss.Item;
|
||||||
|
@ -34,11 +35,12 @@ import com.sun.syndication.io.FeedException;
|
||||||
/**
|
/**
|
||||||
* Feed Generator for RSS 0.91
|
* Feed Generator for RSS 0.91
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Elaine Chien
|
* @author Elaine Chien
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RSS091UserlandGenerator extends RSS090Generator {
|
public class RSS091UserlandGenerator extends RSS090Generator {
|
||||||
|
|
||||||
private final String version;
|
private final String version;
|
||||||
|
|
||||||
public RSS091UserlandGenerator() {
|
public RSS091UserlandGenerator() {
|
||||||
|
@ -68,6 +70,7 @@ public class RSS091UserlandGenerator extends RSS090Generator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addChannel(final Channel channel, final Element parent) throws FeedException {
|
protected void addChannel(final Channel channel, final Element parent) throws FeedException {
|
||||||
|
|
||||||
super.addChannel(channel, parent);
|
super.addChannel(channel, parent);
|
||||||
|
|
||||||
final Element eChannel = parent.getChild("channel", getFeedNamespace());
|
final Element eChannel = parent.getChild("channel", getFeedNamespace());
|
||||||
|
@ -75,15 +78,16 @@ public class RSS091UserlandGenerator extends RSS090Generator {
|
||||||
addImage(channel, eChannel);
|
addImage(channel, eChannel);
|
||||||
addTextInput(channel, eChannel);
|
addTextInput(channel, eChannel);
|
||||||
addItems(channel, eChannel);
|
addItems(channel, eChannel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkChannelConstraints(final Element eChannel) throws FeedException {
|
protected void checkChannelConstraints(final Element eChannel) throws FeedException {
|
||||||
|
|
||||||
checkNotNullAndLength(eChannel, "title", 1, 100);
|
checkNotNullAndLength(eChannel, "title", 1, 100);
|
||||||
checkNotNullAndLength(eChannel, "description", 1, 500);
|
checkNotNullAndLength(eChannel, "description", 1, 500);
|
||||||
checkNotNullAndLength(eChannel, "link", 1, 500);
|
checkNotNullAndLength(eChannel, "link", 1, 500);
|
||||||
checkNotNullAndLength(eChannel, "language", 2, 5);
|
checkNotNullAndLength(eChannel, "language", 2, 5);
|
||||||
|
|
||||||
checkLength(eChannel, "rating", 20, 500);
|
checkLength(eChannel, "rating", 20, 500);
|
||||||
checkLength(eChannel, "copyright", 1, 100);
|
checkLength(eChannel, "copyright", 1, 100);
|
||||||
checkLength(eChannel, "pubDate", 1, 100);
|
checkLength(eChannel, "pubDate", 1, 100);
|
||||||
|
@ -95,10 +99,10 @@ public class RSS091UserlandGenerator extends RSS090Generator {
|
||||||
final Element skipHours = eChannel.getChild("skipHours");
|
final Element skipHours = eChannel.getChild("skipHours");
|
||||||
|
|
||||||
if (skipHours != null) {
|
if (skipHours != null) {
|
||||||
final List<Element> hours = skipHours.getChildren();
|
|
||||||
|
|
||||||
for (int i = 0; i < hours.size(); i++) {
|
final List<Element> hours = skipHours.getChildren();
|
||||||
final Element hour = hours.get(i);
|
for (final Element hour : hours) {
|
||||||
|
|
||||||
final int value = Integer.parseInt(hour.getText().trim());
|
final int value = Integer.parseInt(hour.getText().trim());
|
||||||
|
|
||||||
if (isHourFormat24()) {
|
if (isHourFormat24()) {
|
||||||
|
@ -110,15 +114,17 @@ public class RSS091UserlandGenerator extends RSS090Generator {
|
||||||
throw new FeedException("Invalid hour value " + value + ", it must be between 0 and 23");
|
throw new FeedException("Invalid hour value " + value + ", it must be between 0 and 23");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkImageConstraints(final Element eImage) throws FeedException {
|
protected void checkImageConstraints(final Element eImage) throws FeedException {
|
||||||
checkNotNullAndLength(eImage, "title", 1, 100);
|
checkNotNullAndLength(eImage, "title", 1, 100);
|
||||||
checkNotNullAndLength(eImage, "url", 1, 500);
|
checkNotNullAndLength(eImage, "url", 1, 500);
|
||||||
|
|
||||||
checkLength(eImage, "link", 1, 500);
|
checkLength(eImage, "link", 1, 500);
|
||||||
checkLength(eImage, "width", 1, 3);
|
checkLength(eImage, "width", 1, 3);
|
||||||
checkLength(eImage, "width", 1, 3);
|
checkLength(eImage, "width", 1, 3);
|
||||||
|
@ -129,7 +135,6 @@ public class RSS091UserlandGenerator extends RSS090Generator {
|
||||||
protected void checkItemConstraints(final Element eItem) throws FeedException {
|
protected void checkItemConstraints(final Element eItem) throws FeedException {
|
||||||
checkNotNullAndLength(eItem, "title", 1, 100);
|
checkNotNullAndLength(eItem, "title", 1, 100);
|
||||||
checkNotNullAndLength(eItem, "link", 1, 500);
|
checkNotNullAndLength(eItem, "link", 1, 500);
|
||||||
|
|
||||||
checkLength(eItem, "description", 1, 500);
|
checkLength(eItem, "description", 1, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,93 +158,80 @@ public class RSS091UserlandGenerator extends RSS090Generator {
|
||||||
root.setAttribute(version);
|
root.setAttribute(version);
|
||||||
root.addNamespaceDeclaration(getContentNamespace());
|
root.addNamespaceDeclaration(getContentNamespace());
|
||||||
generateModuleNamespaceDefs(root);
|
generateModuleNamespaceDefs(root);
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateSkipDaysElement(final List<String> days) {
|
protected Element generateSkipDaysElement(final List<String> days) {
|
||||||
final Element skipDaysElement = new Element("skipDays");
|
final Element skipDaysElement = new Element("skipDays");
|
||||||
|
for (final String day : days) {
|
||||||
for (int i = 0; i < days.size(); i++) {
|
skipDaysElement.addContent(generateSimpleElement("day", day.toString()));
|
||||||
skipDaysElement.addContent(generateSimpleElement("day", days.get(i).toString()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return skipDaysElement;
|
return skipDaysElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateSkipHoursElement(final List<Integer> hours) {
|
protected Element generateSkipHoursElement(final List<Integer> hours) {
|
||||||
final Element skipHoursElement = new Element("skipHours", getFeedNamespace());
|
final Element skipHoursElement = new Element("skipHours", getFeedNamespace());
|
||||||
|
for (final Integer hour : hours) {
|
||||||
for (int i = 0; i < hours.size(); i++) {
|
skipHoursElement.addContent(generateSimpleElement("hour", hour.toString()));
|
||||||
skipHoursElement.addContent(generateSimpleElement("hour", hours.get(i).toString()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return skipHoursElement;
|
return skipHoursElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void populateChannel(final Channel channel, final Element eChannel) {
|
protected void populateChannel(final Channel channel, final Element eChannel) {
|
||||||
|
|
||||||
super.populateChannel(channel, eChannel);
|
super.populateChannel(channel, eChannel);
|
||||||
|
|
||||||
final String language = channel.getLanguage();
|
final String language = channel.getLanguage();
|
||||||
|
|
||||||
if (language != null) {
|
if (language != null) {
|
||||||
eChannel.addContent(generateSimpleElement("language", language));
|
eChannel.addContent(generateSimpleElement("language", language));
|
||||||
}
|
}
|
||||||
|
|
||||||
final String rating = channel.getRating();
|
final String rating = channel.getRating();
|
||||||
|
|
||||||
if (rating != null) {
|
if (rating != null) {
|
||||||
eChannel.addContent(generateSimpleElement("rating", rating));
|
eChannel.addContent(generateSimpleElement("rating", rating));
|
||||||
}
|
}
|
||||||
|
|
||||||
final String copyright = channel.getCopyright();
|
final String copyright = channel.getCopyright();
|
||||||
|
|
||||||
if (copyright != null) {
|
if (copyright != null) {
|
||||||
eChannel.addContent(generateSimpleElement("copyright", copyright));
|
eChannel.addContent(generateSimpleElement("copyright", copyright));
|
||||||
}
|
}
|
||||||
|
|
||||||
final Date pubDate = channel.getPubDate();
|
final Date pubDate = channel.getPubDate();
|
||||||
|
|
||||||
if (pubDate != null) {
|
if (pubDate != null) {
|
||||||
eChannel.addContent(generateSimpleElement("pubDate", DateParser.formatRFC822(pubDate, Locale.US)));
|
eChannel.addContent(generateSimpleElement("pubDate", DateParser.formatRFC822(pubDate, Locale.US)));
|
||||||
}
|
}
|
||||||
|
|
||||||
final Date lastBuildDate = channel.getLastBuildDate();
|
final Date lastBuildDate = channel.getLastBuildDate();
|
||||||
|
|
||||||
if (lastBuildDate != null) {
|
if (lastBuildDate != null) {
|
||||||
eChannel.addContent(generateSimpleElement("lastBuildDate", DateParser.formatRFC822(lastBuildDate, Locale.US)));
|
eChannel.addContent(generateSimpleElement("lastBuildDate", DateParser.formatRFC822(lastBuildDate, Locale.US)));
|
||||||
}
|
}
|
||||||
|
|
||||||
final String docs = channel.getDocs();
|
final String docs = channel.getDocs();
|
||||||
|
|
||||||
if (docs != null) {
|
if (docs != null) {
|
||||||
eChannel.addContent(generateSimpleElement("docs", docs));
|
eChannel.addContent(generateSimpleElement("docs", docs));
|
||||||
}
|
}
|
||||||
|
|
||||||
final String managingEditor = channel.getManagingEditor();
|
final String managingEditor = channel.getManagingEditor();
|
||||||
|
|
||||||
if (managingEditor != null) {
|
if (managingEditor != null) {
|
||||||
eChannel.addContent(generateSimpleElement("managingEditor", managingEditor));
|
eChannel.addContent(generateSimpleElement("managingEditor", managingEditor));
|
||||||
}
|
}
|
||||||
|
|
||||||
final String webMaster = channel.getWebMaster();
|
final String webMaster = channel.getWebMaster();
|
||||||
|
|
||||||
if (webMaster != null) {
|
if (webMaster != null) {
|
||||||
eChannel.addContent(generateSimpleElement("webMaster", webMaster));
|
eChannel.addContent(generateSimpleElement("webMaster", webMaster));
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Integer> skipHours = channel.getSkipHours();
|
final List<Integer> skipHours = channel.getSkipHours();
|
||||||
|
|
||||||
if (skipHours != null && !skipHours.isEmpty()) {
|
if (skipHours != null && !skipHours.isEmpty()) {
|
||||||
eChannel.addContent(generateSkipHoursElement(skipHours));
|
eChannel.addContent(generateSkipHoursElement(skipHours));
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> skipDays = channel.getSkipDays();
|
final List<String> skipDays = channel.getSkipDays();
|
||||||
|
|
||||||
if (skipDays != null && !skipDays.isEmpty()) {
|
if (skipDays != null && !skipDays.isEmpty()) {
|
||||||
eChannel.addContent(generateSkipDaysElement(skipDays));
|
eChannel.addContent(generateSkipDaysElement(skipDays));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -249,41 +241,44 @@ public class RSS091UserlandGenerator extends RSS090Generator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void populateImage(final Image image, final Element eImage) {
|
protected void populateImage(final Image image, final Element eImage) {
|
||||||
|
|
||||||
super.populateImage(image, eImage);
|
super.populateImage(image, eImage);
|
||||||
|
|
||||||
final Integer width = image.getWidth();
|
final Integer width = image.getWidth();
|
||||||
|
|
||||||
if (width != null) {
|
if (width != null) {
|
||||||
eImage.addContent(generateSimpleElement("width", String.valueOf(width)));
|
eImage.addContent(generateSimpleElement("width", String.valueOf(width)));
|
||||||
}
|
}
|
||||||
|
|
||||||
final Integer height = image.getHeight();
|
final Integer height = image.getHeight();
|
||||||
|
|
||||||
if (height != null) {
|
if (height != null) {
|
||||||
eImage.addContent(generateSimpleElement("height", String.valueOf(height)));
|
eImage.addContent(generateSimpleElement("height", String.valueOf(height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
final String description = image.getDescription();
|
final String description = image.getDescription();
|
||||||
|
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
eImage.addContent(generateSimpleElement("description", description));
|
eImage.addContent(generateSimpleElement("description", description));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void populateItem(final Item item, final Element eItem, final int index) {
|
protected void populateItem(final Item item, final Element eItem, final int index) {
|
||||||
|
|
||||||
super.populateItem(item, eItem, index);
|
super.populateItem(item, eItem, index);
|
||||||
|
|
||||||
final Description description = item.getDescription();
|
final Description description = item.getDescription();
|
||||||
|
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
eItem.addContent(generateSimpleElement("description", description.getValue()));
|
eItem.addContent(generateSimpleElement("description", description.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getModule(getContentNamespace().getURI()) == null && item.getContent() != null) {
|
final Namespace contentNamespace = getContentNamespace();
|
||||||
final Element elem = new Element("encoded", getContentNamespace());
|
final Content content = item.getContent();
|
||||||
elem.addContent(item.getContent().getValue());
|
if (item.getModule(contentNamespace.getURI()) == null && content != null) {
|
||||||
|
final Element elem = new Element("encoded", contentNamespace);
|
||||||
|
elem.addContent(content.getValue());
|
||||||
eItem.addContent(elem);
|
eItem.addContent(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,17 +47,9 @@ public class RSS091UserlandParser extends RSS090Parser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMyType(final Document document) {
|
public boolean isMyType(final Document document) {
|
||||||
boolean ok;
|
|
||||||
final Element rssRoot = document.getRootElement();
|
final Element rssRoot = document.getRootElement();
|
||||||
ok = rssRoot.getName().equals("rss");
|
final Attribute version = rssRoot.getAttribute("version");
|
||||||
if (ok) {
|
return rssRoot.getName().equals("rss") && version != null && version.getValue().equals(getRSSVersion());
|
||||||
ok = false;
|
|
||||||
final Attribute version = rssRoot.getAttribute("version");
|
|
||||||
if (version != null) {
|
|
||||||
ok = version.getValue().equals(getRSSVersion());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getRSSVersion() {
|
protected String getRSSVersion() {
|
||||||
|
@ -82,73 +74,82 @@ public class RSS091UserlandParser extends RSS090Parser {
|
||||||
* It first invokes super.parseChannel and then parses and injects the following properties if
|
* It first invokes super.parseChannel and then parses and injects the following properties if
|
||||||
* present: language, pubDate, rating and copyright.
|
* present: language, pubDate, rating and copyright.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @param rssRoot the root element of the RSS document to parse.
|
* @param rssRoot the root element of the RSS document to parse.
|
||||||
* @return the parsed Channel bean.
|
* @return the parsed Channel bean.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
|
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
|
||||||
|
|
||||||
final Channel channel = (Channel) super.parseChannel(rssRoot, locale);
|
final Channel channel = (Channel) super.parseChannel(rssRoot, locale);
|
||||||
|
|
||||||
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
||||||
|
|
||||||
Element e = eChannel.getChild("language", getRSSNamespace());
|
final Element language = eChannel.getChild("language", getRSSNamespace());
|
||||||
if (e != null) {
|
if (language != null) {
|
||||||
channel.setLanguage(e.getText());
|
channel.setLanguage(language.getText());
|
||||||
}
|
}
|
||||||
e = eChannel.getChild("rating", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element atinge = eChannel.getChild("rating", getRSSNamespace());
|
||||||
channel.setRating(e.getText());
|
if (atinge != null) {
|
||||||
|
channel.setRating(atinge.getText());
|
||||||
}
|
}
|
||||||
e = eChannel.getChild("copyright", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element copyright = eChannel.getChild("copyright", getRSSNamespace());
|
||||||
channel.setCopyright(e.getText());
|
if (copyright != null) {
|
||||||
|
channel.setCopyright(copyright.getText());
|
||||||
}
|
}
|
||||||
e = eChannel.getChild("pubDate", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element pubDate = eChannel.getChild("pubDate", getRSSNamespace());
|
||||||
channel.setPubDate(DateParser.parseDate(e.getText(), locale));
|
if (pubDate != null) {
|
||||||
|
channel.setPubDate(DateParser.parseDate(pubDate.getText(), locale));
|
||||||
}
|
}
|
||||||
e = eChannel.getChild("lastBuildDate", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element lastBuildDate = eChannel.getChild("lastBuildDate", getRSSNamespace());
|
||||||
channel.setLastBuildDate(DateParser.parseDate(e.getText(), locale));
|
if (lastBuildDate != null) {
|
||||||
|
channel.setLastBuildDate(DateParser.parseDate(lastBuildDate.getText(), locale));
|
||||||
}
|
}
|
||||||
e = eChannel.getChild("docs", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element docs = eChannel.getChild("docs", getRSSNamespace());
|
||||||
channel.setDocs(e.getText());
|
if (docs != null) {
|
||||||
|
channel.setDocs(docs.getText());
|
||||||
}
|
}
|
||||||
e = eChannel.getChild("generator", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element generator = eChannel.getChild("generator", getRSSNamespace());
|
||||||
channel.setGenerator(e.getText());
|
if (generator != null) {
|
||||||
|
channel.setGenerator(generator.getText());
|
||||||
}
|
}
|
||||||
e = eChannel.getChild("managingEditor", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element managingEditor = eChannel.getChild("managingEditor", getRSSNamespace());
|
||||||
channel.setManagingEditor(e.getText());
|
if (managingEditor != null) {
|
||||||
|
channel.setManagingEditor(managingEditor.getText());
|
||||||
}
|
}
|
||||||
e = eChannel.getChild("webMaster", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element webMaster = eChannel.getChild("webMaster", getRSSNamespace());
|
||||||
channel.setWebMaster(e.getText());
|
if (webMaster != null) {
|
||||||
|
channel.setWebMaster(webMaster.getText());
|
||||||
}
|
}
|
||||||
e = eChannel.getChild("skipHours");
|
|
||||||
if (e != null) {
|
final Element eSkipHours = eChannel.getChild("skipHours");
|
||||||
|
if (eSkipHours != null) {
|
||||||
final List<Integer> skipHours = new ArrayList<Integer>();
|
final List<Integer> skipHours = new ArrayList<Integer>();
|
||||||
final List<Element> eHours = e.getChildren("hour", getRSSNamespace());
|
final List<Element> eHours = eSkipHours.getChildren("hour", getRSSNamespace());
|
||||||
for (int i = 0; i < eHours.size(); i++) {
|
for (final Element eHour : eHours) {
|
||||||
final Element eHour = eHours.get(i);
|
|
||||||
skipHours.add(new Integer(eHour.getText().trim()));
|
skipHours.add(new Integer(eHour.getText().trim()));
|
||||||
}
|
}
|
||||||
channel.setSkipHours(skipHours);
|
channel.setSkipHours(skipHours);
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eChannel.getChild("skipDays");
|
final Element eSkipDays = eChannel.getChild("skipDays");
|
||||||
if (e != null) {
|
if (eSkipDays != null) {
|
||||||
final List<String> skipDays = new ArrayList<String>();
|
final List<String> skipDays = new ArrayList<String>();
|
||||||
final List<Element> eDays = e.getChildren("day", getRSSNamespace());
|
final List<Element> eDays = eSkipDays.getChildren("day", getRSSNamespace());
|
||||||
for (int i = 0; i < eDays.size(); i++) {
|
for (final Element eDay : eDays) {
|
||||||
final Element eDay = eDays.get(i);
|
|
||||||
skipDays.add(eDay.getText().trim());
|
skipDays.add(eDay.getText().trim());
|
||||||
}
|
}
|
||||||
channel.setSkipDays(skipDays);
|
channel.setSkipDays(skipDays);
|
||||||
}
|
}
|
||||||
|
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,35 +159,43 @@ public class RSS091UserlandParser extends RSS090Parser {
|
||||||
* It first invokes super.parseImage and then parses and injects the following properties if
|
* It first invokes super.parseImage and then parses and injects the following properties if
|
||||||
* present: url, link, width, height and description.
|
* present: url, link, width, height and description.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @param rssRoot the root element of the RSS document to parse for image information.
|
* @param rssRoot the root element of the RSS document to parse for image information.
|
||||||
* @return the parsed RSSImage bean.
|
* @return the parsed RSSImage bean.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Image parseImage(final Element rssRoot) {
|
protected Image parseImage(final Element rssRoot) {
|
||||||
|
|
||||||
final Image image = super.parseImage(rssRoot);
|
final Image image = super.parseImage(rssRoot);
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
|
|
||||||
final Element eImage = getImage(rssRoot);
|
final Element eImage = getImage(rssRoot);
|
||||||
Element e = eImage.getChild("width", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element width = eImage.getChild("width", getRSSNamespace());
|
||||||
final Integer val = NumberParser.parseInt(e.getText());
|
if (width != null) {
|
||||||
|
final Integer val = NumberParser.parseInt(width.getText());
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
image.setWidth(val.intValue());
|
image.setWidth(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e = eImage.getChild("height", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element height = eImage.getChild("height", getRSSNamespace());
|
||||||
final Integer val = NumberParser.parseInt(e.getText());
|
if (height != null) {
|
||||||
|
final Integer val = NumberParser.parseInt(height.getText());
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
image.setHeight(val.intValue());
|
image.setHeight(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e = eImage.getChild("description", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element description = eImage.getChild("description", getRSSNamespace());
|
||||||
image.setDescription(e.getText());
|
if (description != null) {
|
||||||
|
image.setDescription(description.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,13 +203,15 @@ public class RSS091UserlandParser extends RSS090Parser {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected List<Element> getItems(final Element rssRoot) {
|
protected List<Element> getItems(final Element rssRoot) {
|
||||||
|
|
||||||
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
||||||
final List<Element> emptyList = Collections.emptyList();
|
|
||||||
if (eChannel != null) {
|
if (eChannel != null) {
|
||||||
return eChannel.getChildren("item", getRSSNamespace());
|
return eChannel.getChildren("item", getRSSNamespace());
|
||||||
} else {
|
} else {
|
||||||
return emptyList;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,12 +219,15 @@ public class RSS091UserlandParser extends RSS090Parser {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Element getImage(final Element rssRoot) {
|
protected Element getImage(final Element rssRoot) {
|
||||||
|
|
||||||
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
||||||
|
|
||||||
if (eChannel != null) {
|
if (eChannel != null) {
|
||||||
return eChannel.getChild("image", getRSSNamespace());
|
return eChannel.getChild("image", getRSSNamespace());
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,13 +242,16 @@ public class RSS091UserlandParser extends RSS090Parser {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Element getTextInput(final Element rssRoot) {
|
protected Element getTextInput(final Element rssRoot) {
|
||||||
|
|
||||||
final String elementName = getTextInputLabel();
|
final String elementName = getTextInputLabel();
|
||||||
|
|
||||||
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
||||||
if (eChannel != null) {
|
if (eChannel != null) {
|
||||||
return eChannel.getChild(elementName, getRSSNamespace());
|
return eChannel.getChild(elementName, getRSSNamespace());
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,26 +260,31 @@ public class RSS091UserlandParser extends RSS090Parser {
|
||||||
* It first invokes super.parseItem and then parses and injects the description property if
|
* It first invokes super.parseItem and then parses and injects the description property if
|
||||||
* present.
|
* present.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @param rssRoot the root element of the RSS document in case it's needed for context.
|
* @param rssRoot the root element of the RSS document in case it's needed for context.
|
||||||
* @param eItem the item element to parse.
|
* @param eItem the item element to parse.
|
||||||
* @return the parsed RSSItem bean.
|
* @return the parsed RSSItem bean.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
|
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
|
||||||
|
|
||||||
final Item item = super.parseItem(rssRoot, eItem, locale);
|
final Item item = super.parseItem(rssRoot, eItem, locale);
|
||||||
final Element e = eItem.getChild("description", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element description = eItem.getChild("description", getRSSNamespace());
|
||||||
item.setDescription(parseItemDescription(rssRoot, e));
|
if (description != null) {
|
||||||
|
item.setDescription(parseItemDescription(rssRoot, description));
|
||||||
}
|
}
|
||||||
final Element ce = eItem.getChild("encoded", getContentNamespace());
|
|
||||||
if (ce != null) {
|
final Element encoded = eItem.getChild("encoded", getContentNamespace());
|
||||||
|
if (encoded != null) {
|
||||||
final Content content = new Content();
|
final Content content = new Content();
|
||||||
content.setType(Content.HTML);
|
content.setType(Content.HTML);
|
||||||
content.setValue(ce.getText());
|
content.setValue(encoded.getText());
|
||||||
item.setContent(content);
|
item.setContent(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Description parseItemDescription(final Element rssRoot, final Element eDesc) {
|
protected Description parseItemDescription(final Element rssRoot, final Element eDesc) {
|
||||||
|
|
|
@ -31,12 +31,10 @@ import com.sun.syndication.io.FeedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feed Generator for RSS 0.92
|
* Feed Generator for RSS 0.92
|
||||||
* <p/>
|
*
|
||||||
*
|
|
||||||
* @author Elaine Chien
|
* @author Elaine Chien
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RSS092Generator extends RSS091UserlandGenerator {
|
public class RSS092Generator extends RSS091UserlandGenerator {
|
||||||
|
|
||||||
public RSS092Generator() {
|
public RSS092Generator() {
|
||||||
|
@ -49,37 +47,47 @@ public class RSS092Generator extends RSS091UserlandGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void populateChannel(final Channel channel, final Element eChannel) {
|
protected void populateChannel(final Channel channel, final Element eChannel) {
|
||||||
|
|
||||||
super.populateChannel(channel, eChannel);
|
super.populateChannel(channel, eChannel);
|
||||||
|
|
||||||
final Cloud cloud = channel.getCloud();
|
final Cloud cloud = channel.getCloud();
|
||||||
if (cloud != null) {
|
if (cloud != null) {
|
||||||
eChannel.addContent(generateCloud(cloud));
|
eChannel.addContent(generateCloud(cloud));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateCloud(final Cloud cloud) {
|
protected Element generateCloud(final Cloud cloud) {
|
||||||
|
|
||||||
final Element eCloud = new Element("cloud", getFeedNamespace());
|
final Element eCloud = new Element("cloud", getFeedNamespace());
|
||||||
|
|
||||||
if (cloud.getDomain() != null) {
|
final String domain = cloud.getDomain();
|
||||||
eCloud.setAttribute(new Attribute("domain", cloud.getDomain()));
|
if (domain != null) {
|
||||||
|
eCloud.setAttribute(new Attribute("domain", domain));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cloud.getPort() != 0) {
|
final int port = cloud.getPort();
|
||||||
eCloud.setAttribute(new Attribute("port", String.valueOf(cloud.getPort())));
|
if (port != 0) {
|
||||||
|
eCloud.setAttribute(new Attribute("port", String.valueOf(port)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cloud.getPath() != null) {
|
final String path = cloud.getPath();
|
||||||
eCloud.setAttribute(new Attribute("path", cloud.getPath()));
|
if (path != null) {
|
||||||
|
eCloud.setAttribute(new Attribute("path", path));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cloud.getRegisterProcedure() != null) {
|
final String registerProcedure = cloud.getRegisterProcedure();
|
||||||
eCloud.setAttribute(new Attribute("registerProcedure", cloud.getRegisterProcedure()));
|
if (registerProcedure != null) {
|
||||||
|
eCloud.setAttribute(new Attribute("registerProcedure", registerProcedure));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cloud.getProtocol() != null) {
|
final String protocol = cloud.getProtocol();
|
||||||
eCloud.setAttribute(new Attribute("protocol", cloud.getProtocol()));
|
if (protocol != null) {
|
||||||
|
eCloud.setAttribute(new Attribute("protocol", protocol));
|
||||||
}
|
}
|
||||||
|
|
||||||
return eCloud;
|
return eCloud;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Another one to thanks DW for
|
// Another one to thanks DW for
|
||||||
|
@ -93,6 +101,7 @@ public class RSS092Generator extends RSS091UserlandGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void populateItem(final Item item, final Element eItem, final int index) {
|
protected void populateItem(final Item item, final Element eItem, final int index) {
|
||||||
|
|
||||||
super.populateItem(item, eItem, index);
|
super.populateItem(item, eItem, index);
|
||||||
|
|
||||||
final Source source = item.getSource();
|
final Source source = item.getSource();
|
||||||
|
@ -106,40 +115,59 @@ public class RSS092Generator extends RSS091UserlandGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Category> categories = item.getCategories();
|
final List<Category> categories = item.getCategories();
|
||||||
for (int i = 0; i < categories.size(); i++) {
|
for (final Category category : categories) {
|
||||||
eItem.addContent(generateCategoryElement(categories.get(i)));
|
eItem.addContent(generateCategoryElement(category));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateSourceElement(final Source source) {
|
protected Element generateSourceElement(final Source source) {
|
||||||
|
|
||||||
final Element sourceElement = new Element("source", getFeedNamespace());
|
final Element sourceElement = new Element("source", getFeedNamespace());
|
||||||
if (source.getUrl() != null) {
|
|
||||||
sourceElement.setAttribute(new Attribute("url", source.getUrl()));
|
final String url = source.getUrl();
|
||||||
|
if (url != null) {
|
||||||
|
sourceElement.setAttribute(new Attribute("url", url));
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceElement.addContent(source.getValue());
|
sourceElement.addContent(source.getValue());
|
||||||
|
|
||||||
return sourceElement;
|
return sourceElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateEnclosure(final Enclosure enclosure) {
|
protected Element generateEnclosure(final Enclosure enclosure) {
|
||||||
|
|
||||||
final Element enclosureElement = new Element("enclosure", getFeedNamespace());
|
final Element enclosureElement = new Element("enclosure", getFeedNamespace());
|
||||||
if (enclosure.getUrl() != null) {
|
|
||||||
enclosureElement.setAttribute("url", enclosure.getUrl());
|
final String url = enclosure.getUrl();
|
||||||
|
if (url != null) {
|
||||||
|
enclosureElement.setAttribute("url", url);
|
||||||
}
|
}
|
||||||
if (enclosure.getLength() != 0) {
|
|
||||||
enclosureElement.setAttribute("length", String.valueOf(enclosure.getLength()));
|
final long length = enclosure.getLength();
|
||||||
|
if (length != 0) {
|
||||||
|
enclosureElement.setAttribute("length", String.valueOf(length));
|
||||||
}
|
}
|
||||||
if (enclosure.getType() != null) {
|
|
||||||
enclosureElement.setAttribute("type", enclosure.getType());
|
final String type = enclosure.getType();
|
||||||
|
if (type != null) {
|
||||||
|
enclosureElement.setAttribute("type", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return enclosureElement;
|
return enclosureElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Element generateCategoryElement(final Category category) {
|
protected Element generateCategoryElement(final Category category) {
|
||||||
|
|
||||||
final Element categoryElement = new Element("category", getFeedNamespace());
|
final Element categoryElement = new Element("category", getFeedNamespace());
|
||||||
if (category.getDomain() != null) {
|
|
||||||
categoryElement.setAttribute("domain", category.getDomain());
|
final String domain = category.getDomain();
|
||||||
|
if (domain != null) {
|
||||||
|
categoryElement.setAttribute("domain", domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
categoryElement.addContent(category.getValue());
|
categoryElement.addContent(category.getValue());
|
||||||
|
|
||||||
return categoryElement;
|
return categoryElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,41 +56,47 @@ public class RSS092Parser extends RSS091UserlandParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
|
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
|
||||||
|
|
||||||
final Channel channel = (Channel) super.parseChannel(rssRoot, locale);
|
final Channel channel = (Channel) super.parseChannel(rssRoot, locale);
|
||||||
|
|
||||||
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
||||||
|
|
||||||
final Element eCloud = eChannel.getChild("cloud", getRSSNamespace());
|
final Element eCloud = eChannel.getChild("cloud", getRSSNamespace());
|
||||||
|
|
||||||
if (eCloud != null) {
|
if (eCloud != null) {
|
||||||
final Cloud cloud = new Cloud();
|
final Cloud cloud = new Cloud();
|
||||||
String att = eCloud.getAttributeValue("domain");// getRSSNamespace());
|
|
||||||
// DONT KNOW WHY
|
final String domain = eCloud.getAttributeValue("domain");
|
||||||
// DOESN'T WORK
|
if (domain != null) {
|
||||||
if (att != null) {
|
cloud.setDomain(domain);
|
||||||
cloud.setDomain(att);
|
|
||||||
}
|
}
|
||||||
att = eCloud.getAttributeValue("port");// getRSSNamespace()); DONT
|
|
||||||
// KNOW WHY DOESN'T WORK
|
// getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
|
||||||
if (att != null) {
|
final String port = eCloud.getAttributeValue("port");
|
||||||
cloud.setPort(Integer.parseInt(att.trim()));
|
if (port != null) {
|
||||||
|
cloud.setPort(Integer.parseInt(port.trim()));
|
||||||
}
|
}
|
||||||
att = eCloud.getAttributeValue("path");// getRSSNamespace()); DONT
|
|
||||||
// KNOW WHY DOESN'T WORK
|
// getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
|
||||||
if (att != null) {
|
final String path = eCloud.getAttributeValue("path");
|
||||||
cloud.setPath(att);
|
if (path != null) {
|
||||||
|
cloud.setPath(path);
|
||||||
}
|
}
|
||||||
att = eCloud.getAttributeValue("registerProcedure");// getRSSNamespace());
|
|
||||||
// DONT KNOW WHY
|
// getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
|
||||||
// DOESN'T WORK
|
final String registerProcedure = eCloud.getAttributeValue("registerProcedure");
|
||||||
if (att != null) {
|
if (registerProcedure != null) {
|
||||||
cloud.setRegisterProcedure(att);
|
cloud.setRegisterProcedure(registerProcedure);
|
||||||
}
|
}
|
||||||
att = eCloud.getAttributeValue("protocol");// getRSSNamespace());
|
|
||||||
// DONT KNOW WHY DOESN'T
|
// getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
|
||||||
// WORK
|
final String protocol = eCloud.getAttributeValue("protocol");
|
||||||
if (att != null) {
|
if (protocol != null) {
|
||||||
cloud.setProtocol(att);
|
cloud.setProtocol(protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.setCloud(cloud);
|
channel.setCloud(cloud);
|
||||||
|
|
||||||
}
|
}
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
@ -99,76 +105,83 @@ public class RSS092Parser extends RSS091UserlandParser {
|
||||||
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
|
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
|
||||||
final Item item = super.parseItem(rssRoot, eItem, locale);
|
final Item item = super.parseItem(rssRoot, eItem, locale);
|
||||||
|
|
||||||
Element e = eItem.getChild("source", getRSSNamespace());
|
final Element eSource = eItem.getChild("source", getRSSNamespace());
|
||||||
if (e != null) {
|
if (eSource != null) {
|
||||||
final Source source = new Source();
|
final Source source = new Source();
|
||||||
final String url = e.getAttributeValue("url");// getRSSNamespace());
|
// getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
|
||||||
// DONT
|
final String url = eSource.getAttributeValue("url");
|
||||||
// KNOW WHY DOESN'T WORK
|
|
||||||
source.setUrl(url);
|
source.setUrl(url);
|
||||||
source.setValue(e.getText());
|
source.setValue(eSource.getText());
|
||||||
item.setSource(source);
|
item.setSource(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0.92 allows one enclosure occurrence, 0.93 multiple
|
// 0.92 allows one enclosure occurrence, 0.93 multiple just saving to write some code.
|
||||||
// just saving to write some code.
|
// getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
|
||||||
final List<Element> eEnclosures = eItem.getChildren("enclosure");// getRSSNamespace());
|
final List<Element> eEnclosures = eItem.getChildren("enclosure");
|
||||||
// DONT KNOW
|
|
||||||
// WHY
|
|
||||||
// DOESN'T
|
|
||||||
// WORK
|
|
||||||
if (!eEnclosures.isEmpty()) {
|
if (!eEnclosures.isEmpty()) {
|
||||||
|
|
||||||
final List<Enclosure> enclosures = new ArrayList<Enclosure>();
|
final List<Enclosure> enclosures = new ArrayList<Enclosure>();
|
||||||
for (int i = 0; i < eEnclosures.size(); i++) {
|
|
||||||
e = eEnclosures.get(i);
|
for (final Element eEnclosure : eEnclosures) {
|
||||||
|
|
||||||
final Enclosure enclosure = new Enclosure();
|
final Enclosure enclosure = new Enclosure();
|
||||||
String att = e.getAttributeValue("url");// getRSSNamespace());
|
// getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
|
||||||
// DONT KNOW WHY DOESN'T
|
final String url = eEnclosure.getAttributeValue("url");
|
||||||
// WORK
|
if (url != null) {
|
||||||
if (att != null) {
|
enclosure.setUrl(url);
|
||||||
enclosure.setUrl(att);
|
|
||||||
}
|
}
|
||||||
att = e.getAttributeValue("length");// getRSSNamespace()); DONT
|
|
||||||
// KNOW WHY DOESN'T WORK
|
|
||||||
enclosure.setLength(NumberParser.parseLong(att, 0L));
|
|
||||||
|
|
||||||
att = e.getAttributeValue("type");// getRSSNamespace()); DONT
|
// getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
|
||||||
// KNOW WHY DOESN'T WORK
|
final String length = eEnclosure.getAttributeValue("length");
|
||||||
if (att != null) {
|
enclosure.setLength(NumberParser.parseLong(length, 0L));
|
||||||
enclosure.setType(att);
|
|
||||||
|
// getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
|
||||||
|
final String type = eEnclosure.getAttributeValue("type");
|
||||||
|
if (type != null) {
|
||||||
|
enclosure.setType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
enclosures.add(enclosure);
|
enclosures.add(enclosure);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
item.setEnclosures(enclosures);
|
item.setEnclosures(enclosures);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Element> eCats = eItem.getChildren("category");// getRSSNamespace());
|
// getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
|
||||||
// DONT KNOW WHY
|
final List<Element> categories = eItem.getChildren("category");
|
||||||
// DOESN'T WORK
|
item.setCategories(parseCategories(categories));
|
||||||
item.setCategories(parseCategories(eCats));
|
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Category> parseCategories(final List<Element> eCats) {
|
protected List<Category> parseCategories(final List<Element> eCats) {
|
||||||
|
|
||||||
List<Category> cats = null;
|
List<Category> cats = null;
|
||||||
|
|
||||||
if (!eCats.isEmpty()) {
|
if (!eCats.isEmpty()) {
|
||||||
|
|
||||||
cats = new ArrayList<Category>();
|
cats = new ArrayList<Category>();
|
||||||
for (int i = 0; i < eCats.size(); i++) {
|
for (final Element eCat : eCats) {
|
||||||
|
|
||||||
final Category cat = new Category();
|
final Category cat = new Category();
|
||||||
final Element e = eCats.get(i);
|
|
||||||
final String att = e.getAttributeValue("domain");// getRSSNamespace());
|
// getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
|
||||||
// DONT KNOW WHY
|
final String domain = eCat.getAttributeValue("domain");
|
||||||
// DOESN'T WORK
|
if (domain != null) {
|
||||||
if (att != null) {
|
cat.setDomain(domain);
|
||||||
cat.setDomain(att);
|
|
||||||
}
|
}
|
||||||
cat.setValue(e.getText());
|
|
||||||
|
cat.setValue(eCat.getText());
|
||||||
|
|
||||||
cats.add(cat);
|
cats.add(cat);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cats;
|
return cats;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -41,23 +41,29 @@ public class RSS093Parser extends RSS092Parser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
|
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
|
||||||
|
|
||||||
final Item item = super.parseItem(rssRoot, eItem, locale);
|
final Item item = super.parseItem(rssRoot, eItem, locale);
|
||||||
Element e = eItem.getChild("pubDate", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element pubDate = eItem.getChild("pubDate", getRSSNamespace());
|
||||||
item.setPubDate(DateParser.parseDate(e.getText(), locale));
|
if (pubDate != null) {
|
||||||
|
item.setPubDate(DateParser.parseDate(pubDate.getText(), locale));
|
||||||
}
|
}
|
||||||
e = eItem.getChild("expirationDate", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element expirationDate = eItem.getChild("expirationDate", getRSSNamespace());
|
||||||
item.setExpirationDate(DateParser.parseDate(e.getText(), locale));
|
if (expirationDate != null) {
|
||||||
|
item.setExpirationDate(DateParser.parseDate(expirationDate.getText(), locale));
|
||||||
}
|
}
|
||||||
e = eItem.getChild("description", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element description = eItem.getChild("description", getRSSNamespace());
|
||||||
final String type = e.getAttributeValue("type");
|
if (description != null) {
|
||||||
|
final String type = description.getAttributeValue("type");
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
item.getDescription().setType(type);
|
item.getDescription().setType(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,6 @@ import com.sun.syndication.feed.rss.Channel;
|
||||||
import com.sun.syndication.feed.rss.Guid;
|
import com.sun.syndication.feed.rss.Guid;
|
||||||
import com.sun.syndication.feed.rss.Item;
|
import com.sun.syndication.feed.rss.Item;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class RSS094Parser extends RSS093Parser {
|
public class RSS094Parser extends RSS093Parser {
|
||||||
|
|
||||||
public RSS094Parser() {
|
public RSS094Parser() {
|
||||||
|
@ -45,22 +43,19 @@ public class RSS094Parser extends RSS093Parser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
|
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
|
||||||
|
|
||||||
final Channel channel = (Channel) super.parseChannel(rssRoot, locale);
|
final Channel channel = (Channel) super.parseChannel(rssRoot, locale);
|
||||||
|
|
||||||
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
||||||
|
|
||||||
final List<Element> eCats = eChannel.getChildren("category", getRSSNamespace());
|
final List<Element> categories = eChannel.getChildren("category", getRSSNamespace());
|
||||||
channel.setCategories(parseCategories(eCats));
|
channel.setCategories(parseCategories(categories));
|
||||||
|
|
||||||
final Element eTtl = eChannel.getChild("ttl", getRSSNamespace());
|
final Element ttl = eChannel.getChild("ttl", getRSSNamespace());
|
||||||
if (eTtl != null && eTtl.getText() != null) {
|
if (ttl != null && ttl.getText() != null) {
|
||||||
Integer ttlValue = null;
|
final Integer ttlValue = NumberParser.parseInt(ttl.getText());
|
||||||
try {
|
|
||||||
ttlValue = new Integer(eTtl.getText());
|
|
||||||
} catch (final NumberFormatException nfe) {
|
|
||||||
; // let it go by
|
|
||||||
}
|
|
||||||
if (ttlValue != null) {
|
if (ttlValue != null) {
|
||||||
channel.setTtl(ttlValue.intValue());
|
channel.setTtl(ttlValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,33 +64,40 @@ public class RSS094Parser extends RSS093Parser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
|
public Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
|
||||||
|
|
||||||
final Item item = super.parseItem(rssRoot, eItem, locale);
|
final Item item = super.parseItem(rssRoot, eItem, locale);
|
||||||
|
|
||||||
item.setExpirationDate(null);
|
item.setExpirationDate(null);
|
||||||
|
|
||||||
Element e = eItem.getChild("author", getRSSNamespace());
|
final Element author = eItem.getChild("author", getRSSNamespace());
|
||||||
if (e != null) {
|
if (author != null) {
|
||||||
item.setAuthor(e.getText());
|
item.setAuthor(author.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eItem.getChild("guid", getRSSNamespace());
|
final Element eGuid = eItem.getChild("guid", getRSSNamespace());
|
||||||
if (e != null) {
|
if (eGuid != null) {
|
||||||
|
|
||||||
final Guid guid = new Guid();
|
final Guid guid = new Guid();
|
||||||
final String att = e.getAttributeValue("isPermaLink");// getRSSNamespace());
|
|
||||||
// DONT KNOW WHY
|
// getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
|
||||||
// DOESN'T WORK
|
final String att = eGuid.getAttributeValue("isPermaLink");
|
||||||
if (att != null) {
|
if (att != null) {
|
||||||
guid.setPermaLink(att.equalsIgnoreCase("true"));
|
guid.setPermaLink(att.equalsIgnoreCase("true"));
|
||||||
}
|
}
|
||||||
guid.setValue(e.getText());
|
|
||||||
|
guid.setValue(eGuid.getText());
|
||||||
|
|
||||||
item.setGuid(guid);
|
item.setGuid(guid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e = eItem.getChild("comments", getRSSNamespace());
|
final Element comments = eItem.getChild("comments", getRSSNamespace());
|
||||||
if (e != null) {
|
if (comments != null) {
|
||||||
item.setComments(e.getText());
|
item.setComments(comments.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,9 @@ import com.sun.syndication.io.FeedException;
|
||||||
/**
|
/**
|
||||||
* Feed Generator for RSS 1.0
|
* Feed Generator for RSS 1.0
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Elaine Chien
|
* @author Elaine Chien
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RSS10Generator extends RSS090Generator {
|
public class RSS10Generator extends RSS090Generator {
|
||||||
|
@ -54,22 +54,25 @@ public class RSS10Generator extends RSS090Generator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void populateChannel(final Channel channel, final Element eChannel) {
|
protected void populateChannel(final Channel channel, final Element eChannel) {
|
||||||
|
|
||||||
super.populateChannel(channel, eChannel);
|
super.populateChannel(channel, eChannel);
|
||||||
if (channel.getUri() != null) {
|
|
||||||
eChannel.setAttribute("about", channel.getUri(), getRDFNamespace());
|
final String channelUri = channel.getUri();
|
||||||
|
if (channelUri != null) {
|
||||||
|
eChannel.setAttribute("about", channelUri, getRDFNamespace());
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Item> items = channel.getItems();
|
final List<Item> items = channel.getItems();
|
||||||
if (!items.isEmpty()) {
|
if (!items.isEmpty()) {
|
||||||
final Element eItems = new Element("items", getFeedNamespace());
|
final Element eItems = new Element("items", getFeedNamespace());
|
||||||
final Element eSeq = new Element("Seq", getRDFNamespace());
|
final Element eSeq = new Element("Seq", getRDFNamespace());
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (final Item item : items) {
|
||||||
final Item item = items.get(i);
|
final Element lis = new Element("li", getRDFNamespace());
|
||||||
final Element eLi = new Element("li", getRDFNamespace());
|
|
||||||
final String uri = item.getUri();
|
final String uri = item.getUri();
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
eLi.setAttribute("resource", uri, getRDFNamespace());
|
lis.setAttribute("resource", uri, getRDFNamespace());
|
||||||
}
|
}
|
||||||
eSeq.addContent(eLi);
|
eSeq.addContent(lis);
|
||||||
}
|
}
|
||||||
eItems.addContent(eSeq);
|
eItems.addContent(eSeq);
|
||||||
eChannel.addContent(eItems);
|
eChannel.addContent(eItems);
|
||||||
|
@ -78,10 +81,11 @@ public class RSS10Generator extends RSS090Generator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void populateItem(final Item item, final Element eItem, final int index) {
|
protected void populateItem(final Item item, final Element eItem, final int index) {
|
||||||
|
|
||||||
super.populateItem(item, eItem, index);
|
super.populateItem(item, eItem, index);
|
||||||
|
|
||||||
final String link = item.getLink();
|
final String link = item.getLink();
|
||||||
final String uri = item.getUri();
|
final String uri = item.getUri();
|
||||||
|
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
eItem.setAttribute("about", uri, getRDFNamespace());
|
eItem.setAttribute("about", uri, getRDFNamespace());
|
||||||
} else if (link != null) {
|
} else if (link != null) {
|
||||||
|
@ -92,11 +96,13 @@ public class RSS10Generator extends RSS090Generator {
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
eItem.addContent(generateSimpleElement("description", description.getValue()));
|
eItem.addContent(generateSimpleElement("description", description.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getModule(getContentNamespace().getURI()) == null && item.getContent() != null) {
|
if (item.getModule(getContentNamespace().getURI()) == null && item.getContent() != null) {
|
||||||
final Element elem = new Element("encoded", getContentNamespace());
|
final Element elem = new Element("encoded", getContentNamespace());
|
||||||
elem.addContent(item.getContent().getValue());
|
elem.addContent(item.getContent().getValue());
|
||||||
eItem.addContent(elem);
|
eItem.addContent(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -49,33 +49,21 @@ public class RSS10Parser extends RSS090Parser {
|
||||||
* It checks for RDF ("http://www.w3.org/1999/02/22-rdf-syntax-ns#") namespace being defined in
|
* It checks for RDF ("http://www.w3.org/1999/02/22-rdf-syntax-ns#") namespace being defined in
|
||||||
* the root element and for the RSS 1.0 ("http://purl.org/rss/1.0/") namespace in the channel
|
* the root element and for the RSS 1.0 ("http://purl.org/rss/1.0/") namespace in the channel
|
||||||
* element.
|
* element.
|
||||||
*
|
*
|
||||||
* @param document document to check if it can be parsed with this parser implementation.
|
* @param document document to check if it can be parsed with this parser implementation.
|
||||||
* @return <b>true</b> if the document is RSS1., <b>false</b> otherwise.
|
* @return <b>true</b> if the document is RSS1., <b>false</b> otherwise.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isMyType(final Document document) {
|
public boolean isMyType(final Document document) {
|
||||||
boolean ok = false;
|
|
||||||
|
|
||||||
final Element rssRoot = document.getRootElement();
|
final Element rssRoot = document.getRootElement();
|
||||||
final Namespace defaultNS = rssRoot.getNamespace();
|
final Namespace defaultNS = rssRoot.getNamespace();
|
||||||
|
return defaultNS != null && defaultNS.equals(getRDFNamespace()) && rssRoot.getChild("channel", getRSSNamespace()) != null;
|
||||||
ok = defaultNS != null && defaultNS.equals(getRDFNamespace());
|
|
||||||
if (ok) {
|
|
||||||
// now also test if the channel element exists with the right
|
|
||||||
// namespace
|
|
||||||
final Element channel = rssRoot.getChild("channel", getRSSNamespace());
|
|
||||||
if (channel == null) {
|
|
||||||
ok = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the namespace used by RSS elements in document of the RSS 1.0
|
* Returns the namespace used by RSS elements in document of the RSS 1.0
|
||||||
* <P>
|
* <P>
|
||||||
*
|
*
|
||||||
* @return returns "http://purl.org/rss/1.0/".
|
* @return returns "http://purl.org/rss/1.0/".
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -89,29 +77,32 @@ public class RSS10Parser extends RSS090Parser {
|
||||||
* It first invokes super.parseItem and then parses and injects the description property if
|
* It first invokes super.parseItem and then parses and injects the description property if
|
||||||
* present.
|
* present.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @param rssRoot the root element of the RSS document in case it's needed for context.
|
* @param rssRoot the root element of the RSS document in case it's needed for context.
|
||||||
* @param eItem the item element to parse.
|
* @param eItem the item element to parse.
|
||||||
* @return the parsed RSSItem bean.
|
* @return the parsed RSSItem bean.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
|
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
|
||||||
|
|
||||||
final Item item = super.parseItem(rssRoot, eItem, locale);
|
final Item item = super.parseItem(rssRoot, eItem, locale);
|
||||||
final Element e = eItem.getChild("description", getRSSNamespace());
|
|
||||||
if (e != null) {
|
final Element description = eItem.getChild("description", getRSSNamespace());
|
||||||
item.setDescription(parseItemDescription(rssRoot, e));
|
if (description != null) {
|
||||||
|
item.setDescription(parseItemDescription(rssRoot, description));
|
||||||
}
|
}
|
||||||
final Element ce = eItem.getChild("encoded", getContentNamespace());
|
|
||||||
if (ce != null) {
|
final Element encoded = eItem.getChild("encoded", getContentNamespace());
|
||||||
|
if (encoded != null) {
|
||||||
final Content content = new Content();
|
final Content content = new Content();
|
||||||
content.setType(Content.HTML);
|
content.setType(Content.HTML);
|
||||||
content.setValue(ce.getText());
|
content.setValue(encoded.getText());
|
||||||
item.setContent(content);
|
item.setContent(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String uri = eItem.getAttributeValue("about", getRDFNamespace());
|
final String about = eItem.getAttributeValue("about", getRDFNamespace());
|
||||||
if (uri != null) {
|
if (about != null) {
|
||||||
item.setUri(uri);
|
item.setUri(about);
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
@ -119,6 +110,7 @@ public class RSS10Parser extends RSS090Parser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
|
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
|
||||||
|
|
||||||
final Channel channel = (Channel) super.parseChannel(rssRoot, locale);
|
final Channel channel = (Channel) super.parseChannel(rssRoot, locale);
|
||||||
|
|
||||||
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
|
||||||
|
|
|
@ -28,11 +28,10 @@ import com.sun.syndication.feed.rss.Item;
|
||||||
/**
|
/**
|
||||||
* Feed Generator for RSS 2.0
|
* Feed Generator for RSS 2.0
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Elaine Chien
|
* @author Elaine Chien
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RSS20Generator extends RSS094Generator {
|
public class RSS20Generator extends RSS094Generator {
|
||||||
|
|
||||||
public RSS20Generator() {
|
public RSS20Generator() {
|
||||||
|
@ -45,6 +44,7 @@ public class RSS20Generator extends RSS094Generator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void populateChannel(final Channel channel, final Element eChannel) {
|
protected void populateChannel(final Channel channel, final Element eChannel) {
|
||||||
|
|
||||||
super.populateChannel(channel, eChannel);
|
super.populateChannel(channel, eChannel);
|
||||||
|
|
||||||
final String generator = channel.getGenerator();
|
final String generator = channel.getGenerator();
|
||||||
|
@ -58,19 +58,20 @@ public class RSS20Generator extends RSS094Generator {
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Category> categories = channel.getCategories();
|
final List<Category> categories = channel.getCategories();
|
||||||
for (int i = 0; i < categories.size(); i++) {
|
for (final Category category : categories) {
|
||||||
eChannel.addContent(generateCategoryElement(categories.get(i)));
|
eChannel.addContent(generateCategoryElement(category));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populateItem(final Item item, final Element eItem, final int index) {
|
public void populateItem(final Item item, final Element eItem, final int index) {
|
||||||
|
|
||||||
super.populateItem(item, eItem, index);
|
super.populateItem(item, eItem, index);
|
||||||
|
|
||||||
final Element eDescription = eItem.getChild("description", getFeedNamespace());
|
final Element description = eItem.getChild("description", getFeedNamespace());
|
||||||
if (eDescription != null) {
|
if (description != null) {
|
||||||
eDescription.removeAttribute("type");
|
description.removeAttribute("type");
|
||||||
}
|
}
|
||||||
|
|
||||||
final String author = item.getAuthor();
|
final String author = item.getAuthor();
|
||||||
|
|
|
@ -22,8 +22,6 @@ import org.jdom2.Element;
|
||||||
|
|
||||||
import com.sun.syndication.feed.rss.Description;
|
import com.sun.syndication.feed.rss.Description;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class RSS20Parser extends RSS094Parser {
|
public class RSS20Parser extends RSS094Parser {
|
||||||
|
|
||||||
public RSS20Parser() {
|
public RSS20Parser() {
|
||||||
|
@ -52,19 +50,11 @@ public class RSS20Parser extends RSS094Parser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMyType(final Document document) {
|
public boolean isMyType(final Document document) {
|
||||||
boolean ok;
|
|
||||||
final Element rssRoot = document.getRootElement();
|
final Element rssRoot = document.getRootElement();
|
||||||
ok = rssRoot.getName().equals("rss");
|
final Attribute version = rssRoot.getAttribute("version");
|
||||||
if (ok) {
|
// as far ROME is concerned RSS 2.0, 2.00 and 2.0.X are all the same, so let's use
|
||||||
ok = false;
|
// startsWith for leniency.
|
||||||
final Attribute version = rssRoot.getAttribute("version");
|
return rssRoot.getName().equals("rss") && version != null && version.getValue().startsWith(getRSSVersion());
|
||||||
if (version != null) {
|
|
||||||
// At this point, as far ROME is concerned RSS 2.0, 2.00 and
|
|
||||||
// 2.0.X are all the same, so let's use startsWith for leniency.
|
|
||||||
ok = version.getValue().startsWith(getRSSVersion());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,16 +26,17 @@ import com.sun.syndication.feed.WireFeed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To address issue with certain feeds (brought up by Charles Miller):
|
* To address issue with certain feeds (brought up by Charles Miller):
|
||||||
*
|
*
|
||||||
* "During the debacle that was the rollout of RSS2.0, this namespace was tried, and even appeared
|
* "During the debacle that was the rollout of RSS2.0, this namespace was tried, and even appeared
|
||||||
* in Dave Winer's Scripting News feed for a while. It was then withdrawn, but the wonderful thing
|
* in Dave Winer's Scripting News feed for a while. It was then withdrawn, but the wonderful thing
|
||||||
* about standards is the moment you roll one out, even if it's marked as unfinished and subject to
|
* about standards is the moment you roll one out, even if it's marked as unfinished and subject to
|
||||||
* change, someone will end up stuck with it forever."
|
* change, someone will end up stuck with it forever."
|
||||||
*
|
*
|
||||||
* Note that there is not counter part on the generator, we only generate the final RSS2
|
* Note that there is not counter part on the generator, we only generate the final RSS2
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RSS20wNSParser extends RSS20Parser {
|
public class RSS20wNSParser extends RSS20Parser {
|
||||||
|
|
||||||
private static String RSS20_URI = "http://backend.userland.com/rss2";
|
private static String RSS20_URI = "http://backend.userland.com/rss2";
|
||||||
|
|
||||||
public RSS20wNSParser() {
|
public RSS20wNSParser() {
|
||||||
|
@ -50,11 +51,7 @@ public class RSS20wNSParser extends RSS20Parser {
|
||||||
public boolean isMyType(final Document document) {
|
public boolean isMyType(final Document document) {
|
||||||
final Element rssRoot = document.getRootElement();
|
final Element rssRoot = document.getRootElement();
|
||||||
final Namespace defaultNS = rssRoot.getNamespace();
|
final Namespace defaultNS = rssRoot.getNamespace();
|
||||||
boolean ok = defaultNS != null && defaultNS.equals(getRSSNamespace());
|
return defaultNS != null && defaultNS.equals(getRSSNamespace()) && super.isMyType(document);
|
||||||
if (ok) {
|
|
||||||
ok = super.isMyType(document);
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,7 +62,7 @@ public class RSS20wNSParser extends RSS20Parser {
|
||||||
/**
|
/**
|
||||||
* After we parse the feed we put "rss_2.0" in it (so converters and generators work) this
|
* After we parse the feed we put "rss_2.0" in it (so converters and generators work) this
|
||||||
* parser is a phantom.
|
* parser is a phantom.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
|
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package com.sun.syndication.io.impl;
|
package com.sun.syndication.io.impl;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -31,11 +32,10 @@ import com.sun.syndication.io.ModuleGenerator;
|
||||||
/**
|
/**
|
||||||
* Feed Generator for SY ModuleImpl
|
* Feed Generator for SY ModuleImpl
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Elaine Chien
|
* @author Elaine Chien
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SyModuleGenerator implements ModuleGenerator {
|
public class SyModuleGenerator implements ModuleGenerator {
|
||||||
|
|
||||||
private static final String SY_URI = "http://purl.org/rss/1.0/modules/syndication/";
|
private static final String SY_URI = "http://purl.org/rss/1.0/modules/syndication/";
|
||||||
|
@ -60,7 +60,7 @@ public class SyModuleGenerator implements ModuleGenerator {
|
||||||
* It is used by the the feed generators to add their namespace definition in the root element
|
* It is used by the the feed generators to add their namespace definition in the root element
|
||||||
* of the generated document (forward-missing of Java 5.0 Generics).
|
* of the generated document (forward-missing of Java 5.0 Generics).
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @return a set with all the URIs (JDOM Namespace elements) this module generator uses.
|
* @return a set with all the URIs (JDOM Namespace elements) this module generator uses.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,9 +73,10 @@ public class SyModuleGenerator implements ModuleGenerator {
|
||||||
|
|
||||||
final SyModule syModule = (SyModule) module;
|
final SyModule syModule = (SyModule) module;
|
||||||
|
|
||||||
if (syModule.getUpdatePeriod() != null) {
|
final String updatePeriod = syModule.getUpdatePeriod();
|
||||||
|
if (updatePeriod != null) {
|
||||||
final Element updatePeriodElement = new Element("updatePeriod", SY_NS);
|
final Element updatePeriodElement = new Element("updatePeriod", SY_NS);
|
||||||
updatePeriodElement.addContent(syModule.getUpdatePeriod());
|
updatePeriodElement.addContent(updatePeriod);
|
||||||
element.addContent(updatePeriodElement);
|
element.addContent(updatePeriodElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,10 +84,13 @@ public class SyModuleGenerator implements ModuleGenerator {
|
||||||
updateFrequencyElement.addContent(String.valueOf(syModule.getUpdateFrequency()));
|
updateFrequencyElement.addContent(String.valueOf(syModule.getUpdateFrequency()));
|
||||||
element.addContent(updateFrequencyElement);
|
element.addContent(updateFrequencyElement);
|
||||||
|
|
||||||
if (syModule.getUpdateBase() != null) {
|
final Date updateBase = syModule.getUpdateBase();
|
||||||
|
if (updateBase != null) {
|
||||||
final Element updateBaseElement = new Element("updateBase", SY_NS);
|
final Element updateBaseElement = new Element("updateBase", SY_NS);
|
||||||
updateBaseElement.addContent(DateParser.formatW3CDateTime(syModule.getUpdateBase(), Locale.US));
|
updateBaseElement.addContent(DateParser.formatW3CDateTime(updateBase, Locale.US));
|
||||||
element.addContent(updateBaseElement);
|
element.addContent(updateBaseElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,8 @@ import com.sun.syndication.feed.module.SyModule;
|
||||||
import com.sun.syndication.feed.module.SyModuleImpl;
|
import com.sun.syndication.feed.module.SyModuleImpl;
|
||||||
import com.sun.syndication.io.ModuleParser;
|
import com.sun.syndication.io.ModuleParser;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class SyModuleParser implements ModuleParser {
|
public class SyModuleParser implements ModuleParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNamespaceUri() {
|
public String getNamespaceUri() {
|
||||||
return SyModule.URI;
|
return SyModule.URI;
|
||||||
|
@ -40,29 +39,35 @@ public class SyModuleParser implements ModuleParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Module parse(final Element syndRoot, final Locale locale) {
|
public Module parse(final Element syndRoot, final Locale locale) {
|
||||||
|
|
||||||
boolean foundSomething = false;
|
boolean foundSomething = false;
|
||||||
|
|
||||||
final SyModule sm = new SyModuleImpl();
|
final SyModule sm = new SyModuleImpl();
|
||||||
|
|
||||||
Element e = syndRoot.getChild("updatePeriod", getDCNamespace());
|
final Element updatePeriod = syndRoot.getChild("updatePeriod", getDCNamespace());
|
||||||
if (e != null) {
|
if (updatePeriod != null) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
sm.setUpdatePeriod(e.getText());
|
sm.setUpdatePeriod(updatePeriod.getText());
|
||||||
}
|
}
|
||||||
e = syndRoot.getChild("updateFrequency", getDCNamespace());
|
|
||||||
if (e != null) {
|
final Element updateFrequency = syndRoot.getChild("updateFrequency", getDCNamespace());
|
||||||
|
if (updateFrequency != null) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
sm.setUpdateFrequency(Integer.parseInt(e.getText().trim()));
|
sm.setUpdateFrequency(Integer.parseInt(updateFrequency.getText().trim()));
|
||||||
}
|
}
|
||||||
e = syndRoot.getChild("updateBase", getDCNamespace());
|
|
||||||
if (e != null) {
|
final Element updateBase = syndRoot.getChild("updateBase", getDCNamespace());
|
||||||
|
if (updateBase != null) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
sm.setUpdateBase(DateParser.parseDate(e.getText(), locale));
|
sm.setUpdateBase(DateParser.parseDate(updateBase.getText(), locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundSomething) {
|
if (foundSomething) {
|
||||||
return sm;
|
return sm;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue