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 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 List values;
private List<CustomTag> values;
/** Creates a new instance of CustomTagsImpl */
public CustomTagsImpl() {
}
@Override
public List getValues() {
values = values == null ? new ArrayList() : values;
public List<CustomTag> getValues() {
values = values == null ? new ArrayList<CustomTag>() : values;
return values;
}
@Override
public void setValues(final List values) {
public void setValues(final List<CustomTag> values) {
this.values = values;
}
@Override
public void copyFrom(final CopyFrom object) {
final CustomTags ct = (CustomTags) object;
values = new ArrayList(ct.getValues());
values = new ArrayList<CustomTag>(ct.getValues());
}
@Override
public Object clone() {
final CustomTagsImpl cti = new CustomTagsImpl();
cti.values = new ArrayList(values);
cti.values = new ArrayList<CustomTag>(values);
return cti;
}

View file

@ -24,8 +24,10 @@ import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.jdom2.Element;
import org.jdom2.Namespace;
import org.rometools.feed.module.base.CustomTag;
import org.rometools.feed.module.base.CustomTagImpl;
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>
*/
public class CustomTagGenerator implements ModuleGenerator {
static final HashSet NAMESPACES = new HashSet();
static final HashSet<Namespace> NAMESPACES = new HashSet<Namespace>();
static {
NAMESPACES.add(CustomTagParser.NS);
@ -58,7 +61,7 @@ public class CustomTagGenerator implements ModuleGenerator {
}
@Override
public java.util.Set getNamespaces() {
public Set<Namespace> getNamespaces() {
return NAMESPACES;
}
@ -68,11 +71,11 @@ public class CustomTagGenerator implements ModuleGenerator {
return;
}
final List tags = ((CustomTags) module).getValues();
final Iterator it = tags.iterator();
final List<CustomTag> tags = ((CustomTags) module).getValues();
final Iterator<CustomTag> it = tags.iterator();
while (it.hasNext()) {
final CustomTag tag = (CustomTag) it.next();
final CustomTag tag = it.next();
if (tag.getValue() instanceof DateTimeRange) {
final DateTimeRange dtr = (DateTimeRange) tag.getValue();

View file

@ -32,6 +32,7 @@ import java.util.logging.Logger;
import org.jdom2.Element;
import org.jdom2.Namespace;
import org.rometools.feed.module.base.CustomTag;
import org.rometools.feed.module.base.CustomTagImpl;
import org.rometools.feed.module.base.CustomTags;
import org.rometools.feed.module.base.CustomTagsImpl;
@ -59,11 +60,11 @@ public class CustomTagParser implements ModuleParser {
@Override
public Module parse(final Element element, final Locale locale) {
final CustomTags module = new CustomTagsImpl();
final ArrayList tags = new ArrayList();
final List elements = element.getChildren();
final Iterator it = elements.iterator();
final ArrayList<CustomTag> tags = new ArrayList<CustomTag>();
final List<Element> elements = element.getChildren();
final Iterator<Element> it = elements.iterator();
while (it.hasNext()) {
final Element child = (Element) it.next();
final Element child = it.next();
if (child.getNamespace().equals(NS)) {
final String type = child.getAttributeValue("type");
try {
@ -95,7 +96,7 @@ public class CustomTagParser implements ModuleParser {
try {
tags.add(new CustomTagImpl(child.getName(), new DateTimeRange(GoogleBaseParser.LONG_DT_FMT.parse(child
.getChild("start", CustomTagParser.NS).getText().trim()), GoogleBaseParser.LONG_DT_FMT.parse(child
.getChild("end", CustomTagParser.NS).getText().trim()))));
.getChild("end", CustomTagParser.NS).getText().trim()))));
} catch (final Exception e) {
log.log(Level.WARNING, "Unable to parse date type on " + child.getName(), e);
}

View file

@ -84,17 +84,16 @@ public class GoogleBaseGenerator implements ModuleGenerator {
}
@Override
public Set getNamespaces() {
final HashSet set = new HashSet();
public Set<Namespace> getNamespaces() {
final HashSet<Namespace> set = new HashSet<Namespace>();
set.add(GoogleBaseGenerator.NS);
return set;
}
@Override
public void generate(final Module module, final Element element) {
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;
for (final PropertyDescriptor pd : pds) {

View file

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

View file

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

View file

@ -47,7 +47,9 @@ import java.util.HashMap;
* @version $Revision: 1.1 $
*/
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 CHECK = new PaymentTypeEnumeration("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) {
return (PaymentTypeEnumeration) lookup.get(value.toUpperCase());
return lookup.get(value.toUpperCase());
}
@Override

View file

@ -139,7 +139,7 @@ public class ShippingType implements CloneableType {
/**
* 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
*/
@ -184,7 +184,7 @@ public class ShippingType implements CloneableType {
* @return ServiceEnumeration or null.
*/
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 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 HashSet NAMESPACES = new HashSet();
private static final HashSet<Namespace> NAMESPACES = new HashSet<Namespace>();
static {
NAMESPACES.add(RSS1);
NAMESPACES.add(RSS2);
@ -90,7 +90,7 @@ public class CCModuleGenerator implements ModuleGenerator {
}
@Override
public Set getNamespaces() {
public Set<Namespace> getNamespaces() {
return NAMESPACES;
}

View file

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

View file

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

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>
*/
public class License {
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[] {
Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION });
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) {
License found = (License) License.lookupLicense.get(uri);
License found = License.lookupLicense.get(uri);
// 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
// current licenses, then make a new one with the same permissions.
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) {
final String key = (String) it.next();
final String key = it.next();
try {
if (key.startsWith(CC_START)) {
final String licensePath = key.substring(CC_START.length(), key.length());
final StringTokenizer tok = new StringTokenizer(licensePath, "/");
final String license = tok.nextToken();
final String version = tok.nextToken();
// final String version = tok.nextToken();
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());
}
}
@ -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) {
found = new License(uri, null, null);
}
@ -169,7 +171,7 @@ public class License {
}
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 DISTRIBUTION = new Behaviour("http://web.resource.org/cc/Distribution");
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) {
return (Behaviour) Behaviour.lookup.get(uri);
return Behaviour.lookup.get(uri);
}
@Override

View file

@ -43,8 +43,11 @@ package org.rometools.feed.module.content;
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 $
* @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 String contentAbout;
private String contentValueParseType;
private List contentValueNamespace;
private List<Namespace> contentValueNamespace;
private String contentResource;
/** Creates a new instance of ContentItem */
@ -111,11 +114,11 @@ public class ContentItem implements Cloneable {
this.contentValueParseType = contentValueParseType;
}
public List getContentValueNamespaces() {
public List<Namespace> getContentValueNamespaces() {
return contentValueNamespace;
}
public void setContentValueNamespaces(final List contentValueNamespace) {
public void setContentValueNamespaces(final List<Namespace> 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>
*/
public interface ContentModule extends Module {
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#";
@ -57,14 +58,14 @@ public interface ContentModule extends Module {
*
* @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.
*
* @return List of content Strings
*/
public void setEncodeds(List encodeds);
public void setEncodeds(List<String> encodeds);
@Override
public String getUri();
@ -77,7 +78,7 @@ public interface ContentModule extends Module {
* @see com.totsp.xml.syndication.content.ContentItem
* @return List of ContentItems.
*/
public List getContentItems();
public List<ContentItem> getContentItems();
/**
* 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
* @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
*/
public List getContents();
public List<String> getContents();
/**
* Sets a List of Strings containing whatever new or original syntax items are in the element.
*
* @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 com.sun.syndication.feed.CopyFrom;
import com.sun.syndication.feed.module.ModuleImpl;
/**
* @version $Revision: 1.4 $
* @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 List encodeds;
private List contents;
private List contentItems;
private List<String> encodeds;
private List<String> contents;
private List<ContentItem> contentItems;
public ContentModuleImpl() {
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);
}
@Override
public List getEncodeds() {
encodeds = encodeds == null ? new ArrayList() : encodeds;
public List<String> getEncodeds() {
encodeds = encodeds == null ? new ArrayList<String>() : encodeds;
return encodeds;
}
@Override
public void setEncodeds(final List encodeds) {
public void setEncodeds(final List<String> encodeds) {
this.encodeds = encodeds;
}
@ -94,24 +94,24 @@ public class ContentModuleImpl extends com.sun.syndication.feed.module.ModuleImp
}
@Override
public List getContentItems() {
contentItems = contentItems == null ? new ArrayList() : contentItems;
public List<ContentItem> getContentItems() {
contentItems = contentItems == null ? new ArrayList<ContentItem>() : contentItems;
return contentItems;
}
@Override
public void setContentItems(final List list) {
public void setContentItems(final List<ContentItem> list) {
contentItems = list;
}
@Override
public List getContents() {
contents = contents == null ? new ArrayList() : contents;
public List<String> getContents() {
contents = contents == null ? new ArrayList<String>() : contents;
return contents;
}
@Override
public void setContents(final List contents) {
public void setContents(final List<String> 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>
*/
public class ContentModuleGenerator implements com.sun.syndication.io.ModuleGenerator {
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 Set NAMESPACES;
private static final Set<Namespace> NAMESPACES;
static {
final Set nss = new HashSet();
final Set<Namespace> nss = new HashSet<Namespace>();
nss.add(CONTENT_NS);
NAMESPACES = Collections.unmodifiableSet(nss);
}
@ -91,9 +92,8 @@ public class ContentModuleGenerator implements com.sun.syndication.io.ModuleGene
final ContentModule cm = (ContentModule) module;
final List encodeds = cm.getEncodeds();
final List<String> encodeds = cm.getEncodeds();
//
if (encodeds != null) {
System.out.println(cm.getEncodeds().size());
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) {
final Element items = new Element("items", CONTENT_NS);
@ -109,7 +109,7 @@ public class ContentModuleGenerator implements com.sun.syndication.io.ModuleGene
items.addContent(bag);
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 item = new Element("item", CONTENT_NS);
@ -144,14 +144,14 @@ public class ContentModuleGenerator implements com.sun.syndication.io.ModuleGene
}
if (contentItem.getContentValueNamespaces() != null) {
final List namespaces = contentItem.getContentValueNamespaces();
final List<Namespace> namespaces = contentItem.getContentValueNamespaces();
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++) {
detached.add(((Content) contentItem.getContentValueDOM().get(c)).clone().detach());
@ -190,7 +190,7 @@ public class ContentModuleGenerator implements com.sun.syndication.io.ModuleGene
}
@Override
public java.util.Set getNamespaces() {
public Set<Namespace> getNamespaces() {
return NAMESPACES;
}
}

View file

@ -48,6 +48,7 @@ import java.util.List;
import java.util.Locale;
import org.jdom2.Attribute;
import org.jdom2.Content;
import org.jdom2.Element;
import org.jdom2.Namespace;
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) {
boolean foundSomething = false;
final ContentModule cm = new ContentModuleImpl();
final List encodeds = element.getChildren("encoded", CONTENT_NS);
final ArrayList contentStrings = new ArrayList();
final ArrayList encodedStrings = new ArrayList();
final List<Element> encodeds = element.getChildren("encoded", CONTENT_NS);
final ArrayList<String> contentStrings = new ArrayList<String>();
final ArrayList<String> encodedStrings = new ArrayList<String>();
if (encodeds.size() > 0) {
foundSomething = true;
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());
contentStrings.add(encodedElement.getText());
}
}
final ArrayList contentItems = new ArrayList();
final List items = element.getChildren("items", CONTENT_NS);
final ArrayList<ContentItem> contentItems = new ArrayList<ContentItem>();
final List<Element> items = element.getChildren("items", CONTENT_NS);
for (int i = 0; i < items.size(); i++) {
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++) {
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 format = item.getChild("format", 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) {
final StringBuffer sb = new StringBuffer();
final XMLOutputter xo = new XMLOutputter();
final List children = e.getContent();
final List<Content> children = e.getContent();
sb.append(xo.outputString(children));
return sb.toString();

View file

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

View file

@ -23,6 +23,7 @@ import java.util.List;
import java.util.Set;
import org.jdom2.Element;
import org.jdom2.Namespace;
import org.rometools.feed.module.georss.geometries.AbstractGeometry;
import org.rometools.feed.module.georss.geometries.AbstractRing;
import org.rometools.feed.module.georss.geometries.Envelope;
@ -45,10 +46,10 @@ import com.sun.syndication.io.ModuleGenerator;
*/
public class GMLGenerator implements ModuleGenerator {
private static final Set NAMESPACES;
private static final Set<Namespace> NAMESPACES;
static {
final Set nss = new HashSet();
final Set<Namespace> nss = new HashSet<Namespace>();
nss.add(GeoRSSModule.GML_NS);
NAMESPACES = Collections.unmodifiableSet(nss);
}
@ -78,13 +79,14 @@ public class GMLGenerator implements ModuleGenerator {
* @see com.sun.syndication.io.ModuleGenerator#getNamespaces()
*/
@Override
public Set getNamespaces() {
public Set<Namespace> getNamespaces() {
return NAMESPACES;
}
/*
* (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
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());
}
}
final List interiorList = ((Polygon) geometry).getInterior();
final Iterator it = interiorList.iterator();
final List<AbstractRing> interiorList = ((Polygon) geometry).getInterior();
final Iterator<AbstractRing> it = interiorList.iterator();
while (it.hasNext()) {
final AbstractRing ring = (AbstractRing) it.next();
final AbstractRing ring = it.next();
if (ring instanceof LinearRing) {
final Element interiorElement = new Element("interior", GeoRSSModule.GML_NS);
polygonElement.addContent(interiorElement);

View file

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

View file

@ -25,7 +25,8 @@ import com.sun.syndication.feed.CopyFrom;
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
* @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);
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);
}

View file

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

View file

@ -21,6 +21,7 @@ import java.util.HashSet;
import java.util.Set;
import org.jdom2.Element;
import org.jdom2.Namespace;
import org.rometools.feed.module.georss.geometries.AbstractGeometry;
import org.rometools.feed.module.georss.geometries.Point;
import org.rometools.feed.module.georss.geometries.Position;
@ -39,10 +40,10 @@ public class W3CGeoGenerator implements ModuleGenerator {
private static boolean isShort = true;
private static final Set NAMESPACES;
private static final Set<Namespace> NAMESPACES;
static {
final Set nss = new HashSet();
final Set<Namespace> nss = new HashSet<Namespace>();
nss.add(GeoRSSModule.W3CGEO_NS);
NAMESPACES = Collections.unmodifiableSet(nss);
}
@ -65,13 +66,14 @@ public class W3CGeoGenerator implements ModuleGenerator {
* @see com.sun.syndication.io.ModuleGenerator#getNamespaces()
*/
@Override
public Set getNamespaces() {
public Set<Namespace> getNamespaces() {
return NAMESPACES;
}
/*
* (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
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 AbstractRing exterior;
private List interior;
private List<AbstractRing> interior;
/** Creates a new instance of Polygon */
public Polygon() {
@ -38,11 +38,11 @@ public final class Polygon extends AbstractSurface implements Cloneable {
retval.exterior = (AbstractRing) exterior.clone();
}
if (interior != null) {
retval.interior = new ArrayList();
final Iterator it = interior.iterator();
retval.interior = new ArrayList<AbstractRing>();
final Iterator<AbstractRing> it = interior.iterator();
while (it.hasNext()) {
final AbstractRing r = (AbstractRing) it.next();
retval.interior.add(r.clone());
final AbstractRing r = it.next();
retval.interior.add((AbstractRing) r.clone());
}
}
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).
Iterator it = interior.iterator();
Iterator<AbstractRing> it = interior.iterator();
while (it.hasNext()) {
if (!pol.interior.contains(it.next())) {
return false;
@ -95,9 +95,9 @@ public final class Polygon extends AbstractSurface implements Cloneable {
*
* @return the list of border rings
*/
public List getInterior() {
public List<AbstractRing> getInterior() {
if (interior == null) {
interior = new ArrayList();
interior = new ArrayList<AbstractRing>();
}
return interior;
}
@ -116,7 +116,7 @@ public final class Polygon extends AbstractSurface implements Cloneable {
*
* @param interior the list of inner rings
*/
public void setInterior(final List interior) {
public void setInterior(final List<AbstractRing> interior) {
this.interior = interior;
}
}

View file

@ -43,7 +43,8 @@ package org.rometools.feed.module.itunes;
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 $
* @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.util.List;
import org.rometools.feed.module.itunes.types.Category;
/**
* 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
*/
public List getCategories();
public List<Category> getCategories();
/**
* 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.

View file

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

View file

@ -41,7 +41,8 @@
package org.rometools.feed.module.itunes.io;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.jdom2.Element;
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>
*/
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 {
SET.add(NS);
NAMESPACES.add(NAMESPACE);
}
/** Creates a new instance of ITunesGenerator */
@ -77,7 +79,7 @@ public class ITunesGenerator implements ModuleGenerator {
root = (Element) root.getParent();
}
root.addNamespaceDeclaration(NS);
root.addNamespaceDeclaration(NAMESPACE);
if (!(module instanceof AbstractITunesObject)) {
return;
@ -102,8 +104,9 @@ public class ITunesGenerator implements ModuleGenerator {
element.addContent(image);
}
for (final Iterator it = info.getCategories().iterator(); it.hasNext();) {
final Category cat = (Category) it.next();
final List<Category> categories = info.getCategories();
for (final Category cat : categories) {
final Element category = generateSimpleElement("category", "");
category.setAttribute("text", cat.getName());
@ -166,8 +169,8 @@ public class ITunesGenerator implements ModuleGenerator {
* @return set of Namespace objects.
*/
@Override
public java.util.Set getNamespaces() {
return SET;
public Set<Namespace> getNamespaces() {
return NAMESPACES;
}
/**
@ -181,7 +184,7 @@ public class ITunesGenerator implements ModuleGenerator {
}
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);
return element;

View file

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

View file

@ -45,8 +45,9 @@ import com.sun.syndication.io.ModuleGenerator;
//this class TBI
public class MediaModuleGenerator implements ModuleGenerator {
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 {
NAMESPACES.add(NS);
@ -58,7 +59,7 @@ public class MediaModuleGenerator implements ModuleGenerator {
}
@Override
public Set getNamespaces() {
public Set<Namespace> getNamespaces() {
return NAMESPACES;
}

View file

@ -102,12 +102,13 @@ public class MediaModuleParser implements ModuleParser {
}
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 {
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;
if (content.getAttributeValue("url") != null) {
@ -194,15 +195,15 @@ public class MediaModuleParser implements ModuleParser {
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) {
final List groups = e.getChildren("group", getNS());
final ArrayList values = new ArrayList();
final List<Element> groups = e.getChildren("group", getNS());
final ArrayList<MediaGroup> values = new ArrayList<MediaGroup>();
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));
for (int j = 0; j < g.getContents().length; j++) {
@ -217,26 +218,26 @@ public class MediaModuleParser implements ModuleParser {
values.add(g);
}
return (MediaGroup[]) values.toArray(new MediaGroup[values.size()]);
return values.toArray(new MediaGroup[values.size()]);
}
private Metadata parseMetadata(final Element e) {
final Metadata md = new Metadata();
// categories
{
final List categories = e.getChildren("category", getNS());
final ArrayList values = new ArrayList();
final List<Element> categories = e.getChildren("category", getNS());
final ArrayList<Category> values = new ArrayList<Category>();
for (int i = 0; categories != null && i < categories.size(); i++) {
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()));
} catch (final Exception 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
@ -252,14 +253,14 @@ public class MediaModuleParser implements ModuleParser {
}
// credits
{
final List credits = e.getChildren("credit", getNS());
final ArrayList values = new ArrayList();
final List<Element> credits = e.getChildren("credit", getNS());
final ArrayList<Credit> values = new ArrayList<Credit>();
for (int i = 0; credits != null && i < credits.size(); i++) {
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()));
md.setCredits((Credit[]) values.toArray(new Credit[values.size()]));
md.setCredits(values.toArray(new Credit[values.size()]));
} catch (final Exception ex) {
LOG.log(Level.WARNING, "Exception parsing credit tag.", ex);
}
@ -305,28 +306,28 @@ public class MediaModuleParser implements ModuleParser {
}
// ratings
{
final List ratings = e.getChildren("rating", getNS());
final ArrayList values = new ArrayList();
final List<Element> ratings = e.getChildren("rating", getNS());
final ArrayList<Rating> values = new ArrayList<Rating>();
for (int i = 0; ratings != null && i < ratings.size(); i++) {
try {
final Element rat = (Element) ratings.get(i);
final Element rat = ratings.get(i);
values.add(new Rating(rat.getAttributeValue("scheme"), rat.getText()));
} catch (final Exception 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
{
final List texts = e.getChildren("text", getNS());
final ArrayList values = new ArrayList();
final List<Element> texts = e.getChildren("text", getNS());
final ArrayList<Text> values = new ArrayList<Text>();
for (int i = 0; texts != null && i < texts.size(); i++) {
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 end = text.getAttributeValue("end") == null ? null : new Time(text.getAttributeValue("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
{
final List thumbnails = e.getChildren("thumbnail", getNS());
final ArrayList values = new ArrayList();
final List<Element> thumbnails = e.getChildren("thumbnail", getNS());
final ArrayList<Thumbnail> values = new ArrayList<Thumbnail>();
for (int i = 0; thumbnails != null && i < thumbnails.size(); i++) {
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 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"));
@ -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
{
@ -367,11 +368,11 @@ public class MediaModuleParser implements ModuleParser {
}
// restrictions
{
final List restrictions = e.getChildren("restriction", getNS());
final ArrayList values = new ArrayList();
final List<Element> restrictions = e.getChildren("restriction", getNS());
final ArrayList<Restriction> values = new ArrayList<Restriction>();
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;
if (r.getAttributeValue("type").equalsIgnoreCase("uri")) {
@ -392,7 +393,7 @@ public class MediaModuleParser implements ModuleParser {
values.add(value);
}
md.setRestrictions((Restriction[]) values.toArray(new Restriction[values.size()]));
md.setRestrictions(values.toArray(new Restriction[values.size()]));
}
// handle adult
{

View file

@ -21,7 +21,6 @@
*/
package org.rometools.feed.module.mediarss.io;
import java.util.List;
import java.util.Locale;
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.
* <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.
* @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 Namespace defaultNS = rssRoot.getNamespace();
final List additionalNSs = rssRoot.getAdditionalNamespaces();
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

View file

@ -58,7 +58,7 @@ import com.sun.syndication.io.ModuleGenerator;
public class Generator implements ModuleGenerator {
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";
static {
NAMESPACES.add(NS);
@ -94,7 +94,7 @@ public class Generator implements ModuleGenerator {
}
@Override
public Set getNamespaces() {
public Set<Namespace> getNamespaces() {
return Generator.NAMESPACES;
}

View file

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

View file

@ -41,6 +41,7 @@
package org.rometools.feed.module.slash.io;
import java.util.HashSet;
import java.util.Set;
import org.jdom2.Element;
import org.jdom2.Namespace;
@ -57,7 +58,7 @@ import com.sun.syndication.io.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 */
public SlashModuleGenerator() {
@ -93,15 +94,15 @@ public class SlashModuleGenerator implements ModuleGenerator {
}
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);
return element;
}
@Override
public java.util.Set getNamespaces() {
final HashSet set = new HashSet();
set.add(SlashModuleGenerator.NS);
public Set<Namespace> getNamespaces() {
final HashSet<Namespace> set = new HashSet<Namespace>();
set.add(SlashModuleGenerator.NAMESPACE);
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.
*
* <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>
*
* @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.
* <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
* operation and should not be called frequently!
* This method will take a SyndFeed object with a SimpleListExtension on it and populate the
* entries with current SleEntry values for sorting and grouping. <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 operation and should not be called frequently!
*/
public static void initializeForSorting(final SyndFeed feed) throws FeedException {
final List syndEntries = feed.getEntries();
@ -163,7 +165,6 @@ public class SleUtility {
* performs a selection sort on all the beans in the List
*/
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 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>
*/
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 {
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.
* <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
* Generics).
* It is used by the the feed generators to add their namespace definition in the root element
* of the generated document (forward-missing of Java 5.0 Generics).
* <p/>
*
* @return a set with all the URIs (JDOM Namespace elements) this module generator uses.
*/
@Override
public Set getNamespaces() {
public Set<Namespace> getNamespaces() {
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>
*/
public class ConditionCode implements Serializable {
/**
*
*/
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 TROPICAL_STORM = new ConditionCode(1, "tropical storm");
public static final ConditionCode HURRICANE = new ConditionCode(2, "hurricane");
@ -380,7 +379,7 @@ public class ConditionCode implements Serializable {
* @return a ConditionCode instance or null
*/
public static ConditionCode fromCode(final int code) {
return (ConditionCode) ConditionCode.LOOKUP.get(new Integer(code));
return ConditionCode.LOOKUP.get(new Integer(code));
}
@Override

View file

@ -50,22 +50,22 @@ public class ITunesGeneratorTest extends AbstractTestCase {
private void testFile(final String filename) throws Exception {
final File feed = new File(getTestFile(filename));
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 File outfeed = new File("target/" + feed.getName());
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());
assertEquals("Feed Level: ", syndfeed.getModule(AbstractITunesObject.URI).toString(), syndCheck.getModule(AbstractITunesObject.URI).toString());
final List syndEntries = syndfeed.getEntries();
final List syndChecks = syndCheck.getEntries();
final List<SyndEntry> syndEntries = syndfeed.getEntries();
final List<SyndEntry> syndChecks = syndCheck.getEntries();
for (int i = 0; i < syndEntries.size(); i++) {
final SyndEntry entry = (SyndEntry) syndEntries.get(i);
final SyndEntry check = (SyndEntry) syndChecks.get(i);
final SyndEntry entry = syndEntries.get(i);
final SyndEntry check = syndChecks.get(i);
System.out.println("Original: " + entry.getModule(AbstractITunesObject.URI));
System.out.println("Check: " + check.getModule(AbstractITunesObject.URI));
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;
}
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++) {
System.out.println(((SyndEntry) entries.get(i)).getModule(MediaModule.URI));
System.out.println(entries.get(i).getModule(MediaModule.URI));
}
final SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, 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++) {
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 = new BufferedWriter(new FileWriter("target/" + j + "b.txt"));
b.write("" + feed2.getEntries().get(i).getModule(MediaModule.URI));
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 {
//
/*
* //You can test with blip tv or broadcast machine String rss = "http://blip.tv/?1=1&&skin=rss";// // String rss =
* "http://openvision.tv/bm/rss.php?i=4"; // String rss =
* "http://api.search.yahoo.com/VideoSearchService/rss/videoSearch.xml?appid=yahoosearchvideorss&query=surfing&adult_ok=0"; URLConnection uc = new
* URL(rss).openConnection(); String contentType = uc.getContentEncoding(); WireFeedInput input = new WireFeedInput(); XmlReader xmlReader = new
* XmlReader(uc.getInputStream(), contentType, true); Channel chnl = (Channel)input.build(xmlReader); String feedTitle = chnl.getTitle(); String
* feedDesc = chnl.getDescription(); List items = chnl.getItems(); ListIterator li = items.listIterator(); Item item = null; Enclosure enc = null;
* MediaModule mModule = null; while (li.hasNext()) { item = (Item)li.next(); enc = (Enclosure)item.getEnclosures().get(0); mModule =
* (MediaModule)item.getModule(MediaModule.URI); List modules = item.getModules(); System.out.println("title: " + item.getTitle());
* System.out.println("module count: " + 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!"); } }
* //You can test with blip tv or broadcast machine String rss =
* "http://blip.tv/?1=1&&skin=rss";// // String rss = "http://openvision.tv/bm/rss.php?i=4";
* // String rss =
* "http://api.search.yahoo.com/VideoSearchService/rss/videoSearch.xml?appid=yahoosearchvideorss&query=surfing&adult_ok=0"
* ; URLConnection uc = new URL(rss).openConnection(); String contentType =
* uc.getContentEncoding(); WireFeedInput input = new WireFeedInput(); XmlReader xmlReader =
* new XmlReader(uc.getInputStream(), contentType, true); Channel chnl =
* (Channel)input.build(xmlReader); String feedTitle = chnl.getTitle(); String feedDesc =
* chnl.getDescription(); List items = chnl.getItems(); ListIterator li =
* items.listIterator(); Item item = null; Enclosure enc = null; MediaModule mModule = null;
* while (li.hasNext()) { item = (Item)li.next(); enc =
* (Enclosure)item.getEnclosures().get(0); mModule =
* (MediaModule)item.getModule(MediaModule.URI); List modules = item.getModules();
* System.out.println("title: " + item.getTitle()); System.out.println("module count: " +
* 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.List;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.junit.Assert;
import org.rometools.feed.module.AbstractTestCase;
import org.rometools.feed.module.base.CustomTag;
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"));
final SyndFeed feed2 = input.build(new File("target/custom-tags-example.xml"));
final List entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = entries.get(0);
final CustomTags customTags = (CustomTags) entry.getModule(CustomTags.URI);
final List entries2 = feed2.getEntries();
final SyndEntry entry2 = (SyndEntry) entries2.get(0);
final List<SyndEntry> entries2 = feed2.getEntries();
final SyndEntry entry2 = entries2.get(0);
final CustomTags customTags2 = (CustomTags) entry2.getModule(CustomTags.URI);
final Iterator it = customTags.getValues().iterator();
final Iterator it2 = customTags2.getValues().iterator();
final Iterator<CustomTag> it = customTags.getValues().iterator();
final Iterator<CustomTag> it2 = customTags2.getValues().iterator();
while (it.hasNext()) {
final CustomTag tag = (CustomTag) it.next();
final CustomTag tag2 = (CustomTag) it2.next();
final CustomTag tag = it.next();
final CustomTag tag2 = it2.next();
System.out.println("tag1:" + tag);
System.out.println("tag2:" + tag2);
Assert.assertEquals(tag, tag2);

View file

@ -14,10 +14,10 @@ import java.util.Date;
import java.util.Iterator;
import java.util.List;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.junit.Assert;
import org.rometools.feed.module.AbstractTestCase;
import org.rometools.feed.module.base.CustomTag;
import org.rometools.feed.module.base.CustomTagImpl;
@ -50,12 +50,12 @@ public class CustomTagParserTest extends AbstractTestCase {
final SyndFeedInput input = new SyndFeedInput();
final SyndFeed feed = input.build(new File(super.getTestFile("xml/custom-tags-example.xml")));
final List entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = entries.get(0);
final CustomTags customTags = (CustomTags) entry.getModule(CustomTags.URI);
final Iterator it = customTags.getValues().iterator();
final Iterator<CustomTag> it = customTags.getValues().iterator();
while (it.hasNext()) {
final CustomTag tag = (CustomTag) it.next();
final CustomTag tag = it.next();
System.out.println(tag);
if (tag.getName().equals("language_skills")) {
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.List;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.junit.Assert;
import org.rometools.feed.module.AbstractTestCase;
import org.rometools.feed.module.base.GoogleBase;
import org.rometools.feed.module.base.GoogleBaseImpl;
@ -85,7 +85,7 @@ public class GoogleBaseGeneratorTest extends AbstractTestCase {
feed.setLink("http://rome.dev.java.net");
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;
SyndContent description;
@ -104,6 +104,7 @@ public class GoogleBaseGeneratorTest extends AbstractTestCase {
product.setCondition("New");
product.setDeliveryNotes("Insight");
// FIXME
final List modules = new ArrayList();
modules.add(vehicle);
modules.add(product);

View file

@ -11,10 +11,10 @@ import java.net.URL;
import java.util.Calendar;
import java.util.List;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.junit.Assert;
import org.rometools.feed.module.AbstractTestCase;
import org.rometools.feed.module.base.Article;
import org.rometools.feed.module.base.Course;
@ -76,9 +76,9 @@ public class GoogleBaseParserTest extends AbstractTestCase {
} catch (final Exception 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++) {
final SyndEntry entry = (SyndEntry) entries.get(i);
final SyndEntry entry = entries.get(i);
System.out.println(entry.getModules().size());
for (int j = 0; j < entry.getModules().size(); j++) {
System.out.println(entry.getModules().get(j).getClass());
@ -104,8 +104,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final SyndFeedInput input = new SyndFeedInput();
final SyndFeed feed = input.build(new File(super.getTestFile("xml/courses2.xml")));
final List entries = feed.getEntries();
SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
SyndEntry entry = entries.get(0);
Course course = (Course) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", course.getImageLinks()[0].toString());
Calendar cal = Calendar.getInstance();
@ -123,7 +123,7 @@ public class GoogleBaseParserTest extends AbstractTestCase {
this.assertEquals("Subject", new String[] { "computer science" }, course.getSubjects());
Assert.assertEquals("University", "Johnson State", course.getUniversity());
entry = (SyndEntry) entries.get(1);
entry = entries.get(1);
course = (Course) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", course.getImageLinks()[0].toString());
cal = Calendar.getInstance();
@ -150,8 +150,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final SyndFeedInput input = new SyndFeedInput();
final SyndFeed feed = input.build(new File(super.getTestFile("xml/events2.xml")));
final List entries = feed.getEntries();
SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
SyndEntry entry = entries.get(0);
Event event = (Event) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", event.getImageLinks()[0].toString());
final Calendar cal = Calendar.getInstance();
@ -167,7 +167,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
PaymentTypeEnumeration.VISA }, event.getPaymentAccepted());
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);
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 Percentage", new Float(8.25), event.getTaxPercent());
entry = (SyndEntry) entries.get(1);
entry = entries.get(1);
event = (Event) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image2.jpg", event.getImageLinks()[0].toString());
cal.setTimeInMillis(0);
@ -195,7 +196,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
PaymentTypeEnumeration.VISA }, event.getPaymentAccepted());
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);
Assert.assertEquals("Start Time", cal.getTime(), event.getEventDateRange().getStart());
@ -219,8 +221,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/housing2.xml")));
final List entries = feed.getEntries();
SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
SyndEntry entry = entries.get(0);
Housing module = (Housing) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
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 Percentage", new Float(8.25), module.getTaxPercent());
entry = (SyndEntry) entries.get(1);
entry = entries.get(1);
module = (Housing) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image2.jpg", module.getImageLinks()[0].toString());
cal.set(2008, 11, 20, 0, 0, 0);
@ -283,8 +285,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/jobs2.xml")));
final List entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = entries.get(0);
final Job module = (Job) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0);
@ -313,8 +315,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/news2.xml")));
final List entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = entries.get(0);
final Article module = (Article) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2007, 2, 20, 0, 0, 0);
@ -337,8 +339,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/travel2.xml")));
final List entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = entries.get(0);
final Travel module = (Travel) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0);
@ -375,8 +377,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/personals2.xml")));
final List entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = entries.get(0);
final Person module = (Person) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0);
@ -403,8 +405,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/products2.xml")));
final List entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = entries.get(0);
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());
cal.set(2005, 11, 20, 0, 0, 0);
@ -442,8 +444,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/research2.xml")));
final List entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = entries.get(0);
final ScholarlyArticle module = (ScholarlyArticle) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0);
@ -466,8 +468,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/reviews2.xml")));
final List entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = entries.get(0);
final Review module = (Review) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0);
@ -493,8 +495,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/services2.xml")));
final List entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = entries.get(0);
final Service module = (Service) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0);
@ -523,8 +525,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/vehicles2.xml")));
final List entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = entries.get(0);
final Vehicle module = (Vehicle) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
cal.set(2005, 11, 20, 0, 0, 0);
@ -557,8 +559,8 @@ public class GoogleBaseParserTest extends AbstractTestCase {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
final SyndFeed feed = input.build(new File(super.getTestFile("xml/wanted2.xml")));
final List entries = feed.getEntries();
final SyndEntry entry = (SyndEntry) entries.get(0);
final List<SyndEntry> entries = feed.getEntries();
final SyndEntry entry = entries.get(0);
final Wanted module = (Wanted) entry.getModule(GoogleBase.URI);
Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
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()));
final SyndFeed feed2 = input.build(new File("target/" + testFiles[h].getName()));
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 CreativeCommons base = (CreativeCommons) entry.getModule(CreativeCommons.URI);
// / FIXME
// final CreativeCommons base = (CreativeCommons)
// entry.getModule(CreativeCommons.URI);
final CreativeCommons base2 = (CreativeCommons) entry2.getModule(CreativeCommons.URI);
System.out.println(base2);
// FIXME
// 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());
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);
System.out.println(fMod);
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);
System.out.println("\nEntry:");
System.out.println(eMod);

View file

@ -46,9 +46,9 @@ public class ContentModuleGeneratorTest extends AbstractTestCase {
System.out.println("testGenerate");
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 ContentModule module = (ContentModule) entry.getModule(ContentModule.URI);
entry.getModule(ContentModule.URI);
final SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, new java.io.PrintWriter(System.out));
}

View file

@ -19,7 +19,8 @@ import junit.framework.TestCase;
public class ContentModuleImplTest extends TestCase {
private final ContentModuleImpl module = new ContentModuleImpl();
public static ArrayList contentItems = new ArrayList();
public static ArrayList<ContentItem> contentItems = new ArrayList<ContentItem>();
static {
ContentItem item = new ContentItem();
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.
*/
public void testEncodeds() {
final ArrayList encodeds = new ArrayList();
final ArrayList<String> encodeds = new ArrayList<String>();
encodeds.add("Foo");
encodeds.add("Bar");
encodeds.add("Baz");
module.setEncodeds(encodeds);
final List check = module.getEncodeds();
final List<String> check = module.getEncodeds();
assertTrue(check.equals(encodeds));
}
@ -105,12 +106,12 @@ public class ContentModuleImplTest extends TestCase {
*/
public void testContents() {
System.out.println("testContents");
final ArrayList contents = new ArrayList();
final ArrayList<String> contents = new ArrayList<String>();
contents.add("Foo");
contents.add("Bar");
contents.add("Baz");
module.setContents(contents);
final List check = module.getContents();
final List<String> check = module.getContents();
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 {
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 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++) {
final ContentItem item = (ContentItem) ContentModuleImplTest.contentItems.get(i);
// TODO fix this.
// FIXME
// final ContentItem item = ContentModuleImplTest.contentItems.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 List entries = feed.getEntries();
final List<SyndEntry> entries = feed.getEntries();
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 Position position = geoRSSModule.getPosition();
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.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;
SyndContent description;
@ -197,9 +197,9 @@ public class RssTest extends TestCase {
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++) {
entry = (SyndEntry) entries.get(i);
entry = entries.get(i);
geoRSSModule = (SimpleModuleImpl) GeoRSSUtils.getGeoRSS(entry);
final LineString lineString = (LineString) geoRSSModule.getGeometry();
positionList = lineString.getPositionList();

View file

@ -54,22 +54,22 @@ public class ITunesGeneratorTest extends AbstractTestCase {
private void testFile(final String filename) throws Exception {
final File feed = new File(getTestFile(filename));
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 File outfeed = new File(feed.getAbsolutePath() + ".output");
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());
assertEquals("Feed Level: ", syndfeed.getModule(AbstractITunesObject.URI).toString(), syndCheck.getModule(AbstractITunesObject.URI).toString());
final List syndEntries = syndfeed.getEntries();
final List syndChecks = syndCheck.getEntries();
final List<SyndEntry> syndEntries = syndfeed.getEntries();
final List<SyndEntry> syndChecks = syndCheck.getEntries();
for (int i = 0; i < syndEntries.size(); i++) {
final SyndEntry entry = (SyndEntry) syndEntries.get(i);
final SyndEntry check = (SyndEntry) syndChecks.get(i);
final SyndEntry entry = syndEntries.get(i);
final SyndEntry check = syndChecks.get(i);
System.out.println("Original: " + entry.getModule(AbstractITunesObject.URI));
System.out.println("Check: " + check.getModule(AbstractITunesObject.URI));
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.itunes.io.ITunesGenerator;
import org.rometools.feed.module.itunes.types.Category;
import com.sun.syndication.feed.module.Module;
import com.sun.syndication.feed.synd.SyndEntry;
@ -61,7 +60,7 @@ public class ITunesParserTest extends AbstractTestCase {
public void testParse() throws Exception {
File feed = new File(getTestFile("xml/leshow.xml"));
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 FeedInformationImpl feedInfo = (FeedInformationImpl) module;
@ -69,28 +68,28 @@ public class ITunesParserTest extends AbstractTestCase {
assertEquals("owner", "Harry Shearer", feedInfo.getOwnerName());
assertEquals("email", "", feedInfo.getOwnerEmailAddress());
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(
"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.",
feedInfo.getSummary());
List entries = syndfeed.getEntries();
Iterator it = entries.iterator();
List<SyndEntry> entries = syndfeed.getEntries();
Iterator<SyndEntry> it = entries.iterator();
while (it.hasNext()) {
final SyndEntry entry = (SyndEntry) it.next();
final SyndEntry entry = it.next();
final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
System.out.println(entryInfo);
}
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();
it = entries.iterator();
while (it.hasNext()) {
final SyndEntry entry = (SyndEntry) it.next();
final SyndEntry entry = it.next();
final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
System.out.println(entryInfo.getDuration());
}

View file

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

View file

@ -44,29 +44,30 @@ public class GeneratorTest extends AbstractTestCase {
final SyndFeedInput input = new SyndFeedInput();
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++) {
System.out.println(((SyndEntry) entries.get(i)).getModule(PhotocastModule.URI));
System.out.println(entries.get(i).getModule(PhotocastModule.URI));
}
final SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, 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++) {
assertEquals("Module test", ((SyndEntry) entries.get(i)).getModule(PhotocastModule.URI),
((SyndEntry) entries2.get(i)).getModule(PhotocastModule.URI));
assertEquals("Module test", entries.get(i).getModule(PhotocastModule.URI), 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() {
// 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() {
// TODO add your test code.

View file

@ -14,6 +14,7 @@ import junit.framework.Test;
import junit.framework.TestSuite;
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.SyndFeed;
@ -43,21 +44,24 @@ public class GroupAndSortTest extends AbstractTestCase {
final SyndFeed feed = input.build(new File(super.getTestFile("data/bookexample.xml")));
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);
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);
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.setTitle("ZZZZZ");
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());
for (int i = 0; i < sortedEntries.size(); i++) {
entry = (SyndEntry) sortedEntries.get(i);
@ -74,14 +78,14 @@ public class GroupAndSortTest extends AbstractTestCase {
entry = (SyndEntry) sortedEntries.get(1);
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);
System.out.println(entry.getTitle());
assertEquals("Horror Stories, vol 16", entry.getTitle());
entry = (SyndEntry) sortedEntries.get(1);
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);
System.out.println(entry.getTitle());
assertEquals("Horror Stories, vol 16", entry.getTitle());

View file

@ -18,6 +18,7 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.jdom2.Attribute;
import org.jdom2.Content;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.input.SAXBuilder;
@ -63,7 +64,7 @@ public class SSEParserTest extends AbstractTestCase {
}
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
final SAXBuilder builder = new SAXBuilder();
final Document directlyBuilt = builder.build(feedURL);
@ -77,8 +78,10 @@ public class SSEParserTest extends AbstractTestCase {
// XMLOutputter outputter = new XMLOutputter();
// outputter.setFormat(Format.getPrettyFormat());
// outputter.output(directlyBuilt, new FileOutputStream("c:\\cygwin\\tmp\\sync-direct.xml"));
// outputter.output(parsedAndGenerated, new FileOutputStream("c:\\cygwin\\tmp\\sync-pg.xml"));
// outputter.output(directlyBuilt, new
// FileOutputStream("c:\\cygwin\\tmp\\sync-direct.xml"));
// outputter.output(parsedAndGenerated, new
// FileOutputStream("c:\\cygwin\\tmp\\sync-pg.xml"));
assertDocumentsEqual(directlyBuilt, parsedAndGenerated);
}
@ -115,8 +118,8 @@ public class SSEParserTest extends AbstractTestCase {
}
private boolean equalAttributes(final Element one, final Element two, final boolean doAssert) {
final List attrs1 = one.getAttributes();
final List attrs2 = two.getAttributes();
final List<Attribute> attrs1 = one.getAttributes();
final List<Attribute> attrs2 = two.getAttributes();
boolean equal = nullEqual(attrs1, attrs2);
if (doAssert) {
@ -128,9 +131,9 @@ public class SSEParserTest extends AbstractTestCase {
}
if (equal) {
for (final Iterator oneIter = attrs1.iterator(); oneIter.hasNext();) {
for (final Object element : attrs1) {
// 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);
equal = a2 != null;
@ -165,9 +168,8 @@ public class SSEParserTest extends AbstractTestCase {
return equal;
}
private Attribute findAttribute(final String name, final List attrs) {
for (final Iterator attrIter = attrs.iterator(); attrIter.hasNext();) {
final Attribute a = (Attribute) attrIter.next();
private Attribute findAttribute(final String name, final List<Attribute> attrs) {
for (final Attribute a : attrs) {
if (a.getName().equalsIgnoreCase(name)) {
return a;
}
@ -176,8 +178,8 @@ public class SSEParserTest extends AbstractTestCase {
}
private void asserEqualContent(final Element one, final Element two) {
final List oneContent = one.getContent();
final List twoContent = two.getContent();
final List<Content> oneContent = one.getContent();
final List<Content> twoContent = two.getContent();
if (bothNull(oneContent, twoContent)) {
return;
}
@ -186,15 +188,13 @@ public class SSEParserTest extends AbstractTestCase {
assertEqualAttributes(one, two);
// scan through the content to make sure each element is equal
for (final Iterator oneIter = oneContent.iterator(); oneIter.hasNext();) {
final Object content1 = oneIter.next();
for (final Object content1 : oneContent) {
if (content1 instanceof Element) {
final Element e1 = (Element) content1;
boolean foundEqual = false;
final List messages = new ArrayList();
for (final Iterator twoIter = twoContent.iterator(); twoIter.hasNext();) {
final Object o = twoIter.next();
final ArrayList<String> messages = new ArrayList<String>();
for (final Object o : twoContent) {
if (o instanceof Element) {
final Element e2 = (Element) o;
@ -233,13 +233,13 @@ public class SSEParserTest extends AbstractTestCase {
public void xtestV5() throws Exception {
final File feed = new File(getTestFile("xml/v/v5.xml"));
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 Iterator it = entries.iterator();
final List<SyndEntry> entries = syndfeed.getEntries();
final Iterator<SyndEntry> it = entries.iterator();
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);
assertEquals(String.valueOf(id), sync.getId());
@ -254,16 +254,16 @@ public class SSEParserTest extends AbstractTestCase {
for (int ep = 1; ep <= 2; ep++) {
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 String id = sync.getId();
assertEquals("ep" + ep + "." + i, id);
if (id.equals("ep1.100")) {
final List conflicts = sync.getConflicts();
final List<Conflict> conflicts = sync.getConflicts();
assertNotNull(conflicts);
final Conflict conflict = (Conflict) conflicts.get(0);
final Conflict conflict = conflicts.get(0);
final Item conflictItem = conflict.getItem();
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 junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.junit.Assert;
import org.rometools.feed.module.AbstractTestCase;
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 List entries = feed.getEntries();
final List<SyndEntry> entries = feed.getEntries();
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());
for (int j = 0; j < entry.getModules().size(); j++) {
System.out.println(entry.getModules().get(j).getClass());