Refactoring code to use generics

This commit is contained in:
Patrick Gotthard 2014-04-12 22:22:45 +02:00
parent 6e2a56066b
commit e3848c5582
59 changed files with 455 additions and 393 deletions

View file

@ -32,8 +32,8 @@ public interface CustomTags extends Module {
public static final String URI = "http://base.google.com/cns/1.0"; public static final String URI = "http://base.google.com/cns/1.0";
public List getValues(); public List<CustomTag> getValues();
public void setValues(List values); public void setValues(List<CustomTag> values);
} }

View file

@ -35,33 +35,33 @@ public class CustomTagsImpl implements CustomTags {
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private List values; private List<CustomTag> values;
/** Creates a new instance of CustomTagsImpl */ /** Creates a new instance of CustomTagsImpl */
public CustomTagsImpl() { public CustomTagsImpl() {
} }
@Override @Override
public List getValues() { public List<CustomTag> getValues() {
values = values == null ? new ArrayList() : values; values = values == null ? new ArrayList<CustomTag>() : values;
return values; return values;
} }
@Override @Override
public void setValues(final List values) { public void setValues(final List<CustomTag> values) {
this.values = values; this.values = values;
} }
@Override @Override
public void copyFrom(final CopyFrom object) { public void copyFrom(final CopyFrom object) {
final CustomTags ct = (CustomTags) object; final CustomTags ct = (CustomTags) object;
values = new ArrayList(ct.getValues()); values = new ArrayList<CustomTag>(ct.getValues());
} }
@Override @Override
public Object clone() { public Object clone() {
final CustomTagsImpl cti = new CustomTagsImpl(); final CustomTagsImpl cti = new CustomTagsImpl();
cti.values = new ArrayList(values); cti.values = new ArrayList<CustomTag>(values);
return cti; return cti;
} }

View file

@ -24,8 +24,10 @@ import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.Namespace;
import org.rometools.feed.module.base.CustomTag; import org.rometools.feed.module.base.CustomTag;
import org.rometools.feed.module.base.CustomTagImpl; import org.rometools.feed.module.base.CustomTagImpl;
import org.rometools.feed.module.base.CustomTags; import org.rometools.feed.module.base.CustomTags;
@ -42,7 +44,8 @@ import com.sun.syndication.io.ModuleGenerator;
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class CustomTagGenerator implements ModuleGenerator { public class CustomTagGenerator implements ModuleGenerator {
static final HashSet NAMESPACES = new HashSet();
static final HashSet<Namespace> NAMESPACES = new HashSet<Namespace>();
static { static {
NAMESPACES.add(CustomTagParser.NS); NAMESPACES.add(CustomTagParser.NS);
@ -58,7 +61,7 @@ public class CustomTagGenerator implements ModuleGenerator {
} }
@Override @Override
public java.util.Set getNamespaces() { public Set<Namespace> getNamespaces() {
return NAMESPACES; return NAMESPACES;
} }
@ -68,11 +71,11 @@ public class CustomTagGenerator implements ModuleGenerator {
return; return;
} }
final List tags = ((CustomTags) module).getValues(); final List<CustomTag> tags = ((CustomTags) module).getValues();
final Iterator it = tags.iterator(); final Iterator<CustomTag> it = tags.iterator();
while (it.hasNext()) { while (it.hasNext()) {
final CustomTag tag = (CustomTag) it.next(); final CustomTag tag = it.next();
if (tag.getValue() instanceof DateTimeRange) { if (tag.getValue() instanceof DateTimeRange) {
final DateTimeRange dtr = (DateTimeRange) tag.getValue(); final DateTimeRange dtr = (DateTimeRange) tag.getValue();

View file

@ -32,6 +32,7 @@ import java.util.logging.Logger;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.Namespace; import org.jdom2.Namespace;
import org.rometools.feed.module.base.CustomTag;
import org.rometools.feed.module.base.CustomTagImpl; import org.rometools.feed.module.base.CustomTagImpl;
import org.rometools.feed.module.base.CustomTags; import org.rometools.feed.module.base.CustomTags;
import org.rometools.feed.module.base.CustomTagsImpl; import org.rometools.feed.module.base.CustomTagsImpl;
@ -59,11 +60,11 @@ public class CustomTagParser implements ModuleParser {
@Override @Override
public Module parse(final Element element, final Locale locale) { public Module parse(final Element element, final Locale locale) {
final CustomTags module = new CustomTagsImpl(); final CustomTags module = new CustomTagsImpl();
final ArrayList tags = new ArrayList(); final ArrayList<CustomTag> tags = new ArrayList<CustomTag>();
final List elements = element.getChildren(); final List<Element> elements = element.getChildren();
final Iterator it = elements.iterator(); final Iterator<Element> it = elements.iterator();
while (it.hasNext()) { while (it.hasNext()) {
final Element child = (Element) it.next(); final Element child = it.next();
if (child.getNamespace().equals(NS)) { if (child.getNamespace().equals(NS)) {
final String type = child.getAttributeValue("type"); final String type = child.getAttributeValue("type");
try { try {

View file

@ -84,17 +84,16 @@ public class GoogleBaseGenerator implements ModuleGenerator {
} }
@Override @Override
public Set getNamespaces() { public Set<Namespace> getNamespaces() {
final HashSet set = new HashSet(); final HashSet<Namespace> set = new HashSet<Namespace>();
set.add(GoogleBaseGenerator.NS); set.add(GoogleBaseGenerator.NS);
return set; return set;
} }
@Override @Override
public void generate(final Module module, final Element element) { public void generate(final Module module, final Element element) {
final GoogleBaseImpl mod = (GoogleBaseImpl) module; final GoogleBaseImpl mod = (GoogleBaseImpl) module;
final HashMap props2tags = new HashMap(GoogleBaseParser.PROPS2TAGS); final HashMap<Object, Object> props2tags = new HashMap<Object, Object>(GoogleBaseParser.PROPS2TAGS);
final PropertyDescriptor[] pds = GoogleBaseParser.pds; final PropertyDescriptor[] pds = GoogleBaseParser.pds;
for (final PropertyDescriptor pd : pds) { for (final PropertyDescriptor pd : pds) {

View file

@ -111,7 +111,7 @@ public class GoogleBaseParser implements ModuleParser {
@Override @Override
public Module parse(final Element element, final Locale locale) { public Module parse(final Element element, final Locale locale) {
final HashMap tag2pd = new HashMap(); final HashMap<String, PropertyDescriptor> tag2pd = new HashMap<String, PropertyDescriptor>();
final GoogleBaseImpl module = new GoogleBaseImpl(); final GoogleBaseImpl module = new GoogleBaseImpl();
try { try {
@ -128,14 +128,14 @@ public class GoogleBaseParser implements ModuleParser {
throw new RuntimeException("Exception building tag to property mapping. ", e); throw new RuntimeException("Exception building tag to property mapping. ", e);
} }
final List children = element.getChildren(); final List<Element> children = element.getChildren();
final Iterator it = children.iterator(); final Iterator<Element> it = children.iterator();
while (it.hasNext()) { while (it.hasNext()) {
final Element child = (Element) it.next(); final Element child = it.next();
if (child.getNamespace().equals(GoogleBaseParser.NS)) { if (child.getNamespace().equals(GoogleBaseParser.NS)) {
final PropertyDescriptor pd = (PropertyDescriptor) tag2pd.get(child.getName()); final PropertyDescriptor pd = tag2pd.get(child.getName());
if (pd != null) { if (pd != null) {
try { try {

View file

@ -48,7 +48,8 @@ import java.util.HashMap;
* @version $Revision: 1.1 $ * @version $Revision: 1.1 $
*/ */
public class CurrencyEnumeration { public class CurrencyEnumeration {
private static final HashMap lookup = new HashMap();
private static final HashMap<String, CurrencyEnumeration> lookup = new HashMap<String, CurrencyEnumeration>();
// <xs:restriction base="xs:string"> // <xs:restriction base="xs:string">
// <xs:enumeration value="AED"/> // <xs:enumeration value="AED"/>
@ -590,7 +591,7 @@ public class CurrencyEnumeration {
} }
public static CurrencyEnumeration findByValue(final String value) { public static CurrencyEnumeration findByValue(final String value) {
return (CurrencyEnumeration) lookup.get(value.trim().toUpperCase()); return lookup.get(value.trim().toUpperCase());
} }
@Override @Override

View file

@ -47,7 +47,9 @@ import java.util.HashMap;
* @version $Revision: 1.1 $ * @version $Revision: 1.1 $
*/ */
public class PaymentTypeEnumeration { public class PaymentTypeEnumeration {
private static final HashMap lookup = new HashMap();
private static final HashMap<String, PaymentTypeEnumeration> lookup = new HashMap<String, PaymentTypeEnumeration>();
public static final PaymentTypeEnumeration CASH = new PaymentTypeEnumeration("Cash"); public static final PaymentTypeEnumeration CASH = new PaymentTypeEnumeration("Cash");
public static final PaymentTypeEnumeration CHECK = new PaymentTypeEnumeration("Check"); public static final PaymentTypeEnumeration CHECK = new PaymentTypeEnumeration("Check");
public static final PaymentTypeEnumeration TRAVELERS_CHECK = new PaymentTypeEnumeration("Traveler<EFBFBD>s Check"); public static final PaymentTypeEnumeration TRAVELERS_CHECK = new PaymentTypeEnumeration("Traveler<EFBFBD>s Check");
@ -70,7 +72,7 @@ public class PaymentTypeEnumeration {
} }
public static PaymentTypeEnumeration findByValue(final String value) { public static PaymentTypeEnumeration findByValue(final String value) {
return (PaymentTypeEnumeration) lookup.get(value.toUpperCase()); return lookup.get(value.toUpperCase());
} }
@Override @Override

View file

@ -139,7 +139,7 @@ public class ShippingType implements CloneableType {
/** /**
* Looks up a ServiceEnumeration based on the string value. * Looks up a ServiceEnumeration based on the string value.
*/ */
private static final HashMap lookup = new HashMap(); private static final HashMap<String, ServiceEnumeration> lookup = new HashMap<String, ServiceEnumeration>();
/** /**
* Standard * Standard
*/ */
@ -184,7 +184,7 @@ public class ShippingType implements CloneableType {
* @return ServiceEnumeration or null. * @return ServiceEnumeration or null.
*/ */
public static ServiceEnumeration findByValue(final String value) { public static ServiceEnumeration findByValue(final String value) {
return (ServiceEnumeration) lookup.get(value.toUpperCase()); return lookup.get(value.toUpperCase());
} }
/** /**

View file

@ -62,7 +62,7 @@ public class CCModuleGenerator implements ModuleGenerator {
private static final Namespace RSS2 = Namespace.getNamespace("creativeCommons", CreativeCommonsImpl.RSS2_URI); private static final Namespace RSS2 = Namespace.getNamespace("creativeCommons", CreativeCommonsImpl.RSS2_URI);
private static final Namespace RSS = Namespace.getNamespace("http://purl.org/rss/1.0/"); private static final Namespace RSS = Namespace.getNamespace("http://purl.org/rss/1.0/");
private static final Namespace RDF = Namespace.getNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); private static final Namespace RDF = Namespace.getNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
private static final HashSet NAMESPACES = new HashSet(); private static final HashSet<Namespace> NAMESPACES = new HashSet<Namespace>();
static { static {
NAMESPACES.add(RSS1); NAMESPACES.add(RSS1);
NAMESPACES.add(RSS2); NAMESPACES.add(RSS2);
@ -90,7 +90,7 @@ public class CCModuleGenerator implements ModuleGenerator {
} }
@Override @Override
public Set getNamespaces() { public Set<Namespace> getNamespaces() {
return NAMESPACES; return NAMESPACES;
} }

View file

@ -49,6 +49,7 @@ import org.jdom2.Element;
import org.jdom2.Namespace; import org.jdom2.Namespace;
import org.rometools.feed.module.cc.CreativeCommonsImpl; import org.rometools.feed.module.cc.CreativeCommonsImpl;
import org.rometools.feed.module.cc.types.License; import org.rometools.feed.module.cc.types.License;
import org.rometools.feed.module.cc.types.License.Behaviour;
import com.sun.syndication.feed.module.Module; import com.sun.syndication.feed.module.Module;
import com.sun.syndication.io.ModuleParser; import com.sun.syndication.io.ModuleParser;
@ -77,50 +78,50 @@ public class ModuleParserRSS1 implements ModuleParser {
while (root.getParentElement() != null) { while (root.getParentElement() != null) {
root = root.getParentElement(); root = root.getParentElement();
} }
final List licenseList = root.getChildren("License", NS); final List<Element> licenseList = root.getChildren("License", NS);
final ArrayList licenses = new ArrayList(); final ArrayList<License> licenses = new ArrayList<License>();
final Iterator it = licenseList.iterator(); final Iterator<Element> it = licenseList.iterator();
while (it.hasNext()) { while (it.hasNext()) {
final Element licenseTag = (Element) it.next(); final Element licenseTag = it.next();
final String licenseURI = licenseTag.getAttributeValue("about", RDF); final String licenseURI = licenseTag.getAttributeValue("about", RDF);
if (licenseURI == null) { if (licenseURI == null) {
continue; continue;
} }
License license = License.findByValue(licenseURI); License license = License.findByValue(licenseURI);
{ {
final ArrayList permitsValues = new ArrayList(); final ArrayList<Behaviour> permitsValues = new ArrayList<Behaviour>();
final ArrayList requiresValues = new ArrayList(); final ArrayList<Behaviour> requiresValues = new ArrayList<Behaviour>();
final List permitsTags = licenseTag.getChildren("permits", NS); final List<Element> permitsTags = licenseTag.getChildren("permits", NS);
Iterator sit = permitsTags.iterator(); Iterator<Element> sit = permitsTags.iterator();
while (sit.hasNext()) { while (sit.hasNext()) {
final Element permitTag = (Element) sit.next(); final Element permitTag = sit.next();
permitsValues.add(License.Behaviour.findByValue(permitTag.getAttributeValue("resource", RDF))); permitsValues.add(License.Behaviour.findByValue(permitTag.getAttributeValue("resource", RDF)));
} }
final List requiresTags = licenseTag.getChildren("requires", NS); final List<Element> requiresTags = licenseTag.getChildren("requires", NS);
sit = requiresTags.iterator(); sit = requiresTags.iterator();
while (sit.hasNext()) { while (sit.hasNext()) {
final Element requireTag = (Element) sit.next(); final Element requireTag = sit.next();
requiresValues.add(License.Behaviour.findByValue(requireTag.getAttributeValue("resource", RDF))); requiresValues.add(License.Behaviour.findByValue(requireTag.getAttributeValue("resource", RDF)));
} }
license = new License(licenseURI, (License.Behaviour[]) requiresValues.toArray(new License.Behaviour[requiresValues.size()]), license = new License(licenseURI, requiresValues.toArray(new License.Behaviour[requiresValues.size()]),
(License.Behaviour[]) permitsValues.toArray(new License.Behaviour[permitsValues.size()])); permitsValues.toArray(new License.Behaviour[permitsValues.size()]));
} }
licenses.add(license); licenses.add(license);
} }
module.setAllLicenses((License[]) licenses.toArray(new License[0])); module.setAllLicenses(licenses.toArray(new License[0]));
} }
final ArrayList licenses = new ArrayList(); final ArrayList<License> licenses = new ArrayList<License>();
final List licenseTags = element.getChildren("license", NS); final List<Element> licenseTags = element.getChildren("license", NS);
final Iterator lit = licenseTags.iterator(); final Iterator<Element> lit = licenseTags.iterator();
while (lit.hasNext()) { while (lit.hasNext()) {
final Element licenseTag = (Element) lit.next(); final Element licenseTag = lit.next();
licenses.add(License.findByValue(licenseTag.getAttributeValue("resource", RDF))); licenses.add(License.findByValue(licenseTag.getAttributeValue("resource", RDF)));
} }
if (licenses.size() > 0) { if (licenses.size() > 0) {
module.setLicenses((License[]) licenses.toArray(new License[licenses.size()])); module.setLicenses(licenses.toArray(new License[licenses.size()]));
} }
if (module.getLicenses() != null || module.getAllLicenses() != null) { if (module.getLicenses() != null || module.getAllLicenses() != null) {

View file

@ -75,21 +75,21 @@ public class ModuleParserRSS2 implements ModuleParser {
while (!root.getName().equals("channel") && !root.getName().equals("feed")) { while (!root.getName().equals("channel") && !root.getName().equals("feed")) {
root = root.getParentElement(); root = root.getParentElement();
} }
final ArrayList licenses = new ArrayList(); final ArrayList<License> licenses = new ArrayList<License>();
List items = null; List<Element> items = null;
if (root.getName().equals("channel")) { if (root.getName().equals("channel")) {
items = root.getChildren("item"); items = root.getChildren("item");
} else { } else {
items = root.getChildren("entry"); items = root.getChildren("entry");
} }
final Iterator iit = items.iterator(); final Iterator<Element> iit = items.iterator();
while (iit.hasNext()) { while (iit.hasNext()) {
final Element item = (Element) iit.next(); final Element item = iit.next();
final List licenseTags = item.getChildren("license", NS); final List<Element> licenseTags = item.getChildren("license", NS);
final Iterator lit = licenseTags.iterator(); final Iterator<Element> lit = licenseTags.iterator();
while (lit.hasNext()) { while (lit.hasNext()) {
final Element licenseTag = (Element) lit.next(); final Element licenseTag = lit.next();
final License license = License.findByValue(licenseTag.getTextTrim()); final License license = License.findByValue(licenseTag.getTextTrim());
if (!licenses.contains(license)) { if (!licenses.contains(license)) {
; ;
@ -98,19 +98,19 @@ public class ModuleParserRSS2 implements ModuleParser {
} }
} }
if (licenses.size() > 0) { if (licenses.size() > 0) {
module.setAllLicenses((License[]) licenses.toArray(new License[0])); module.setAllLicenses(licenses.toArray(new License[0]));
} }
} }
// do element local // do element local
final ArrayList licenses = new ArrayList(); final ArrayList<License> licenses = new ArrayList<License>();
final List licenseTags = element.getChildren("license", NS); final List<Element> licenseTags = element.getChildren("license", NS);
final Iterator it = licenseTags.iterator(); final Iterator<Element> it = licenseTags.iterator();
while (it.hasNext()) { while (it.hasNext()) {
final Element licenseTag = (Element) it.next(); final Element licenseTag = it.next();
licenses.add(License.findByValue(licenseTag.getTextTrim())); licenses.add(License.findByValue(licenseTag.getTextTrim()));
} }
if (licenses.size() > 0) { if (licenses.size() > 0) {
module.setLicenses((License[]) licenses.toArray(new License[0])); module.setLicenses(licenses.toArray(new License[0]));
} }
if (module.getLicenses() != null && module.getAllLicenses() != null) { if (module.getLicenses() != null && module.getAllLicenses() != null) {

View file

@ -53,8 +53,9 @@ import com.sun.syndication.feed.impl.ToStringBean;
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class License { public class License {
private static final String CC_START = "http://creativecommons.org/licenses/"; private static final String CC_START = "http://creativecommons.org/licenses/";
private static final Map lookupLicense = new ConcurrentHashMap(); private static final Map<String, License> lookupLicense = new ConcurrentHashMap<String, License>();
public static final License NO_DERIVS = new License("http://creativecommons.org/licenses/nd/1.0/", new Behaviour[0], new Behaviour[] { public static final License NO_DERIVS = new License("http://creativecommons.org/licenses/nd/1.0/", new Behaviour[0], new Behaviour[] {
Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION }); Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION });
public static final License NO_DERIVS_NONCOMMERCIAL = new License("http://creativecommons.org/licenses/nd-nc/1.0/", public static final License NO_DERIVS_NONCOMMERCIAL = new License("http://creativecommons.org/licenses/nd-nc/1.0/",
@ -98,23 +99,23 @@ public class License {
} }
public static License findByValue(final String uri) { public static License findByValue(final String uri) {
License found = (License) License.lookupLicense.get(uri); License found = License.lookupLicense.get(uri);
// No I am going to try an guess about unknown licenses // No I am going to try an guess about unknown licenses
// This is try and match known CC licenses of other versions or various URLs to // This is try and match known CC licenses of other versions or various URLs to
// current licenses, then make a new one with the same permissions. // current licenses, then make a new one with the same permissions.
if (found == null && uri.startsWith("http://") && uri.toLowerCase().indexOf("creativecommons.org") != -1) { if (found == null && uri.startsWith("http://") && uri.toLowerCase().indexOf("creativecommons.org") != -1) {
final Iterator it = License.lookupLicense.keySet().iterator(); final Iterator<String> it = License.lookupLicense.keySet().iterator();
while (it.hasNext() && found == null) { while (it.hasNext() && found == null) {
final String key = (String) it.next(); final String key = it.next();
try { try {
if (key.startsWith(CC_START)) { if (key.startsWith(CC_START)) {
final String licensePath = key.substring(CC_START.length(), key.length()); final String licensePath = key.substring(CC_START.length(), key.length());
final StringTokenizer tok = new StringTokenizer(licensePath, "/"); final StringTokenizer tok = new StringTokenizer(licensePath, "/");
final String license = tok.nextToken(); final String license = tok.nextToken();
final String version = tok.nextToken(); // final String version = tok.nextToken();
if (uri.toLowerCase().indexOf("creativecommons.org/licenses/" + license) != -1) { if (uri.toLowerCase().indexOf("creativecommons.org/licenses/" + license) != -1) {
final License current = (License) lookupLicense.get(key); final License current = lookupLicense.get(key);
found = new License(uri, current.getRequires(), current.getPermits()); found = new License(uri, current.getRequires(), current.getPermits());
} }
} }
@ -123,7 +124,8 @@ public class License {
} }
} }
} }
// OK, we got here. If we haven't found a match, return a new License with unknown permissions. // OK, we got here. If we haven't found a match, return a new License with unknown
// permissions.
if (found == null) { if (found == null) {
found = new License(uri, null, null); found = new License(uri, null, null);
} }
@ -169,7 +171,7 @@ public class License {
} }
public static class Behaviour { public static class Behaviour {
private static final Map lookup = new HashMap(); private static final Map<String, Behaviour> lookup = new HashMap<String, Behaviour>();
public static final Behaviour REPRODUCTION = new Behaviour("http://web.resource.org/cc/Reproduction"); public static final Behaviour REPRODUCTION = new Behaviour("http://web.resource.org/cc/Reproduction");
public static final Behaviour DISTRIBUTION = new Behaviour("http://web.resource.org/cc/Distribution"); public static final Behaviour DISTRIBUTION = new Behaviour("http://web.resource.org/cc/Distribution");
public static final Behaviour DERIVATIVE = new Behaviour("http://web.resource.org/cc/DerivativeWorks"); public static final Behaviour DERIVATIVE = new Behaviour("http://web.resource.org/cc/DerivativeWorks");
@ -185,7 +187,7 @@ public class License {
} }
public static Behaviour findByValue(final String uri) { public static Behaviour findByValue(final String uri) {
return (Behaviour) Behaviour.lookup.get(uri); return Behaviour.lookup.get(uri);
} }
@Override @Override

View file

@ -43,8 +43,11 @@ package org.rometools.feed.module.content;
import java.util.List; import java.util.List;
import org.jdom2.Namespace;
/** /**
* This class represents a content item per the "Original Syntax". http://purl.org/rss/1.0/modules/content/ * This class represents a content item per the "Original Syntax".
* http://purl.org/rss/1.0/modules/content/
* *
* @version $Revision: 1.1 $ * @version $Revision: 1.1 $
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
@ -56,7 +59,7 @@ public class ContentItem implements Cloneable {
private List contentValueDOM; private List contentValueDOM;
private String contentAbout; private String contentAbout;
private String contentValueParseType; private String contentValueParseType;
private List contentValueNamespace; private List<Namespace> contentValueNamespace;
private String contentResource; private String contentResource;
/** Creates a new instance of ContentItem */ /** Creates a new instance of ContentItem */
@ -111,11 +114,11 @@ public class ContentItem implements Cloneable {
this.contentValueParseType = contentValueParseType; this.contentValueParseType = contentValueParseType;
} }
public List getContentValueNamespaces() { public List<Namespace> getContentValueNamespaces() {
return contentValueNamespace; return contentValueNamespace;
} }
public void setContentValueNamespaces(final List contentValueNamespace) { public void setContentValueNamespaces(final List<Namespace> contentValueNamespace) {
this.contentValueNamespace = contentValueNamespace; this.contentValueNamespace = contentValueNamespace;
} }

View file

@ -49,6 +49,7 @@ import com.sun.syndication.feed.module.Module;
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public interface ContentModule extends Module { public interface ContentModule extends Module {
public static final String URI = "http://purl.org/rss/1.0/modules/content/"; public static final String URI = "http://purl.org/rss/1.0/modules/content/";
public static final String RDF_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; public static final String RDF_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
@ -57,14 +58,14 @@ public interface ContentModule extends Module {
* *
* @return List of content Strings * @return List of content Strings
*/ */
public List getEncodeds(); public List<String> getEncodeds();
/** /**
* Sets a List of Strings containing the New Syntax Encoded values are in the element. * Sets a List of Strings containing the New Syntax Encoded values are in the element.
* *
* @return List of content Strings * @return List of content Strings
*/ */
public void setEncodeds(List encodeds); public void setEncodeds(List<String> encodeds);
@Override @Override
public String getUri(); public String getUri();
@ -77,7 +78,7 @@ public interface ContentModule extends Module {
* @see com.totsp.xml.syndication.content.ContentItem * @see com.totsp.xml.syndication.content.ContentItem
* @return List of ContentItems. * @return List of ContentItems.
*/ */
public List getContentItems(); public List<ContentItem> getContentItems();
/** /**
* Contains a list of ContentItems that represent the "Original Syntax" set. * Contains a list of ContentItems that represent the "Original Syntax" set.
@ -85,19 +86,21 @@ public interface ContentModule extends Module {
* @see com.totsp.xml.syndication.content.ContentItem * @see com.totsp.xml.syndication.content.ContentItem
* @param List of ContentItems. * @param List of ContentItems.
*/ */
public void setContentItems(List list); public void setContentItems(List<ContentItem> list);
/** /**
* Returns a List of Strings containing whatever new or original syntax items are in the element. * Returns a List of Strings containing whatever new or original syntax items are in the
* element.
* *
* @return List of content Strings * @return List of content Strings
*/ */
public List getContents(); public List<String> getContents();
/** /**
* Sets a List of Strings containing whatever new or original syntax items are in the element. * Sets a List of Strings containing whatever new or original syntax items are in the element.
* *
* @return List of content Strings * @return List of content Strings
*/ */
public void setContents(List contents); public void setContents(List<String> contents);
} }

View file

@ -47,36 +47,36 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.CopyFrom;
import com.sun.syndication.feed.module.ModuleImpl;
/** /**
* @version $Revision: 1.4 $ * @version $Revision: 1.4 $
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class ContentModuleImpl extends com.sun.syndication.feed.module.ModuleImpl implements ContentModule { public class ContentModuleImpl extends ModuleImpl implements ContentModule {
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private List encodeds;
private List contents; private List<String> encodeds;
private List contentItems; private List<String> contents;
private List<ContentItem> contentItems;
public ContentModuleImpl() { public ContentModuleImpl() {
super(ContentModuleImpl.class, URI); super(ContentModuleImpl.class, URI);
} }
protected ContentModuleImpl(final java.lang.Class beanClass, final java.lang.String uri) { protected ContentModuleImpl(final Class beanClass, final java.lang.String uri) {
super(beanClass, uri); super(beanClass, uri);
} }
@Override @Override
public List getEncodeds() { public List<String> getEncodeds() {
encodeds = encodeds == null ? new ArrayList() : encodeds; encodeds = encodeds == null ? new ArrayList<String>() : encodeds;
return encodeds; return encodeds;
} }
@Override @Override
public void setEncodeds(final List encodeds) { public void setEncodeds(final List<String> encodeds) {
this.encodeds = encodeds; this.encodeds = encodeds;
} }
@ -94,24 +94,24 @@ public class ContentModuleImpl extends com.sun.syndication.feed.module.ModuleImp
} }
@Override @Override
public List getContentItems() { public List<ContentItem> getContentItems() {
contentItems = contentItems == null ? new ArrayList() : contentItems; contentItems = contentItems == null ? new ArrayList<ContentItem>() : contentItems;
return contentItems; return contentItems;
} }
@Override @Override
public void setContentItems(final List list) { public void setContentItems(final List<ContentItem> list) {
contentItems = list; contentItems = list;
} }
@Override @Override
public List getContents() { public List<String> getContents() {
contents = contents == null ? new ArrayList() : contents; contents = contents == null ? new ArrayList<String>() : contents;
return contents; return contents;
} }
@Override @Override
public void setContents(final List contents) { public void setContents(final List<String> contents) {
this.contents = contents; this.contents = contents;
} }

View file

@ -60,12 +60,13 @@ import org.rometools.feed.module.content.ContentModule;
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class ContentModuleGenerator implements com.sun.syndication.io.ModuleGenerator { public class ContentModuleGenerator implements com.sun.syndication.io.ModuleGenerator {
private static final Namespace CONTENT_NS = Namespace.getNamespace("content", ContentModule.URI); private static final Namespace CONTENT_NS = Namespace.getNamespace("content", ContentModule.URI);
private static final Namespace RDF_NS = Namespace.getNamespace("rdf", ContentModule.RDF_URI); private static final Namespace RDF_NS = Namespace.getNamespace("rdf", ContentModule.RDF_URI);
private static final Set NAMESPACES; private static final Set<Namespace> NAMESPACES;
static { static {
final Set nss = new HashSet(); final Set<Namespace> nss = new HashSet<Namespace>();
nss.add(CONTENT_NS); nss.add(CONTENT_NS);
NAMESPACES = Collections.unmodifiableSet(nss); NAMESPACES = Collections.unmodifiableSet(nss);
} }
@ -91,9 +92,8 @@ public class ContentModuleGenerator implements com.sun.syndication.io.ModuleGene
final ContentModule cm = (ContentModule) module; final ContentModule cm = (ContentModule) module;
final List encodeds = cm.getEncodeds(); final List<String> encodeds = cm.getEncodeds();
//
if (encodeds != null) { if (encodeds != null) {
System.out.println(cm.getEncodeds().size()); System.out.println(cm.getEncodeds().size());
for (int i = 0; i < encodeds.size(); i++) { for (int i = 0; i < encodeds.size(); i++) {
@ -101,7 +101,7 @@ public class ContentModuleGenerator implements com.sun.syndication.io.ModuleGene
} }
} }
final List contentItems = cm.getContentItems(); final List<ContentItem> contentItems = cm.getContentItems();
if (contentItems != null && contentItems.size() > 0) { if (contentItems != null && contentItems.size() > 0) {
final Element items = new Element("items", CONTENT_NS); final Element items = new Element("items", CONTENT_NS);
@ -109,7 +109,7 @@ public class ContentModuleGenerator implements com.sun.syndication.io.ModuleGene
items.addContent(bag); items.addContent(bag);
for (int i = 0; i < contentItems.size(); i++) { for (int i = 0; i < contentItems.size(); i++) {
final ContentItem contentItem = (ContentItem) contentItems.get(i); final ContentItem contentItem = contentItems.get(i);
final Element li = new Element("li", RDF_NS); final Element li = new Element("li", RDF_NS);
final Element item = new Element("item", CONTENT_NS); final Element item = new Element("item", CONTENT_NS);
@ -144,14 +144,14 @@ public class ContentModuleGenerator implements com.sun.syndication.io.ModuleGene
} }
if (contentItem.getContentValueNamespaces() != null) { if (contentItem.getContentValueNamespaces() != null) {
final List namespaces = contentItem.getContentValueNamespaces(); final List<Namespace> namespaces = contentItem.getContentValueNamespaces();
for (int ni = 0; ni < namespaces.size(); ni++) { for (int ni = 0; ni < namespaces.size(); ni++) {
value.addNamespaceDeclaration((Namespace) namespaces.get(ni)); value.addNamespaceDeclaration(namespaces.get(ni));
} }
} }
final List detached = new ArrayList(); final List<Content> detached = new ArrayList<Content>();
for (int c = 0; c < contentItem.getContentValueDOM().size(); c++) { for (int c = 0; c < contentItem.getContentValueDOM().size(); c++) {
detached.add(((Content) contentItem.getContentValueDOM().get(c)).clone().detach()); detached.add(((Content) contentItem.getContentValueDOM().get(c)).clone().detach());
@ -190,7 +190,7 @@ public class ContentModuleGenerator implements com.sun.syndication.io.ModuleGene
} }
@Override @Override
public java.util.Set getNamespaces() { public Set<Namespace> getNamespaces() {
return NAMESPACES; return NAMESPACES;
} }
} }

View file

@ -48,6 +48,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.jdom2.Attribute; import org.jdom2.Attribute;
import org.jdom2.Content;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.Namespace; import org.jdom2.Namespace;
import org.jdom2.output.XMLOutputter; import org.jdom2.output.XMLOutputter;
@ -76,31 +77,31 @@ public class ContentModuleParser implements com.sun.syndication.io.ModuleParser
public com.sun.syndication.feed.module.Module parse(final Element element, final Locale locale) { public com.sun.syndication.feed.module.Module parse(final Element element, final Locale locale) {
boolean foundSomething = false; boolean foundSomething = false;
final ContentModule cm = new ContentModuleImpl(); final ContentModule cm = new ContentModuleImpl();
final List encodeds = element.getChildren("encoded", CONTENT_NS); final List<Element> encodeds = element.getChildren("encoded", CONTENT_NS);
final ArrayList contentStrings = new ArrayList(); final ArrayList<String> contentStrings = new ArrayList<String>();
final ArrayList encodedStrings = new ArrayList(); final ArrayList<String> encodedStrings = new ArrayList<String>();
if (encodeds.size() > 0) { if (encodeds.size() > 0) {
foundSomething = true; foundSomething = true;
for (int i = 0; i < encodeds.size(); i++) { for (int i = 0; i < encodeds.size(); i++) {
final Element encodedElement = (Element) encodeds.get(i); final Element encodedElement = encodeds.get(i);
encodedStrings.add(encodedElement.getText()); encodedStrings.add(encodedElement.getText());
contentStrings.add(encodedElement.getText()); contentStrings.add(encodedElement.getText());
} }
} }
final ArrayList contentItems = new ArrayList(); final ArrayList<ContentItem> contentItems = new ArrayList<ContentItem>();
final List items = element.getChildren("items", CONTENT_NS); final List<Element> items = element.getChildren("items", CONTENT_NS);
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
foundSomething = true; foundSomething = true;
final List lis = ((Element) items.get(i)).getChild("Bag", RDF_NS).getChildren("li", RDF_NS); final List<Element> lis = items.get(i).getChild("Bag", RDF_NS).getChildren("li", RDF_NS);
for (int j = 0; j < lis.size(); j++) { for (int j = 0; j < lis.size(); j++) {
final ContentItem ci = new ContentItem(); final ContentItem ci = new ContentItem();
final Element li = (Element) lis.get(j); final Element li = lis.get(j);
final Element item = li.getChild("item", CONTENT_NS); final Element item = li.getChild("item", CONTENT_NS);
final Element format = item.getChild("format", CONTENT_NS); final Element format = item.getChild("format", CONTENT_NS);
final Element encoding = item.getChild("encoding", CONTENT_NS); final Element encoding = item.getChild("encoding", CONTENT_NS);
@ -153,7 +154,7 @@ public class ContentModuleParser implements com.sun.syndication.io.ModuleParser
protected String getXmlInnerText(final Element e) { protected String getXmlInnerText(final Element e) {
final StringBuffer sb = new StringBuffer(); final StringBuffer sb = new StringBuffer();
final XMLOutputter xo = new XMLOutputter(); final XMLOutputter xo = new XMLOutputter();
final List children = e.getContent(); final List<Content> children = e.getContent();
sb.append(xo.outputString(children)); sb.append(xo.outputString(children));
return sb.toString(); return sb.toString();

View file

@ -42,10 +42,9 @@ public class FeedBurnerModuleGenerator implements ModuleGenerator {
} }
@Override @Override
public Set getNamespaces() { public Set<Namespace> getNamespaces() {
final HashSet set = new HashSet(); final HashSet<Namespace> set = new HashSet<Namespace>();
set.add(FeedBurnerModuleGenerator.NS); set.add(FeedBurnerModuleGenerator.NS);
return set; return set;
} }

View file

@ -23,6 +23,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.Namespace;
import org.rometools.feed.module.georss.geometries.AbstractGeometry; import org.rometools.feed.module.georss.geometries.AbstractGeometry;
import org.rometools.feed.module.georss.geometries.AbstractRing; import org.rometools.feed.module.georss.geometries.AbstractRing;
import org.rometools.feed.module.georss.geometries.Envelope; import org.rometools.feed.module.georss.geometries.Envelope;
@ -45,10 +46,10 @@ import com.sun.syndication.io.ModuleGenerator;
*/ */
public class GMLGenerator implements ModuleGenerator { public class GMLGenerator implements ModuleGenerator {
private static final Set NAMESPACES; private static final Set<Namespace> NAMESPACES;
static { static {
final Set nss = new HashSet(); final Set<Namespace> nss = new HashSet<Namespace>();
nss.add(GeoRSSModule.GML_NS); nss.add(GeoRSSModule.GML_NS);
NAMESPACES = Collections.unmodifiableSet(nss); NAMESPACES = Collections.unmodifiableSet(nss);
} }
@ -78,13 +79,14 @@ public class GMLGenerator implements ModuleGenerator {
* @see com.sun.syndication.io.ModuleGenerator#getNamespaces() * @see com.sun.syndication.io.ModuleGenerator#getNamespaces()
*/ */
@Override @Override
public Set getNamespaces() { public Set<Namespace> getNamespaces() {
return NAMESPACES; return NAMESPACES;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see com.sun.syndication.io.ModuleGenerator#generate(com.sun.syndication.feed.module.Module, org.jdom2.Element) * @see com.sun.syndication.io.ModuleGenerator#generate(com.sun.syndication.feed.module.Module,
* org.jdom2.Element)
*/ */
@Override @Override
public void generate(final Module module, final Element element) { public void generate(final Module module, final Element element) {
@ -135,10 +137,10 @@ public class GMLGenerator implements ModuleGenerator {
System.err.println("GeoRSS GML format can't handle rings of type: " + ring.getClass().getName()); System.err.println("GeoRSS GML format can't handle rings of type: " + ring.getClass().getName());
} }
} }
final List interiorList = ((Polygon) geometry).getInterior(); final List<AbstractRing> interiorList = ((Polygon) geometry).getInterior();
final Iterator it = interiorList.iterator(); final Iterator<AbstractRing> it = interiorList.iterator();
while (it.hasNext()) { while (it.hasNext()) {
final AbstractRing ring = (AbstractRing) it.next(); final AbstractRing ring = it.next();
if (ring instanceof LinearRing) { if (ring instanceof LinearRing) {
final Element interiorElement = new Element("interior", GeoRSSModule.GML_NS); final Element interiorElement = new Element("interior", GeoRSSModule.GML_NS);
polygonElement.addContent(interiorElement); polygonElement.addContent(interiorElement);

View file

@ -111,10 +111,10 @@ public class GMLParser implements ModuleParser {
} }
// The internal rings (holes) // The internal rings (holes)
final List interiorElementList = polygonElement.getChildren("interior", GeoRSSModule.GML_NS); final List<Element> interiorElementList = polygonElement.getChildren("interior", GeoRSSModule.GML_NS);
final Iterator it = interiorElementList.iterator(); final Iterator<Element> it = interiorElementList.iterator();
while (it.hasNext()) { while (it.hasNext()) {
final Element interiorElement = (Element) it.next(); final Element interiorElement = it.next();
if (interiorElement != null) { if (interiorElement != null) {
final Element linearRingElement = interiorElement.getChild("LinearRing", GeoRSSModule.GML_NS); final Element linearRingElement = interiorElement.getChild("LinearRing", GeoRSSModule.GML_NS);
if (linearRingElement != null) { if (linearRingElement != null) {

View file

@ -25,7 +25,8 @@ import com.sun.syndication.feed.CopyFrom;
import com.sun.syndication.feed.module.ModuleImpl; import com.sun.syndication.feed.module.ModuleImpl;
/** /**
* GeoRSSModule is the main georss interface defining the methods to produce and consume georss elements. * GeoRSSModule is the main georss interface defining the methods to produce and consume georss
* elements.
* *
* @author Marc Wick * @author Marc Wick
* @version $Id: GeoRSSModule.java,v 1.8 2007/06/06 09:47:32 marcwick Exp $ * @version $Id: GeoRSSModule.java,v 1.8 2007/06/06 09:47:32 marcwick Exp $
@ -72,7 +73,7 @@ public abstract class GeoRSSModule extends ModuleImpl implements Cloneable {
*/ */
public static final Namespace GML_NS = Namespace.getNamespace("gml", GeoRSSModule.GEORSS_GML_URI); public static final Namespace GML_NS = Namespace.getNamespace("gml", GeoRSSModule.GEORSS_GML_URI);
protected GeoRSSModule(final java.lang.Class beanClass, final java.lang.String uri) { protected GeoRSSModule(final Class beanClass, final java.lang.String uri) {
super(beanClass, uri); super(beanClass, uri);
} }

View file

@ -21,6 +21,7 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.Namespace;
import org.rometools.feed.module.georss.geometries.AbstractGeometry; import org.rometools.feed.module.georss.geometries.AbstractGeometry;
import org.rometools.feed.module.georss.geometries.AbstractRing; import org.rometools.feed.module.georss.geometries.AbstractRing;
import org.rometools.feed.module.georss.geometries.Envelope; import org.rometools.feed.module.georss.geometries.Envelope;
@ -43,9 +44,9 @@ import com.sun.syndication.io.ModuleGenerator;
*/ */
public class SimpleGenerator implements ModuleGenerator { public class SimpleGenerator implements ModuleGenerator {
private static final Set NAMESPACES; private static final Set<Namespace> NAMESPACES;
static { static {
final Set nss = new HashSet(); final Set<Namespace> nss = new HashSet<Namespace>();
nss.add(GeoRSSModule.SIMPLE_NS); nss.add(GeoRSSModule.SIMPLE_NS);
NAMESPACES = Collections.unmodifiableSet(nss); NAMESPACES = Collections.unmodifiableSet(nss);
} }
@ -72,13 +73,14 @@ public class SimpleGenerator implements ModuleGenerator {
* @see com.sun.syndication.io.ModuleGenerator#getNamespaces() * @see com.sun.syndication.io.ModuleGenerator#getNamespaces()
*/ */
@Override @Override
public Set getNamespaces() { public Set<Namespace> getNamespaces() {
return NAMESPACES; return NAMESPACES;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see com.sun.syndication.io.ModuleGenerator#generate(com.sun.syndication.feed.module.Module, org.jdom2.Element) * @see com.sun.syndication.io.ModuleGenerator#generate(com.sun.syndication.feed.module.Module,
* org.jdom2.Element)
*/ */
@Override @Override
public void generate(final Module module, final Element element) { public void generate(final Module module, final Element element) {

View file

@ -21,6 +21,7 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.Namespace;
import org.rometools.feed.module.georss.geometries.AbstractGeometry; import org.rometools.feed.module.georss.geometries.AbstractGeometry;
import org.rometools.feed.module.georss.geometries.Point; import org.rometools.feed.module.georss.geometries.Point;
import org.rometools.feed.module.georss.geometries.Position; import org.rometools.feed.module.georss.geometries.Position;
@ -39,10 +40,10 @@ public class W3CGeoGenerator implements ModuleGenerator {
private static boolean isShort = true; private static boolean isShort = true;
private static final Set NAMESPACES; private static final Set<Namespace> NAMESPACES;
static { static {
final Set nss = new HashSet(); final Set<Namespace> nss = new HashSet<Namespace>();
nss.add(GeoRSSModule.W3CGEO_NS); nss.add(GeoRSSModule.W3CGEO_NS);
NAMESPACES = Collections.unmodifiableSet(nss); NAMESPACES = Collections.unmodifiableSet(nss);
} }
@ -65,13 +66,14 @@ public class W3CGeoGenerator implements ModuleGenerator {
* @see com.sun.syndication.io.ModuleGenerator#getNamespaces() * @see com.sun.syndication.io.ModuleGenerator#getNamespaces()
*/ */
@Override @Override
public Set getNamespaces() { public Set<Namespace> getNamespaces() {
return NAMESPACES; return NAMESPACES;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see com.sun.syndication.io.ModuleGenerator#generate(com.sun.syndication.feed.module.Module, org.jdom2.Element) * @see com.sun.syndication.io.ModuleGenerator#generate(com.sun.syndication.feed.module.Module,
* org.jdom2.Element)
*/ */
@Override @Override
public void generate(final Module module, final Element element) { public void generate(final Module module, final Element element) {

View file

@ -24,7 +24,7 @@ public final class Polygon extends AbstractSurface implements Cloneable {
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private AbstractRing exterior; private AbstractRing exterior;
private List interior; private List<AbstractRing> interior;
/** Creates a new instance of Polygon */ /** Creates a new instance of Polygon */
public Polygon() { public Polygon() {
@ -38,11 +38,11 @@ public final class Polygon extends AbstractSurface implements Cloneable {
retval.exterior = (AbstractRing) exterior.clone(); retval.exterior = (AbstractRing) exterior.clone();
} }
if (interior != null) { if (interior != null) {
retval.interior = new ArrayList(); retval.interior = new ArrayList<AbstractRing>();
final Iterator it = interior.iterator(); final Iterator<AbstractRing> it = interior.iterator();
while (it.hasNext()) { while (it.hasNext()) {
final AbstractRing r = (AbstractRing) it.next(); final AbstractRing r = it.next();
retval.interior.add(r.clone()); retval.interior.add((AbstractRing) r.clone());
} }
} }
return retval; return retval;
@ -66,7 +66,7 @@ public final class Polygon extends AbstractSurface implements Cloneable {
} }
// Not efficient.... (but the number of internal ringr is usually small). // Not efficient.... (but the number of internal ringr is usually small).
Iterator it = interior.iterator(); Iterator<AbstractRing> it = interior.iterator();
while (it.hasNext()) { while (it.hasNext()) {
if (!pol.interior.contains(it.next())) { if (!pol.interior.contains(it.next())) {
return false; return false;
@ -95,9 +95,9 @@ public final class Polygon extends AbstractSurface implements Cloneable {
* *
* @return the list of border rings * @return the list of border rings
*/ */
public List getInterior() { public List<AbstractRing> getInterior() {
if (interior == null) { if (interior == null) {
interior = new ArrayList(); interior = new ArrayList<AbstractRing>();
} }
return interior; return interior;
} }
@ -116,7 +116,7 @@ public final class Polygon extends AbstractSurface implements Cloneable {
* *
* @param interior the list of inner rings * @param interior the list of inner rings
*/ */
public void setInterior(final List interior) { public void setInterior(final List<AbstractRing> interior) {
this.interior = interior; this.interior = interior;
} }
} }

View file

@ -43,7 +43,8 @@ package org.rometools.feed.module.itunes;
import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.CopyFrom;
/** /**
* This is an abstract object that implements the attributes common across Feeds or Items in an iTunes compatible RSS feed. * This is an abstract object that implements the attributes common across Feeds or Items in an
* iTunes compatible RSS feed.
* *
* @version $Revision: 1.4 $ * @version $Revision: 1.4 $
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>

View file

@ -43,6 +43,8 @@ package org.rometools.feed.module.itunes;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
import org.rometools.feed.module.itunes.types.Category;
/** /**
* This class contains information for iTunes podcast feeds that exist at the Channel level. * This class contains information for iTunes podcast feeds that exist at the Channel level.
* *
@ -56,14 +58,14 @@ public interface FeedInformation extends ITunes {
* *
* @return The parent categories for this feed * @return The parent categories for this feed
*/ */
public List getCategories(); public List<Category> getCategories();
/** /**
* The parent categories for this feed * The parent categories for this feed
* *
* @param categories The parent categories for this feed * @param categories The parent categories for this feed
*/ */
public void setCategories(List categories); public void setCategories(List<Category> categories);
/** /**
* Sets the URL for the image. * Sets the URL for the image.

View file

@ -47,6 +47,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.rometools.feed.module.itunes.types.Category;
import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.CopyFrom;
/** /**
@ -63,7 +65,7 @@ public class FeedInformationImpl extends AbstractITunesObject implements FeedInf
private String ownerName; private String ownerName;
private String ownerEmailAddress; private String ownerEmailAddress;
private URL image; private URL image;
private List categories; private List<Category> categories;
/** /**
* Creates a new instance of FeedInformationImpl * Creates a new instance of FeedInformationImpl
@ -77,8 +79,8 @@ public class FeedInformationImpl extends AbstractITunesObject implements FeedInf
* @return The parent categories for this feed * @return The parent categories for this feed
*/ */
@Override @Override
public List getCategories() { public List<Category> getCategories() {
return categories == null ? (categories = new ArrayList()) : categories; return categories == null ? (categories = new ArrayList<Category>()) : categories;
} }
/** /**
@ -87,7 +89,7 @@ public class FeedInformationImpl extends AbstractITunesObject implements FeedInf
* @param categories The parent categories for this feed * @param categories The parent categories for this feed
*/ */
@Override @Override
public void setCategories(final List categories) { public void setCategories(final List<Category> categories) {
this.categories = categories; this.categories = categories;
} }

View file

@ -41,7 +41,8 @@
package org.rometools.feed.module.itunes.io; package org.rometools.feed.module.itunes.io;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.List;
import java.util.Set;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.Namespace; import org.jdom2.Namespace;
@ -58,11 +59,12 @@ import com.sun.syndication.io.ModuleGenerator;
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class ITunesGenerator implements ModuleGenerator { public class ITunesGenerator implements ModuleGenerator {
private static final HashSet SET = new HashSet();
private static final Namespace NS = Namespace.getNamespace(AbstractITunesObject.PREFIX, AbstractITunesObject.URI); private static final HashSet<Namespace> NAMESPACES = new HashSet<Namespace>();
private static final Namespace NAMESPACE = Namespace.getNamespace(AbstractITunesObject.PREFIX, AbstractITunesObject.URI);
static { static {
SET.add(NS); NAMESPACES.add(NAMESPACE);
} }
/** Creates a new instance of ITunesGenerator */ /** Creates a new instance of ITunesGenerator */
@ -77,7 +79,7 @@ public class ITunesGenerator implements ModuleGenerator {
root = (Element) root.getParent(); root = (Element) root.getParent();
} }
root.addNamespaceDeclaration(NS); root.addNamespaceDeclaration(NAMESPACE);
if (!(module instanceof AbstractITunesObject)) { if (!(module instanceof AbstractITunesObject)) {
return; return;
@ -102,8 +104,9 @@ public class ITunesGenerator implements ModuleGenerator {
element.addContent(image); element.addContent(image);
} }
for (final Iterator it = info.getCategories().iterator(); it.hasNext();) { final List<Category> categories = info.getCategories();
final Category cat = (Category) it.next(); for (final Category cat : categories) {
final Element category = generateSimpleElement("category", ""); final Element category = generateSimpleElement("category", "");
category.setAttribute("text", cat.getName()); category.setAttribute("text", cat.getName());
@ -166,8 +169,8 @@ public class ITunesGenerator implements ModuleGenerator {
* @return set of Namespace objects. * @return set of Namespace objects.
*/ */
@Override @Override
public java.util.Set getNamespaces() { public Set<Namespace> getNamespaces() {
return SET; return NAMESPACES;
} }
/** /**
@ -181,7 +184,7 @@ public class ITunesGenerator implements ModuleGenerator {
} }
protected Element generateSimpleElement(final String name, final String value) { protected Element generateSimpleElement(final String name, final String value) {
final Element element = new Element(name, NS); final Element element = new Element(name, NAMESPACE);
element.addContent(value); element.addContent(value);
return element; return element;

View file

@ -42,12 +42,12 @@ package org.rometools.feed.module.itunes.io;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jdom2.Content;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.Namespace; import org.jdom2.Namespace;
import org.jdom2.output.XMLOutputter; import org.jdom2.output.XMLOutputter;
@ -117,9 +117,9 @@ public class ITunesParser implements ModuleParser {
} }
} }
final List categories = element.getChildren("category", ns); final List<Element> categories = element.getChildren("category", ns);
for (final Iterator it = categories.iterator(); it.hasNext();) { for (final Element element2 : categories) {
final Element category = (Element) it.next(); final Element category = element2;
if (category != null && category.getAttribute("text") != null) { if (category != null && category.getAttribute("text") != null) {
final Category cat = new Category(); final Category cat = new Category();
cat.setName(category.getAttribute("text").getValue().trim()); cat.setName(category.getAttribute("text").getValue().trim());
@ -201,9 +201,8 @@ public class ITunesParser implements ModuleParser {
protected String getXmlInnerText(final Element e) { protected String getXmlInnerText(final Element e) {
final StringBuffer sb = new StringBuffer(); final StringBuffer sb = new StringBuffer();
final XMLOutputter xo = new XMLOutputter(); final XMLOutputter xo = new XMLOutputter();
final List children = e.getContent(); final List<Content> children = e.getContent();
sb.append(xo.outputString(children)); sb.append(xo.outputString(children));
return sb.toString(); return sb.toString();
} }
} }

View file

@ -45,8 +45,9 @@ import com.sun.syndication.io.ModuleGenerator;
//this class TBI //this class TBI
public class MediaModuleGenerator implements ModuleGenerator { public class MediaModuleGenerator implements ModuleGenerator {
private static final Namespace NS = Namespace.getNamespace("media", MediaModule.URI); private static final Namespace NS = Namespace.getNamespace("media", MediaModule.URI);
private static final Set NAMESPACES = new HashSet(); private static final Set<Namespace> NAMESPACES = new HashSet<Namespace>();
static { static {
NAMESPACES.add(NS); NAMESPACES.add(NS);
@ -58,7 +59,7 @@ public class MediaModuleGenerator implements ModuleGenerator {
} }
@Override @Override
public Set getNamespaces() { public Set<Namespace> getNamespaces() {
return NAMESPACES; return NAMESPACES;
} }

View file

@ -102,12 +102,13 @@ public class MediaModuleParser implements ModuleParser {
} }
private MediaContent[] parseContent(final Element e) { private MediaContent[] parseContent(final Element e) {
final List contents = e.getChildren("content", getNS());
final ArrayList values = new ArrayList(); final List<Element> contents = e.getChildren("content", getNS());
final ArrayList<MediaContent> values = new ArrayList<MediaContent>();
try { try {
for (int i = 0; contents != null && i < contents.size(); i++) { for (int i = 0; contents != null && i < contents.size(); i++) {
final Element content = (Element) contents.get(i); final Element content = contents.get(i);
MediaContent mc = null; MediaContent mc = null;
if (content.getAttributeValue("url") != null) { if (content.getAttributeValue("url") != null) {
@ -194,15 +195,15 @@ public class MediaModuleParser implements ModuleParser {
LOG.log(Level.WARNING, "Exception parsing content tag.", ex); LOG.log(Level.WARNING, "Exception parsing content tag.", ex);
} }
return (MediaContent[]) values.toArray(new MediaContent[values.size()]); return values.toArray(new MediaContent[values.size()]);
} }
private MediaGroup[] parseGroup(final Element e) { private MediaGroup[] parseGroup(final Element e) {
final List groups = e.getChildren("group", getNS()); final List<Element> groups = e.getChildren("group", getNS());
final ArrayList values = new ArrayList(); final ArrayList<MediaGroup> values = new ArrayList<MediaGroup>();
for (int i = 0; groups != null && i < groups.size(); i++) { for (int i = 0; groups != null && i < groups.size(); i++) {
final Element group = (Element) groups.get(i); final Element group = groups.get(i);
final MediaGroup g = new MediaGroup(parseContent(group)); final MediaGroup g = new MediaGroup(parseContent(group));
for (int j = 0; j < g.getContents().length; j++) { for (int j = 0; j < g.getContents().length; j++) {
@ -217,26 +218,26 @@ public class MediaModuleParser implements ModuleParser {
values.add(g); values.add(g);
} }
return (MediaGroup[]) values.toArray(new MediaGroup[values.size()]); return values.toArray(new MediaGroup[values.size()]);
} }
private Metadata parseMetadata(final Element e) { private Metadata parseMetadata(final Element e) {
final Metadata md = new Metadata(); final Metadata md = new Metadata();
// categories // categories
{ {
final List categories = e.getChildren("category", getNS()); final List<Element> categories = e.getChildren("category", getNS());
final ArrayList values = new ArrayList(); final ArrayList<Category> values = new ArrayList<Category>();
for (int i = 0; categories != null && i < categories.size(); i++) { for (int i = 0; categories != null && i < categories.size(); i++) {
try { try {
final Element cat = (Element) categories.get(i); final Element cat = categories.get(i);
values.add(new Category(cat.getAttributeValue("scheme"), cat.getAttributeValue("label"), cat.getText())); values.add(new Category(cat.getAttributeValue("scheme"), cat.getAttributeValue("label"), cat.getText()));
} catch (final Exception ex) { } catch (final Exception ex) {
LOG.log(Level.WARNING, "Exception parsing category tag.", ex); LOG.log(Level.WARNING, "Exception parsing category tag.", ex);
} }
} }
md.setCategories((Category[]) values.toArray(new Category[values.size()])); md.setCategories(values.toArray(new Category[values.size()]));
} }
// copyright // copyright
@ -252,14 +253,14 @@ public class MediaModuleParser implements ModuleParser {
} }
// credits // credits
{ {
final List credits = e.getChildren("credit", getNS()); final List<Element> credits = e.getChildren("credit", getNS());
final ArrayList values = new ArrayList(); final ArrayList<Credit> values = new ArrayList<Credit>();
for (int i = 0; credits != null && i < credits.size(); i++) { for (int i = 0; credits != null && i < credits.size(); i++) {
try { try {
final Element cred = (Element) credits.get(i); final Element cred = credits.get(i);
values.add(new Credit(cred.getAttributeValue("scheme"), cred.getAttributeValue("role"), cred.getText())); values.add(new Credit(cred.getAttributeValue("scheme"), cred.getAttributeValue("role"), cred.getText()));
md.setCredits((Credit[]) values.toArray(new Credit[values.size()])); md.setCredits(values.toArray(new Credit[values.size()]));
} catch (final Exception ex) { } catch (final Exception ex) {
LOG.log(Level.WARNING, "Exception parsing credit tag.", ex); LOG.log(Level.WARNING, "Exception parsing credit tag.", ex);
} }
@ -305,28 +306,28 @@ public class MediaModuleParser implements ModuleParser {
} }
// ratings // ratings
{ {
final List ratings = e.getChildren("rating", getNS()); final List<Element> ratings = e.getChildren("rating", getNS());
final ArrayList values = new ArrayList(); final ArrayList<Rating> values = new ArrayList<Rating>();
for (int i = 0; ratings != null && i < ratings.size(); i++) { for (int i = 0; ratings != null && i < ratings.size(); i++) {
try { try {
final Element rat = (Element) ratings.get(i); final Element rat = ratings.get(i);
values.add(new Rating(rat.getAttributeValue("scheme"), rat.getText())); values.add(new Rating(rat.getAttributeValue("scheme"), rat.getText()));
} catch (final Exception ex) { } catch (final Exception ex) {
LOG.log(Level.WARNING, "Exception parsing rating tag.", ex); LOG.log(Level.WARNING, "Exception parsing rating tag.", ex);
} }
} }
md.setRatings((Rating[]) values.toArray(new Rating[values.size()])); md.setRatings(values.toArray(new Rating[values.size()]));
} }
// text // text
{ {
final List texts = e.getChildren("text", getNS()); final List<Element> texts = e.getChildren("text", getNS());
final ArrayList values = new ArrayList(); final ArrayList<Text> values = new ArrayList<Text>();
for (int i = 0; texts != null && i < texts.size(); i++) { for (int i = 0; texts != null && i < texts.size(); i++) {
try { try {
final Element text = (Element) texts.get(i); final Element text = texts.get(i);
final Time start = text.getAttributeValue("start") == null ? null : new Time(text.getAttributeValue("start")); final Time start = text.getAttributeValue("start") == null ? null : new Time(text.getAttributeValue("start"));
final Time end = text.getAttributeValue("end") == null ? null : new Time(text.getAttributeValue("end")); final Time end = text.getAttributeValue("end") == null ? null : new Time(text.getAttributeValue("end"));
values.add(new Text(text.getAttributeValue("type"), text.getTextTrim(), start, end)); values.add(new Text(text.getAttributeValue("type"), text.getTextTrim(), start, end));
@ -335,16 +336,16 @@ public class MediaModuleParser implements ModuleParser {
} }
} }
md.setText((Text[]) values.toArray(new Text[values.size()])); md.setText(values.toArray(new Text[values.size()]));
} }
// thumbnails // thumbnails
{ {
final List thumbnails = e.getChildren("thumbnail", getNS()); final List<Element> thumbnails = e.getChildren("thumbnail", getNS());
final ArrayList values = new ArrayList(); final ArrayList<Thumbnail> values = new ArrayList<Thumbnail>();
for (int i = 0; thumbnails != null && i < thumbnails.size(); i++) { for (int i = 0; thumbnails != null && i < thumbnails.size(); i++) {
try { try {
final Element thumb = (Element) thumbnails.get(i); final Element thumb = thumbnails.get(i);
final Time t = thumb.getAttributeValue("time") == null ? null : new Time(thumb.getAttributeValue("time")); final Time t = thumb.getAttributeValue("time") == null ? null : new Time(thumb.getAttributeValue("time"));
final Integer width = thumb.getAttributeValue("width") == null ? null : new Integer(thumb.getAttributeValue("width")); final Integer width = thumb.getAttributeValue("width") == null ? null : new Integer(thumb.getAttributeValue("width"));
final Integer height = thumb.getAttributeValue("height") == null ? null : new Integer(thumb.getAttributeValue("height")); final Integer height = thumb.getAttributeValue("height") == null ? null : new Integer(thumb.getAttributeValue("height"));
@ -354,7 +355,7 @@ public class MediaModuleParser implements ModuleParser {
} }
} }
md.setThumbnail((Thumbnail[]) values.toArray(new Thumbnail[values.size()])); md.setThumbnail(values.toArray(new Thumbnail[values.size()]));
} }
// title // title
{ {
@ -367,11 +368,11 @@ public class MediaModuleParser implements ModuleParser {
} }
// restrictions // restrictions
{ {
final List restrictions = e.getChildren("restriction", getNS()); final List<Element> restrictions = e.getChildren("restriction", getNS());
final ArrayList values = new ArrayList(); final ArrayList<Restriction> values = new ArrayList<Restriction>();
for (int i = 0; i < restrictions.size(); i++) { for (int i = 0; i < restrictions.size(); i++) {
final Element r = (Element) restrictions.get(i); final Element r = restrictions.get(i);
Restriction.Type type = null; Restriction.Type type = null;
if (r.getAttributeValue("type").equalsIgnoreCase("uri")) { if (r.getAttributeValue("type").equalsIgnoreCase("uri")) {
@ -392,7 +393,7 @@ public class MediaModuleParser implements ModuleParser {
values.add(value); values.add(value);
} }
md.setRestrictions((Restriction[]) values.toArray(new Restriction[values.size()])); md.setRestrictions(values.toArray(new Restriction[values.size()]));
} }
// handle adult // handle adult
{ {

View file

@ -21,7 +21,6 @@
*/ */
package org.rometools.feed.module.mediarss.io; package org.rometools.feed.module.mediarss.io;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.jdom2.Document; import org.jdom2.Document;
@ -52,7 +51,8 @@ public class RSS20YahooParser extends RSS20Parser {
/** /**
* Indicates if a JDom document is an RSS instance that can be parsed with the parser. * Indicates if a JDom document is an RSS instance that can be parsed with the parser.
* <p/> * <p/>
* It checks for RDF ("http://www.w3.org/1999/02/22-rdf-syntax-ns#") and RSS ("http://purl.org/rss/1.0/") namespaces being defined in the root element. * It checks for RDF ("http://www.w3.org/1999/02/22-rdf-syntax-ns#") and RSS
* ("http://purl.org/rss/1.0/") namespaces being defined in the root element.
* *
* @param document document to check if it can be parsed with this parser implementation. * @param document document to check if it can be parsed with this parser implementation.
* @return <b>true</b> if the document is RSS1., <b>false</b> otherwise. * @return <b>true</b> if the document is RSS1., <b>false</b> otherwise.
@ -63,7 +63,6 @@ public class RSS20YahooParser extends RSS20Parser {
final Element rssRoot = document.getRootElement(); final Element rssRoot = document.getRootElement();
final Namespace defaultNS = rssRoot.getNamespace(); final Namespace defaultNS = rssRoot.getNamespace();
final List additionalNSs = rssRoot.getAdditionalNamespaces();
ok = defaultNS != null && defaultNS.equals(getRSSNamespace()); ok = defaultNS != null && defaultNS.equals(getRSSNamespace());
@ -82,7 +81,8 @@ public class RSS20YahooParser extends RSS20Parser {
} }
/** /**
* After we parse the feed we put "rss_2.0" in it (so converters and generators work) this parser is a phantom. * After we parse the feed we put "rss_2.0" in it (so converters and generators work) this
* parser is a phantom.
* *
*/ */
@Override @Override

View file

@ -58,7 +58,7 @@ import com.sun.syndication.io.ModuleGenerator;
public class Generator implements ModuleGenerator { public class Generator implements ModuleGenerator {
private static final Namespace NS = Namespace.getNamespace("apple-wallpapers", PhotocastModule.URI); private static final Namespace NS = Namespace.getNamespace("apple-wallpapers", PhotocastModule.URI);
private static final HashSet NAMESPACES = new HashSet(); private static final HashSet<Namespace> NAMESPACES = new HashSet<Namespace>();
private static final String FEED_VERSION = "0.9"; private static final String FEED_VERSION = "0.9";
static { static {
NAMESPACES.add(NS); NAMESPACES.add(NS);
@ -94,7 +94,7 @@ public class Generator implements ModuleGenerator {
} }
@Override @Override
public Set getNamespaces() { public Set<Namespace> getNamespaces() {
return Generator.NAMESPACES; return Generator.NAMESPACES;
} }

View file

@ -84,10 +84,10 @@ public class Parser implements ModuleParser {
return null; return null;
} }
final PhotocastModule pm = new PhotocastModuleImpl(); final PhotocastModule pm = new PhotocastModuleImpl();
final List children = element.getChildren(); final List<Element> children = element.getChildren();
final Iterator it = children.iterator(); final Iterator<Element> it = children.iterator();
while (it.hasNext()) { while (it.hasNext()) {
final Element e = (Element) it.next(); final Element e = it.next();
if (!e.getNamespace().equals(Parser.NS)) { if (!e.getNamespace().equals(Parser.NS)) {
continue; continue;
} }

View file

@ -41,6 +41,7 @@
package org.rometools.feed.module.slash.io; package org.rometools.feed.module.slash.io;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.Namespace; import org.jdom2.Namespace;
@ -57,7 +58,7 @@ import com.sun.syndication.io.ModuleGenerator;
*/ */
public class SlashModuleGenerator implements ModuleGenerator { public class SlashModuleGenerator implements ModuleGenerator {
private static final Namespace NS = Namespace.getNamespace("slash", Slash.URI); private static final Namespace NAMESPACE = Namespace.getNamespace("slash", Slash.URI);
/** Creates a new instance of SlashModuleGenerator */ /** Creates a new instance of SlashModuleGenerator */
public SlashModuleGenerator() { public SlashModuleGenerator() {
@ -93,15 +94,15 @@ public class SlashModuleGenerator implements ModuleGenerator {
} }
protected Element generateSimpleElement(final String name, final String value) { protected Element generateSimpleElement(final String name, final String value) {
final Element element = new Element(name, SlashModuleGenerator.NS); final Element element = new Element(name, SlashModuleGenerator.NAMESPACE);
element.addContent(value); element.addContent(value);
return element; return element;
} }
@Override @Override
public java.util.Set getNamespaces() { public Set<Namespace> getNamespaces() {
final HashSet set = new HashSet(); final HashSet<Namespace> set = new HashSet<Namespace>();
set.add(SlashModuleGenerator.NS); set.add(SlashModuleGenerator.NAMESPACE);
return set; return set;
} }

View file

@ -37,7 +37,8 @@ import com.sun.syndication.io.impl.ModuleGenerators;
* This is a utiltiy class for grouping and sorting lists of entries based on the SLE. * This is a utiltiy class for grouping and sorting lists of entries based on the SLE.
* *
* <p> * <p>
* Note, this class can <b>ONLY</b> be used on parsed feeds, unless you manually add the appropriate SleEntry objects on the items. * Note, this class can <b>ONLY</b> be used on parsed feeds, unless you manually add the appropriate
* SleEntry objects on the items.
* </p> * </p>
* *
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
@ -101,9 +102,10 @@ public class SleUtility {
} }
/** /**
* This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries with current SleEntry values for sorting and grouping. * This method will take a SyndFeed object with a SimpleListExtension on it and populate the
* <b>NB</b>: This basically does this by re-generating the XML for all the entries then re-parsing them into the SLE data structures. It is a very heavy * entries with current SleEntry values for sorting and grouping. <b>NB</b>: This basically does
* operation and should not be called frequently! * this by re-generating the XML for all the entries then re-parsing them into the SLE data
* structures. It is a very heavy operation and should not be called frequently!
*/ */
public static void initializeForSorting(final SyndFeed feed) throws FeedException { public static void initializeForSorting(final SyndFeed feed) throws FeedException {
final List syndEntries = feed.getEntries(); final List syndEntries = feed.getEntries();
@ -163,7 +165,6 @@ public class SleUtility {
* performs a selection sort on all the beans in the List * performs a selection sort on all the beans in the List
*/ */
public synchronized void sortOnProperty(final Object value, final boolean ascending, final ValueStrategy strat) { public synchronized void sortOnProperty(final Object value, final boolean ascending, final ValueStrategy strat) {
final Extendable temp = null;
for (int i = 0; i < size() - 1; i++) { for (int i = 0; i < size() - 1; i++) {
for (int j = i + 1; j < size(); j++) { for (int j = i + 1; j < size(); j++) {

View file

@ -24,7 +24,8 @@ import com.sun.syndication.feed.module.Module;
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class ModuleGenerator implements com.sun.syndication.io.ModuleGenerator { public class ModuleGenerator implements com.sun.syndication.io.ModuleGenerator {
private static final Set NAMESPACES = new HashSet();
private static final Set<Namespace> NAMESPACES = new HashSet<Namespace>();
static { static {
NAMESPACES.add(ModuleParser.NS); NAMESPACES.add(ModuleParser.NS);
@ -49,14 +50,14 @@ public class ModuleGenerator implements com.sun.syndication.io.ModuleGenerator {
/** /**
* Returns a set with all the URIs (JDOM Namespace elements) this module generator uses. * Returns a set with all the URIs (JDOM Namespace elements) this module generator uses.
* <p/> * <p/>
* It is used by the the feed generators to add their namespace definition in the root element of the generated document (forward-missing of Java 5.0 * It is used by the the feed generators to add their namespace definition in the root element
* Generics). * of the generated document (forward-missing of Java 5.0 Generics).
* <p/> * <p/>
* *
* @return a set with all the URIs (JDOM Namespace elements) this module generator uses. * @return a set with all the URIs (JDOM Namespace elements) this module generator uses.
*/ */
@Override @Override
public Set getNamespaces() { public Set<Namespace> getNamespaces() {
return NAMESPACES; return NAMESPACES;
} }

View file

@ -286,11 +286,10 @@ import com.sun.syndication.feed.impl.EqualsBean;
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class ConditionCode implements Serializable { public class ConditionCode implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private transient static Map LOOKUP = new HashMap(); /* <Integer, Condition> */
private transient static Map<Integer, ConditionCode> LOOKUP = new HashMap<Integer, ConditionCode>();
public static final ConditionCode TORNADO = new ConditionCode(0, "tornado"); public static final ConditionCode TORNADO = new ConditionCode(0, "tornado");
public static final ConditionCode TROPICAL_STORM = new ConditionCode(1, "tropical storm"); public static final ConditionCode TROPICAL_STORM = new ConditionCode(1, "tropical storm");
public static final ConditionCode HURRICANE = new ConditionCode(2, "hurricane"); public static final ConditionCode HURRICANE = new ConditionCode(2, "hurricane");
@ -380,7 +379,7 @@ public class ConditionCode implements Serializable {
* @return a ConditionCode instance or null * @return a ConditionCode instance or null
*/ */
public static ConditionCode fromCode(final int code) { public static ConditionCode fromCode(final int code) {
return (ConditionCode) ConditionCode.LOOKUP.get(new Integer(code)); return ConditionCode.LOOKUP.get(new Integer(code));
} }
@Override @Override

View file

@ -50,22 +50,22 @@ public class ITunesGeneratorTest extends AbstractTestCase {
private void testFile(final String filename) throws Exception { private void testFile(final String filename) throws Exception {
final File feed = new File(getTestFile(filename)); final File feed = new File(getTestFile(filename));
final SyndFeedInput input = new SyndFeedInput(); final SyndFeedInput input = new SyndFeedInput();
final SyndFeed syndfeed = input.build(new XmlReader(feed.toURL())); final SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));
final SyndFeedOutput output = new SyndFeedOutput(); final SyndFeedOutput output = new SyndFeedOutput();
final File outfeed = new File("target/" + feed.getName()); final File outfeed = new File("target/" + feed.getName());
output.output(syndfeed, outfeed); output.output(syndfeed, outfeed);
final SyndFeed syndCheck = input.build(new XmlReader(outfeed.toURL())); final SyndFeed syndCheck = input.build(new XmlReader(outfeed.toURI().toURL()));
System.out.println(syndCheck.getModule(AbstractITunesObject.URI).toString()); System.out.println(syndCheck.getModule(AbstractITunesObject.URI).toString());
assertEquals("Feed Level: ", syndfeed.getModule(AbstractITunesObject.URI).toString(), syndCheck.getModule(AbstractITunesObject.URI).toString()); assertEquals("Feed Level: ", syndfeed.getModule(AbstractITunesObject.URI).toString(), syndCheck.getModule(AbstractITunesObject.URI).toString());
final List syndEntries = syndfeed.getEntries(); final List<SyndEntry> syndEntries = syndfeed.getEntries();
final List syndChecks = syndCheck.getEntries(); final List<SyndEntry> syndChecks = syndCheck.getEntries();
for (int i = 0; i < syndEntries.size(); i++) { for (int i = 0; i < syndEntries.size(); i++) {
final SyndEntry entry = (SyndEntry) syndEntries.get(i); final SyndEntry entry = syndEntries.get(i);
final SyndEntry check = (SyndEntry) syndChecks.get(i); final SyndEntry check = syndChecks.get(i);
System.out.println("Original: " + entry.getModule(AbstractITunesObject.URI)); System.out.println("Original: " + entry.getModule(AbstractITunesObject.URI));
System.out.println("Check: " + check.getModule(AbstractITunesObject.URI)); System.out.println("Check: " + check.getModule(AbstractITunesObject.URI));
assertEquals("Entry Level: ", entry.getModule(AbstractITunesObject.URI).toString(), check.getModule(AbstractITunesObject.URI).toString()); assertEquals("Entry Level: ", entry.getModule(AbstractITunesObject.URI).toString(), check.getModule(AbstractITunesObject.URI).toString());

View file

@ -47,21 +47,21 @@ public class MediaModuleTest extends AbstractTestCase {
continue; continue;
} }
final SyndFeed feed = input.build(files[j]); final SyndFeed feed = input.build(files[j]);
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
for (int i = 0; i < entries.size(); i++) { for (int i = 0; i < entries.size(); i++) {
System.out.println(((SyndEntry) entries.get(i)).getModule(MediaModule.URI)); System.out.println(entries.get(i).getModule(MediaModule.URI));
} }
final SyndFeedOutput output = new SyndFeedOutput(); final SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, new File("target/" + j + "media.xml")); output.output(feed, new File("target/" + j + "media.xml"));
final SyndFeed feed2 = input.build(new File("target/" + j + "media.xml")); final SyndFeed feed2 = input.build(new File("target/" + j + "media.xml"));
for (int i = 0; i < entries.size(); i++) { for (int i = 0; i < entries.size(); i++) {
BufferedWriter b = new BufferedWriter(new FileWriter("target/" + j + "a.txt")); BufferedWriter b = new BufferedWriter(new FileWriter("target/" + j + "a.txt"));
b.write("" + ((SyndEntry) entries.get(i)).getModule(MediaModule.URI)); b.write("" + entries.get(i).getModule(MediaModule.URI));
b.close(); b.close();
b = new BufferedWriter(new FileWriter("target/" + j + "b.txt")); b = new BufferedWriter(new FileWriter("target/" + j + "b.txt"));
b.write("" + feed2.getEntries().get(i).getModule(MediaModule.URI)); b.write("" + feed2.getEntries().get(i).getModule(MediaModule.URI));
b.close(); b.close();
assertEquals(((SyndEntry) entries.get(i)).getModule(MediaModule.URI), feed2.getEntries().get(i).getModule(MediaModule.URI)); assertEquals(entries.get(i).getModule(MediaModule.URI), feed2.getEntries().get(i).getModule(MediaModule.URI));
} }
} }
} }
@ -72,21 +72,33 @@ public class MediaModuleTest extends AbstractTestCase {
public void xtestOriginal() throws Exception { public void xtestOriginal() throws Exception {
// //
/* /*
* //You can test with blip tv or broadcast machine String rss = "http://blip.tv/?1=1&&skin=rss";// // String rss = * //You can test with blip tv or broadcast machine String rss =
* "http://openvision.tv/bm/rss.php?i=4"; // String rss = * "http://blip.tv/?1=1&&skin=rss";// // String rss = "http://openvision.tv/bm/rss.php?i=4";
* "http://api.search.yahoo.com/VideoSearchService/rss/videoSearch.xml?appid=yahoosearchvideorss&query=surfing&adult_ok=0"; URLConnection uc = new * // String rss =
* URL(rss).openConnection(); String contentType = uc.getContentEncoding(); WireFeedInput input = new WireFeedInput(); XmlReader xmlReader = new * "http://api.search.yahoo.com/VideoSearchService/rss/videoSearch.xml?appid=yahoosearchvideorss&query=surfing&adult_ok=0"
* XmlReader(uc.getInputStream(), contentType, true); Channel chnl = (Channel)input.build(xmlReader); String feedTitle = chnl.getTitle(); String * ; URLConnection uc = new URL(rss).openConnection(); String contentType =
* feedDesc = chnl.getDescription(); List items = chnl.getItems(); ListIterator li = items.listIterator(); Item item = null; Enclosure enc = null; * uc.getContentEncoding(); WireFeedInput input = new WireFeedInput(); XmlReader xmlReader =
* MediaModule mModule = null; while (li.hasNext()) { item = (Item)li.next(); enc = (Enclosure)item.getEnclosures().get(0); mModule = * new XmlReader(uc.getInputStream(), contentType, true); Channel chnl =
* (MediaModule)item.getModule(MediaModule.URI); List modules = item.getModules(); System.out.println("title: " + item.getTitle()); * (Channel)input.build(xmlReader); String feedTitle = chnl.getTitle(); String feedDesc =
* System.out.println("module count: " + modules.size()); if (mModule != null) { Thumbnail[] mThumbs = mModule.getMediaThumbnails(); if (mThumbs != * chnl.getDescription(); List items = chnl.getItems(); ListIterator li =
* null) { for (int i = 0; i < mThumbs.length; i++) { String imgUrl = mThumbs[i].getUrl(); System.out.println("got MediaModule img " + i + ": " + * items.listIterator(); Item item = null; Enclosure enc = null; MediaModule mModule = null;
* imgUrl); } } System.out.println("MediaModule title: " + mModule.getTitle()); System.out.println("MediaModule isAdult: " + mModule.isAdult()); /* if * while (li.hasNext()) { item = (Item)li.next(); enc =
* (mModule.getMediaContent() != null) { for (int i = 0; i < mModule.getMediaContent().length; i++) { MediaContent mc = mModule.getMediaContent()[i]; * (Enclosure)item.getEnclosures().get(0); mModule =
* mThumbs = mc.getMediaThumbnails(); if (mThumbs != null) { for (int n = 0; n < mThumbs.length; n++) { String imgUrl = mThumbs[n].getUrl(); * (MediaModule)item.getModule(MediaModule.URI); List modules = item.getModules();
* System.out.println("got MediaContentImage " + n + " img: " + imgUrl); } } System.out.println("MediaContent title:" + mc.getTitle()); * System.out.println("title: " + item.getTitle()); System.out.println("module count: " +
* System.out.println("MediaContent text:" + mc.getText()); } } } else { System.out.println("no MediaModule!"); } } * modules.size()); if (mModule != null) { Thumbnail[] mThumbs =
* mModule.getMediaThumbnails(); if (mThumbs != null) { for (int i = 0; i < mThumbs.length;
* i++) { String imgUrl = mThumbs[i].getUrl(); System.out.println("got MediaModule img " + i
* + ": " + imgUrl); } } System.out.println("MediaModule title: " + mModule.getTitle());
* System.out.println("MediaModule isAdult: " + mModule.isAdult()); /* if
* (mModule.getMediaContent() != null) { for (int i = 0; i <
* mModule.getMediaContent().length; i++) { MediaContent mc = mModule.getMediaContent()[i];
* mThumbs = mc.getMediaThumbnails(); if (mThumbs != null) { for (int n = 0; n <
* mThumbs.length; n++) { String imgUrl = mThumbs[n].getUrl();
* System.out.println("got MediaContentImage " + n + " img: " + imgUrl); } }
* System.out.println("MediaContent title:" + mc.getTitle());
* System.out.println("MediaContent text:" + mc.getText()); } } } else {
* System.out.println("no MediaModule!"); } }
*/ */
} }
} }

View file

@ -11,10 +11,10 @@ import java.io.File;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import junit.framework.Assert;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.junit.Assert;
import org.rometools.feed.module.AbstractTestCase; import org.rometools.feed.module.AbstractTestCase;
import org.rometools.feed.module.base.CustomTag; import org.rometools.feed.module.base.CustomTag;
import org.rometools.feed.module.base.CustomTags; import org.rometools.feed.module.base.CustomTags;
@ -48,19 +48,19 @@ public class CustomTagGeneratorTest extends AbstractTestCase {
output.output(feed, new File("target/custom-tags-example.xml")); output.output(feed, new File("target/custom-tags-example.xml"));
final SyndFeed feed2 = input.build(new File("target/custom-tags-example.xml")); final SyndFeed feed2 = input.build(new File("target/custom-tags-example.xml"));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0); final SyndEntry entry = entries.get(0);
final CustomTags customTags = (CustomTags) entry.getModule(CustomTags.URI); final CustomTags customTags = (CustomTags) entry.getModule(CustomTags.URI);
final List entries2 = feed2.getEntries(); final List<SyndEntry> entries2 = feed2.getEntries();
final SyndEntry entry2 = (SyndEntry) entries2.get(0); final SyndEntry entry2 = entries2.get(0);
final CustomTags customTags2 = (CustomTags) entry2.getModule(CustomTags.URI); final CustomTags customTags2 = (CustomTags) entry2.getModule(CustomTags.URI);
final Iterator it = customTags.getValues().iterator(); final Iterator<CustomTag> it = customTags.getValues().iterator();
final Iterator it2 = customTags2.getValues().iterator(); final Iterator<CustomTag> it2 = customTags2.getValues().iterator();
while (it.hasNext()) { while (it.hasNext()) {
final CustomTag tag = (CustomTag) it.next(); final CustomTag tag = it.next();
final CustomTag tag2 = (CustomTag) it2.next(); final CustomTag tag2 = it2.next();
System.out.println("tag1:" + tag); System.out.println("tag1:" + tag);
System.out.println("tag2:" + tag2); System.out.println("tag2:" + tag2);
Assert.assertEquals(tag, tag2); Assert.assertEquals(tag, tag2);

View file

@ -14,10 +14,10 @@ import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import junit.framework.Assert;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.junit.Assert;
import org.rometools.feed.module.AbstractTestCase; import org.rometools.feed.module.AbstractTestCase;
import org.rometools.feed.module.base.CustomTag; import org.rometools.feed.module.base.CustomTag;
import org.rometools.feed.module.base.CustomTagImpl; import org.rometools.feed.module.base.CustomTagImpl;
@ -50,12 +50,12 @@ public class CustomTagParserTest extends AbstractTestCase {
final SyndFeedInput input = new SyndFeedInput(); final SyndFeedInput input = new SyndFeedInput();
final SyndFeed feed = input.build(new File(super.getTestFile("xml/custom-tags-example.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/custom-tags-example.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0); final SyndEntry entry = entries.get(0);
final CustomTags customTags = (CustomTags) entry.getModule(CustomTags.URI); final CustomTags customTags = (CustomTags) entry.getModule(CustomTags.URI);
final Iterator it = customTags.getValues().iterator(); final Iterator<CustomTag> it = customTags.getValues().iterator();
while (it.hasNext()) { while (it.hasNext()) {
final CustomTag tag = (CustomTag) it.next(); final CustomTag tag = it.next();
System.out.println(tag); System.out.println(tag);
if (tag.getName().equals("language_skills")) { if (tag.getName().equals("language_skills")) {
Assert.assertEquals("Fluent in English and German", tag.getValue()); Assert.assertEquals("Fluent in English and German", tag.getValue());

View file

@ -10,10 +10,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import junit.framework.Assert;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.junit.Assert;
import org.rometools.feed.module.AbstractTestCase; import org.rometools.feed.module.AbstractTestCase;
import org.rometools.feed.module.base.GoogleBase; import org.rometools.feed.module.base.GoogleBase;
import org.rometools.feed.module.base.GoogleBaseImpl; import org.rometools.feed.module.base.GoogleBaseImpl;
@ -85,7 +85,7 @@ public class GoogleBaseGeneratorTest extends AbstractTestCase {
feed.setLink("http://rome.dev.java.net"); feed.setLink("http://rome.dev.java.net");
feed.setDescription("This feed has been created using Rome (Java syndication utilities"); feed.setDescription("This feed has been created using Rome (Java syndication utilities");
final List entries = new ArrayList(); final List<SyndEntry> entries = new ArrayList<SyndEntry>();
SyndEntry entry; SyndEntry entry;
SyndContent description; SyndContent description;
@ -104,6 +104,7 @@ public class GoogleBaseGeneratorTest extends AbstractTestCase {
product.setCondition("New"); product.setCondition("New");
product.setDeliveryNotes("Insight"); product.setDeliveryNotes("Insight");
// FIXME
final List modules = new ArrayList(); final List modules = new ArrayList();
modules.add(vehicle); modules.add(vehicle);
modules.add(product); modules.add(product);

View file

@ -11,10 +11,10 @@ import java.net.URL;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import junit.framework.Assert;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.junit.Assert;
import org.rometools.feed.module.AbstractTestCase; import org.rometools.feed.module.AbstractTestCase;
import org.rometools.feed.module.base.Article; import org.rometools.feed.module.base.Article;
import org.rometools.feed.module.base.Course; import org.rometools.feed.module.base.Course;
@ -76,9 +76,9 @@ public class GoogleBaseParserTest extends AbstractTestCase {
} catch (final Exception e) { } catch (final Exception e) {
throw new RuntimeException(testFiles[h].getAbsolutePath(), e); throw new RuntimeException(testFiles[h].getAbsolutePath(), e);
} }
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
for (int i = 0; i < entries.size(); i++) { for (int i = 0; i < entries.size(); i++) {
final SyndEntry entry = (SyndEntry) entries.get(i); final SyndEntry entry = entries.get(i);
System.out.println(entry.getModules().size()); System.out.println(entry.getModules().size());
for (int j = 0; j < entry.getModules().size(); j++) { for (int j = 0; j < entry.getModules().size(); j++) {
System.out.println(entry.getModules().get(j).getClass()); System.out.println(entry.getModules().get(j).getClass());
@ -104,8 +104,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final SyndFeedInput input = new SyndFeedInput(); final SyndFeedInput input = new SyndFeedInput();
final SyndFeed feed = input.build(new File(super.getTestFile("xml/courses2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/courses2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
SyndEntry entry = (SyndEntry) entries.get(0); SyndEntry entry = entries.get(0);
Course course = (Course) entry.getModule(GoogleBase.URI); Course course = (Course) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", course.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", course.getImageLinks()[0].toString());
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
@ -123,7 +123,7 @@ public class GoogleBaseParserTest extends AbstractTestCase {
this.assertEquals("Subject", new String[] { "computer science" }, course.getSubjects()); this.assertEquals("Subject", new String[] { "computer science" }, course.getSubjects());
Assert.assertEquals("University", "Johnson State", course.getUniversity()); Assert.assertEquals("University", "Johnson State", course.getUniversity());
entry = (SyndEntry) entries.get(1); entry = entries.get(1);
course = (Course) entry.getModule(GoogleBase.URI); course = (Course) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", course.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", course.getImageLinks()[0].toString());
cal = Calendar.getInstance(); cal = Calendar.getInstance();
@ -150,8 +150,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final SyndFeedInput input = new SyndFeedInput(); final SyndFeedInput input = new SyndFeedInput();
final SyndFeed feed = input.build(new File(super.getTestFile("xml/events2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/events2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
SyndEntry entry = (SyndEntry) entries.get(0); SyndEntry entry = entries.get(0);
Event event = (Event) entry.getModule(GoogleBase.URI); Event event = (Event) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", event.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", event.getImageLinks()[0].toString());
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
@ -167,7 +167,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
PaymentTypeEnumeration.VISA }, event.getPaymentAccepted()); PaymentTypeEnumeration.VISA }, event.getPaymentAccepted());
Assert.assertEquals("Payment Notes", "Cash only for local orders", event.getPaymentNotes()); Assert.assertEquals("Payment Notes", "Cash only for local orders", event.getPaymentNotes());
/* /*
* <g:event_date_range> <g:start>2005-07-04T20:00:00</g:start> <g:end>2005-07-04T23:00:00</g:end> </g:event_date_range> * <g:event_date_range> <g:start>2005-07-04T20:00:00</g:start>
* <g:end>2005-07-04T23:00:00</g:end> </g:event_date_range>
*/ */
cal.set(2005, 06, 04, 20, 00, 00); cal.set(2005, 06, 04, 20, 00, 00);
Assert.assertEquals("Start Time", cal.getTime(), event.getEventDateRange().getStart()); Assert.assertEquals("Start Time", cal.getTime(), event.getEventDateRange().getStart());
@ -180,7 +181,7 @@ public class GoogleBaseParserTest extends AbstractTestCase {
Assert.assertEquals("Tax Region", "California", event.getTaxRegion()); Assert.assertEquals("Tax Region", "California", event.getTaxRegion());
Assert.assertEquals("Tax Percentage", new Float(8.25), event.getTaxPercent()); Assert.assertEquals("Tax Percentage", new Float(8.25), event.getTaxPercent());
entry = (SyndEntry) entries.get(1); entry = entries.get(1);
event = (Event) entry.getModule(GoogleBase.URI); event = (Event) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image2.jpg", event.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image2.jpg", event.getImageLinks()[0].toString());
cal.setTimeInMillis(0); cal.setTimeInMillis(0);
@ -195,7 +196,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
PaymentTypeEnumeration.VISA }, event.getPaymentAccepted()); PaymentTypeEnumeration.VISA }, event.getPaymentAccepted());
Assert.assertEquals("Payment Notes", "Cash only for local orders", event.getPaymentNotes()); Assert.assertEquals("Payment Notes", "Cash only for local orders", event.getPaymentNotes());
/* /*
* <g:event_date_range> <g:start>2005-08-23T20:00:00</g:start> <g:end>2005-08-23T23:00:00</g:end> </g:event_date_range> * <g:event_date_range> <g:start>2005-08-23T20:00:00</g:start>
* <g:end>2005-08-23T23:00:00</g:end> </g:event_date_range>
*/ */
cal.set(2005, 07, 23, 20, 00, 00); cal.set(2005, 07, 23, 20, 00, 00);
Assert.assertEquals("Start Time", cal.getTime(), event.getEventDateRange().getStart()); Assert.assertEquals("Start Time", cal.getTime(), event.getEventDateRange().getStart());
@ -219,8 +221,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0); cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/housing2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/housing2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
SyndEntry entry = (SyndEntry) entries.get(0); SyndEntry entry = entries.get(0);
Housing module = (Housing) entry.getModule(GoogleBase.URI); Housing module = (Housing) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2007, 11, 20, 0, 0, 0); cal.set(2007, 11, 20, 0, 0, 0);
@ -247,7 +249,7 @@ public class GoogleBaseParserTest extends AbstractTestCase {
Assert.assertEquals("Tax Region", "California", module.getTaxRegion()); Assert.assertEquals("Tax Region", "California", module.getTaxRegion());
Assert.assertEquals("Tax Percentage", new Float(8.25), module.getTaxPercent()); Assert.assertEquals("Tax Percentage", new Float(8.25), module.getTaxPercent());
entry = (SyndEntry) entries.get(1); entry = entries.get(1);
module = (Housing) entry.getModule(GoogleBase.URI); module = (Housing) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image2.jpg", module.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image2.jpg", module.getImageLinks()[0].toString());
cal.set(2008, 11, 20, 0, 0, 0); cal.set(2008, 11, 20, 0, 0, 0);
@ -283,8 +285,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0); cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/jobs2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/jobs2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0); final SyndEntry entry = entries.get(0);
final Job module = (Job) entry.getModule(GoogleBase.URI); final Job module = (Job) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0); cal.set(2005, 11, 20, 0, 0, 0);
@ -313,8 +315,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0); cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/news2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/news2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0); final SyndEntry entry = entries.get(0);
final Article module = (Article) entry.getModule(GoogleBase.URI); final Article module = (Article) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2007, 2, 20, 0, 0, 0); cal.set(2007, 2, 20, 0, 0, 0);
@ -337,8 +339,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0); cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/travel2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/travel2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0); final SyndEntry entry = entries.get(0);
final Travel module = (Travel) entry.getModule(GoogleBase.URI); final Travel module = (Travel) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0); cal.set(2005, 11, 20, 0, 0, 0);
@ -375,8 +377,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0); cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/personals2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/personals2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0); final SyndEntry entry = entries.get(0);
final Person module = (Person) entry.getModule(GoogleBase.URI); final Person module = (Person) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0); cal.set(2005, 11, 20, 0, 0, 0);
@ -403,8 +405,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0); cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/products2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/products2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0); final SyndEntry entry = entries.get(0);
final Product module = (Product) entry.getModule(GoogleBase.URI); final Product module = (Product) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.googlestore.com/appliance/images/products/GO0144E.jpg", module.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.googlestore.com/appliance/images/products/GO0144E.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0); cal.set(2005, 11, 20, 0, 0, 0);
@ -442,8 +444,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0); cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/research2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/research2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0); final SyndEntry entry = entries.get(0);
final ScholarlyArticle module = (ScholarlyArticle) entry.getModule(GoogleBase.URI); final ScholarlyArticle module = (ScholarlyArticle) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0); cal.set(2005, 11, 20, 0, 0, 0);
@ -466,8 +468,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0); cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/reviews2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/reviews2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0); final SyndEntry entry = entries.get(0);
final Review module = (Review) entry.getModule(GoogleBase.URI); final Review module = (Review) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0); cal.set(2005, 11, 20, 0, 0, 0);
@ -493,8 +495,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0); cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/services2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/services2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0); final SyndEntry entry = entries.get(0);
final Service module = (Service) entry.getModule(GoogleBase.URI); final Service module = (Service) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0); cal.set(2005, 11, 20, 0, 0, 0);
@ -523,8 +525,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0); cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/vehicles2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/vehicles2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0); final SyndEntry entry = entries.get(0);
final Vehicle module = (Vehicle) entry.getModule(GoogleBase.URI); final Vehicle module = (Vehicle) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0); cal.set(2005, 11, 20, 0, 0, 0);
@ -557,8 +559,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0); cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/wanted2.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("xml/wanted2.xml")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0); final SyndEntry entry = entries.get(0);
final Wanted module = (Wanted) entry.getModule(GoogleBase.URI); final Wanted module = (Wanted) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString()); Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0); cal.set(2005, 11, 20, 0, 0, 0);

View file

@ -57,13 +57,18 @@ public class CCModuleGeneratorTest extends AbstractTestCase {
output.output(feed, new File("target/" + testFiles[h].getName())); output.output(feed, new File("target/" + testFiles[h].getName()));
final SyndFeed feed2 = input.build(new File("target/" + testFiles[h].getName())); final SyndFeed feed2 = input.build(new File("target/" + testFiles[h].getName()));
for (int i = 0; i < feed.getEntries().size(); i++) { for (int i = 0; i < feed.getEntries().size(); i++) {
final SyndEntry entry = feed.getEntries().get(i); // FIXME
// final SyndEntry entry = feed.getEntries().get(i);
final SyndEntry entry2 = feed2.getEntries().get(i); final SyndEntry entry2 = feed2.getEntries().get(i);
final CreativeCommons base = (CreativeCommons) entry.getModule(CreativeCommons.URI); // / FIXME
// final CreativeCommons base = (CreativeCommons)
// entry.getModule(CreativeCommons.URI);
final CreativeCommons base2 = (CreativeCommons) entry2.getModule(CreativeCommons.URI); final CreativeCommons base2 = (CreativeCommons) entry2.getModule(CreativeCommons.URI);
System.out.println(base2); System.out.println(base2);
// FIXME
// if( base != null) // if( base != null)
// this.assertEquals( testFiles[h].getName(), base.getLicenses(), base2.getLicenses() ); // this.assertEquals( testFiles[h].getName(), base.getLicenses(),
// base2.getLicenses() );
} }
} }
} }

View file

@ -51,11 +51,11 @@ public class ModuleParserTest extends AbstractTestCase {
} }
System.out.println(testFiles[h].getName()); System.out.println(testFiles[h].getName());
final SyndFeed feed = input.build(testFiles[h]); final SyndFeed feed = input.build(testFiles[h]);
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
final CreativeCommons fMod = (CreativeCommons) feed.getModule(CreativeCommons.URI); final CreativeCommons fMod = (CreativeCommons) feed.getModule(CreativeCommons.URI);
System.out.println(fMod); System.out.println(fMod);
for (int i = 0; i < entries.size(); i++) { for (int i = 0; i < entries.size(); i++) {
final SyndEntry entry = (SyndEntry) entries.get(i); final SyndEntry entry = entries.get(i);
final CreativeCommons eMod = (CreativeCommons) entry.getModule(CreativeCommons.URI); final CreativeCommons eMod = (CreativeCommons) entry.getModule(CreativeCommons.URI);
System.out.println("\nEntry:"); System.out.println("\nEntry:");
System.out.println(eMod); System.out.println(eMod);

View file

@ -46,9 +46,9 @@ public class ContentModuleGeneratorTest extends AbstractTestCase {
System.out.println("testGenerate"); System.out.println("testGenerate");
final SyndFeedInput input = new SyndFeedInput(); final SyndFeedInput input = new SyndFeedInput();
final SyndFeed feed = input.build(new XmlReader(new File(getTestFile("xml/test-rdf.xml")).toURL())); final SyndFeed feed = input.build(new XmlReader(new File(getTestFile("xml/test-rdf.xml")).toURI().toURL()));
final SyndEntry entry = feed.getEntries().get(0); final SyndEntry entry = feed.getEntries().get(0);
final ContentModule module = (ContentModule) entry.getModule(ContentModule.URI); entry.getModule(ContentModule.URI);
final SyndFeedOutput output = new SyndFeedOutput(); final SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, new java.io.PrintWriter(System.out)); output.output(feed, new java.io.PrintWriter(System.out));
} }

View file

@ -19,7 +19,8 @@ import junit.framework.TestCase;
public class ContentModuleImplTest extends TestCase { public class ContentModuleImplTest extends TestCase {
private final ContentModuleImpl module = new ContentModuleImpl(); private final ContentModuleImpl module = new ContentModuleImpl();
public static ArrayList contentItems = new ArrayList(); public static ArrayList<ContentItem> contentItems = new ArrayList<ContentItem>();
static { static {
ContentItem item = new ContentItem(); ContentItem item = new ContentItem();
item.setContentFormat("http://www.w3.org/1999/xhtml"); item.setContentFormat("http://www.w3.org/1999/xhtml");
@ -73,12 +74,12 @@ public class ContentModuleImplTest extends TestCase {
* Test of getEncodeds method, of class com.totsp.xml.syndication.content.ContentModuleImpl. * Test of getEncodeds method, of class com.totsp.xml.syndication.content.ContentModuleImpl.
*/ */
public void testEncodeds() { public void testEncodeds() {
final ArrayList encodeds = new ArrayList(); final ArrayList<String> encodeds = new ArrayList<String>();
encodeds.add("Foo"); encodeds.add("Foo");
encodeds.add("Bar"); encodeds.add("Bar");
encodeds.add("Baz"); encodeds.add("Baz");
module.setEncodeds(encodeds); module.setEncodeds(encodeds);
final List check = module.getEncodeds(); final List<String> check = module.getEncodeds();
assertTrue(check.equals(encodeds)); assertTrue(check.equals(encodeds));
} }
@ -105,12 +106,12 @@ public class ContentModuleImplTest extends TestCase {
*/ */
public void testContents() { public void testContents() {
System.out.println("testContents"); System.out.println("testContents");
final ArrayList contents = new ArrayList(); final ArrayList<String> contents = new ArrayList<String>();
contents.add("Foo"); contents.add("Foo");
contents.add("Bar"); contents.add("Bar");
contents.add("Baz"); contents.add("Baz");
module.setContents(contents); module.setContents(contents);
final List check = module.getContents(); final List<String> check = module.getContents();
assertTrue(check.equals(contents)); assertTrue(check.equals(contents));
} }

View file

@ -40,20 +40,23 @@ public class ContentModuleParserTest extends AbstractTestCase {
} }
/** /**
* Test of parse method, of class com.sun.syndication.feed.module.content.ContentModuleParser. It will test through the whole ROME framework. * Test of parse method, of class com.sun.syndication.feed.module.content.ContentModuleParser.
* It will test through the whole ROME framework.
*/ */
public void testParse() throws Exception { public void testParse() throws Exception {
final SyndFeedInput input = new SyndFeedInput(); final SyndFeedInput input = new SyndFeedInput();
final SyndFeed feed = input.build(new XmlReader(new File(getTestFile("xml/test-rdf.xml")).toURL())); final SyndFeed feed = input.build(new XmlReader(new File(getTestFile("xml/test-rdf.xml")).toURI().toURL()));
final SyndEntry entry = feed.getEntries().get(0); final SyndEntry entry = feed.getEntries().get(0);
final ContentModule module = (ContentModule) entry.getModule(ContentModule.URI); final ContentModule module = (ContentModule) entry.getModule(ContentModule.URI);
final List items = module.getContentItems(); final List<ContentItem> items = module.getContentItems();
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
final ContentItem item = (ContentItem) ContentModuleImplTest.contentItems.get(i); // FIXME
// TODO fix this. // final ContentItem item = ContentModuleImplTest.contentItems.get(i);
// assertEquals (item , items.get(i)); // assertEquals (item , items.get(i));
} }
} }
} }

View file

@ -62,9 +62,9 @@ public class RssTest extends TestCase {
final SyndFeed feed = input.build(new XmlReader(in)); final SyndFeed feed = input.build(new XmlReader(in));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
for (int i = 0; i < entries.size(); i++) { for (int i = 0; i < entries.size(); i++) {
final SyndEntry entry = (SyndEntry) entries.get(i); final SyndEntry entry = entries.get(i);
final GeoRSSModule geoRSSModule = GeoRSSUtils.getGeoRSS(entry); final GeoRSSModule geoRSSModule = GeoRSSUtils.getGeoRSS(entry);
final Position position = geoRSSModule.getPosition(); final Position position = geoRSSModule.getPosition();
assertEquals("lat " + i, expectedLat[i], position.getLatitude(), DELTA); assertEquals("lat " + i, expectedLat[i], position.getLatitude(), DELTA);
@ -80,7 +80,7 @@ public class RssTest extends TestCase {
feed.setLink("http://rome.dev.java.net"); feed.setLink("http://rome.dev.java.net");
feed.setDescription("This feed has been created using ROME (Java syndication utilities"); feed.setDescription("This feed has been created using ROME (Java syndication utilities");
final List entries = new ArrayList(); final List<SyndEntry> entries = new ArrayList<SyndEntry>();
SyndEntry entry; SyndEntry entry;
SyndContent description; SyndContent description;
@ -197,9 +197,9 @@ public class RssTest extends TestCase {
feed = input.build(new XmlReader(in)); feed = input.build(new XmlReader(in));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
for (int i = 0; i < entries.size(); i++) { for (int i = 0; i < entries.size(); i++) {
entry = (SyndEntry) entries.get(i); entry = entries.get(i);
geoRSSModule = (SimpleModuleImpl) GeoRSSUtils.getGeoRSS(entry); geoRSSModule = (SimpleModuleImpl) GeoRSSUtils.getGeoRSS(entry);
final LineString lineString = (LineString) geoRSSModule.getGeometry(); final LineString lineString = (LineString) geoRSSModule.getGeometry();
positionList = lineString.getPositionList(); positionList = lineString.getPositionList();

View file

@ -54,22 +54,22 @@ public class ITunesGeneratorTest extends AbstractTestCase {
private void testFile(final String filename) throws Exception { private void testFile(final String filename) throws Exception {
final File feed = new File(getTestFile(filename)); final File feed = new File(getTestFile(filename));
final SyndFeedInput input = new SyndFeedInput(); final SyndFeedInput input = new SyndFeedInput();
final SyndFeed syndfeed = input.build(new XmlReader(feed.toURL())); final SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));
final SyndFeedOutput output = new SyndFeedOutput(); final SyndFeedOutput output = new SyndFeedOutput();
final File outfeed = new File(feed.getAbsolutePath() + ".output"); final File outfeed = new File(feed.getAbsolutePath() + ".output");
output.output(syndfeed, outfeed); output.output(syndfeed, outfeed);
final SyndFeed syndCheck = input.build(new XmlReader(outfeed.toURL())); final SyndFeed syndCheck = input.build(new XmlReader(outfeed.toURI().toURL()));
System.out.println(syndCheck.getModule(AbstractITunesObject.URI).toString()); System.out.println(syndCheck.getModule(AbstractITunesObject.URI).toString());
assertEquals("Feed Level: ", syndfeed.getModule(AbstractITunesObject.URI).toString(), syndCheck.getModule(AbstractITunesObject.URI).toString()); assertEquals("Feed Level: ", syndfeed.getModule(AbstractITunesObject.URI).toString(), syndCheck.getModule(AbstractITunesObject.URI).toString());
final List syndEntries = syndfeed.getEntries(); final List<SyndEntry> syndEntries = syndfeed.getEntries();
final List syndChecks = syndCheck.getEntries(); final List<SyndEntry> syndChecks = syndCheck.getEntries();
for (int i = 0; i < syndEntries.size(); i++) { for (int i = 0; i < syndEntries.size(); i++) {
final SyndEntry entry = (SyndEntry) syndEntries.get(i); final SyndEntry entry = syndEntries.get(i);
final SyndEntry check = (SyndEntry) syndChecks.get(i); final SyndEntry check = syndChecks.get(i);
System.out.println("Original: " + entry.getModule(AbstractITunesObject.URI)); System.out.println("Original: " + entry.getModule(AbstractITunesObject.URI));
System.out.println("Check: " + check.getModule(AbstractITunesObject.URI)); System.out.println("Check: " + check.getModule(AbstractITunesObject.URI));
System.out.println(entry.getModule(AbstractITunesObject.URI).toString()); System.out.println(entry.getModule(AbstractITunesObject.URI).toString());

View file

@ -15,7 +15,6 @@ import junit.framework.TestSuite;
import org.rometools.feed.module.AbstractTestCase; import org.rometools.feed.module.AbstractTestCase;
import org.rometools.feed.module.itunes.io.ITunesGenerator; import org.rometools.feed.module.itunes.io.ITunesGenerator;
import org.rometools.feed.module.itunes.types.Category;
import com.sun.syndication.feed.module.Module; import com.sun.syndication.feed.module.Module;
import com.sun.syndication.feed.synd.SyndEntry; import com.sun.syndication.feed.synd.SyndEntry;
@ -61,7 +60,7 @@ public class ITunesParserTest extends AbstractTestCase {
public void testParse() throws Exception { public void testParse() throws Exception {
File feed = new File(getTestFile("xml/leshow.xml")); File feed = new File(getTestFile("xml/leshow.xml"));
final SyndFeedInput input = new SyndFeedInput(); final SyndFeedInput input = new SyndFeedInput();
SyndFeed syndfeed = input.build(new XmlReader(feed.toURL())); SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));
final Module module = syndfeed.getModule(AbstractITunesObject.URI); final Module module = syndfeed.getModule(AbstractITunesObject.URI);
final FeedInformationImpl feedInfo = (FeedInformationImpl) module; final FeedInformationImpl feedInfo = (FeedInformationImpl) module;
@ -69,28 +68,28 @@ public class ITunesParserTest extends AbstractTestCase {
assertEquals("owner", "Harry Shearer", feedInfo.getOwnerName()); assertEquals("owner", "Harry Shearer", feedInfo.getOwnerName());
assertEquals("email", "", feedInfo.getOwnerEmailAddress()); assertEquals("email", "", feedInfo.getOwnerEmailAddress());
assertEquals("image", "http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg", feedInfo.getImage().toExternalForm()); assertEquals("image", "http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg", feedInfo.getImage().toExternalForm());
assertEquals("category", "Comedy", ((Category) feedInfo.getCategories().get(0)).getName()); assertEquals("category", "Comedy", feedInfo.getCategories().get(0).getName());
assertEquals( assertEquals(
"summary", "summary",
"A weekly, hour-long romp through the worlds of media, politics, sports and show business, leavened with an eclectic mix of mysterious music, hosted by Harry Shearer.", "A weekly, hour-long romp through the worlds of media, politics, sports and show business, leavened with an eclectic mix of mysterious music, hosted by Harry Shearer.",
feedInfo.getSummary()); feedInfo.getSummary());
List entries = syndfeed.getEntries(); List<SyndEntry> entries = syndfeed.getEntries();
Iterator it = entries.iterator(); Iterator<SyndEntry> it = entries.iterator();
while (it.hasNext()) { while (it.hasNext()) {
final SyndEntry entry = (SyndEntry) it.next(); final SyndEntry entry = it.next();
final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI); final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
System.out.println(entryInfo); System.out.println(entryInfo);
} }
feed = new File(getTestFile("xml/rsr.xml")); feed = new File(getTestFile("xml/rsr.xml"));
syndfeed = input.build(new XmlReader(feed.toURL())); syndfeed = input.build(new XmlReader(feed.toURI().toURL()));
entries = syndfeed.getEntries(); entries = syndfeed.getEntries();
it = entries.iterator(); it = entries.iterator();
while (it.hasNext()) { while (it.hasNext()) {
final SyndEntry entry = (SyndEntry) it.next(); final SyndEntry entry = it.next();
final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI); final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
System.out.println(entryInfo.getDuration()); System.out.println(entryInfo.getDuration());
} }

View file

@ -7,11 +7,12 @@
package org.rometools.feed.module.mediarss.types; package org.rometools.feed.module.mediarss.types;
import junit.framework.Assert;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.junit.Assert;
/** /**
* *
* @author cooper * @author cooper

View file

@ -44,29 +44,30 @@ public class GeneratorTest extends AbstractTestCase {
final SyndFeedInput input = new SyndFeedInput(); final SyndFeedInput input = new SyndFeedInput();
final SyndFeed feed = input.build(new File(super.getTestFile("index.rss"))); final SyndFeed feed = input.build(new File(super.getTestFile("index.rss")));
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
for (int i = 0; i < entries.size(); i++) { for (int i = 0; i < entries.size(); i++) {
System.out.println(((SyndEntry) entries.get(i)).getModule(PhotocastModule.URI)); System.out.println(entries.get(i).getModule(PhotocastModule.URI));
} }
final SyndFeedOutput output = new SyndFeedOutput(); final SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, new File("target/index.rss")); output.output(feed, new File("target/index.rss"));
final SyndFeed feed2 = input.build(new File("target/index.rss")); final SyndFeed feed2 = input.build(new File("target/index.rss"));
final List entries2 = feed2.getEntries(); final List<SyndEntry> entries2 = feed2.getEntries();
for (int i = 0; i < entries.size(); i++) { for (int i = 0; i < entries.size(); i++) {
assertEquals("Module test", ((SyndEntry) entries.get(i)).getModule(PhotocastModule.URI), assertEquals("Module test", entries.get(i).getModule(PhotocastModule.URI), entries2.get(i).getModule(PhotocastModule.URI));
((SyndEntry) entries2.get(i)).getModule(PhotocastModule.URI));
} }
} }
/** /**
* Test of getNamespaces method, of class com.sun.syndication.feed.module.photocast.io.Generator. * Test of getNamespaces method, of class
* com.sun.syndication.feed.module.photocast.io.Generator.
*/ */
public void testGetNamespaces() { public void testGetNamespaces() {
// TODO add your test code. // TODO add your test code.
} }
/** /**
* Test of getNamespaceUri method, of class com.sun.syndication.feed.module.photocast.io.Generator. * Test of getNamespaceUri method, of class
* com.sun.syndication.feed.module.photocast.io.Generator.
*/ */
public void testGetNamespaceUri() { public void testGetNamespaceUri() {
// TODO add your test code. // TODO add your test code.

View file

@ -14,6 +14,7 @@ import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.rometools.feed.module.AbstractTestCase; import org.rometools.feed.module.AbstractTestCase;
import org.rometools.feed.module.sle.types.Sort;
import com.sun.syndication.feed.synd.SyndEntry; import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed; import com.sun.syndication.feed.synd.SyndFeed;
@ -43,21 +44,24 @@ public class GroupAndSortTest extends AbstractTestCase {
final SyndFeed feed = input.build(new File(super.getTestFile("data/bookexample.xml"))); final SyndFeed feed = input.build(new File(super.getTestFile("data/bookexample.xml")));
final SimpleListExtension sle = (SimpleListExtension) feed.getModule(SimpleListExtension.URI); final SimpleListExtension sle = (SimpleListExtension) feed.getModule(SimpleListExtension.URI);
List sortedEntries = SleUtility.sort(feed.getEntries(), sle.getSortFields()[1], true); final List<SyndEntry> entries = feed.getEntries();
final Sort[] sortFields = sle.getSortFields();
final Sort sort = sortFields[1];
List sortedEntries = SleUtility.sort(entries, sort, true);
SyndEntry entry = (SyndEntry) sortedEntries.get(0); SyndEntry entry = (SyndEntry) sortedEntries.get(0);
assertEquals("Great Journeys of the Past", entry.getTitle()); assertEquals("Great Journeys of the Past", entry.getTitle());
sortedEntries = SleUtility.sort(feed.getEntries(), sle.getSortFields()[1], false); sortedEntries = SleUtility.sort(entries, sort, false);
entry = (SyndEntry) sortedEntries.get(0); entry = (SyndEntry) sortedEntries.get(0);
assertEquals("Horror Stories, vol 16", entry.getTitle()); assertEquals("Horror Stories, vol 16", entry.getTitle());
sortedEntries = SleUtility.sort(feed.getEntries(), sle.getSortFields()[1], true); sortedEntries = SleUtility.sort(entries, sort, true);
entry = (SyndEntry) sortedEntries.get(0); entry = (SyndEntry) sortedEntries.get(0);
entry.setTitle("ZZZZZ"); entry.setTitle("ZZZZZ");
SleUtility.initializeForSorting(feed); SleUtility.initializeForSorting(feed);
System.out.println(feed.getEntries().size() + " **Sorting on " + sle.getSortFields()[2]); System.out.println(entries.size() + " **Sorting on " + sortFields[2]);
sortedEntries = SleUtility.sort(feed.getEntries(), sle.getSortFields()[2], false); sortedEntries = SleUtility.sort(entries, sortFields[2], false);
System.out.println("Sorted: " + sortedEntries.size()); System.out.println("Sorted: " + sortedEntries.size());
for (int i = 0; i < sortedEntries.size(); i++) { for (int i = 0; i < sortedEntries.size(); i++) {
entry = (SyndEntry) sortedEntries.get(i); entry = (SyndEntry) sortedEntries.get(i);
@ -74,14 +78,14 @@ public class GroupAndSortTest extends AbstractTestCase {
entry = (SyndEntry) sortedEntries.get(1); entry = (SyndEntry) sortedEntries.get(1);
System.out.println(entry.getTitle()); System.out.println(entry.getTitle());
sortedEntries = SleUtility.sort(feed.getEntries(), sle.getSortFields()[2], true); sortedEntries = SleUtility.sort(entries, sortFields[2], true);
entry = (SyndEntry) sortedEntries.get(0); entry = (SyndEntry) sortedEntries.get(0);
System.out.println(entry.getTitle()); System.out.println(entry.getTitle());
assertEquals("Horror Stories, vol 16", entry.getTitle()); assertEquals("Horror Stories, vol 16", entry.getTitle());
entry = (SyndEntry) sortedEntries.get(1); entry = (SyndEntry) sortedEntries.get(1);
System.out.println(entry.getTitle()); System.out.println(entry.getTitle());
sortedEntries = SleUtility.sortAndGroup(feed.getEntries(), sle.getGroupFields(), sle.getSortFields()[2], true); sortedEntries = SleUtility.sortAndGroup(entries, sle.getGroupFields(), sortFields[2], true);
entry = (SyndEntry) sortedEntries.get(0); entry = (SyndEntry) sortedEntries.get(0);
System.out.println(entry.getTitle()); System.out.println(entry.getTitle());
assertEquals("Horror Stories, vol 16", entry.getTitle()); assertEquals("Horror Stories, vol 16", entry.getTitle());

View file

@ -18,6 +18,7 @@ import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.jdom2.Attribute; import org.jdom2.Attribute;
import org.jdom2.Content;
import org.jdom2.Document; import org.jdom2.Document;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.input.SAXBuilder; import org.jdom2.input.SAXBuilder;
@ -63,7 +64,7 @@ public class SSEParserTest extends AbstractTestCase {
} }
public void xtestParseGenerateV5() throws Exception { public void xtestParseGenerateV5() throws Exception {
final URL feedURL = new File(getTestFile("xml/v/v5.xml")).toURL(); final URL feedURL = new File(getTestFile("xml/v/v5.xml")).toURI().toURL();
// parse the document for comparison // parse the document for comparison
final SAXBuilder builder = new SAXBuilder(); final SAXBuilder builder = new SAXBuilder();
final Document directlyBuilt = builder.build(feedURL); final Document directlyBuilt = builder.build(feedURL);
@ -77,8 +78,10 @@ public class SSEParserTest extends AbstractTestCase {
// XMLOutputter outputter = new XMLOutputter(); // XMLOutputter outputter = new XMLOutputter();
// outputter.setFormat(Format.getPrettyFormat()); // outputter.setFormat(Format.getPrettyFormat());
// outputter.output(directlyBuilt, new FileOutputStream("c:\\cygwin\\tmp\\sync-direct.xml")); // outputter.output(directlyBuilt, new
// outputter.output(parsedAndGenerated, new FileOutputStream("c:\\cygwin\\tmp\\sync-pg.xml")); // FileOutputStream("c:\\cygwin\\tmp\\sync-direct.xml"));
// outputter.output(parsedAndGenerated, new
// FileOutputStream("c:\\cygwin\\tmp\\sync-pg.xml"));
assertDocumentsEqual(directlyBuilt, parsedAndGenerated); assertDocumentsEqual(directlyBuilt, parsedAndGenerated);
} }
@ -115,8 +118,8 @@ public class SSEParserTest extends AbstractTestCase {
} }
private boolean equalAttributes(final Element one, final Element two, final boolean doAssert) { private boolean equalAttributes(final Element one, final Element two, final boolean doAssert) {
final List attrs1 = one.getAttributes(); final List<Attribute> attrs1 = one.getAttributes();
final List attrs2 = two.getAttributes(); final List<Attribute> attrs2 = two.getAttributes();
boolean equal = nullEqual(attrs1, attrs2); boolean equal = nullEqual(attrs1, attrs2);
if (doAssert) { if (doAssert) {
@ -128,9 +131,9 @@ public class SSEParserTest extends AbstractTestCase {
} }
if (equal) { if (equal) {
for (final Iterator oneIter = attrs1.iterator(); oneIter.hasNext();) { for (final Object element : attrs1) {
// compare the attributes in an order insensitive way // compare the attributes in an order insensitive way
final Attribute a1 = (Attribute) oneIter.next(); final Attribute a1 = (Attribute) element;
final Attribute a2 = findAttribute(a1.getName(), attrs2); final Attribute a2 = findAttribute(a1.getName(), attrs2);
equal = a2 != null; equal = a2 != null;
@ -165,9 +168,8 @@ public class SSEParserTest extends AbstractTestCase {
return equal; return equal;
} }
private Attribute findAttribute(final String name, final List attrs) { private Attribute findAttribute(final String name, final List<Attribute> attrs) {
for (final Iterator attrIter = attrs.iterator(); attrIter.hasNext();) { for (final Attribute a : attrs) {
final Attribute a = (Attribute) attrIter.next();
if (a.getName().equalsIgnoreCase(name)) { if (a.getName().equalsIgnoreCase(name)) {
return a; return a;
} }
@ -176,8 +178,8 @@ public class SSEParserTest extends AbstractTestCase {
} }
private void asserEqualContent(final Element one, final Element two) { private void asserEqualContent(final Element one, final Element two) {
final List oneContent = one.getContent(); final List<Content> oneContent = one.getContent();
final List twoContent = two.getContent(); final List<Content> twoContent = two.getContent();
if (bothNull(oneContent, twoContent)) { if (bothNull(oneContent, twoContent)) {
return; return;
} }
@ -186,15 +188,13 @@ public class SSEParserTest extends AbstractTestCase {
assertEqualAttributes(one, two); assertEqualAttributes(one, two);
// scan through the content to make sure each element is equal // scan through the content to make sure each element is equal
for (final Iterator oneIter = oneContent.iterator(); oneIter.hasNext();) { for (final Object content1 : oneContent) {
final Object content1 = oneIter.next();
if (content1 instanceof Element) { if (content1 instanceof Element) {
final Element e1 = (Element) content1; final Element e1 = (Element) content1;
boolean foundEqual = false; boolean foundEqual = false;
final List messages = new ArrayList(); final ArrayList<String> messages = new ArrayList<String>();
for (final Iterator twoIter = twoContent.iterator(); twoIter.hasNext();) { for (final Object o : twoContent) {
final Object o = twoIter.next();
if (o instanceof Element) { if (o instanceof Element) {
final Element e2 = (Element) o; final Element e2 = (Element) o;
@ -233,13 +233,13 @@ public class SSEParserTest extends AbstractTestCase {
public void xtestV5() throws Exception { public void xtestV5() throws Exception {
final File feed = new File(getTestFile("xml/v/v5.xml")); final File feed = new File(getTestFile("xml/v/v5.xml"));
final SyndFeedInput input = new SyndFeedInput(); final SyndFeedInput input = new SyndFeedInput();
final SyndFeed syndfeed = input.build(new XmlReader(feed.toURL())); final SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));
final List entries = syndfeed.getEntries(); final List<SyndEntry> entries = syndfeed.getEntries();
final Iterator it = entries.iterator(); final Iterator<SyndEntry> it = entries.iterator();
for (int id = 101; it.hasNext() && id <= 113; id++) { for (int id = 101; it.hasNext() && id <= 113; id++) {
final SyndEntry entry = (SyndEntry) it.next(); final SyndEntry entry = it.next();
final Sync sync = (Sync) entry.getModule(SSEModule.SSE_SCHEMA_URI); final Sync sync = (Sync) entry.getModule(SSEModule.SSE_SCHEMA_URI);
assertEquals(String.valueOf(id), sync.getId()); assertEquals(String.valueOf(id), sync.getId());
@ -254,16 +254,16 @@ public class SSEParserTest extends AbstractTestCase {
for (int ep = 1; ep <= 2; ep++) { for (int ep = 1; ep <= 2; ep++) {
for (int i = 100; i < 102; i++) { for (int i = 100; i < 102; i++) {
final SyndEntry entry = (SyndEntry) it.next(); final SyndEntry entry = it.next();
final Sync sync = (Sync) entry.getModule(SSEModule.SSE_SCHEMA_URI); final Sync sync = (Sync) entry.getModule(SSEModule.SSE_SCHEMA_URI);
final String id = sync.getId(); final String id = sync.getId();
assertEquals("ep" + ep + "." + i, id); assertEquals("ep" + ep + "." + i, id);
if (id.equals("ep1.100")) { if (id.equals("ep1.100")) {
final List conflicts = sync.getConflicts(); final List<Conflict> conflicts = sync.getConflicts();
assertNotNull(conflicts); assertNotNull(conflicts);
final Conflict conflict = (Conflict) conflicts.get(0); final Conflict conflict = conflicts.get(0);
final Item conflictItem = conflict.getItem(); final Item conflictItem = conflict.getItem();
assertEquals(conflictItem.getTitle(), "Phish - Coventry Live (the last *good* concert)"); assertEquals(conflictItem.getTitle(), "Phish - Coventry Live (the last *good* concert)");

View file

@ -9,10 +9,10 @@ package org.rometools.feed.module.yahooweather.io;
import java.io.File; import java.io.File;
import junit.framework.Assert;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.junit.Assert;
import org.rometools.feed.module.AbstractTestCase; import org.rometools.feed.module.AbstractTestCase;
import org.rometools.feed.module.yahooweather.YWeatherModule; import org.rometools.feed.module.yahooweather.YWeatherModule;

View file

@ -55,9 +55,9 @@ public class WeatherModuleParserTest extends AbstractTestCase {
} }
final SyndFeed feed = input.build(testFiles[h]); final SyndFeed feed = input.build(testFiles[h]);
final List entries = feed.getEntries(); final List<SyndEntry> entries = feed.getEntries();
for (int i = 0; i < entries.size(); i++) { for (int i = 0; i < entries.size(); i++) {
final SyndEntry entry = (SyndEntry) entries.get(i); final SyndEntry entry = entries.get(i);
System.out.println(entry.getModules().size()); System.out.println(entry.getModules().size());
for (int j = 0; j < entry.getModules().size(); j++) { for (int j = 0; j < entry.getModules().size(); j++) {
System.out.println(entry.getModules().get(j).getClass()); System.out.println(entry.getModules().get(j).getClass());