some generics signatures and some serialVersionUIDs added
This commit is contained in:
parent
cb75d15dd1
commit
8489324695
40 changed files with 234 additions and 211 deletions
|
@ -31,7 +31,7 @@ public interface CopyFrom<T> {
|
||||||
*
|
*
|
||||||
* @return the interface the copyFrom works on.
|
* @return the interface the copyFrom works on.
|
||||||
*/
|
*/
|
||||||
public Class<? extends CopyFrom> getInterface();
|
public Class<? extends CopyFrom<?>> getInterface();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies all the properties of the given bean into this one.
|
* Copies all the properties of the given bean into this one.
|
||||||
|
@ -46,6 +46,6 @@ public interface CopyFrom<T> {
|
||||||
* @param obj the instance to copy properties from.
|
* @param obj the instance to copy properties from.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void copyFrom(CopyFrom obj);
|
public void copyFrom(CopyFrom<?> obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ 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;
|
||||||
import com.sun.syndication.feed.module.impl.ModuleUtils;
|
import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
|
import com.sun.syndication.feed.synd.SyndPerson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean for entry elements of Atom feeds.
|
* 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)
|
* @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 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
|
||||||
|
@ -43,10 +45,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
private Date updated; // AKA modified
|
private Date updated; // AKA modified
|
||||||
private Feed source;
|
private Feed source;
|
||||||
private List<Link> alternateLinks;
|
private List<Link> alternateLinks;
|
||||||
private List<Person> authors;
|
private List<SyndPerson> authors;
|
||||||
private List<Category> categories;
|
private List<Category> categories;
|
||||||
private List<Content> contents;
|
private List<Content> contents;
|
||||||
private List<Person> contributors;
|
private List<SyndPerson> contributors;
|
||||||
private List<Element> foreignMarkup;
|
private List<Element> foreignMarkup;
|
||||||
private List<Module> modules;
|
private List<Module> modules;
|
||||||
private List<Link> otherLinks;
|
private List<Link> otherLinks;
|
||||||
|
@ -93,7 +95,7 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
* @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<Person> authors) {
|
public void setAuthors(final List<SyndPerson> authors) {
|
||||||
this.authors = authors;
|
this.authors = authors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,8 +106,8 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
* @return the entry author, <b>null</b> if none.
|
* @return the entry author, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Person> getAuthors() {
|
public List<SyndPerson> getAuthors() {
|
||||||
return authors == null ? (authors = new ArrayList<Person>()) : authors;
|
return authors == null ? (authors = new ArrayList<SyndPerson>()) : authors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,7 +162,7 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
* contributors to set, an empty list or <b>null</b> if none.
|
* contributors to set, an empty list or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setContributors(final List<Person> contributors) {
|
public void setContributors(final List<SyndPerson> contributors) {
|
||||||
this.contributors = contributors;
|
this.contributors = contributors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,8 +174,8 @@ public class Entry implements Cloneable, Serializable, Extendable {
|
||||||
* list if none.
|
* list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Person> getContributors() {
|
public List<SyndPerson> getContributors() {
|
||||||
return contributors == null ? (contributors = new ArrayList<Person>()) : contributors;
|
return contributors == null ? (contributors = new ArrayList<SyndPerson>()) : contributors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
||||||
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;
|
||||||
|
import com.sun.syndication.feed.synd.SyndPerson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean for Atom feeds.
|
* Bean for Atom feeds.
|
||||||
|
@ -34,11 +35,11 @@ import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
* @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 String xmlBase;
|
private String xmlBase;
|
||||||
private List<Category> categories;
|
private List<Category> categories;
|
||||||
private List<Person> authors;
|
private List<SyndPerson> authors;
|
||||||
private List<Person> contributors;
|
private List<SyndPerson> contributors;
|
||||||
private Generator generator;
|
private Generator generator;
|
||||||
private String icon;
|
private String icon;
|
||||||
private String id;
|
private String id;
|
||||||
|
@ -199,8 +200,8 @@ public class Feed extends WireFeed {
|
||||||
* @return the feed author, <b>null</b> if none.
|
* @return the feed author, <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Person> getAuthors() {
|
public List<SyndPerson> getAuthors() {
|
||||||
return authors == null ? (authors = new ArrayList<Person>()) : authors;
|
return authors == null ? (authors = new ArrayList<SyndPerson>()) : authors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -210,7 +211,7 @@ public class Feed extends WireFeed {
|
||||||
* @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<Person> authors) {
|
public void setAuthors(final List<SyndPerson> authors) {
|
||||||
this.authors = authors;
|
this.authors = authors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,8 +223,8 @@ public class Feed extends WireFeed {
|
||||||
* list if none.
|
* list if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<Person> getContributors() {
|
public List<SyndPerson> getContributors() {
|
||||||
return contributors == null ? (contributors = new ArrayList<Person>()) : contributors;
|
return contributors == null ? (contributors = new ArrayList<SyndPerson>()) : contributors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -234,7 +235,7 @@ public class Feed extends WireFeed {
|
||||||
* contributors to set, an empty list or <b>null</b> if none.
|
* contributors to set, an empty list or <b>null</b> if none.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setContributors(final List<Person> contributors) {
|
public void setContributors(final List<SyndPerson> contributors) {
|
||||||
this.contributors = contributors;
|
this.contributors = contributors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ 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;
|
||||||
import com.sun.syndication.feed.module.impl.ModuleUtils;
|
import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
|
import com.sun.syndication.feed.synd.SyndPerson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean for person elements of Atom feeds.
|
* Bean for person elements of Atom feeds.
|
||||||
|
@ -32,7 +33,9 @@ import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
* @author Dave Johnson (updated for Atom 1.0)
|
* @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;
|
private final ObjectBean objBean;
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,12 +42,12 @@ import java.util.Set;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CloneableBean implements Serializable, Cloneable {
|
public class CloneableBean implements Serializable, Cloneable {
|
||||||
|
private static final long serialVersionUID = -6520053043831187823L;
|
||||||
private static final Class[] NO_PARAMS_DEF = new Class[0];
|
private static final Class<?>[] NO_PARAMS_DEF = new Class[0];
|
||||||
private static final Object[] NO_PARAMS = new Object[0];
|
private static final Object[] NO_PARAMS = new Object[0];
|
||||||
|
|
||||||
private final Object obj;
|
private final Object obj;
|
||||||
private Set ignoreProperties;
|
private Set<String> ignoreProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
|
@ -103,9 +104,9 @@ public class CloneableBean implements Serializable, Cloneable {
|
||||||
* @param ignoreProperties properties to ignore when cloning.
|
* @param ignoreProperties properties to ignore when cloning.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public CloneableBean(final Object obj, final Set ignoreProperties) {
|
public CloneableBean(final Object obj, final Set<String> ignoreProperties) {
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
this.ignoreProperties = ignoreProperties != null ? ignoreProperties : Collections.EMPTY_SET;
|
this.ignoreProperties = ignoreProperties != null ? ignoreProperties : Collections.<String>emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,21 +192,22 @@ public class CloneableBean implements Serializable, Cloneable {
|
||||||
return clonedBean;
|
return clonedBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object doClone(Object value) throws Exception {
|
@SuppressWarnings("unchecked")
|
||||||
|
private <T extends Object> T doClone(T value) throws Exception {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
final Class vClass = value.getClass();
|
final Class<?> vClass = value.getClass();
|
||||||
if (vClass.isArray()) {
|
if (vClass.isArray()) {
|
||||||
value = cloneArray(value);
|
value = (T) cloneArray((T[]) value);
|
||||||
} else if (value instanceof Collection) {
|
} else if (value instanceof Collection) {
|
||||||
value = cloneCollection((Collection) value);
|
value = (T) cloneCollection((Collection<Object>) value);
|
||||||
} else if (value instanceof Map) {
|
} else if (value instanceof Map) {
|
||||||
value = cloneMap((Map) value);
|
value = (T) cloneMap((Map<Object, Object>) value);
|
||||||
} else if (isBasicType(vClass)) {
|
} else if (isBasicType(vClass)) {
|
||||||
// NOTHING SPECIAL TO DO HERE, THEY ARE INMUTABLE
|
// NOTHING SPECIAL TO DO HERE, THEY ARE INMUTABLE
|
||||||
} else if (value instanceof Cloneable) {
|
} else if (value instanceof Cloneable) {
|
||||||
final Method cloneMethod = vClass.getMethod("clone", NO_PARAMS_DEF);
|
final Method cloneMethod = vClass.getMethod("clone", NO_PARAMS_DEF);
|
||||||
if (Modifier.isPublic(cloneMethod.getModifiers())) {
|
if (Modifier.isPublic(cloneMethod.getModifiers())) {
|
||||||
value = cloneMethod.invoke(value, NO_PARAMS);
|
value = (T) cloneMethod.invoke(value, NO_PARAMS);
|
||||||
} else {
|
} else {
|
||||||
throw new CloneNotSupportedException("Cannot clone a " + value.getClass() + " object, clone() is not public");
|
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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object cloneArray(final Object array) throws Exception {
|
private <T> T[] cloneArray(final T[] array) throws Exception {
|
||||||
final Class elementClass = array.getClass().getComponentType();
|
final Class<?> elementClass = array.getClass().getComponentType();
|
||||||
final int length = Array.getLength(array);
|
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++) {
|
for (int i = 0; i < length; i++) {
|
||||||
final Object element = doClone(Array.get(array, i));
|
Array.set(newArray, i, doClone(Array.get(array, i)));
|
||||||
Array.set(newArray, i, element);
|
|
||||||
}
|
}
|
||||||
return newArray;
|
return newArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object cloneCollection(final Collection collection) throws Exception {
|
private <T> Collection<T> cloneCollection(final Collection<T> collection) throws Exception {
|
||||||
final Class mClass = collection.getClass();
|
@SuppressWarnings("unchecked")
|
||||||
final Collection newColl = (Collection) mClass.newInstance();
|
final Class<Collection<T>> mClass = (Class<Collection<T>>) collection.getClass();
|
||||||
final Iterator i = collection.iterator();
|
final Collection<T> newColl = (Collection<T>) mClass.newInstance();
|
||||||
|
final Iterator<T> i = collection.iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
final Object element = doClone(i.next());
|
newColl.add(doClone(i.next()));
|
||||||
newColl.add(element);
|
|
||||||
}
|
}
|
||||||
return newColl;
|
return newColl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object cloneMap(final Map map) throws Exception {
|
private <S, T> Map<S, T> cloneMap(final Map<S, T> map) throws Exception {
|
||||||
final Class mClass = map.getClass();
|
@SuppressWarnings("unchecked")
|
||||||
final Map newMap = (Map) mClass.newInstance();
|
final Class<Map<S, T>> mClass = (Class<Map<S, T>>) map.getClass();
|
||||||
final Iterator entries = map.entrySet().iterator();
|
final Map<S, T> newMap = (Map<S, T>) mClass.newInstance();
|
||||||
|
final Iterator<Entry<S, T>> entries = map.entrySet().iterator();
|
||||||
while (entries.hasNext()) {
|
while (entries.hasNext()) {
|
||||||
final Map.Entry entry = (Map.Entry) entries.next();
|
final Map.Entry<S, T> entry = (Map.Entry<S, T>) entries.next();
|
||||||
final Object key = doClone(entry.getKey());
|
newMap.put(doClone(entry.getKey()), doClone(entry.getValue()));
|
||||||
final Object value = doClone(entry.getValue());
|
|
||||||
newMap.put(key, value);
|
|
||||||
}
|
}
|
||||||
return newMap;
|
return newMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Set BASIC_TYPES = new HashSet();
|
private static final Set<Class<?>> BASIC_TYPES = new HashSet<Class<?>>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BASIC_TYPES.add(Boolean.class);
|
BASIC_TYPES.add(Boolean.class);
|
||||||
|
@ -265,7 +266,7 @@ public class CloneableBean implements Serializable, Cloneable {
|
||||||
BASIC_TYPES.add(String.class);
|
BASIC_TYPES.add(String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map CONSTRUCTOR_BASIC_TYPES = new HashMap();
|
private static final Map<Class<?>, Class<?>[]> CONSTRUCTOR_BASIC_TYPES = new HashMap<Class<?>, Class<?>[]>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
CONSTRUCTOR_BASIC_TYPES.put(Boolean.class, new Class[] { Boolean.TYPE });
|
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 });
|
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);
|
return BASIC_TYPES.contains(vClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.sun.syndication.feed.CopyFrom;
|
import com.sun.syndication.feed.CopyFrom;
|
||||||
|
@ -36,11 +37,11 @@ import com.sun.syndication.feed.CopyFrom;
|
||||||
public class CopyFromHelper {
|
public class CopyFromHelper {
|
||||||
private static final Object[] NO_PARAMS = new Object[0];
|
private static final Object[] NO_PARAMS = new Object[0];
|
||||||
|
|
||||||
private final Class beanInterfaceClass;
|
private final Class<? extends CopyFrom<?>> beanInterfaceClass;
|
||||||
private final Map baseInterfaceMap; // ENTRIES(propertyName,interface.class)
|
private final Map<String, Class<?>> baseInterfaceMap; // ENTRIES(propertyName,interface.class)
|
||||||
private final Map baseImplMap; // ENTRIES(interface.class,implementation.class)
|
private final Map<Class<? extends CopyFrom<?>>, Class<?>> baseImplMap; // ENTRIES(interface.class,implementation.class)
|
||||||
|
|
||||||
public CopyFromHelper(final Class beanInterfaceClass, final Map basePropInterfaceMap, final Map basePropClassImplMap) {
|
public CopyFromHelper(final Class<? extends CopyFrom<?>> beanInterfaceClass, final Map<String, Class<?>> basePropInterfaceMap, final Map<Class<? extends CopyFrom<?>>, Class<?>> basePropClassImplMap) {
|
||||||
this.beanInterfaceClass = beanInterfaceClass;
|
this.beanInterfaceClass = beanInterfaceClass;
|
||||||
baseInterfaceMap = basePropInterfaceMap;
|
baseInterfaceMap = basePropInterfaceMap;
|
||||||
baseImplMap = basePropClassImplMap;
|
baseImplMap = basePropClassImplMap;
|
||||||
|
@ -78,7 +79,7 @@ public class CopyFromHelper {
|
||||||
// copyFrom-able
|
// copyFrom-able
|
||||||
Object value = pReadMethod.invoke(source, NO_PARAMS);
|
Object value = pReadMethod.invoke(source, NO_PARAMS);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
final Class baseInterface = (Class) baseInterfaceMap.get(propertyName);
|
final Class<?> baseInterface = baseInterfaceMap.get(propertyName);
|
||||||
value = doCopy(value, baseInterface);
|
value = doCopy(value, baseInterface);
|
||||||
pWriteMethod.invoke(target, new Object[] { value });
|
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<? extends CopyFrom<?>> interfaceClass) throws Exception {
|
||||||
if (baseImplMap.get(interfaceClass) == null) {
|
if (baseImplMap.get(interfaceClass) == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} 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) {
|
if (value != null) {
|
||||||
final Class vClass = value.getClass();
|
final Class<?> vClass = value.getClass();
|
||||||
if (vClass.isArray()) {
|
if (vClass.isArray()) {
|
||||||
value = doCopyArray(value, baseInterface);
|
value = doCopyArray(value, baseInterface);
|
||||||
} else if (value instanceof Collection) {
|
} else if (value instanceof Collection) {
|
||||||
value = doCopyCollection((Collection) value, baseInterface);
|
value = doCopyCollection((Collection<?>) value, baseInterface);
|
||||||
} else if (value instanceof Map) {
|
} else if (value instanceof Map) {
|
||||||
value = doCopyMap((Map) value, baseInterface);
|
value = doCopyMap((Map<Object, Object>) value, baseInterface);
|
||||||
} else if (isBasicType(vClass)) {
|
} else if (isBasicType(vClass)) {
|
||||||
// value = value; // nothing to do here
|
// value = value; // nothing to do here
|
||||||
if (value instanceof Date) { // because Date it is not inmutable
|
if (value instanceof Date) { // because Date it is not inmutable
|
||||||
value = ((Date) value).clone();
|
value = ((Date) value).clone();
|
||||||
}
|
}
|
||||||
} else { // it goes CopyFrom
|
} else { // it goes CopyFrom
|
||||||
if (value instanceof CopyFrom) {
|
if (value instanceof CopyFrom<?>) {
|
||||||
final CopyFrom source = (CopyFrom) value;
|
final CopyFrom<?> source = (CopyFrom<?>) value;
|
||||||
CopyFrom target = createInstance(source.getInterface());
|
CopyFrom<?> target = createInstance(source.getInterface());
|
||||||
target = target == null ? (CopyFrom) value.getClass().newInstance() : target;
|
target = target == null ? (CopyFrom<?>) value.getClass().newInstance() : target;
|
||||||
target.copyFrom(source);
|
target.copyFrom(source);
|
||||||
value = target;
|
value = target;
|
||||||
} else {
|
} else {
|
||||||
|
@ -127,8 +129,8 @@ public class CopyFromHelper {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object doCopyArray(final Object array, final Class baseInterface) throws Exception {
|
private Object doCopyArray(final Object array, final Class<?> baseInterface) throws Exception {
|
||||||
final Class elementClass = array.getClass().getComponentType();
|
final Class<?> elementClass = array.getClass().getComponentType();
|
||||||
final int length = Array.getLength(array);
|
final int length = Array.getLength(array);
|
||||||
final Object newArray = Array.newInstance(elementClass, length);
|
final Object newArray = Array.newInstance(elementClass, length);
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
|
@ -138,30 +140,27 @@ public class CopyFromHelper {
|
||||||
return newArray;
|
return newArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object doCopyCollection(final Collection collection, final Class baseInterface) throws Exception {
|
private Collection<Object> doCopyCollection(final Collection<?> collection, final Class<?> baseInterface) throws Exception {
|
||||||
// expecting SETs or LISTs only, going default implementation of them
|
// expecting SETs or LISTs only, going default implementation of them
|
||||||
final Collection newColl = collection instanceof Set ? (Collection) new HashSet() : (Collection) new ArrayList();
|
final Collection<Object> newColl = collection instanceof Set ? new HashSet<Object>() : new ArrayList<Object>();
|
||||||
final Iterator i = collection.iterator();
|
final Iterator<?> i = collection.iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
final Object element = doCopy(i.next(), baseInterface);
|
newColl.add(doCopy(i.next(), baseInterface));
|
||||||
newColl.add(element);
|
|
||||||
}
|
}
|
||||||
return newColl;
|
return newColl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object doCopyMap(final Map map, final Class baseInterface) throws Exception {
|
private Map<Object, Object> doCopyMap(final Map<Object, Object> map, final Class<?> baseInterface) throws Exception {
|
||||||
final Map newMap = new HashMap();
|
final Map<Object, Object> newMap = new HashMap<Object, Object>();
|
||||||
final Iterator entries = map.entrySet().iterator();
|
final Iterator<Entry<Object, Object>> entries = map.entrySet().iterator();
|
||||||
while (entries.hasNext()) {
|
while (entries.hasNext()) {
|
||||||
final Map.Entry entry = (Map.Entry) entries.next();
|
final Map.Entry<Object, Object> entry = entries.next();
|
||||||
final Object key = entry.getKey(); // we are assuming string KEYS
|
newMap.put(entry.getKey(), doCopy(entry.getValue(), baseInterface));
|
||||||
final Object element = doCopy(entry.getValue(), baseInterface);
|
|
||||||
newMap.put(key, element);
|
|
||||||
}
|
}
|
||||||
return newMap;
|
return newMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Set BASIC_TYPES = new HashSet();
|
private static final Set<Class<?>> BASIC_TYPES = new HashSet<Class<?>>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BASIC_TYPES.add(Boolean.class);
|
BASIC_TYPES.add(Boolean.class);
|
||||||
|
@ -176,7 +175,7 @@ public class CopyFromHelper {
|
||||||
BASIC_TYPES.add(Date.class);
|
BASIC_TYPES.add(Date.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBasicType(final Class vClass) {
|
private boolean isBasicType(final Class<?> vClass) {
|
||||||
return BASIC_TYPES.contains(vClass);
|
return BASIC_TYPES.contains(vClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ import java.util.Set;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ObjectBean implements Serializable, Cloneable {
|
public class ObjectBean implements Serializable, Cloneable {
|
||||||
|
private static final long serialVersionUID = -8784981605711980095L;
|
||||||
private final EqualsBean equalsBean;
|
private final EqualsBean equalsBean;
|
||||||
private final ToStringBean toStringBean;
|
private final ToStringBean toStringBean;
|
||||||
private final CloneableBean cloneableBean;
|
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.
|
* @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);
|
this(beanClass, obj, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ public class ObjectBean implements Serializable, Cloneable {
|
||||||
* @param ignoreProperties properties to ignore when cloning.
|
* @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<String> ignoreProperties) {
|
||||||
equalsBean = new EqualsBean(beanClass, obj);
|
equalsBean = new EqualsBean(beanClass, obj);
|
||||||
toStringBean = new ToStringBean(beanClass, obj);
|
toStringBean = new ToStringBean(beanClass, obj);
|
||||||
cloneableBean = new CloneableBean(obj, ignoreProperties);
|
cloneableBean = new CloneableBean(obj, ignoreProperties);
|
||||||
|
|
|
@ -19,8 +19,6 @@ package com.sun.syndication.feed.module;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.sun.syndication.feed.CopyFrom;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dublin Core Module.
|
* Dublin Core Module.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -30,7 +28,7 @@ import com.sun.syndication.feed.CopyFrom;
|
||||||
* @author Alejandro Abdelnur
|
* @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/).
|
* URI of the Dublin Core Module (http://purl.org/dc/elements/1.1/).
|
||||||
|
|
|
@ -39,6 +39,7 @@ import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DCModuleImpl extends ModuleImpl implements DCModule {
|
public class DCModuleImpl extends ModuleImpl implements DCModule {
|
||||||
|
private static final long serialVersionUID = -6502372914221178645L;
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
private List<String> title;
|
private List<String> title;
|
||||||
private List<String> creator;
|
private List<String> creator;
|
||||||
|
@ -940,19 +941,19 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Class<? extends CopyFrom> getInterface() {
|
public final Class<DCModule> getInterface() {
|
||||||
return DCModule.class;
|
return DCModule.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void copyFrom(final CopyFrom obj) {
|
public final void copyFrom(final CopyFrom<?> obj) {
|
||||||
COPY_FROM_HELPER.copy(this, obj);
|
COPY_FROM_HELPER.copy(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final Map basePropInterfaceMap = new HashMap();
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
basePropInterfaceMap.put("titles", String.class);
|
basePropInterfaceMap.put("titles", String.class);
|
||||||
basePropInterfaceMap.put("creators", String.class);
|
basePropInterfaceMap.put("creators", String.class);
|
||||||
basePropInterfaceMap.put("subjects", DCSubject.class);
|
basePropInterfaceMap.put("subjects", DCSubject.class);
|
||||||
|
@ -969,7 +970,7 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
|
||||||
basePropInterfaceMap.put("coverages", String.class);
|
basePropInterfaceMap.put("coverages", String.class);
|
||||||
basePropInterfaceMap.put("rightsList", String.class);
|
basePropInterfaceMap.put("rightsList", String.class);
|
||||||
|
|
||||||
final Map basePropClassImplMap = new HashMap();
|
final Map<Class<? extends CopyFrom<?>>, Class<?>> basePropClassImplMap = new HashMap<Class<? extends CopyFrom<?>>, Class<?>>();
|
||||||
basePropClassImplMap.put(DCSubject.class, DCSubjectImpl.class);
|
basePropClassImplMap.put(DCSubject.class, DCSubjectImpl.class);
|
||||||
|
|
||||||
COPY_FROM_HELPER = new CopyFromHelper(DCModule.class, basePropInterfaceMap, basePropClassImplMap);
|
COPY_FROM_HELPER = new CopyFromHelper(DCModule.class, basePropInterfaceMap, basePropClassImplMap);
|
||||||
|
|
|
@ -27,7 +27,7 @@ import com.sun.syndication.feed.CopyFrom;
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface DCSubject extends Cloneable, CopyFrom {
|
public interface DCSubject extends Cloneable, CopyFrom<DCSubject> {
|
||||||
/**
|
/**
|
||||||
* Returns the DublinCore subject taxonomy URI.
|
* Returns the DublinCore subject taxonomy URI.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -35,6 +35,7 @@ import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
||||||
|
private static final long serialVersionUID = 6276396184267118968L;
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
private String taxonomyUri;
|
private String taxonomyUri;
|
||||||
private String value;
|
private String value;
|
||||||
|
@ -155,23 +156,23 @@ public class DCSubjectImpl implements Cloneable, Serializable, DCSubject {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getInterface() {
|
public Class<DCSubject> getInterface() {
|
||||||
return DCSubject.class;
|
return DCSubject.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyFrom(final CopyFrom obj) {
|
public void copyFrom(final CopyFrom<?> obj) {
|
||||||
COPY_FROM_HELPER.copy(this, obj);
|
COPY_FROM_HELPER.copy(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final Map basePropInterfaceMap = new HashMap();
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
basePropInterfaceMap.put("taxonomyUri", String.class);
|
basePropInterfaceMap.put("taxonomyUri", String.class);
|
||||||
basePropInterfaceMap.put("value", String.class);
|
basePropInterfaceMap.put("value", String.class);
|
||||||
|
|
||||||
final Map basePropClassImplMap = Collections.EMPTY_MAP;
|
final Map<Class<? extends CopyFrom<?>>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom<?>>, Class<?>>emptyMap();
|
||||||
|
|
||||||
COPY_FROM_HELPER = new CopyFromHelper(DCSubject.class, basePropInterfaceMap, basePropClassImplMap);
|
COPY_FROM_HELPER = new CopyFromHelper(DCSubject.class, basePropInterfaceMap, basePropClassImplMap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.sun.syndication.feed.CopyFrom;
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface Module extends Cloneable, CopyFrom, Serializable {
|
public interface Module extends Cloneable, CopyFrom<Module>, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the URI of the module.
|
* Returns the URI of the module.
|
||||||
|
|
|
@ -13,6 +13,7 @@ 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 final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
private String url;
|
private String url;
|
||||||
private String type;
|
private String type;
|
||||||
|
@ -148,24 +149,24 @@ public class SyndEnclosureImpl implements Serializable, SyndEnclosure {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends CopyFrom> getInterface() {
|
public Class<SyndEnclosure> getInterface() {
|
||||||
return SyndEnclosure.class;
|
return SyndEnclosure.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyFrom(final CopyFrom obj) {
|
public void copyFrom(final CopyFrom<?> obj) {
|
||||||
COPY_FROM_HELPER.copy(this, obj);
|
COPY_FROM_HELPER.copy(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final Map basePropInterfaceMap = new HashMap();
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
basePropInterfaceMap.put("url", String.class);
|
basePropInterfaceMap.put("url", String.class);
|
||||||
basePropInterfaceMap.put("type", String.class);
|
basePropInterfaceMap.put("type", String.class);
|
||||||
basePropInterfaceMap.put("length", Long.TYPE);
|
basePropInterfaceMap.put("length", Long.TYPE);
|
||||||
|
|
||||||
final Map basePropClassImplMap = Collections.EMPTY_MAP;
|
final Map<Class<? extends CopyFrom<?>>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom<?>>, Class<?>>emptyMap();
|
||||||
|
|
||||||
COPY_FROM_HELPER = new CopyFromHelper(SyndEnclosure.class, basePropInterfaceMap, basePropClassImplMap);
|
COPY_FROM_HELPER = new CopyFromHelper(SyndEnclosure.class, basePropInterfaceMap, basePropClassImplMap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import com.sun.syndication.feed.module.Module;
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface SyndEntry extends Cloneable, CopyFrom, Extendable {
|
public interface SyndEntry extends Cloneable, CopyFrom<SyndEntry>, Extendable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entry URI.
|
* Returns the entry URI.
|
||||||
|
|
|
@ -47,6 +47,7 @@ import com.sun.syndication.feed.synd.impl.URINormalizer;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SyndEntryImpl implements Serializable, SyndEntry {
|
public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
|
private static final long serialVersionUID = 1944144041409866698L;
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
private String uri;
|
private String uri;
|
||||||
private String link;
|
private String link;
|
||||||
|
@ -94,7 +95,7 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
* CloneableBean for details).
|
* CloneableBean for details).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected SyndEntryImpl(final Class beanClass, final Set convenienceProperties) {
|
protected SyndEntryImpl(final Class<?> beanClass, final Set<String> convenienceProperties) {
|
||||||
objBean = new ObjectBean(beanClass, this, convenienceProperties);
|
objBean = new ObjectBean(beanClass, this, convenienceProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,19 +484,19 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getInterface() {
|
public Class<SyndEntry> getInterface() {
|
||||||
return SyndEntry.class;
|
return SyndEntry.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyFrom(final CopyFrom obj) {
|
public void copyFrom(final CopyFrom<?> obj) {
|
||||||
COPY_FROM_HELPER.copy(this, obj);
|
COPY_FROM_HELPER.copy(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final Map basePropInterfaceMap = new HashMap();
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
basePropInterfaceMap.put("uri", String.class);
|
basePropInterfaceMap.put("uri", String.class);
|
||||||
basePropInterfaceMap.put("title", String.class);
|
basePropInterfaceMap.put("title", String.class);
|
||||||
basePropInterfaceMap.put("link", String.class);
|
basePropInterfaceMap.put("link", String.class);
|
||||||
|
@ -505,7 +506,7 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
|
||||||
basePropInterfaceMap.put("enclosures", SyndEnclosure.class);
|
basePropInterfaceMap.put("enclosures", SyndEnclosure.class);
|
||||||
basePropInterfaceMap.put("modules", Module.class);
|
basePropInterfaceMap.put("modules", Module.class);
|
||||||
|
|
||||||
final Map basePropClassImplMap = new HashMap();
|
final Map<Class<? extends CopyFrom<?>>, Class<?>> basePropClassImplMap = new HashMap<Class<? extends CopyFrom<?>>, Class<?>>();
|
||||||
basePropClassImplMap.put(SyndContent.class, SyndContentImpl.class);
|
basePropClassImplMap.put(SyndContent.class, SyndContentImpl.class);
|
||||||
basePropClassImplMap.put(SyndEnclosure.class, SyndEnclosureImpl.class);
|
basePropClassImplMap.put(SyndEnclosure.class, SyndEnclosureImpl.class);
|
||||||
basePropClassImplMap.put(DCModule.class, DCModuleImpl.class);
|
basePropClassImplMap.put(DCModule.class, DCModuleImpl.class);
|
||||||
|
|
|
@ -36,7 +36,7 @@ import com.sun.syndication.feed.module.Module;
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface SyndFeed extends Cloneable, CopyFrom, Extendable {
|
public interface SyndFeed extends Cloneable, CopyFrom<SyndFeed>, Extendable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the real feed types the SyndFeedImpl supports when converting
|
* Returns the real feed types the SyndFeedImpl supports when converting
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.sun.syndication.feed.CopyFrom;
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface SyndImage extends Cloneable, CopyFrom {
|
public interface SyndImage extends Cloneable, CopyFrom<SyndImage> {
|
||||||
/**
|
/**
|
||||||
* Returns the image title.
|
* Returns the image title.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -33,6 +33,7 @@ import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SyndImageImpl implements Serializable, SyndImage {
|
public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
|
private static final long serialVersionUID = 5078981553559513247L;
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
private String title;
|
private String title;
|
||||||
private String url;
|
private String url;
|
||||||
|
@ -199,25 +200,25 @@ public class SyndImageImpl implements Serializable, SyndImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getInterface() {
|
public Class<SyndImage> getInterface() {
|
||||||
return SyndImage.class;
|
return SyndImage.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyFrom(final CopyFrom syndImage) {
|
public void copyFrom(final CopyFrom<?> syndImage) {
|
||||||
COPY_FROM_HELPER.copy(this, syndImage);
|
COPY_FROM_HELPER.copy(this, syndImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final CopyFromHelper COPY_FROM_HELPER;
|
private static final CopyFromHelper COPY_FROM_HELPER;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final Map basePropInterfaceMap = new HashMap();
|
final Map<String, Class<?>> basePropInterfaceMap = new HashMap<String, Class<?>>();
|
||||||
basePropInterfaceMap.put("title", String.class);
|
basePropInterfaceMap.put("title", String.class);
|
||||||
basePropInterfaceMap.put("url", String.class);
|
basePropInterfaceMap.put("url", String.class);
|
||||||
basePropInterfaceMap.put("link", String.class);
|
basePropInterfaceMap.put("link", String.class);
|
||||||
basePropInterfaceMap.put("description", String.class);
|
basePropInterfaceMap.put("description", String.class);
|
||||||
|
|
||||||
final Map basePropClassImplMap = Collections.EMPTY_MAP;
|
final Map<Class<? extends CopyFrom<?>>, Class<?>> basePropClassImplMap = Collections.<Class<? extends CopyFrom<?>>, Class<?>>emptyMap();
|
||||||
|
|
||||||
COPY_FROM_HELPER = new CopyFromHelper(SyndImage.class, basePropInterfaceMap, basePropClassImplMap);
|
COPY_FROM_HELPER = new CopyFromHelper(SyndImage.class, basePropInterfaceMap, basePropClassImplMap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import com.sun.syndication.feed.impl.ObjectBean;
|
||||||
* @author Dave Johnson (updated for Atom 1.0)
|
* @author Dave Johnson (updated for Atom 1.0)
|
||||||
*/
|
*/
|
||||||
public class SyndLinkImpl implements Cloneable, Serializable, SyndLink {
|
public class SyndLinkImpl implements Cloneable, Serializable, SyndLink {
|
||||||
|
private static final long serialVersionUID = -3620141754437170078L;
|
||||||
|
|
||||||
private final ObjectBean objBean;
|
private final ObjectBean objBean;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import com.sun.syndication.feed.module.impl.ModuleUtils;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SyndPersonImpl implements Serializable, SyndPerson {
|
public class SyndPersonImpl implements Serializable, SyndPerson {
|
||||||
|
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;
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class ConverterForAtom03 implements Converter {
|
||||||
syndFeed.setLanguage(language);
|
syndFeed.setLanguage(language);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Person> authors = aFeed.getAuthors();
|
final List<SyndPerson> authors = aFeed.getAuthors();
|
||||||
if (authors != null && authors.size() > 0) {
|
if (authors != null && authors.size() > 0) {
|
||||||
syndFeed.setAuthors(createSyndPersons(authors));
|
syndFeed.setAuthors(createSyndPersons(authors));
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ public class ConverterForAtom03 implements Converter {
|
||||||
syndEntry.setContents(sContents);
|
syndEntry.setContents(sContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Person> authors = entry.getAuthors();
|
final List<SyndPerson> authors = entry.getAuthors();
|
||||||
if (authors != null && authors.size() > 0) {
|
if (authors != null && authors.size() > 0) {
|
||||||
syndEntry.setAuthors(createSyndPersons(authors));
|
syndEntry.setAuthors(createSyndPersons(authors));
|
||||||
final SyndPerson person0 = syndEntry.getAuthors().get(0);
|
final SyndPerson person0 = syndEntry.getAuthors().get(0);
|
||||||
|
@ -341,8 +341,8 @@ public class ConverterForAtom03 implements Converter {
|
||||||
return aFeed;
|
return aFeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static List<Person> createAtomPersons(final List<SyndPerson> sPersons) {
|
protected static List<SyndPerson> createAtomPersons(final List<SyndPerson> sPersons) {
|
||||||
final List<Person> persons = new ArrayList<Person>();
|
final List<SyndPerson> persons = new ArrayList<SyndPerson>();
|
||||||
for (final SyndPerson syndPerson : sPersons) {
|
for (final SyndPerson syndPerson : sPersons) {
|
||||||
final SyndPerson sPerson = syndPerson;
|
final SyndPerson sPerson = syndPerson;
|
||||||
final Person person = new Person();
|
final Person person = new Person();
|
||||||
|
@ -355,15 +355,14 @@ public class ConverterForAtom03 implements Converter {
|
||||||
return persons;
|
return persons;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static List<SyndPerson> createSyndPersons(final List<Person> aPersons) {
|
protected static List<SyndPerson> createSyndPersons(final List<SyndPerson> aPersons) {
|
||||||
final List<SyndPerson> persons = new ArrayList<SyndPerson>();
|
final List<SyndPerson> persons = new ArrayList<SyndPerson>();
|
||||||
for (final Person person2 : aPersons) {
|
for (final SyndPerson person2 : aPersons) {
|
||||||
final Person aPerson = person2;
|
|
||||||
final SyndPerson person = new SyndPersonImpl();
|
final SyndPerson person = new SyndPersonImpl();
|
||||||
person.setName(aPerson.getName());
|
person.setName(person2.getName());
|
||||||
person.setUri(aPerson.getUri());
|
person.setUri(person2.getUri());
|
||||||
person.setEmail(aPerson.getEmail());
|
person.setEmail(person2.getEmail());
|
||||||
person.setModules(aPerson.getModules());
|
person.setModules(person2.getModules());
|
||||||
persons.add(person);
|
persons.add(person);
|
||||||
}
|
}
|
||||||
return persons;
|
return persons;
|
||||||
|
@ -467,7 +466,7 @@ public class ConverterForAtom03 implements Converter {
|
||||||
} else if (sEntry.getAuthor() != null) {
|
} else if (sEntry.getAuthor() != null) {
|
||||||
final Person person = new Person();
|
final Person person = new Person();
|
||||||
person.setName(sEntry.getAuthor());
|
person.setName(sEntry.getAuthor());
|
||||||
final List<Person> authors = new ArrayList<Person>();
|
final List<SyndPerson> authors = new ArrayList<SyndPerson>();
|
||||||
authors.add(person);
|
authors.add(person);
|
||||||
aEntry.setAuthors(authors);
|
aEntry.setAuthors(authors);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,12 +114,12 @@ public class ConverterForAtom10 implements Converter {
|
||||||
// Core Atom language/author/copyright/modified elements have precedence
|
// Core Atom language/author/copyright/modified elements have precedence
|
||||||
// over DC equivalent info.
|
// over DC equivalent info.
|
||||||
|
|
||||||
final List<Person> authors = aFeed.getAuthors();
|
final List<SyndPerson> authors = aFeed.getAuthors();
|
||||||
if (authors != null && authors.size() > 0) {
|
if (authors != null && authors.size() > 0) {
|
||||||
syndFeed.setAuthors(ConverterForAtom03.createSyndPersons(authors));
|
syndFeed.setAuthors(ConverterForAtom03.createSyndPersons(authors));
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Person> contributors = aFeed.getContributors();
|
final List<SyndPerson> contributors = aFeed.getContributors();
|
||||||
if (contributors != null && contributors.size() > 0) {
|
if (contributors != null && contributors.size() > 0) {
|
||||||
syndFeed.setContributors(ConverterForAtom03.createSyndPersons(contributors));
|
syndFeed.setContributors(ConverterForAtom03.createSyndPersons(contributors));
|
||||||
}
|
}
|
||||||
|
@ -185,14 +185,14 @@ public class ConverterForAtom10 implements Converter {
|
||||||
syndEntry.setContents(sContents);
|
syndEntry.setContents(sContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Person> authors = entry.getAuthors();
|
final List<SyndPerson> authors = entry.getAuthors();
|
||||||
if (authors != null && authors.size() > 0) {
|
if (authors != null && authors.size() > 0) {
|
||||||
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<Person> contributors = entry.getContributors();
|
final List<SyndPerson> contributors = entry.getContributors();
|
||||||
if (contributors != null && contributors.size() > 0) {
|
if (contributors != null && contributors.size() > 0) {
|
||||||
syndEntry.setContributors(ConverterForAtom03.createSyndPersons(contributors));
|
syndEntry.setContributors(ConverterForAtom03.createSyndPersons(contributors));
|
||||||
}
|
}
|
||||||
|
@ -520,13 +520,13 @@ public class ConverterForAtom10 implements Converter {
|
||||||
final List<SyndContent> syndContents = sEntry.getContents();
|
final List<SyndContent> syndContents = sEntry.getContents();
|
||||||
aEntry.setContents(createAtomContents(syndContents));
|
aEntry.setContents(createAtomContents(syndContents));
|
||||||
|
|
||||||
List authors = sEntry.getAuthors();
|
List<SyndPerson> authors = sEntry.getAuthors();
|
||||||
if (authors != null && authors.size() > 0) {
|
if (authors != null && authors.size() > 0) {
|
||||||
aEntry.setAuthors(ConverterForAtom03.createAtomPersons(authors));
|
aEntry.setAuthors(ConverterForAtom03.createAtomPersons(authors));
|
||||||
} else if (sEntry.getAuthor() != null) {
|
} else if (sEntry.getAuthor() != null) {
|
||||||
final Person person = new Person();
|
final Person person = new Person();
|
||||||
person.setName(sEntry.getAuthor());
|
person.setName(sEntry.getAuthor());
|
||||||
authors = new ArrayList();
|
authors = new ArrayList<SyndPerson>();
|
||||||
authors.add(person);
|
authors.add(person);
|
||||||
aEntry.setAuthors(authors);
|
aEntry.setAuthors(authors);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ package com.sun.syndication.io;
|
||||||
*/
|
*/
|
||||||
public class FeedException extends Exception {
|
public class FeedException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -8761681574235401334L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a FeedException with a message.
|
* Creates a FeedException with a message.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -19,6 +19,7 @@ package com.sun.syndication.io;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jdom2.Element;
|
import org.jdom2.Element;
|
||||||
|
import org.jdom2.Namespace;
|
||||||
|
|
||||||
import com.sun.syndication.feed.module.Module;
|
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
|
* @return a set with all the URIs (JDOM Namespace elements) this module
|
||||||
* generator uses.
|
* generator uses.
|
||||||
*/
|
*/
|
||||||
public Set getNamespaces();
|
public Set<Namespace> getNamespaces();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates and injects module metadata into an XML node (JDOM element).
|
* Generates and injects module metadata into an XML node (JDOM element).
|
||||||
|
|
|
@ -27,6 +27,8 @@ import org.jdom2.input.JDOMParseException;
|
||||||
*/
|
*/
|
||||||
public class ParsingFeedException extends FeedException {
|
public class ParsingFeedException extends FeedException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -4791878470117677698L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a FeedException with a message.
|
* Creates a FeedException with a message.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -57,11 +57,11 @@ import com.sun.syndication.io.impl.XmlFixerReader;
|
||||||
*/
|
*/
|
||||||
public class WireFeedInput {
|
public class WireFeedInput {
|
||||||
|
|
||||||
private static Map clMap = new WeakHashMap();
|
private static Map<ClassLoader, FeedParsers> clMap = new WeakHashMap<ClassLoader, FeedParsers>();
|
||||||
|
|
||||||
private static FeedParsers getFeedParsers() {
|
private static FeedParsers getFeedParsers() {
|
||||||
synchronized (WireFeedInput.class) {
|
synchronized (WireFeedInput.class) {
|
||||||
FeedParsers parsers = (FeedParsers) clMap.get(Thread.currentThread().getContextClassLoader());
|
FeedParsers parsers = clMap.get(Thread.currentThread().getContextClassLoader());
|
||||||
if (parsers == null) {
|
if (parsers == null) {
|
||||||
parsers = new FeedParsers();
|
parsers = new FeedParsers();
|
||||||
clMap.put(Thread.currentThread().getContextClassLoader(), parsers);
|
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.
|
* @return a list of String elements with the supported input feed types.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static List getSupportedFeedTypes() {
|
public static List<String> getSupportedFeedTypes() {
|
||||||
return getFeedParsers().getSupportedFeedTypes();
|
return getFeedParsers().getSupportedFeedTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ import com.sun.syndication.io.impl.FeedGenerators;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class WireFeedOutput {
|
public class WireFeedOutput {
|
||||||
private static Map clMap = new WeakHashMap();
|
private static Map<ClassLoader, FeedGenerators> clMap = new WeakHashMap<ClassLoader, FeedGenerators>();
|
||||||
|
|
||||||
private static FeedGenerators getFeedGenerators() {
|
private static FeedGenerators getFeedGenerators() {
|
||||||
synchronized (WireFeedOutput.class) {
|
synchronized (WireFeedOutput.class) {
|
||||||
|
@ -68,7 +68,7 @@ public class WireFeedOutput {
|
||||||
* @return a list of String elements with the supported output feed types.
|
* @return a list of String elements with the supported output feed types.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static List getSupportedFeedTypes() {
|
public static List<String> getSupportedFeedTypes() {
|
||||||
return getFeedGenerators().getSupportedFeedTypes();
|
return getFeedGenerators().getSupportedFeedTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.io.InputStream;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class XmlReaderException extends IOException {
|
public class XmlReaderException extends IOException {
|
||||||
|
private static final long serialVersionUID = 622706428081721579L;
|
||||||
private final String bomEncoding;
|
private final String bomEncoding;
|
||||||
private final String xmlGuessEncoding;
|
private final String xmlGuessEncoding;
|
||||||
private final String xmlEncoding;
|
private final String xmlEncoding;
|
||||||
|
|
|
@ -31,7 +31,7 @@ import com.sun.syndication.feed.atom.Entry;
|
||||||
import com.sun.syndication.feed.atom.Feed;
|
import com.sun.syndication.feed.atom.Feed;
|
||||||
import com.sun.syndication.feed.atom.Generator;
|
import com.sun.syndication.feed.atom.Generator;
|
||||||
import com.sun.syndication.feed.atom.Link;
|
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.FeedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,7 +138,7 @@ public class Atom03Generator extends BaseWireFeedGenerator {
|
||||||
eFeed.addContent(authorElement);
|
eFeed.addContent(authorElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Person> contributors = feed.getContributors();
|
final List<SyndPerson> contributors = feed.getContributors();
|
||||||
for (int i = 0; i < contributors.size(); i++) {
|
for (int i = 0; i < contributors.size(); i++) {
|
||||||
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
||||||
fillPersonElement(contributorElement, contributors.get(i));
|
fillPersonElement(contributorElement, contributors.get(i));
|
||||||
|
@ -198,7 +198,7 @@ public class Atom03Generator extends BaseWireFeedGenerator {
|
||||||
eEntry.addContent(authorElement);
|
eEntry.addContent(authorElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Person> contributors = entry.getContributors();
|
final List<SyndPerson> contributors = entry.getContributors();
|
||||||
for (int i = 0; i < contributors.size(); i++) {
|
for (int i = 0; i < contributors.size(); i++) {
|
||||||
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
||||||
fillPersonElement(contributorElement, contributors.get(i));
|
fillPersonElement(contributorElement, contributors.get(i));
|
||||||
|
@ -271,12 +271,12 @@ public class Atom03Generator extends BaseWireFeedGenerator {
|
||||||
return linkElement;
|
return linkElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fillPersonElement(final Element element, final Person person) {
|
protected void fillPersonElement(final Element element, final SyndPerson person) {
|
||||||
if (person.getName() != null) {
|
if (person.getName() != null) {
|
||||||
element.addContent(generateSimpleElement("name", person.getName()));
|
element.addContent(generateSimpleElement("name", person.getName()));
|
||||||
}
|
}
|
||||||
if (person.getUrl() != null) {
|
if (person.getUri() != null) {
|
||||||
element.addContent(generateSimpleElement("url", person.getUrl()));
|
element.addContent(generateSimpleElement("url", person.getUri()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (person.getEmail() != null) {
|
if (person.getEmail() != null) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import com.sun.syndication.feed.atom.Entry;
|
||||||
import com.sun.syndication.feed.atom.Generator;
|
import com.sun.syndication.feed.atom.Generator;
|
||||||
import com.sun.syndication.feed.atom.Link;
|
import com.sun.syndication.feed.atom.Link;
|
||||||
import com.sun.syndication.feed.atom.Person;
|
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.FeedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,7 +93,7 @@ public class Atom03Parser extends BaseWireFeedParser {
|
||||||
|
|
||||||
e = eFeed.getChild("author", getAtomNamespace());
|
e = eFeed.getChild("author", getAtomNamespace());
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
final List<Person> authors = new ArrayList<Person>();
|
final List<SyndPerson> authors = new ArrayList<SyndPerson>();
|
||||||
authors.add(parsePerson(e));
|
authors.add(parsePerson(e));
|
||||||
feed.setAuthors(authors);
|
feed.setAuthors(authors);
|
||||||
}
|
}
|
||||||
|
@ -220,8 +221,8 @@ public class Atom03Parser extends BaseWireFeedParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// List(Elements) -> List(Persons)
|
// List(Elements) -> List(Persons)
|
||||||
private List<Person> parsePersons(final List<Element> ePersons) {
|
private List<SyndPerson> parsePersons(final List<Element> ePersons) {
|
||||||
final List<Person> persons = new ArrayList<Person>();
|
final List<SyndPerson> persons = new ArrayList<SyndPerson>();
|
||||||
for (int i = 0; i < ePersons.size(); i++) {
|
for (int i = 0; i < ePersons.size(); i++) {
|
||||||
persons.add(parsePerson(ePersons.get(i)));
|
persons.add(parsePerson(ePersons.get(i)));
|
||||||
}
|
}
|
||||||
|
@ -287,7 +288,7 @@ public class Atom03Parser extends BaseWireFeedParser {
|
||||||
|
|
||||||
e = eEntry.getChild("author", getAtomNamespace());
|
e = eEntry.getChild("author", getAtomNamespace());
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
final List<Person> authors = new ArrayList<Person>();
|
final List<SyndPerson> authors = new ArrayList<SyndPerson>();
|
||||||
authors.add(parsePerson(e));
|
authors.add(parsePerson(e));
|
||||||
entry.setAuthors(authors);
|
entry.setAuthors(authors);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import com.sun.syndication.feed.atom.Entry;
|
||||||
import com.sun.syndication.feed.atom.Feed;
|
import com.sun.syndication.feed.atom.Feed;
|
||||||
import com.sun.syndication.feed.atom.Generator;
|
import com.sun.syndication.feed.atom.Generator;
|
||||||
import com.sun.syndication.feed.atom.Link;
|
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.FeedException;
|
||||||
import com.sun.syndication.io.WireFeedOutput;
|
import com.sun.syndication.io.WireFeedOutput;
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ public class Atom10Generator extends BaseWireFeedGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Person> authors = feed.getAuthors();
|
final List<SyndPerson> authors = feed.getAuthors();
|
||||||
if (authors != null && authors.size() > 0) {
|
if (authors != null && authors.size() > 0) {
|
||||||
for (int i = 0; i < authors.size(); i++) {
|
for (int i = 0; i < authors.size(); i++) {
|
||||||
final Element authorElement = new Element("author", getFeedNamespace());
|
final Element authorElement = new Element("author", getFeedNamespace());
|
||||||
|
@ -166,7 +166,7 @@ public class Atom10Generator extends BaseWireFeedGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Person> contributors = feed.getContributors();
|
final List<SyndPerson> contributors = feed.getContributors();
|
||||||
if (contributors != null && contributors.size() > 0) {
|
if (contributors != null && contributors.size() > 0) {
|
||||||
for (int i = 0; i < contributors.size(); i++) {
|
for (int i = 0; i < contributors.size(); i++) {
|
||||||
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
||||||
|
@ -234,7 +234,7 @@ public class Atom10Generator extends BaseWireFeedGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Person> authors = entry.getAuthors();
|
final List<SyndPerson> authors = entry.getAuthors();
|
||||||
if (authors != null && authors.size() > 0) {
|
if (authors != null && authors.size() > 0) {
|
||||||
for (int i = 0; i < authors.size(); i++) {
|
for (int i = 0; i < authors.size(); i++) {
|
||||||
final Element authorElement = new Element("author", getFeedNamespace());
|
final Element authorElement = new Element("author", getFeedNamespace());
|
||||||
|
@ -243,7 +243,7 @@ public class Atom10Generator extends BaseWireFeedGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Person> contributors = entry.getContributors();
|
final List<SyndPerson> contributors = entry.getContributors();
|
||||||
if (contributors != null && contributors.size() > 0) {
|
if (contributors != null && contributors.size() > 0) {
|
||||||
for (int i = 0; i < contributors.size(); i++) {
|
for (int i = 0; i < contributors.size(); i++) {
|
||||||
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
final Element contributorElement = new Element("contributor", getFeedNamespace());
|
||||||
|
@ -349,7 +349,7 @@ public class Atom10Generator extends BaseWireFeedGenerator {
|
||||||
return linkElement;
|
return linkElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fillPersonElement(final Element element, final Person person) {
|
protected void fillPersonElement(final Element element, final SyndPerson person) {
|
||||||
if (person.getName() != null) {
|
if (person.getName() != null) {
|
||||||
element.addContent(generateSimpleElement("name", person.getName()));
|
element.addContent(generateSimpleElement("name", person.getName()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ import com.sun.syndication.feed.atom.Feed;
|
||||||
import com.sun.syndication.feed.atom.Generator;
|
import com.sun.syndication.feed.atom.Generator;
|
||||||
import com.sun.syndication.feed.atom.Link;
|
import com.sun.syndication.feed.atom.Link;
|
||||||
import com.sun.syndication.feed.atom.Person;
|
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.FeedException;
|
||||||
import com.sun.syndication.io.WireFeedInput;
|
import com.sun.syndication.io.WireFeedInput;
|
||||||
import com.sun.syndication.io.WireFeedOutput;
|
import com.sun.syndication.io.WireFeedOutput;
|
||||||
|
@ -293,8 +294,8 @@ public class Atom10Parser extends BaseWireFeedParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// List(Elements) -> List(Persons)
|
// List(Elements) -> List(Persons)
|
||||||
private List<Person> parsePersons(final String baseURI, final List<Element> ePersons) {
|
private List<SyndPerson> parsePersons(final String baseURI, final List<Element> ePersons) {
|
||||||
final List<Person> persons = new ArrayList<Person>();
|
final List<SyndPerson> persons = new ArrayList<SyndPerson>();
|
||||||
for (int i = 0; i < ePersons.size(); i++) {
|
for (int i = 0; i < ePersons.size(); i++) {
|
||||||
persons.add(parsePerson(baseURI, ePersons.get(i)));
|
persons.add(parsePerson(baseURI, ePersons.get(i)));
|
||||||
}
|
}
|
||||||
|
@ -594,7 +595,6 @@ public class Atom10Parser extends BaseWireFeedParser {
|
||||||
base = stripTrailingSlash(base);
|
base = stripTrailingSlash(base);
|
||||||
append = stripStartingSlash(append);
|
append = stripStartingSlash(append);
|
||||||
if (append.startsWith("..")) {
|
if (append.startsWith("..")) {
|
||||||
final String ret = null;
|
|
||||||
final String[] parts = append.split("/");
|
final String[] parts = append.split("/");
|
||||||
for (final String part : parts) {
|
for (final String part : parts) {
|
||||||
if ("..".equals(part)) {
|
if ("..".equals(part)) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.sun.syndication.io.impl;
|
package com.sun.syndication.io.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -9,6 +10,7 @@ import org.jdom2.Element;
|
||||||
import org.jdom2.Namespace;
|
import org.jdom2.Namespace;
|
||||||
import org.jdom2.Parent;
|
import org.jdom2.Parent;
|
||||||
|
|
||||||
|
import com.sun.syndication.feed.module.Module;
|
||||||
import com.sun.syndication.io.WireFeedGenerator;
|
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);
|
feedModuleGenerators = new ModuleGenerators(type + FEED_MODULE_GENERATORS_POSFIX_KEY, this);
|
||||||
itemModuleGenerators = new ModuleGenerators(type + ITEM_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);
|
personModuleGenerators = new ModuleGenerators(type + PERSON_MODULE_GENERATORS_POSFIX_KEY, this);
|
||||||
final Set allModuleNamespaces = new HashSet();
|
final Set<Namespace> allModuleNamespaces = new HashSet<Namespace>();
|
||||||
Iterator i = feedModuleGenerators.getAllNamespaces().iterator();
|
Iterator<Namespace> i = feedModuleGenerators.getAllNamespaces().iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
allModuleNamespaces.add(i.next());
|
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<Module> modules, final Element feed) {
|
||||||
feedModuleGenerators.generateModules(modules, feed);
|
feedModuleGenerators.generateModules(modules, feed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateItemModules(final List modules, final Element item) {
|
public void generateItemModules(final List<Module> modules, final Element item) {
|
||||||
itemModuleGenerators.generateModules(modules, item);
|
itemModuleGenerators.generateModules(modules, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generatePersonModules(final List modules, final Element person) {
|
public void generatePersonModules(final List<Module> modules, final Element person) {
|
||||||
personModuleGenerators.generateModules(modules, person);
|
personModuleGenerators.generateModules(modules, person);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void generateForeignMarkup(final Element e, final List foreignMarkup) {
|
protected void generateForeignMarkup(final Element e, final List<Element> foreignMarkup) {
|
||||||
if (foreignMarkup != null) {
|
if (foreignMarkup != null) {
|
||||||
final Iterator elems = foreignMarkup.iterator();
|
final Iterator<Element> elems = foreignMarkup.iterator();
|
||||||
while (elems.hasNext()) {
|
while (elems.hasNext()) {
|
||||||
final Element elem = (Element) elems.next();
|
final Element elem = (Element) elems.next();
|
||||||
final Parent parent = elem.getParent();
|
final Parent parent = elem.getParent();
|
||||||
|
@ -109,17 +111,17 @@ public abstract class BaseWireFeedGenerator implements WireFeedGenerator {
|
||||||
* make sure their namespace declarations are present.
|
* make sure their namespace declarations are present.
|
||||||
*/
|
*/
|
||||||
protected static void purgeUnusedNamespaceDeclarations(final Element root) {
|
protected static void purgeUnusedNamespaceDeclarations(final Element root) {
|
||||||
final java.util.Set usedPrefixes = new java.util.HashSet();
|
final Set<String> usedPrefixes = new HashSet<String>();
|
||||||
collectUsedPrefixes(root, usedPrefixes);
|
collectUsedPrefixes(root, usedPrefixes);
|
||||||
|
|
||||||
final List list = root.getAdditionalNamespaces();
|
final List<Namespace> list = root.getAdditionalNamespaces();
|
||||||
final List additionalNamespaces = new java.util.ArrayList();
|
final List<Namespace> additionalNamespaces = new ArrayList<Namespace>();
|
||||||
additionalNamespaces.addAll(list); // the duplication will prevent a
|
additionalNamespaces.addAll(list); // the duplication will prevent a
|
||||||
// ConcurrentModificationException
|
// ConcurrentModificationException
|
||||||
// below
|
// below
|
||||||
|
|
||||||
for (int i = 0; i < additionalNamespaces.size(); i++) {
|
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();
|
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);
|
||||||
|
@ -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<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 kids = el.getChildren();
|
final List<Element> kids = el.getChildren();
|
||||||
for (int i = 0; i < kids.size(); i++) {
|
for (int i = 0; i < kids.size(); i++) {
|
||||||
collectUsedPrefixes((Element) kids.get(i), collector); // recursion
|
collectUsedPrefixes((Element) kids.get(i), collector); // recursion
|
||||||
// - worth it
|
// - worth it
|
||||||
|
|
|
@ -75,6 +75,7 @@ public class DateParser {
|
||||||
* are a lot more forgiving than what the Atom spec allows. The forms that
|
* are a lot more forgiving than what the Atom spec allows. The forms that
|
||||||
* are invalid according to the spec are indicated.
|
* 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
|
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
|
||||||
|
|
|
@ -36,7 +36,7 @@ import com.sun.syndication.io.WireFeedGenerator;
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FeedGenerators extends PluginManager {
|
public class FeedGenerators extends PluginManager<WireFeedGenerator> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WireFeedGenerator.classes= [className] ...
|
* WireFeedGenerator.classes= [className] ...
|
||||||
|
@ -49,7 +49,7 @@ public class FeedGenerators extends PluginManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public WireFeedGenerator getGenerator(final String feedType) {
|
public WireFeedGenerator getGenerator(final String feedType) {
|
||||||
return (WireFeedGenerator) getPlugin(feedType);
|
return getPlugin(feedType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,7 +57,7 @@ public class FeedGenerators extends PluginManager {
|
||||||
return ((WireFeedGenerator) obj).getType();
|
return ((WireFeedGenerator) obj).getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getSupportedFeedTypes() {
|
public List<String> getSupportedFeedTypes() {
|
||||||
return getKeys();
|
return getKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ import com.sun.syndication.io.WireFeedParser;
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FeedParsers extends PluginManager {
|
public class FeedParsers extends PluginManager<WireFeedParser> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WireFeedParser.classes= [className] ...
|
* WireFeedParser.classes= [className] ...
|
||||||
|
@ -57,7 +57,7 @@ public class FeedParsers extends PluginManager {
|
||||||
super(FEED_PARSERS_KEY);
|
super(FEED_PARSERS_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getSupportedFeedTypes() {
|
public List<String> getSupportedFeedTypes() {
|
||||||
return getKeys();
|
return getKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class FeedParsers extends PluginManager {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public WireFeedParser getParserFor(final Document document) {
|
public WireFeedParser getParserFor(final Document document) {
|
||||||
final List parsers = getPlugins();
|
final List<WireFeedParser> parsers = getPlugins();
|
||||||
WireFeedParser parser = null;
|
WireFeedParser parser = null;
|
||||||
for (int i = 0; parser == null && i < parsers.size(); i++) {
|
for (int i = 0; parser == null && i < parsers.size(); i++) {
|
||||||
parser = (WireFeedParser) parsers.get(i);
|
parser = (WireFeedParser) parsers.get(i);
|
||||||
|
|
|
@ -22,14 +22,15 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jdom2.Element;
|
import org.jdom2.Element;
|
||||||
|
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 {
|
public class ModuleGenerators extends PluginManager<ModuleGenerator> {
|
||||||
private Set allNamespaces;
|
private Set<Namespace> allNamespaces;
|
||||||
|
|
||||||
public ModuleGenerators(final String propertyKey, final BaseWireFeedGenerator parentGenerator) {
|
public ModuleGenerators(final String propertyKey, final BaseWireFeedGenerator parentGenerator) {
|
||||||
super(propertyKey, null, parentGenerator);
|
super(propertyKey, null, parentGenerator);
|
||||||
|
@ -44,28 +45,28 @@ public class ModuleGenerators extends PluginManager {
|
||||||
return ((ModuleGenerator) obj).getNamespaceUri();
|
return ((ModuleGenerator) obj).getNamespaceUri();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getModuleNamespaces() {
|
public List<String> getModuleNamespaces() {
|
||||||
return getKeys();
|
return getKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateModules(final List modules, final Element element) {
|
public void generateModules(final List<Module> modules, final Element element) {
|
||||||
final Map generators = getPluginMap();
|
final Map<String, ModuleGenerator> generators = getPluginMap();
|
||||||
for (int i = 0; i < modules.size(); i++) {
|
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 String namespaceUri = module.getUri();
|
||||||
final ModuleGenerator generator = (ModuleGenerator) generators.get(namespaceUri);
|
final ModuleGenerator generator = generators.get(namespaceUri);
|
||||||
if (generator != null) {
|
if (generator != null) {
|
||||||
generator.generate(module, element);
|
generator.generate(module, element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set getAllNamespaces() {
|
public Set<Namespace> getAllNamespaces() {
|
||||||
if (allNamespaces == null) {
|
if (allNamespaces == null) {
|
||||||
allNamespaces = new HashSet();
|
allNamespaces = new HashSet<Namespace>();
|
||||||
final List mUris = getModuleNamespaces();
|
final List<String> mUris = getModuleNamespaces();
|
||||||
for (int i = 0; i < mUris.size(); i++) {
|
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());
|
allNamespaces.addAll(mGen.getNamespaces());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.sun.syndication.io.WireFeedParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class ModuleParsers extends PluginManager {
|
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);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class ModuleParsers extends PluginManager {
|
||||||
return ((ModuleParser) obj).getNamespaceUri();
|
return ((ModuleParser) obj).getNamespaceUri();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getModuleNamespaces() {
|
public List<String> getModuleNamespaces() {
|
||||||
return getKeys();
|
return getKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,11 @@ import com.sun.syndication.io.WireFeedParser;
|
||||||
* @author Alejandro Abdelnur
|
* @author Alejandro Abdelnur
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class PluginManager {
|
public abstract class PluginManager<T> {
|
||||||
private final String[] propertyValues;
|
private final String[] propertyValues;
|
||||||
private Map pluginsMap;
|
private Map<String, T> pluginsMap;
|
||||||
private List pluginsList;
|
private List<T> pluginsList;
|
||||||
private final List keys;
|
private final List<String> keys;
|
||||||
private final WireFeedParser parentParser;
|
private final WireFeedParser parentParser;
|
||||||
private final WireFeedGenerator parentGenerator;
|
private final WireFeedGenerator parentGenerator;
|
||||||
|
|
||||||
|
@ -60,39 +60,39 @@ public abstract class PluginManager {
|
||||||
loadPlugins();
|
loadPlugins();
|
||||||
pluginsMap = Collections.unmodifiableMap(pluginsMap);
|
pluginsMap = Collections.unmodifiableMap(pluginsMap);
|
||||||
pluginsList = Collections.unmodifiableList(pluginsList);
|
pluginsList = Collections.unmodifiableList(pluginsList);
|
||||||
keys = Collections.unmodifiableList(new ArrayList(pluginsMap.keySet()));
|
keys = Collections.unmodifiableList(new ArrayList<String>(pluginsMap.keySet()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract String getKey(Object obj);
|
protected abstract String getKey(Object obj);
|
||||||
|
|
||||||
protected List getKeys() {
|
protected List<String> getKeys() {
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List getPlugins() {
|
protected List<T> getPlugins() {
|
||||||
return pluginsList;
|
return pluginsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map getPluginMap() {
|
protected Map<String, T> getPluginMap() {
|
||||||
return pluginsMap;
|
return pluginsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object getPlugin(final String key) {
|
protected T getPlugin(final String key) {
|
||||||
return pluginsMap.get(key);
|
return pluginsMap.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PRIVATE - LOADER PART
|
// PRIVATE - LOADER PART
|
||||||
|
|
||||||
private void loadPlugins() {
|
private void loadPlugins() {
|
||||||
final List finalPluginsList = new ArrayList();
|
final List<T> finalPluginsList = new ArrayList<T>();
|
||||||
pluginsList = new ArrayList();
|
pluginsList = new ArrayList<T>();
|
||||||
pluginsMap = new HashMap();
|
pluginsMap = new HashMap<String, T>();
|
||||||
String className = null;
|
String className = null;
|
||||||
try {
|
try {
|
||||||
final Class[] classes = getClasses();
|
final Class<T>[] classes = getClasses();
|
||||||
for (final Class classe : classes) {
|
for (final Class<T> classe : classes) {
|
||||||
className = classe.getName();
|
className = classe.getName();
|
||||||
final Object plugin = classe.newInstance();
|
final T plugin = classe.newInstance();
|
||||||
if (plugin instanceof DelegatingModuleParser) {
|
if (plugin instanceof DelegatingModuleParser) {
|
||||||
((DelegatingModuleParser) plugin).setFeedParser(parentParser);
|
((DelegatingModuleParser) plugin).setFeedParser(parentParser);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public abstract class PluginManager {
|
||||||
// definition
|
// definition
|
||||||
// in the rome.properties files
|
// in the rome.properties files
|
||||||
}
|
}
|
||||||
Iterator i = pluginsMap.values().iterator();
|
Iterator<T> i = pluginsMap.values().iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
finalPluginsList.add(i.next()); // to remove overridden plugin
|
finalPluginsList.add(i.next()); // to remove overridden plugin
|
||||||
// impls
|
// impls
|
||||||
|
@ -140,15 +140,17 @@ public abstract class PluginManager {
|
||||||
* failure is ON.
|
* failure is ON.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private Class[] getClasses() throws ClassNotFoundException {
|
private Class<T>[] getClasses() throws ClassNotFoundException {
|
||||||
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||||
final List classes = new ArrayList();
|
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 mClass = useLoadClass ? classLoader.loadClass(_propertyValue) : Class.forName(_propertyValue, true, classLoader);
|
@SuppressWarnings("unchecked")
|
||||||
|
final Class<T> mClass = (Class<T>) (useLoadClass ? classLoader.loadClass(_propertyValue) : Class.forName(_propertyValue, true, classLoader));
|
||||||
classes.add(mClass);
|
classes.add(mClass);
|
||||||
}
|
}
|
||||||
final Class[] array = new Class[classes.size()];
|
@SuppressWarnings("unchecked")
|
||||||
|
final Class<T>[] array = (Class<T>[]) new Class[classes.size()];
|
||||||
classes.toArray(array);
|
classes.toArray(array);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.jdom2.Element;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RSS091NetscapeGenerator extends RSS091UserlandGenerator {
|
public class RSS091NetscapeGenerator extends RSS091UserlandGenerator {
|
||||||
private String version;
|
|
||||||
|
|
||||||
public RSS091NetscapeGenerator() {
|
public RSS091NetscapeGenerator() {
|
||||||
this("rss_0.91N", "0.91");
|
this("rss_0.91N", "0.91");
|
||||||
|
|
Loading…
Reference in a new issue