From 848932469529261fd4fb167d05be8cc7cd446d00 Mon Sep 17 00:00:00 2001 From: Martin Kurz Date: Fri, 4 Oct 2013 00:26:33 +0200 Subject: [PATCH] some generics signatures and some serialVersionUIDs added --- .../com/sun/syndication/feed/CopyFrom.java | 4 +- .../com/sun/syndication/feed/atom/Entry.java | 18 ++--- .../com/sun/syndication/feed/atom/Feed.java | 19 +++--- .../com/sun/syndication/feed/atom/Person.java | 5 +- .../syndication/feed/impl/CloneableBean.java | 67 ++++++++++--------- .../syndication/feed/impl/CopyFromHelper.java | 61 +++++++++-------- .../sun/syndication/feed/impl/ObjectBean.java | 5 +- .../sun/syndication/feed/module/DCModule.java | 4 +- .../syndication/feed/module/DCModuleImpl.java | 9 +-- .../syndication/feed/module/DCSubject.java | 2 +- .../feed/module/DCSubjectImpl.java | 9 +-- .../sun/syndication/feed/module/Module.java | 2 +- .../feed/synd/SyndEnclosureImpl.java | 9 +-- .../sun/syndication/feed/synd/SyndEntry.java | 2 +- .../syndication/feed/synd/SyndEntryImpl.java | 11 +-- .../sun/syndication/feed/synd/SyndFeed.java | 2 +- .../sun/syndication/feed/synd/SyndImage.java | 2 +- .../syndication/feed/synd/SyndImageImpl.java | 9 +-- .../syndication/feed/synd/SyndLinkImpl.java | 1 + .../syndication/feed/synd/SyndPersonImpl.java | 1 + .../feed/synd/impl/ConverterForAtom03.java | 23 +++---- .../feed/synd/impl/ConverterForAtom10.java | 12 ++-- .../com/sun/syndication/io/FeedException.java | 2 + .../sun/syndication/io/ModuleGenerator.java | 3 +- .../syndication/io/ParsingFeedException.java | 2 + .../com/sun/syndication/io/WireFeedInput.java | 6 +- .../sun/syndication/io/WireFeedOutput.java | 4 +- .../syndication/io/XmlReaderException.java | 1 + .../syndication/io/impl/Atom03Generator.java | 12 ++-- .../sun/syndication/io/impl/Atom03Parser.java | 9 +-- .../syndication/io/impl/Atom10Generator.java | 12 ++-- .../sun/syndication/io/impl/Atom10Parser.java | 6 +- .../io/impl/BaseWireFeedGenerator.java | 28 ++++---- .../sun/syndication/io/impl/DateParser.java | 1 + .../syndication/io/impl/FeedGenerators.java | 6 +- .../sun/syndication/io/impl/FeedParsers.java | 6 +- .../syndication/io/impl/ModuleGenerators.java | 23 ++++--- .../syndication/io/impl/ModuleParsers.java | 4 +- .../syndication/io/impl/PluginManager.java | 42 ++++++------ .../io/impl/RSS091NetscapeGenerator.java | 1 - 40 files changed, 234 insertions(+), 211 deletions(-) diff --git a/src/main/java/com/sun/syndication/feed/CopyFrom.java b/src/main/java/com/sun/syndication/feed/CopyFrom.java index 09d07c8..ad303f4 100644 --- a/src/main/java/com/sun/syndication/feed/CopyFrom.java +++ b/src/main/java/com/sun/syndication/feed/CopyFrom.java @@ -31,7 +31,7 @@ public interface CopyFrom { * * @return the interface the copyFrom works on. */ - public Class getInterface(); + public Class> getInterface(); /** * Copies all the properties of the given bean into this one. @@ -46,6 +46,6 @@ public interface CopyFrom { * @param obj the instance to copy properties from. * */ - public void copyFrom(CopyFrom obj); + public void copyFrom(CopyFrom obj); } diff --git a/src/main/java/com/sun/syndication/feed/atom/Entry.java b/src/main/java/com/sun/syndication/feed/atom/Entry.java index d2ab156..b989f5d 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Entry.java +++ b/src/main/java/com/sun/syndication/feed/atom/Entry.java @@ -27,6 +27,7 @@ import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.module.Extendable; import com.sun.syndication.feed.module.Module; import com.sun.syndication.feed.module.impl.ModuleUtils; +import com.sun.syndication.feed.synd.SyndPerson; /** * Bean for entry elements of Atom feeds. @@ -36,6 +37,7 @@ import com.sun.syndication.feed.module.impl.ModuleUtils; * @author Dave Johnson (updated for Atom 1.0) */ public class Entry implements Cloneable, Serializable, Extendable { + private static final long serialVersionUID = 4874483180016783939L; private Content summary; private Content title; private Date created; // Atom 0.3 only @@ -43,10 +45,10 @@ public class Entry implements Cloneable, Serializable, Extendable { private Date updated; // AKA modified private Feed source; private List alternateLinks; - private List authors; + private List authors; private List categories; private List contents; - private List contributors; + private List contributors; private List foreignMarkup; private List modules; private List otherLinks; @@ -93,7 +95,7 @@ public class Entry implements Cloneable, Serializable, Extendable { * @param authors the author of the entry, null if none. * */ - public void setAuthors(final List authors) { + public void setAuthors(final List authors) { this.authors = authors; } @@ -104,8 +106,8 @@ public class Entry implements Cloneable, Serializable, Extendable { * @return the entry author, null if none. * */ - public List getAuthors() { - return authors == null ? (authors = new ArrayList()) : authors; + public List getAuthors() { + return authors == null ? (authors = new ArrayList()) : authors; } /** @@ -160,7 +162,7 @@ public class Entry implements Cloneable, Serializable, Extendable { * contributors to set, an empty list or null if none. * */ - public void setContributors(final List contributors) { + public void setContributors(final List contributors) { this.contributors = contributors; } @@ -172,8 +174,8 @@ public class Entry implements Cloneable, Serializable, Extendable { * list if none. * */ - public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + public List getContributors() { + return contributors == null ? (contributors = new ArrayList()) : contributors; } /** diff --git a/src/main/java/com/sun/syndication/feed/atom/Feed.java b/src/main/java/com/sun/syndication/feed/atom/Feed.java index a9b4d74..706f708 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Feed.java +++ b/src/main/java/com/sun/syndication/feed/atom/Feed.java @@ -23,6 +23,7 @@ import java.util.List; import com.sun.syndication.feed.WireFeed; import com.sun.syndication.feed.module.Module; import com.sun.syndication.feed.module.impl.ModuleUtils; +import com.sun.syndication.feed.synd.SyndPerson; /** * Bean for Atom feeds. @@ -34,11 +35,11 @@ import com.sun.syndication.feed.module.impl.ModuleUtils; * @author Dave Johnson (updated for Atom 1.0) */ public class Feed extends WireFeed { - + private static final long serialVersionUID = -9175445106675422528L; private String xmlBase; private List categories; - private List authors; - private List contributors; + private List authors; + private List contributors; private Generator generator; private String icon; private String id; @@ -199,8 +200,8 @@ public class Feed extends WireFeed { * @return the feed author, null if none. * */ - public List getAuthors() { - return authors == null ? (authors = new ArrayList()) : authors; + public List getAuthors() { + return authors == null ? (authors = new ArrayList()) : authors; } /** @@ -210,7 +211,7 @@ public class Feed extends WireFeed { * @param authors the feed author to set, null if none. * */ - public void setAuthors(final List authors) { + public void setAuthors(final List authors) { this.authors = authors; } @@ -222,8 +223,8 @@ public class Feed extends WireFeed { * list if none. * */ - public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + public List getContributors() { + return contributors == null ? (contributors = new ArrayList()) : contributors; } /** @@ -234,7 +235,7 @@ public class Feed extends WireFeed { * contributors to set, an empty list or null if none. * */ - public void setContributors(final List contributors) { + public void setContributors(final List contributors) { this.contributors = contributors; } diff --git a/src/main/java/com/sun/syndication/feed/atom/Person.java b/src/main/java/com/sun/syndication/feed/atom/Person.java index 76bbc71..a9055d3 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Person.java +++ b/src/main/java/com/sun/syndication/feed/atom/Person.java @@ -24,6 +24,7 @@ import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.module.Extendable; import com.sun.syndication.feed.module.Module; import com.sun.syndication.feed.module.impl.ModuleUtils; +import com.sun.syndication.feed.synd.SyndPerson; /** * Bean for person elements of Atom feeds. @@ -32,7 +33,9 @@ import com.sun.syndication.feed.module.impl.ModuleUtils; * @author Alejandro Abdelnur * @author Dave Johnson (updated for Atom 1.0) */ -public class Person implements Cloneable, Serializable, Extendable { +public class Person implements SyndPerson, Cloneable, Serializable, Extendable { + + private static final long serialVersionUID = 8853656713347735541L; private final ObjectBean objBean; diff --git a/src/main/java/com/sun/syndication/feed/impl/CloneableBean.java b/src/main/java/com/sun/syndication/feed/impl/CloneableBean.java index afc9dc6..b2ad189 100644 --- a/src/main/java/com/sun/syndication/feed/impl/CloneableBean.java +++ b/src/main/java/com/sun/syndication/feed/impl/CloneableBean.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; /** @@ -41,12 +42,12 @@ import java.util.Set; * */ public class CloneableBean implements Serializable, Cloneable { - - private static final Class[] NO_PARAMS_DEF = new Class[0]; + private static final long serialVersionUID = -6520053043831187823L; + private static final Class[] NO_PARAMS_DEF = new Class[0]; private static final Object[] NO_PARAMS = new Object[0]; private final Object obj; - private Set ignoreProperties; + private Set ignoreProperties; /** * Default constructor. @@ -103,9 +104,9 @@ public class CloneableBean implements Serializable, Cloneable { * @param ignoreProperties properties to ignore when cloning. * */ - public CloneableBean(final Object obj, final Set ignoreProperties) { + public CloneableBean(final Object obj, final Set ignoreProperties) { this.obj = obj; - this.ignoreProperties = ignoreProperties != null ? ignoreProperties : Collections.EMPTY_SET; + this.ignoreProperties = ignoreProperties != null ? ignoreProperties : Collections.emptySet(); } /** @@ -191,21 +192,22 @@ public class CloneableBean implements Serializable, Cloneable { return clonedBean; } - private Object doClone(Object value) throws Exception { + @SuppressWarnings("unchecked") + private T doClone(T value) throws Exception { if (value != null) { - final Class vClass = value.getClass(); + final Class vClass = value.getClass(); if (vClass.isArray()) { - value = cloneArray(value); + value = (T) cloneArray((T[]) value); } else if (value instanceof Collection) { - value = cloneCollection((Collection) value); + value = (T) cloneCollection((Collection) value); } else if (value instanceof Map) { - value = cloneMap((Map) value); + value = (T) cloneMap((Map) value); } else if (isBasicType(vClass)) { // NOTHING SPECIAL TO DO HERE, THEY ARE INMUTABLE } else if (value instanceof Cloneable) { final Method cloneMethod = vClass.getMethod("clone", NO_PARAMS_DEF); if (Modifier.isPublic(cloneMethod.getModifiers())) { - value = cloneMethod.invoke(value, NO_PARAMS); + value = (T) cloneMethod.invoke(value, NO_PARAMS); } else { throw new CloneNotSupportedException("Cannot clone a " + value.getClass() + " object, clone() is not public"); } @@ -216,42 +218,41 @@ public class CloneableBean implements Serializable, Cloneable { return value; } - private Object cloneArray(final Object array) throws Exception { - final Class elementClass = array.getClass().getComponentType(); + private T[] cloneArray(final T[] array) throws Exception { + final Class elementClass = array.getClass().getComponentType(); final int length = Array.getLength(array); - final Object newArray = Array.newInstance(elementClass, length); + @SuppressWarnings("unchecked") + final T[] newArray = (T[]) Array.newInstance(elementClass, length); for (int i = 0; i < length; i++) { - final Object element = doClone(Array.get(array, i)); - Array.set(newArray, i, element); + Array.set(newArray, i, doClone(Array.get(array, i))); } return newArray; } - private Object cloneCollection(final Collection collection) throws Exception { - final Class mClass = collection.getClass(); - final Collection newColl = (Collection) mClass.newInstance(); - final Iterator i = collection.iterator(); + private Collection cloneCollection(final Collection collection) throws Exception { + @SuppressWarnings("unchecked") + final Class> mClass = (Class>) collection.getClass(); + final Collection newColl = (Collection) mClass.newInstance(); + final Iterator i = collection.iterator(); while (i.hasNext()) { - final Object element = doClone(i.next()); - newColl.add(element); + newColl.add(doClone(i.next())); } return newColl; } - private Object cloneMap(final Map map) throws Exception { - final Class mClass = map.getClass(); - final Map newMap = (Map) mClass.newInstance(); - final Iterator entries = map.entrySet().iterator(); + private Map cloneMap(final Map map) throws Exception { + @SuppressWarnings("unchecked") + final Class> mClass = (Class>) map.getClass(); + final Map newMap = (Map) mClass.newInstance(); + final Iterator> entries = map.entrySet().iterator(); while (entries.hasNext()) { - final Map.Entry entry = (Map.Entry) entries.next(); - final Object key = doClone(entry.getKey()); - final Object value = doClone(entry.getValue()); - newMap.put(key, value); + final Map.Entry entry = (Map.Entry) entries.next(); + newMap.put(doClone(entry.getKey()), doClone(entry.getValue())); } return newMap; } - private static final Set BASIC_TYPES = new HashSet(); + private static final Set> BASIC_TYPES = new HashSet>(); static { BASIC_TYPES.add(Boolean.class); @@ -265,7 +266,7 @@ public class CloneableBean implements Serializable, Cloneable { BASIC_TYPES.add(String.class); } - private static final Map CONSTRUCTOR_BASIC_TYPES = new HashMap(); + private static final Map, Class[]> CONSTRUCTOR_BASIC_TYPES = new HashMap, Class[]>(); static { CONSTRUCTOR_BASIC_TYPES.put(Boolean.class, new Class[] { Boolean.TYPE }); @@ -279,7 +280,7 @@ public class CloneableBean implements Serializable, Cloneable { CONSTRUCTOR_BASIC_TYPES.put(String.class, new Class[] { String.class }); } - private boolean isBasicType(final Class vClass) { + private boolean isBasicType(final Class vClass) { return BASIC_TYPES.contains(vClass); } diff --git a/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java b/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java index 084fa6a..2c31080 100644 --- a/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java +++ b/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import com.sun.syndication.feed.CopyFrom; @@ -36,11 +37,11 @@ import com.sun.syndication.feed.CopyFrom; public class CopyFromHelper { private static final Object[] NO_PARAMS = new Object[0]; - private final Class beanInterfaceClass; - private final Map baseInterfaceMap; // ENTRIES(propertyName,interface.class) - private final Map baseImplMap; // ENTRIES(interface.class,implementation.class) + private final Class> beanInterfaceClass; + private final Map> baseInterfaceMap; // ENTRIES(propertyName,interface.class) + private final Map>, Class> baseImplMap; // ENTRIES(interface.class,implementation.class) - public CopyFromHelper(final Class beanInterfaceClass, final Map basePropInterfaceMap, final Map basePropClassImplMap) { + public CopyFromHelper(final Class> beanInterfaceClass, final Map> basePropInterfaceMap, final Map>, Class> basePropClassImplMap) { this.beanInterfaceClass = beanInterfaceClass; baseInterfaceMap = basePropInterfaceMap; baseImplMap = basePropClassImplMap; @@ -78,7 +79,7 @@ public class CopyFromHelper { // copyFrom-able Object value = pReadMethod.invoke(source, NO_PARAMS); if (value != null) { - final Class baseInterface = (Class) baseInterfaceMap.get(propertyName); + final Class baseInterface = baseInterfaceMap.get(propertyName); value = doCopy(value, baseInterface); pWriteMethod.invoke(target, new Object[] { value }); } @@ -90,33 +91,34 @@ public class CopyFromHelper { } } - private CopyFrom createInstance(final Class interfaceClass) throws Exception { + private CopyFrom createInstance(final Class> interfaceClass) throws Exception { if (baseImplMap.get(interfaceClass) == null) { return null; } else { - return (CopyFrom) ((Class) baseImplMap.get(interfaceClass)).newInstance(); + return (CopyFrom) baseImplMap.get(interfaceClass).newInstance(); } } - private Object doCopy(Object value, final Class baseInterface) throws Exception { + @SuppressWarnings("unchecked") + private Object doCopy(Object value, final Class baseInterface) throws Exception { if (value != null) { - final Class vClass = value.getClass(); + final Class vClass = value.getClass(); if (vClass.isArray()) { value = doCopyArray(value, baseInterface); } else if (value instanceof Collection) { - value = doCopyCollection((Collection) value, baseInterface); + value = doCopyCollection((Collection) value, baseInterface); } else if (value instanceof Map) { - value = doCopyMap((Map) value, baseInterface); + value = doCopyMap((Map) value, baseInterface); } else if (isBasicType(vClass)) { // value = value; // nothing to do here if (value instanceof Date) { // because Date it is not inmutable value = ((Date) value).clone(); } } else { // it goes CopyFrom - if (value instanceof CopyFrom) { - final CopyFrom source = (CopyFrom) value; - CopyFrom target = createInstance(source.getInterface()); - target = target == null ? (CopyFrom) value.getClass().newInstance() : target; + if (value instanceof CopyFrom) { + final CopyFrom source = (CopyFrom) value; + CopyFrom target = createInstance(source.getInterface()); + target = target == null ? (CopyFrom) value.getClass().newInstance() : target; target.copyFrom(source); value = target; } else { @@ -127,8 +129,8 @@ public class CopyFromHelper { return value; } - private Object doCopyArray(final Object array, final Class baseInterface) throws Exception { - final Class elementClass = array.getClass().getComponentType(); + private Object doCopyArray(final Object array, final Class baseInterface) throws Exception { + final Class elementClass = array.getClass().getComponentType(); final int length = Array.getLength(array); final Object newArray = Array.newInstance(elementClass, length); for (int i = 0; i < length; i++) { @@ -138,30 +140,27 @@ public class CopyFromHelper { return newArray; } - private Object doCopyCollection(final Collection collection, final Class baseInterface) throws Exception { + private Collection doCopyCollection(final Collection collection, final Class baseInterface) throws Exception { // expecting SETs or LISTs only, going default implementation of them - final Collection newColl = collection instanceof Set ? (Collection) new HashSet() : (Collection) new ArrayList(); - final Iterator i = collection.iterator(); + final Collection newColl = collection instanceof Set ? new HashSet() : new ArrayList(); + final Iterator i = collection.iterator(); while (i.hasNext()) { - final Object element = doCopy(i.next(), baseInterface); - newColl.add(element); + newColl.add(doCopy(i.next(), baseInterface)); } return newColl; } - private Object doCopyMap(final Map map, final Class baseInterface) throws Exception { - final Map newMap = new HashMap(); - final Iterator entries = map.entrySet().iterator(); + private Map doCopyMap(final Map map, final Class baseInterface) throws Exception { + final Map newMap = new HashMap(); + final Iterator> entries = map.entrySet().iterator(); while (entries.hasNext()) { - final Map.Entry entry = (Map.Entry) entries.next(); - final Object key = entry.getKey(); // we are assuming string KEYS - final Object element = doCopy(entry.getValue(), baseInterface); - newMap.put(key, element); + final Map.Entry entry = entries.next(); + newMap.put(entry.getKey(), doCopy(entry.getValue(), baseInterface)); } return newMap; } - private static final Set BASIC_TYPES = new HashSet(); + private static final Set> BASIC_TYPES = new HashSet>(); static { BASIC_TYPES.add(Boolean.class); @@ -176,7 +175,7 @@ public class CopyFromHelper { BASIC_TYPES.add(Date.class); } - private boolean isBasicType(final Class vClass) { + private boolean isBasicType(final Class vClass) { return BASIC_TYPES.contains(vClass); } diff --git a/src/main/java/com/sun/syndication/feed/impl/ObjectBean.java b/src/main/java/com/sun/syndication/feed/impl/ObjectBean.java index 47266af..ff5bc29 100644 --- a/src/main/java/com/sun/syndication/feed/impl/ObjectBean.java +++ b/src/main/java/com/sun/syndication/feed/impl/ObjectBean.java @@ -43,6 +43,7 @@ import java.util.Set; * */ public class ObjectBean implements Serializable, Cloneable { + private static final long serialVersionUID = -8784981605711980095L; private final EqualsBean equalsBean; private final ToStringBean toStringBean; private final CloneableBean cloneableBean; @@ -54,7 +55,7 @@ public class ObjectBean implements Serializable, Cloneable { * @param beanClass the class/interface to be used for property scanning. * */ - public ObjectBean(final Class beanClass, final Object obj) { + public ObjectBean(final Class beanClass, final Object obj) { this(beanClass, obj, null); } @@ -74,7 +75,7 @@ public class ObjectBean implements Serializable, Cloneable { * @param ignoreProperties properties to ignore when cloning. * */ - public ObjectBean(final Class beanClass, final Object obj, final Set ignoreProperties) { + public ObjectBean(final Class beanClass, final Object obj, final Set ignoreProperties) { equalsBean = new EqualsBean(beanClass, obj); toStringBean = new ToStringBean(beanClass, obj); cloneableBean = new CloneableBean(obj, ignoreProperties); diff --git a/src/main/java/com/sun/syndication/feed/module/DCModule.java b/src/main/java/com/sun/syndication/feed/module/DCModule.java index d851003..89b305b 100644 --- a/src/main/java/com/sun/syndication/feed/module/DCModule.java +++ b/src/main/java/com/sun/syndication/feed/module/DCModule.java @@ -19,8 +19,6 @@ package com.sun.syndication.feed.module; import java.util.Date; import java.util.List; -import com.sun.syndication.feed.CopyFrom; - /** * Dublin Core Module. *

@@ -30,7 +28,7 @@ import com.sun.syndication.feed.CopyFrom; * @author Alejandro Abdelnur * */ -public interface DCModule extends Module, CopyFrom { +public interface DCModule extends Module { /** * URI of the Dublin Core Module (http://purl.org/dc/elements/1.1/). diff --git a/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java b/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java index d659de9..5e472e1 100644 --- a/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java +++ b/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java @@ -39,6 +39,7 @@ import com.sun.syndication.feed.impl.ObjectBean; * */ public class DCModuleImpl extends ModuleImpl implements DCModule { + private static final long serialVersionUID = -6502372914221178645L; private final ObjectBean objBean; private List title; private List creator; @@ -940,19 +941,19 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { } @Override - public final Class getInterface() { + public final Class getInterface() { return DCModule.class; } @Override - public final void copyFrom(final CopyFrom obj) { + public final void copyFrom(final CopyFrom obj) { COPY_FROM_HELPER.copy(this, obj); } private static final CopyFromHelper COPY_FROM_HELPER; static { - final Map basePropInterfaceMap = new HashMap(); + final Map> basePropInterfaceMap = new HashMap>(); basePropInterfaceMap.put("titles", String.class); basePropInterfaceMap.put("creators", String.class); basePropInterfaceMap.put("subjects", DCSubject.class); @@ -969,7 +970,7 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { basePropInterfaceMap.put("coverages", String.class); basePropInterfaceMap.put("rightsList", String.class); - final Map basePropClassImplMap = new HashMap(); + final Map>, Class> basePropClassImplMap = new HashMap>, Class>(); basePropClassImplMap.put(DCSubject.class, DCSubjectImpl.class); COPY_FROM_HELPER = new CopyFromHelper(DCModule.class, basePropInterfaceMap, basePropClassImplMap); diff --git a/src/main/java/com/sun/syndication/feed/module/DCSubject.java b/src/main/java/com/sun/syndication/feed/module/DCSubject.java index 3c79b4d..a0646ea 100644 --- a/src/main/java/com/sun/syndication/feed/module/DCSubject.java +++ b/src/main/java/com/sun/syndication/feed/module/DCSubject.java @@ -27,7 +27,7 @@ import com.sun.syndication.feed.CopyFrom; * @author Alejandro Abdelnur * */ -public interface DCSubject extends Cloneable, CopyFrom { +public interface DCSubject extends Cloneable, CopyFrom { /** * Returns the DublinCore subject taxonomy URI. *

diff --git a/src/main/java/com/sun/syndication/feed/module/DCSubjectImpl.java b/src/main/java/com/sun/syndication/feed/module/DCSubjectImpl.java index fe909dc..b8bb5d6 100644 --- a/src/main/java/com/sun/syndication/feed/module/DCSubjectImpl.java +++ b/src/main/java/com/sun/syndication/feed/module/DCSubjectImpl.java @@ -35,6 +35,7 @@ import com.sun.syndication.feed.impl.ObjectBean; * */ public class DCSubjectImpl implements Cloneable, Serializable, DCSubject { + private static final long serialVersionUID = 6276396184267118968L; private final ObjectBean objBean; private String taxonomyUri; private String value; @@ -155,23 +156,23 @@ public class DCSubjectImpl implements Cloneable, Serializable, DCSubject { } @Override - public Class getInterface() { + public Class getInterface() { return DCSubject.class; } @Override - public void copyFrom(final CopyFrom obj) { + public void copyFrom(final CopyFrom obj) { COPY_FROM_HELPER.copy(this, obj); } private static final CopyFromHelper COPY_FROM_HELPER; static { - final Map basePropInterfaceMap = new HashMap(); + final Map> basePropInterfaceMap = new HashMap>(); basePropInterfaceMap.put("taxonomyUri", String.class); basePropInterfaceMap.put("value", String.class); - final Map basePropClassImplMap = Collections.EMPTY_MAP; + final Map>, Class> basePropClassImplMap = Collections.>, Class>emptyMap(); COPY_FROM_HELPER = new CopyFromHelper(DCSubject.class, basePropInterfaceMap, basePropClassImplMap); } diff --git a/src/main/java/com/sun/syndication/feed/module/Module.java b/src/main/java/com/sun/syndication/feed/module/Module.java index 4e2950d..58f89bd 100644 --- a/src/main/java/com/sun/syndication/feed/module/Module.java +++ b/src/main/java/com/sun/syndication/feed/module/Module.java @@ -28,7 +28,7 @@ import com.sun.syndication.feed.CopyFrom; * @author Alejandro Abdelnur * */ -public interface Module extends Cloneable, CopyFrom, Serializable { +public interface Module extends Cloneable, CopyFrom, Serializable { /** * Returns the URI of the module. diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndEnclosureImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndEnclosureImpl.java index c8b1482..3d986b3 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndEnclosureImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndEnclosureImpl.java @@ -13,6 +13,7 @@ import com.sun.syndication.feed.impl.ObjectBean; * @author Alejandro Abdelnur */ public class SyndEnclosureImpl implements Serializable, SyndEnclosure { + private static final long serialVersionUID = -5813049622142257411L; private final ObjectBean objBean; private String url; private String type; @@ -148,24 +149,24 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure { } @Override - public Class getInterface() { + public Class getInterface() { return SyndEnclosure.class; } @Override - public void copyFrom(final CopyFrom obj) { + public void copyFrom(final CopyFrom obj) { COPY_FROM_HELPER.copy(this, obj); } private static final CopyFromHelper COPY_FROM_HELPER; static { - final Map basePropInterfaceMap = new HashMap(); + final Map> basePropInterfaceMap = new HashMap>(); basePropInterfaceMap.put("url", String.class); basePropInterfaceMap.put("type", String.class); basePropInterfaceMap.put("length", Long.TYPE); - final Map basePropClassImplMap = Collections.EMPTY_MAP; + final Map>, Class> basePropClassImplMap = Collections.>, Class>emptyMap(); COPY_FROM_HELPER = new CopyFromHelper(SyndEnclosure.class, basePropInterfaceMap, basePropClassImplMap); } diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndEntry.java b/src/main/java/com/sun/syndication/feed/synd/SyndEntry.java index 1610ed9..3ff631c 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndEntry.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndEntry.java @@ -32,7 +32,7 @@ import com.sun.syndication.feed.module.Module; * @author Alejandro Abdelnur * */ -public interface SyndEntry extends Cloneable, CopyFrom, Extendable { +public interface SyndEntry extends Cloneable, CopyFrom, Extendable { /** * Returns the entry URI. diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java index 0b91e87..20bb33f 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java @@ -47,6 +47,7 @@ import com.sun.syndication.feed.synd.impl.URINormalizer; * */ public class SyndEntryImpl implements Serializable, SyndEntry { + private static final long serialVersionUID = 1944144041409866698L; private final ObjectBean objBean; private String uri; private String link; @@ -94,7 +95,7 @@ public class SyndEntryImpl implements Serializable, SyndEntry { * CloneableBean for details). * */ - protected SyndEntryImpl(final Class beanClass, final Set convenienceProperties) { + protected SyndEntryImpl(final Class beanClass, final Set convenienceProperties) { objBean = new ObjectBean(beanClass, this, convenienceProperties); } @@ -483,19 +484,19 @@ public class SyndEntryImpl implements Serializable, SyndEntry { } @Override - public Class getInterface() { + public Class getInterface() { return SyndEntry.class; } @Override - public void copyFrom(final CopyFrom obj) { + public void copyFrom(final CopyFrom obj) { COPY_FROM_HELPER.copy(this, obj); } private static final CopyFromHelper COPY_FROM_HELPER; static { - final Map basePropInterfaceMap = new HashMap(); + final Map> basePropInterfaceMap = new HashMap>(); basePropInterfaceMap.put("uri", String.class); basePropInterfaceMap.put("title", String.class); basePropInterfaceMap.put("link", String.class); @@ -505,7 +506,7 @@ public class SyndEntryImpl implements Serializable, SyndEntry { basePropInterfaceMap.put("enclosures", SyndEnclosure.class); basePropInterfaceMap.put("modules", Module.class); - final Map basePropClassImplMap = new HashMap(); + final Map>, Class> basePropClassImplMap = new HashMap>, Class>(); basePropClassImplMap.put(SyndContent.class, SyndContentImpl.class); basePropClassImplMap.put(SyndEnclosure.class, SyndEnclosureImpl.class); basePropClassImplMap.put(DCModule.class, DCModuleImpl.class); diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndFeed.java b/src/main/java/com/sun/syndication/feed/synd/SyndFeed.java index 96446b3..11f0ad1 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndFeed.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndFeed.java @@ -36,7 +36,7 @@ import com.sun.syndication.feed.module.Module; * @author Alejandro Abdelnur * */ -public interface SyndFeed extends Cloneable, CopyFrom, Extendable { +public interface SyndFeed extends Cloneable, CopyFrom, Extendable { /** * Returns the real feed types the SyndFeedImpl supports when converting diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndImage.java b/src/main/java/com/sun/syndication/feed/synd/SyndImage.java index 249302b..9de2511 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndImage.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndImage.java @@ -26,7 +26,7 @@ import com.sun.syndication.feed.CopyFrom; * @author Alejandro Abdelnur * */ -public interface SyndImage extends Cloneable, CopyFrom { +public interface SyndImage extends Cloneable, CopyFrom { /** * Returns the image title. *

diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndImageImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndImageImpl.java index ffba60d..416e1d2 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndImageImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndImageImpl.java @@ -33,6 +33,7 @@ import com.sun.syndication.feed.impl.ObjectBean; * */ public class SyndImageImpl implements Serializable, SyndImage { + private static final long serialVersionUID = 5078981553559513247L; private final ObjectBean objBean; private String title; private String url; @@ -199,25 +200,25 @@ public class SyndImageImpl implements Serializable, SyndImage { } @Override - public Class getInterface() { + public Class getInterface() { return SyndImage.class; } @Override - public void copyFrom(final CopyFrom syndImage) { + public void copyFrom(final CopyFrom syndImage) { COPY_FROM_HELPER.copy(this, syndImage); } private static final CopyFromHelper COPY_FROM_HELPER; static { - final Map basePropInterfaceMap = new HashMap(); + final Map> basePropInterfaceMap = new HashMap>(); basePropInterfaceMap.put("title", String.class); basePropInterfaceMap.put("url", String.class); basePropInterfaceMap.put("link", String.class); basePropInterfaceMap.put("description", String.class); - final Map basePropClassImplMap = Collections.EMPTY_MAP; + final Map>, Class> basePropClassImplMap = Collections.>, Class>emptyMap(); COPY_FROM_HELPER = new CopyFromHelper(SyndImage.class, basePropInterfaceMap, basePropClassImplMap); } diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndLinkImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndLinkImpl.java index df9bc79..17cebc0 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndLinkImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndLinkImpl.java @@ -29,6 +29,7 @@ import com.sun.syndication.feed.impl.ObjectBean; * @author Dave Johnson (updated for Atom 1.0) */ public class SyndLinkImpl implements Cloneable, Serializable, SyndLink { + private static final long serialVersionUID = -3620141754437170078L; private final ObjectBean objBean; diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndPersonImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndPersonImpl.java index 3b992f3..f825742 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndPersonImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndPersonImpl.java @@ -33,6 +33,7 @@ import com.sun.syndication.feed.module.impl.ModuleUtils; * */ public class SyndPersonImpl implements Serializable, SyndPerson { + private static final long serialVersionUID = 8523373264589239335L; private final ObjectBean objBean; private String name; private String uri; diff --git a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForAtom03.java b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForAtom03.java index de09bd5..58f48a0 100644 --- a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForAtom03.java +++ b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForAtom03.java @@ -108,7 +108,7 @@ public class ConverterForAtom03 implements Converter { syndFeed.setLanguage(language); } - final List authors = aFeed.getAuthors(); + final List authors = aFeed.getAuthors(); if (authors != null && authors.size() > 0) { syndFeed.setAuthors(createSyndPersons(authors)); } @@ -232,7 +232,7 @@ public class ConverterForAtom03 implements Converter { syndEntry.setContents(sContents); } - final List authors = entry.getAuthors(); + final List authors = entry.getAuthors(); if (authors != null && authors.size() > 0) { syndEntry.setAuthors(createSyndPersons(authors)); final SyndPerson person0 = syndEntry.getAuthors().get(0); @@ -341,8 +341,8 @@ public class ConverterForAtom03 implements Converter { return aFeed; } - protected static List createAtomPersons(final List sPersons) { - final List persons = new ArrayList(); + protected static List createAtomPersons(final List sPersons) { + final List persons = new ArrayList(); for (final SyndPerson syndPerson : sPersons) { final SyndPerson sPerson = syndPerson; final Person person = new Person(); @@ -355,15 +355,14 @@ public class ConverterForAtom03 implements Converter { return persons; } - protected static List createSyndPersons(final List aPersons) { + protected static List createSyndPersons(final List aPersons) { final List persons = new ArrayList(); - for (final Person person2 : aPersons) { - final Person aPerson = person2; + for (final SyndPerson person2 : aPersons) { final SyndPerson person = new SyndPersonImpl(); - person.setName(aPerson.getName()); - person.setUri(aPerson.getUri()); - person.setEmail(aPerson.getEmail()); - person.setModules(aPerson.getModules()); + person.setName(person2.getName()); + person.setUri(person2.getUri()); + person.setEmail(person2.getEmail()); + person.setModules(person2.getModules()); persons.add(person); } return persons; @@ -467,7 +466,7 @@ public class ConverterForAtom03 implements Converter { } else if (sEntry.getAuthor() != null) { final Person person = new Person(); person.setName(sEntry.getAuthor()); - final List authors = new ArrayList(); + final List authors = new ArrayList(); authors.add(person); aEntry.setAuthors(authors); } diff --git a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForAtom10.java b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForAtom10.java index f306666..b8c58f5 100644 --- a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForAtom10.java +++ b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForAtom10.java @@ -114,12 +114,12 @@ public class ConverterForAtom10 implements Converter { // Core Atom language/author/copyright/modified elements have precedence // over DC equivalent info. - final List authors = aFeed.getAuthors(); + final List authors = aFeed.getAuthors(); if (authors != null && authors.size() > 0) { syndFeed.setAuthors(ConverterForAtom03.createSyndPersons(authors)); } - final List contributors = aFeed.getContributors(); + final List contributors = aFeed.getContributors(); if (contributors != null && contributors.size() > 0) { syndFeed.setContributors(ConverterForAtom03.createSyndPersons(contributors)); } @@ -185,14 +185,14 @@ public class ConverterForAtom10 implements Converter { syndEntry.setContents(sContents); } - final List authors = entry.getAuthors(); + final List authors = entry.getAuthors(); if (authors != null && authors.size() > 0) { syndEntry.setAuthors(ConverterForAtom03.createSyndPersons(authors)); final SyndPerson person0 = syndEntry.getAuthors().get(0); syndEntry.setAuthor(person0.getName()); } - final List contributors = entry.getContributors(); + final List contributors = entry.getContributors(); if (contributors != null && contributors.size() > 0) { syndEntry.setContributors(ConverterForAtom03.createSyndPersons(contributors)); } @@ -520,13 +520,13 @@ public class ConverterForAtom10 implements Converter { final List syndContents = sEntry.getContents(); aEntry.setContents(createAtomContents(syndContents)); - List authors = sEntry.getAuthors(); + List authors = sEntry.getAuthors(); if (authors != null && authors.size() > 0) { aEntry.setAuthors(ConverterForAtom03.createAtomPersons(authors)); } else if (sEntry.getAuthor() != null) { final Person person = new Person(); person.setName(sEntry.getAuthor()); - authors = new ArrayList(); + authors = new ArrayList(); authors.add(person); aEntry.setAuthors(authors); } diff --git a/src/main/java/com/sun/syndication/io/FeedException.java b/src/main/java/com/sun/syndication/io/FeedException.java index 7a32c71..0a4ee97 100644 --- a/src/main/java/com/sun/syndication/io/FeedException.java +++ b/src/main/java/com/sun/syndication/io/FeedException.java @@ -26,6 +26,8 @@ package com.sun.syndication.io; */ public class FeedException extends Exception { + private static final long serialVersionUID = -8761681574235401334L; + /** * Creates a FeedException with a message. *

diff --git a/src/main/java/com/sun/syndication/io/ModuleGenerator.java b/src/main/java/com/sun/syndication/io/ModuleGenerator.java index 7ba3cc5..7b92363 100644 --- a/src/main/java/com/sun/syndication/io/ModuleGenerator.java +++ b/src/main/java/com/sun/syndication/io/ModuleGenerator.java @@ -19,6 +19,7 @@ package com.sun.syndication.io; import java.util.Set; import org.jdom2.Element; +import org.jdom2.Namespace; import com.sun.syndication.feed.module.Module; @@ -56,7 +57,7 @@ public interface ModuleGenerator { * @return a set with all the URIs (JDOM Namespace elements) this module * generator uses. */ - public Set getNamespaces(); + public Set getNamespaces(); /** * Generates and injects module metadata into an XML node (JDOM element). diff --git a/src/main/java/com/sun/syndication/io/ParsingFeedException.java b/src/main/java/com/sun/syndication/io/ParsingFeedException.java index d4acf0f..1175eb8 100644 --- a/src/main/java/com/sun/syndication/io/ParsingFeedException.java +++ b/src/main/java/com/sun/syndication/io/ParsingFeedException.java @@ -27,6 +27,8 @@ import org.jdom2.input.JDOMParseException; */ public class ParsingFeedException extends FeedException { + private static final long serialVersionUID = -4791878470117677698L; + /** * Creates a FeedException with a message. *

diff --git a/src/main/java/com/sun/syndication/io/WireFeedInput.java b/src/main/java/com/sun/syndication/io/WireFeedInput.java index 86edee4..34a215b 100644 --- a/src/main/java/com/sun/syndication/io/WireFeedInput.java +++ b/src/main/java/com/sun/syndication/io/WireFeedInput.java @@ -57,11 +57,11 @@ import com.sun.syndication.io.impl.XmlFixerReader; */ public class WireFeedInput { - private static Map clMap = new WeakHashMap(); + private static Map clMap = new WeakHashMap(); private static FeedParsers getFeedParsers() { synchronized (WireFeedInput.class) { - FeedParsers parsers = (FeedParsers) clMap.get(Thread.currentThread().getContextClassLoader()); + FeedParsers parsers = clMap.get(Thread.currentThread().getContextClassLoader()); if (parsers == null) { parsers = new FeedParsers(); clMap.put(Thread.currentThread().getContextClassLoader(), parsers); @@ -96,7 +96,7 @@ public class WireFeedInput { * @return a list of String elements with the supported input feed types. * */ - public static List getSupportedFeedTypes() { + public static List getSupportedFeedTypes() { return getFeedParsers().getSupportedFeedTypes(); } diff --git a/src/main/java/com/sun/syndication/io/WireFeedOutput.java b/src/main/java/com/sun/syndication/io/WireFeedOutput.java index d5c4038..ca5628e 100644 --- a/src/main/java/com/sun/syndication/io/WireFeedOutput.java +++ b/src/main/java/com/sun/syndication/io/WireFeedOutput.java @@ -46,7 +46,7 @@ import com.sun.syndication.io.impl.FeedGenerators; * */ public class WireFeedOutput { - private static Map clMap = new WeakHashMap(); + private static Map clMap = new WeakHashMap(); private static FeedGenerators getFeedGenerators() { synchronized (WireFeedOutput.class) { @@ -68,7 +68,7 @@ public class WireFeedOutput { * @return a list of String elements with the supported output feed types. * */ - public static List getSupportedFeedTypes() { + public static List getSupportedFeedTypes() { return getFeedGenerators().getSupportedFeedTypes(); } diff --git a/src/main/java/com/sun/syndication/io/XmlReaderException.java b/src/main/java/com/sun/syndication/io/XmlReaderException.java index 509a06b..e9b37df 100644 --- a/src/main/java/com/sun/syndication/io/XmlReaderException.java +++ b/src/main/java/com/sun/syndication/io/XmlReaderException.java @@ -18,6 +18,7 @@ import java.io.InputStream; * */ public class XmlReaderException extends IOException { + private static final long serialVersionUID = 622706428081721579L; private final String bomEncoding; private final String xmlGuessEncoding; private final String xmlEncoding; diff --git a/src/main/java/com/sun/syndication/io/impl/Atom03Generator.java b/src/main/java/com/sun/syndication/io/impl/Atom03Generator.java index 9988b2b..89e0e7c 100644 --- a/src/main/java/com/sun/syndication/io/impl/Atom03Generator.java +++ b/src/main/java/com/sun/syndication/io/impl/Atom03Generator.java @@ -31,7 +31,7 @@ import com.sun.syndication.feed.atom.Entry; import com.sun.syndication.feed.atom.Feed; import com.sun.syndication.feed.atom.Generator; import com.sun.syndication.feed.atom.Link; -import com.sun.syndication.feed.atom.Person; +import com.sun.syndication.feed.synd.SyndPerson; import com.sun.syndication.io.FeedException; /** @@ -138,7 +138,7 @@ public class Atom03Generator extends BaseWireFeedGenerator { eFeed.addContent(authorElement); } - final List contributors = feed.getContributors(); + final List contributors = feed.getContributors(); for (int i = 0; i < contributors.size(); i++) { final Element contributorElement = new Element("contributor", getFeedNamespace()); fillPersonElement(contributorElement, contributors.get(i)); @@ -198,7 +198,7 @@ public class Atom03Generator extends BaseWireFeedGenerator { eEntry.addContent(authorElement); } - final List contributors = entry.getContributors(); + final List contributors = entry.getContributors(); for (int i = 0; i < contributors.size(); i++) { final Element contributorElement = new Element("contributor", getFeedNamespace()); fillPersonElement(contributorElement, contributors.get(i)); @@ -271,12 +271,12 @@ public class Atom03Generator extends BaseWireFeedGenerator { return linkElement; } - protected void fillPersonElement(final Element element, final Person person) { + protected void fillPersonElement(final Element element, final SyndPerson person) { if (person.getName() != null) { element.addContent(generateSimpleElement("name", person.getName())); } - if (person.getUrl() != null) { - element.addContent(generateSimpleElement("url", person.getUrl())); + if (person.getUri() != null) { + element.addContent(generateSimpleElement("url", person.getUri())); } if (person.getEmail() != null) { diff --git a/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java b/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java index 6a3cb0a..e4acb45 100644 --- a/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java +++ b/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java @@ -31,6 +31,7 @@ import com.sun.syndication.feed.atom.Entry; import com.sun.syndication.feed.atom.Generator; import com.sun.syndication.feed.atom.Link; import com.sun.syndication.feed.atom.Person; +import com.sun.syndication.feed.synd.SyndPerson; import com.sun.syndication.io.FeedException; /** @@ -92,7 +93,7 @@ public class Atom03Parser extends BaseWireFeedParser { e = eFeed.getChild("author", getAtomNamespace()); if (e != null) { - final List authors = new ArrayList(); + final List authors = new ArrayList(); authors.add(parsePerson(e)); feed.setAuthors(authors); } @@ -220,8 +221,8 @@ public class Atom03Parser extends BaseWireFeedParser { } // List(Elements) -> List(Persons) - private List parsePersons(final List ePersons) { - final List persons = new ArrayList(); + private List parsePersons(final List ePersons) { + final List persons = new ArrayList(); for (int i = 0; i < ePersons.size(); i++) { persons.add(parsePerson(ePersons.get(i))); } @@ -287,7 +288,7 @@ public class Atom03Parser extends BaseWireFeedParser { e = eEntry.getChild("author", getAtomNamespace()); if (e != null) { - final List authors = new ArrayList(); + final List authors = new ArrayList(); authors.add(parsePerson(e)); entry.setAuthors(authors); } diff --git a/src/main/java/com/sun/syndication/io/impl/Atom10Generator.java b/src/main/java/com/sun/syndication/io/impl/Atom10Generator.java index 4ceea5b..347e4d7 100644 --- a/src/main/java/com/sun/syndication/io/impl/Atom10Generator.java +++ b/src/main/java/com/sun/syndication/io/impl/Atom10Generator.java @@ -36,7 +36,7 @@ import com.sun.syndication.feed.atom.Entry; import com.sun.syndication.feed.atom.Feed; import com.sun.syndication.feed.atom.Generator; import com.sun.syndication.feed.atom.Link; -import com.sun.syndication.feed.atom.Person; +import com.sun.syndication.feed.synd.SyndPerson; import com.sun.syndication.io.FeedException; import com.sun.syndication.io.WireFeedOutput; @@ -157,7 +157,7 @@ public class Atom10Generator extends BaseWireFeedGenerator { } } - final List authors = feed.getAuthors(); + final List authors = feed.getAuthors(); if (authors != null && authors.size() > 0) { for (int i = 0; i < authors.size(); i++) { final Element authorElement = new Element("author", getFeedNamespace()); @@ -166,7 +166,7 @@ public class Atom10Generator extends BaseWireFeedGenerator { } } - final List contributors = feed.getContributors(); + final List contributors = feed.getContributors(); if (contributors != null && contributors.size() > 0) { for (int i = 0; i < contributors.size(); i++) { final Element contributorElement = new Element("contributor", getFeedNamespace()); @@ -234,7 +234,7 @@ public class Atom10Generator extends BaseWireFeedGenerator { } } - final List authors = entry.getAuthors(); + final List authors = entry.getAuthors(); if (authors != null && authors.size() > 0) { for (int i = 0; i < authors.size(); i++) { final Element authorElement = new Element("author", getFeedNamespace()); @@ -243,7 +243,7 @@ public class Atom10Generator extends BaseWireFeedGenerator { } } - final List contributors = entry.getContributors(); + final List contributors = entry.getContributors(); if (contributors != null && contributors.size() > 0) { for (int i = 0; i < contributors.size(); i++) { final Element contributorElement = new Element("contributor", getFeedNamespace()); @@ -349,7 +349,7 @@ public class Atom10Generator extends BaseWireFeedGenerator { return linkElement; } - protected void fillPersonElement(final Element element, final Person person) { + protected void fillPersonElement(final Element element, final SyndPerson person) { if (person.getName() != null) { element.addContent(generateSimpleElement("name", person.getName())); } diff --git a/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java b/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java index 4f68894..ee535f1 100644 --- a/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java +++ b/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java @@ -41,6 +41,7 @@ import com.sun.syndication.feed.atom.Feed; import com.sun.syndication.feed.atom.Generator; import com.sun.syndication.feed.atom.Link; import com.sun.syndication.feed.atom.Person; +import com.sun.syndication.feed.synd.SyndPerson; import com.sun.syndication.io.FeedException; import com.sun.syndication.io.WireFeedInput; import com.sun.syndication.io.WireFeedOutput; @@ -293,8 +294,8 @@ public class Atom10Parser extends BaseWireFeedParser { } // List(Elements) -> List(Persons) - private List parsePersons(final String baseURI, final List ePersons) { - final List persons = new ArrayList(); + private List parsePersons(final String baseURI, final List ePersons) { + final List persons = new ArrayList(); for (int i = 0; i < ePersons.size(); i++) { persons.add(parsePerson(baseURI, ePersons.get(i))); } @@ -594,7 +595,6 @@ public class Atom10Parser extends BaseWireFeedParser { base = stripTrailingSlash(base); append = stripStartingSlash(append); if (append.startsWith("..")) { - final String ret = null; final String[] parts = append.split("/"); for (final String part : parts) { if ("..".equals(part)) { diff --git a/src/main/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java b/src/main/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java index 4d7fb69..c8d534b 100644 --- a/src/main/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java +++ b/src/main/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java @@ -1,5 +1,6 @@ package com.sun.syndication.io.impl; +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -9,6 +10,7 @@ import org.jdom2.Element; import org.jdom2.Namespace; import org.jdom2.Parent; +import com.sun.syndication.feed.module.Module; import com.sun.syndication.io.WireFeedGenerator; /** @@ -42,8 +44,8 @@ public abstract class BaseWireFeedGenerator implements WireFeedGenerator { feedModuleGenerators = new ModuleGenerators(type + FEED_MODULE_GENERATORS_POSFIX_KEY, this); itemModuleGenerators = new ModuleGenerators(type + ITEM_MODULE_GENERATORS_POSFIX_KEY, this); personModuleGenerators = new ModuleGenerators(type + PERSON_MODULE_GENERATORS_POSFIX_KEY, this); - final Set allModuleNamespaces = new HashSet(); - Iterator i = feedModuleGenerators.getAllNamespaces().iterator(); + final Set allModuleNamespaces = new HashSet(); + Iterator i = feedModuleGenerators.getAllNamespaces().iterator(); while (i.hasNext()) { allModuleNamespaces.add(i.next()); } @@ -70,21 +72,21 @@ public abstract class BaseWireFeedGenerator implements WireFeedGenerator { } } - protected void generateFeedModules(final List modules, final Element feed) { + protected void generateFeedModules(final List modules, final Element feed) { feedModuleGenerators.generateModules(modules, feed); } - public void generateItemModules(final List modules, final Element item) { + public void generateItemModules(final List modules, final Element item) { itemModuleGenerators.generateModules(modules, item); } - public void generatePersonModules(final List modules, final Element person) { + public void generatePersonModules(final List modules, final Element person) { personModuleGenerators.generateModules(modules, person); } - protected void generateForeignMarkup(final Element e, final List foreignMarkup) { + protected void generateForeignMarkup(final Element e, final List foreignMarkup) { if (foreignMarkup != null) { - final Iterator elems = foreignMarkup.iterator(); + final Iterator elems = foreignMarkup.iterator(); while (elems.hasNext()) { final Element elem = (Element) elems.next(); final Parent parent = elem.getParent(); @@ -109,17 +111,17 @@ public abstract class BaseWireFeedGenerator implements WireFeedGenerator { * make sure their namespace declarations are present. */ protected static void purgeUnusedNamespaceDeclarations(final Element root) { - final java.util.Set usedPrefixes = new java.util.HashSet(); + final Set usedPrefixes = new HashSet(); collectUsedPrefixes(root, usedPrefixes); - final List list = root.getAdditionalNamespaces(); - final List additionalNamespaces = new java.util.ArrayList(); + final List list = root.getAdditionalNamespaces(); + final List additionalNamespaces = new ArrayList(); additionalNamespaces.addAll(list); // the duplication will prevent a // ConcurrentModificationException // below for (int i = 0; i < additionalNamespaces.size(); i++) { - final Namespace ns = (Namespace) additionalNamespaces.get(i); + final Namespace ns = additionalNamespaces.get(i); final String prefix = ns.getPrefix(); if (prefix != null && prefix.length() > 0 && !usedPrefixes.contains(prefix)) { root.removeNamespaceDeclaration(ns); @@ -127,12 +129,12 @@ public abstract class BaseWireFeedGenerator implements WireFeedGenerator { } } - private static void collectUsedPrefixes(final Element el, final java.util.Set collector) { + private static void collectUsedPrefixes(final Element el, final Set collector) { final String prefix = el.getNamespacePrefix(); if (prefix != null && prefix.length() > 0 && !collector.contains(prefix)) { collector.add(prefix); } - final List kids = el.getChildren(); + final List kids = el.getChildren(); for (int i = 0; i < kids.size(); i++) { collectUsedPrefixes((Element) kids.get(i), collector); // recursion // - worth it diff --git a/src/main/java/com/sun/syndication/io/impl/DateParser.java b/src/main/java/com/sun/syndication/io/impl/DateParser.java index 0252a75..81de157 100644 --- a/src/main/java/com/sun/syndication/io/impl/DateParser.java +++ b/src/main/java/com/sun/syndication/io/impl/DateParser.java @@ -75,6 +75,7 @@ public class DateParser { * are a lot more forgiving than what the Atom spec allows. The forms that * are invalid according to the spec are indicated. */ + @SuppressWarnings("unused") 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:ssz", "yyyy-MM-dd't'HH:mm:ssz", // invalid diff --git a/src/main/java/com/sun/syndication/io/impl/FeedGenerators.java b/src/main/java/com/sun/syndication/io/impl/FeedGenerators.java index 6d76bed..2dc8364 100644 --- a/src/main/java/com/sun/syndication/io/impl/FeedGenerators.java +++ b/src/main/java/com/sun/syndication/io/impl/FeedGenerators.java @@ -36,7 +36,7 @@ import com.sun.syndication.io.WireFeedGenerator; * @author Alejandro Abdelnur * */ -public class FeedGenerators extends PluginManager { +public class FeedGenerators extends PluginManager { /** * WireFeedGenerator.classes= [className] ... @@ -49,7 +49,7 @@ public class FeedGenerators extends PluginManager { } public WireFeedGenerator getGenerator(final String feedType) { - return (WireFeedGenerator) getPlugin(feedType); + return getPlugin(feedType); } @Override @@ -57,7 +57,7 @@ public class FeedGenerators extends PluginManager { return ((WireFeedGenerator) obj).getType(); } - public List getSupportedFeedTypes() { + public List getSupportedFeedTypes() { return getKeys(); } diff --git a/src/main/java/com/sun/syndication/io/impl/FeedParsers.java b/src/main/java/com/sun/syndication/io/impl/FeedParsers.java index a4a48ae..868e7b5 100644 --- a/src/main/java/com/sun/syndication/io/impl/FeedParsers.java +++ b/src/main/java/com/sun/syndication/io/impl/FeedParsers.java @@ -40,7 +40,7 @@ import com.sun.syndication.io.WireFeedParser; * @author Alejandro Abdelnur * */ -public class FeedParsers extends PluginManager { +public class FeedParsers extends PluginManager { /** * WireFeedParser.classes= [className] ... @@ -57,7 +57,7 @@ public class FeedParsers extends PluginManager { super(FEED_PARSERS_KEY); } - public List getSupportedFeedTypes() { + public List getSupportedFeedTypes() { return getKeys(); } @@ -71,7 +71,7 @@ public class FeedParsers extends PluginManager { * */ public WireFeedParser getParserFor(final Document document) { - final List parsers = getPlugins(); + final List parsers = getPlugins(); WireFeedParser parser = null; for (int i = 0; parser == null && i < parsers.size(); i++) { parser = (WireFeedParser) parsers.get(i); diff --git a/src/main/java/com/sun/syndication/io/impl/ModuleGenerators.java b/src/main/java/com/sun/syndication/io/impl/ModuleGenerators.java index ff988d5..f1732f7 100644 --- a/src/main/java/com/sun/syndication/io/impl/ModuleGenerators.java +++ b/src/main/java/com/sun/syndication/io/impl/ModuleGenerators.java @@ -22,14 +22,15 @@ import java.util.Map; import java.util.Set; import org.jdom2.Element; +import org.jdom2.Namespace; import com.sun.syndication.feed.module.Module; import com.sun.syndication.io.ModuleGenerator; /** */ -public class ModuleGenerators extends PluginManager { - private Set allNamespaces; +public class ModuleGenerators extends PluginManager { + private Set allNamespaces; public ModuleGenerators(final String propertyKey, final BaseWireFeedGenerator parentGenerator) { super(propertyKey, null, parentGenerator); @@ -44,28 +45,28 @@ public class ModuleGenerators extends PluginManager { return ((ModuleGenerator) obj).getNamespaceUri(); } - public List getModuleNamespaces() { + public List getModuleNamespaces() { return getKeys(); } - public void generateModules(final List modules, final Element element) { - final Map generators = getPluginMap(); + public void generateModules(final List modules, final Element element) { + final Map generators = getPluginMap(); for (int i = 0; i < modules.size(); i++) { - final Module module = (Module) modules.get(i); + final Module module = modules.get(i); final String namespaceUri = module.getUri(); - final ModuleGenerator generator = (ModuleGenerator) generators.get(namespaceUri); + final ModuleGenerator generator = generators.get(namespaceUri); if (generator != null) { generator.generate(module, element); } } } - public Set getAllNamespaces() { + public Set getAllNamespaces() { if (allNamespaces == null) { - allNamespaces = new HashSet(); - final List mUris = getModuleNamespaces(); + allNamespaces = new HashSet(); + final List mUris = getModuleNamespaces(); for (int i = 0; i < mUris.size(); i++) { - final ModuleGenerator mGen = getGenerator((String) mUris.get(i)); + final ModuleGenerator mGen = getGenerator(mUris.get(i)); allNamespaces.addAll(mGen.getNamespaces()); } } diff --git a/src/main/java/com/sun/syndication/io/impl/ModuleParsers.java b/src/main/java/com/sun/syndication/io/impl/ModuleParsers.java index bb534eb..032a43b 100644 --- a/src/main/java/com/sun/syndication/io/impl/ModuleParsers.java +++ b/src/main/java/com/sun/syndication/io/impl/ModuleParsers.java @@ -28,7 +28,7 @@ import com.sun.syndication.io.WireFeedParser; /** */ -public class ModuleParsers extends PluginManager { +public class ModuleParsers extends PluginManager { public ModuleParsers(final String propertyKey, final WireFeedParser parentParser) { super(propertyKey, parentParser, null); } @@ -38,7 +38,7 @@ public class ModuleParsers extends PluginManager { return ((ModuleParser) obj).getNamespaceUri(); } - public List getModuleNamespaces() { + public List getModuleNamespaces() { return getKeys(); } diff --git a/src/main/java/com/sun/syndication/io/impl/PluginManager.java b/src/main/java/com/sun/syndication/io/impl/PluginManager.java index 6f41d0d..fd448ee 100644 --- a/src/main/java/com/sun/syndication/io/impl/PluginManager.java +++ b/src/main/java/com/sun/syndication/io/impl/PluginManager.java @@ -34,11 +34,11 @@ import com.sun.syndication.io.WireFeedParser; * @author Alejandro Abdelnur * */ -public abstract class PluginManager { +public abstract class PluginManager { private final String[] propertyValues; - private Map pluginsMap; - private List pluginsList; - private final List keys; + private Map pluginsMap; + private List pluginsList; + private final List keys; private final WireFeedParser parentParser; private final WireFeedGenerator parentGenerator; @@ -60,39 +60,39 @@ public abstract class PluginManager { loadPlugins(); pluginsMap = Collections.unmodifiableMap(pluginsMap); pluginsList = Collections.unmodifiableList(pluginsList); - keys = Collections.unmodifiableList(new ArrayList(pluginsMap.keySet())); + keys = Collections.unmodifiableList(new ArrayList(pluginsMap.keySet())); } protected abstract String getKey(Object obj); - protected List getKeys() { + protected List getKeys() { return keys; } - protected List getPlugins() { + protected List getPlugins() { return pluginsList; } - protected Map getPluginMap() { + protected Map getPluginMap() { return pluginsMap; } - protected Object getPlugin(final String key) { + protected T getPlugin(final String key) { return pluginsMap.get(key); } // PRIVATE - LOADER PART private void loadPlugins() { - final List finalPluginsList = new ArrayList(); - pluginsList = new ArrayList(); - pluginsMap = new HashMap(); + final List finalPluginsList = new ArrayList(); + pluginsList = new ArrayList(); + pluginsMap = new HashMap(); String className = null; try { - final Class[] classes = getClasses(); - for (final Class classe : classes) { + final Class[] classes = getClasses(); + for (final Class classe : classes) { className = classe.getName(); - final Object plugin = classe.newInstance(); + final T plugin = classe.newInstance(); if (plugin instanceof DelegatingModuleParser) { ((DelegatingModuleParser) plugin).setFeedParser(parentParser); } @@ -105,7 +105,7 @@ public abstract class PluginManager { // definition // in the rome.properties files } - Iterator i = pluginsMap.values().iterator(); + Iterator i = pluginsMap.values().iterator(); while (i.hasNext()) { finalPluginsList.add(i.next()); // to remove overridden plugin // impls @@ -140,15 +140,17 @@ public abstract class PluginManager { * failure is ON. * */ - private Class[] getClasses() throws ClassNotFoundException { + private Class[] getClasses() throws ClassNotFoundException { final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - final List classes = new ArrayList(); + final List> classes = new ArrayList>(); final boolean useLoadClass = Boolean.valueOf(System.getProperty("rome.pluginmanager.useloadclass", "false")).booleanValue(); for (final String _propertyValue : propertyValues) { - final Class mClass = useLoadClass ? classLoader.loadClass(_propertyValue) : Class.forName(_propertyValue, true, classLoader); + @SuppressWarnings("unchecked") + final Class mClass = (Class) (useLoadClass ? classLoader.loadClass(_propertyValue) : Class.forName(_propertyValue, true, classLoader)); classes.add(mClass); } - final Class[] array = new Class[classes.size()]; + @SuppressWarnings("unchecked") + final Class[] array = (Class[]) new Class[classes.size()]; classes.toArray(array); return array; } diff --git a/src/main/java/com/sun/syndication/io/impl/RSS091NetscapeGenerator.java b/src/main/java/com/sun/syndication/io/impl/RSS091NetscapeGenerator.java index 7462a98..9f8d7ab 100644 --- a/src/main/java/com/sun/syndication/io/impl/RSS091NetscapeGenerator.java +++ b/src/main/java/com/sun/syndication/io/impl/RSS091NetscapeGenerator.java @@ -28,7 +28,6 @@ import org.jdom2.Element; * */ public class RSS091NetscapeGenerator extends RSS091UserlandGenerator { - private String version; public RSS091NetscapeGenerator() { this("rss_0.91N", "0.91");