http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Atom10Generator.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Atom10Generator.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Atom10Generator.java index 6228b21..82537b7 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Atom10Generator.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Atom10Generator.java @@ -16,30 +16,22 @@ */ package com.sun.syndication.io.impl; -import java.io.StringReader; -import java.util.Iterator; -import java.util.List; - +import com.sun.syndication.feed.WireFeed; +import com.sun.syndication.feed.atom.*; +import com.sun.syndication.io.FeedException; +import com.sun.syndication.io.WireFeedOutput; import org.jdom2.Attribute; import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.Namespace; import org.jdom2.input.SAXBuilder; +import org.jdom2.output.XMLOutputter; -import com.sun.syndication.feed.WireFeed; -import com.sun.syndication.feed.atom.Category; -import com.sun.syndication.feed.atom.Content; -import com.sun.syndication.feed.atom.Entry; -import com.sun.syndication.feed.atom.Feed; -import com.sun.syndication.feed.atom.Generator; -import com.sun.syndication.feed.atom.Link; -import com.sun.syndication.feed.atom.Person; -import com.sun.syndication.io.FeedException; -import com.sun.syndication.io.WireFeedOutput; import java.io.IOException; +import java.io.StringReader; import java.io.Writer; import java.util.ArrayList; -import org.jdom2.output.XMLOutputter; +import java.util.List; /** * Feed Generator for Atom @@ -103,17 +95,16 @@ public class Atom10Generator extends BaseWireFeedGenerator { } protected void addFeed(Feed feed,Element parent) throws FeedException { - Element eFeed = parent; - populateFeedHeader(feed,eFeed); - generateForeignMarkup(eFeed, (List)feed.getForeignMarkup()); - checkFeedHeaderConstraints(eFeed); - generateFeedModules(feed.getModules(),eFeed); + populateFeedHeader(feed, parent); + generateForeignMarkup(parent, (List)feed.getForeignMarkup()); + checkFeedHeaderConstraints(parent); + generateFeedModules(feed.getModules(), parent); } protected void addEntries(Feed feed,Element parent) throws FeedException { List items = feed.getEntries(); - for (int i=0;i<items.size();i++) { - addEntry((Entry)items.get(i),parent); + for (Object item : items) { + addEntry((Entry) item, parent); } checkEntriesConstraints(parent); } @@ -138,17 +129,17 @@ public class Atom10Generator extends BaseWireFeedGenerator { } List links = feed.getAlternateLinks(); - if (links != null) for (int i = 0; i < links.size(); i++) { - eFeed.addContent(generateLinkElement((Link)links.get(i))); + if (links != null) for (Object link : links) { + eFeed.addContent(generateLinkElement((Link) link)); } links = feed.getOtherLinks(); - if (links != null) for (int j = 0; j < links.size(); j++) { - eFeed.addContent(generateLinkElement((Link)links.get(j))); + if (links != null) for (Object link : links) { + eFeed.addContent(generateLinkElement((Link) link)); } List cats = feed.getCategories(); - if (cats != null) for (Iterator iter=cats.iterator(); iter.hasNext();) { - eFeed.addContent(generateCategoryElement((Category)iter.next())); + if (cats != null) for (Object cat : cats) { + eFeed.addContent(generateCategoryElement((Category) cat)); } List authors = feed.getAuthors(); @@ -162,9 +153,9 @@ public class Atom10Generator extends BaseWireFeedGenerator { List contributors = feed.getContributors(); if (contributors != null && contributors.size() > 0) { - for (int i = 0; i < contributors.size(); i++) { + for (Object contributor : contributors) { Element contributorElement = new Element("contributor", getFeedNamespace()); - fillPersonElement(contributorElement, (Person)contributors.get(i)); + fillPersonElement(contributorElement, (Person) contributor); eFeed.addContent(contributorElement); } } @@ -210,21 +201,21 @@ public class Atom10Generator extends BaseWireFeedGenerator { } List links = entry.getAlternateLinks(); if (links != null) { - for (int i = 0; i < links.size(); i++) { - eEntry.addContent(generateLinkElement((Link)links.get(i))); + for (Object link : links) { + eEntry.addContent(generateLinkElement((Link) link)); } } links = entry.getOtherLinks(); if (links != null) { - for (int i = 0; i < links.size(); i++) { - eEntry.addContent(generateLinkElement((Link)links.get(i))); + for (Object link : links) { + eEntry.addContent(generateLinkElement((Link) link)); } } List cats = entry.getCategories(); if (cats != null) { - for (int i = 0; i < cats.size(); i++) { - eEntry.addContent(generateCategoryElement((Category)cats.get(i))); + for (Object cat : cats) { + eEntry.addContent(generateCategoryElement((Category) cat)); } } @@ -239,9 +230,9 @@ public class Atom10Generator extends BaseWireFeedGenerator { List contributors = entry.getContributors(); if (contributors != null && contributors.size() > 0) { - for (int i = 0; i < contributors.size(); i++) { + for (Object contributor : contributors) { Element contributorElement = new Element("contributor", getFeedNamespace()); - fillPersonElement(contributorElement, (Person)contributors.get(i)); + fillPersonElement(contributorElement, (Person) contributor); eEntry.addContent(contributorElement); } } @@ -397,7 +388,7 @@ public class Atom10Generator extends BaseWireFeedGenerator { if (atomType != null && (atomType.equals(Content.XHTML) || (atomType.indexOf("/xml")) != -1 || (atomType.indexOf("+xml")) != -1)) { - StringBuffer tmpDocString = new StringBuffer("<tmpdoc>"); + StringBuilder tmpDocString = new StringBuilder("<tmpdoc>"); tmpDocString.append(content.getValue()); tmpDocString.append("</tmpdoc>"); StringReader tmpDocReader = new StringReader(tmpDocString.toString());
http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Atom10Parser.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Atom10Parser.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Atom10Parser.java index ccfc237..2c9896e 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Atom10Parser.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Atom10Parser.java @@ -16,34 +16,22 @@ */ package com.sun.syndication.io.impl; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.jdom2.Document; -import org.jdom2.Element; -import org.jdom2.Namespace; -import org.jdom2.output.XMLOutputter; - import com.sun.syndication.feed.WireFeed; -import com.sun.syndication.feed.atom.Category; +import com.sun.syndication.feed.atom.*; import com.sun.syndication.feed.atom.Content; -import com.sun.syndication.feed.atom.Entry; -import com.sun.syndication.feed.atom.Feed; -import com.sun.syndication.feed.atom.Generator; -import com.sun.syndication.feed.atom.Link; -import com.sun.syndication.feed.atom.Person; import com.sun.syndication.io.FeedException; import com.sun.syndication.io.WireFeedInput; import com.sun.syndication.io.WireFeedOutput; +import org.jdom2.*; +import org.jdom2.input.SAXBuilder; +import org.jdom2.output.XMLOutputter; + import java.io.IOException; import java.io.Reader; import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.List; import java.util.regex.Pattern; -import org.jdom2.Attribute; -import org.jdom2.JDOMException; -import org.jdom2.Parent; -import org.jdom2.input.SAXBuilder; /** * Parser for Atom 1.0 @@ -239,7 +227,7 @@ public class Atom10Parser extends BaseWireFeedParser { if (att!=null) { Long val = NumberParser.parseLong(att); if (val != null) { - link.setLength(val.longValue()); + link.setLength(val); } } return link; @@ -248,8 +236,8 @@ public class Atom10Parser extends BaseWireFeedParser { // List(Elements) -> List(Link) private List parseAlternateLinks(Feed feed, Entry entry, String baseURI, List eLinks) { List links = new ArrayList(); - for (int i=0;i<eLinks.size();i++) { - Element eLink = (Element) eLinks.get(i); + for (Object eLink1 : eLinks) { + Element eLink = (Element) eLink1; Link link = parseLink(feed, entry, baseURI, eLink); if (link.getRel() == null || "".equals(link.getRel().trim()) @@ -262,8 +250,8 @@ public class Atom10Parser extends BaseWireFeedParser { private List parseOtherLinks(Feed feed, Entry entry, String baseURI, List eLinks) { List links = new ArrayList(); - for (int i=0;i<eLinks.size();i++) { - Element eLink = (Element) eLinks.get(i); + for (Object eLink1 : eLinks) { + Element eLink = (Element) eLink1; Link link = parseLink(feed, entry, baseURI, eLink); if (!"alternate".equals(link.getRel())) { links.add(link); @@ -296,8 +284,8 @@ public class Atom10Parser extends BaseWireFeedParser { // List(Elements) -> List(Persons) private List parsePersons(String baseURI, List ePersons) { List persons = new ArrayList(); - for (int i=0;i<ePersons.size();i++) { - persons.add(parsePerson(baseURI, (Element)ePersons.get(i))); + for (Object ePerson : ePersons) { + persons.add(parsePerson(baseURI, (Element) ePerson)); } return (persons.size()>0) ? persons : null; } @@ -321,13 +309,12 @@ public class Atom10Parser extends BaseWireFeedParser { // XHTML content needs special handling XMLOutputter outputter = new XMLOutputter(); List eContent = e.getContent(); - Iterator i = eContent.iterator(); - while (i.hasNext()) { - org.jdom2.Content c = (org.jdom2.Content) i.next(); + for (Object anEContent : eContent) { + org.jdom2.Content c = (org.jdom2.Content) anEContent; if (c instanceof Element) { Element eC = (Element) c; if (eC.getNamespace().equals(getAtomNamespace())) { - ((Element)c).setNamespace(Namespace.NO_NAMESPACE); + ((Element) c).setNamespace(Namespace.NO_NAMESPACE); } } } @@ -342,8 +329,8 @@ public class Atom10Parser extends BaseWireFeedParser { // List(Elements) -> List(Entries) protected List parseEntries(Feed feed, String baseURI, List eEntries) { List entries = new ArrayList(); - for (int i=0;i<eEntries.size();i++) { - entries.add(parseEntry(feed, (Element)eEntries.get(i), baseURI)); + for (Object eEntry : eEntries) { + entries.add(parseEntry(feed, (Element) eEntry, baseURI)); } return (entries.size()>0) ? entries : null; } @@ -431,8 +418,8 @@ public class Atom10Parser extends BaseWireFeedParser { private List parseCategories(String baseURI, List eCategories) { List cats = new ArrayList(); - for (int i=0;i<eCategories.size();i++) { - Element eCategory = (Element) eCategories.get(i); + for (Object eCategory1 : eCategories) { + Element eCategory = (Element) eCategory1; cats.add(parseCategory(baseURI, eCategory)); } return (cats.size()>0) ? cats : null; @@ -547,7 +534,7 @@ public class Atom10Parser extends BaseWireFeedParser { if (findAtomLink(root, "self") != null) { ret = findAtomLink(root, "self"); if (".".equals(ret) || "./".equals(ret)) ret = ""; - if (ret.indexOf("/") != -1) ret = ret.substring(0, ret.lastIndexOf("/")); + if (ret.contains("/")) ret = ret.substring(0, ret.lastIndexOf("/")); ret = resolveURI(null, root, ret); } return ret; @@ -563,12 +550,12 @@ public class Atom10Parser extends BaseWireFeedParser { String ret = null; List linksList = parent.getChildren("link", ATOM_10_NS); if (linksList != null) { - for (Iterator links = linksList.iterator(); links.hasNext(); ) { - Element link = (Element)links.next(); + for (Object aLinksList : linksList) { + Element link = (Element) aLinksList; Attribute relAtt = getAttribute(link, "rel"); Attribute hrefAtt = getAttribute(link, "href"); - if ( (relAtt == null && "alternate".equals(rel)) - || (relAtt != null && relAtt.getValue().equals(rel))) { + if ((relAtt == null && "alternate".equals(rel)) + || (relAtt != null && relAtt.getValue().equals(rel))) { ret = hrefAtt.getValue(); break; } @@ -589,14 +576,13 @@ public class Atom10Parser extends BaseWireFeedParser { if (append.startsWith("..")) { String ret = null; String[] parts = append.split("/"); - for (int i=0; i<parts.length; i++) { - if ("..".equals(parts[i])) { + for (String part : parts) { + if ("..".equals(part)) { int last = base.lastIndexOf("/"); if (last != -1) { base = base.substring(0, last); append = append.substring(3, append.length()); - } - else break; + } else break; } } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Base64.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Base64.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Base64.java index 3c86ef7..177383b 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Base64.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/Base64.java @@ -144,9 +144,9 @@ public class Base64 { } byte[] cleanEData = (byte[]) eData.clone(); int cleanELength = 0; - for (int i=0;i<eData.length;i++) { - if (eData[i]<256 && CODES[eData[i]]<64) { - cleanEData[cleanELength++] = eData[i]; + for (byte anEData : eData) { + if (anEData < 256 && CODES[anEData] < 64) { + cleanEData[cleanELength++] = anEData; } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java index 72a2b70..b4181fc 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java @@ -64,8 +64,8 @@ public abstract class BaseWireFeedGenerator implements WireFeedGenerator { } protected void generateModuleNamespaceDefs(Element root) { - for (int i = 0; i < _allModuleNamespaces.length; i++) { - root.addNamespaceDeclaration(_allModuleNamespaces[i]); + for (Namespace _allModuleNamespace : _allModuleNamespaces) { + root.addNamespaceDeclaration(_allModuleNamespace); } } @@ -113,8 +113,8 @@ public abstract class BaseWireFeedGenerator implements WireFeedGenerator { List additionalNamespaces = new java.util.ArrayList(); additionalNamespaces.addAll(list); // the duplication will prevent a ConcurrentModificationException below - for (int i = 0; i < additionalNamespaces.size(); i++) { - Namespace ns = (Namespace) additionalNamespaces.get(i); + for (Object additionalNamespace : additionalNamespaces) { + Namespace ns = (Namespace) additionalNamespace; String prefix = ns.getPrefix(); if (prefix != null && prefix.length() > 0 && !usedPrefixes.contains(prefix)) { root.removeNamespaceDeclaration(ns); @@ -128,8 +128,8 @@ public abstract class BaseWireFeedGenerator implements WireFeedGenerator { collector.add(prefix); } List kids = el.getChildren(); - for (int i = 0; i < kids.size(); i++) { - collectUsedPrefixes((Element) kids.get(i), collector); // recursion - worth it + for (Object kid : kids) { + collectUsedPrefixes((Element) kid, collector); // recursion - worth it } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/BaseWireFeedParser.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/BaseWireFeedParser.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/BaseWireFeedParser.java index ba48cef..35db418 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/BaseWireFeedParser.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/BaseWireFeedParser.java @@ -3,13 +3,12 @@ package com.sun.syndication.io.impl; import com.sun.syndication.feed.WireFeed; import com.sun.syndication.feed.module.Extendable; import com.sun.syndication.io.WireFeedParser; -import java.util.ArrayList; -import java.util.Iterator; +import org.jdom2.Attribute; import org.jdom2.Element; +import org.jdom2.Namespace; +import java.util.ArrayList; import java.util.List; -import org.jdom2.Namespace; -import org.jdom2.Attribute; /** * @author Alejandro Abdelnur @@ -74,24 +73,21 @@ public abstract class BaseWireFeedParser implements WireFeedParser { protected List extractForeignMarkup(Element e, Extendable ext, Namespace basens) { ArrayList foreignMarkup = new ArrayList(); - Iterator children = e.getChildren().iterator(); - while (children.hasNext()) { - Element elem = (Element)children.next(); - if ( - // if elemet not in the RSS namespace - !basens.equals(elem.getNamespace()) - // and elem was not handled by a module - && null == ext.getModule(elem.getNamespaceURI())) { - - // save it as foreign markup, - // but we can't detach it while we're iterating - foreignMarkup.add(elem.clone()); + for (Element elem : e.getChildren()) { + if ( + // if elemet not in the RSS namespace + !basens.equals(elem.getNamespace()) + // and elem was not handled by a module + && null == ext.getModule(elem.getNamespaceURI())) { + + // save it as foreign markup, + // but we can't detach it while we're iterating + foreignMarkup.add(elem.clone()); } } // Now we can detach the foreign markup elements - Iterator fm = foreignMarkup.iterator(); - while (fm.hasNext()) { - Element elem = (Element)fm.next(); + for (Object aForeignMarkup : foreignMarkup) { + Element elem = (Element) aForeignMarkup; elem.detach(); } return foreignMarkup; http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/DCModuleGenerator.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/DCModuleGenerator.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/DCModuleGenerator.java index b96d3e3..2595b1f 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/DCModuleGenerator.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/DCModuleGenerator.java @@ -101,8 +101,8 @@ public class DCModuleGenerator implements ModuleGenerator { element.addContent(generateSimpleElementList("creator", dcModule.getCreators())); } List subjects = dcModule.getSubjects(); - for (int i = 0; i < subjects.size(); i++) { - element.addContent(generateSubjectElement((DCSubject) subjects.get(i))); + for (Object subject : subjects) { + element.addContent(generateSubjectElement((DCSubject) subject)); } if (dcModule.getDescription() != null) { element.addContent(generateSimpleElementList("description", dcModule.getDescriptions())); @@ -114,9 +114,9 @@ public class DCModuleGenerator implements ModuleGenerator { element.addContent(generateSimpleElementList("contributor", dcModule.getContributors())); } if (dcModule.getDate() != null) { - for (Iterator i = dcModule.getDates().iterator(); i.hasNext();) { + for (Date date : dcModule.getDates()) { element.addContent(generateSimpleElement("date", - DateParser.formatW3CDateTime((Date) i.next()))); + DateParser.formatW3CDateTime(date))); } } if (dcModule.getType() != null) { @@ -197,8 +197,8 @@ public class DCModuleGenerator implements ModuleGenerator { */ protected final List generateSimpleElementList(String name, List value) { List elements = new ArrayList(); - for (Iterator i = value.iterator(); i.hasNext();) { - elements.add(generateSimpleElement(name, (String) i.next())); + for (Object aValue : value) { + elements.add(generateSimpleElement(name, (String) aValue)); } return elements; http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/DCModuleParser.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/DCModuleParser.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/DCModuleParser.java index d42828e..a79beab 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/DCModuleParser.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/DCModuleParser.java @@ -23,7 +23,6 @@ import org.jdom2.Element; import org.jdom2.Namespace; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; /** @@ -169,14 +168,14 @@ public class DCModuleParser implements ModuleParser { */ protected final List parseSubjects(List eList) { List subjects = new ArrayList(); - for (Iterator i = eList.iterator(); i.hasNext();) { - Element eSubject = (Element) i.next(); + for (Object anEList : eList) { + Element eSubject = (Element) anEList; Element eDesc = eSubject.getChild("Description", getRDFNamespace()); if (eDesc != null) { String taxonomy = getTaxonomy(eDesc); List eValues = eDesc.getChildren("value", getRDFNamespace()); - for (Iterator v = eValues.iterator(); v.hasNext();) { - Element eValue = (Element) v.next(); + for (Object eValue1 : eValues) { + Element eValue = (Element) eValue1; DCSubject subject = new DCSubjectImpl(); subject.setTaxonomyUri(taxonomy); subject.setValue(eValue.getText()); @@ -200,8 +199,8 @@ public class DCModuleParser implements ModuleParser { */ protected final List parseElementList(List eList) { List values= new ArrayList(); - for (Iterator i = eList.iterator(); i.hasNext();) { - Element e = (Element) i.next(); + for (Object anEList : eList) { + Element e = (Element) anEList; values.add(e.getText()); } @@ -216,8 +215,8 @@ public class DCModuleParser implements ModuleParser { */ protected final List parseElementListDate(List eList) { List values = new ArrayList(); - for (Iterator i = eList.iterator(); i.hasNext();) { - Element e = (Element) i.next(); + for (Object anEList : eList) { + Element e = (Element) anEList; values.add(DateParser.parseDate(e.getText())); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/ModuleGenerators.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/ModuleGenerators.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/ModuleGenerators.java index 9c493f9..83d1f8d 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/ModuleGenerators.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/ModuleGenerators.java @@ -48,10 +48,10 @@ public class ModuleGenerators extends PluginManager { public void generateModules(List modules, Element element) { Map generators = getPluginMap(); - for (int i = 0; i < modules.size(); i++) { - Module module = (Module) modules.get(i); + for (Object module1 : modules) { + Module module = (Module) module1; String namespaceUri = module.getUri(); - ModuleGenerator generator = (ModuleGenerator)generators.get(namespaceUri); + ModuleGenerator generator = (ModuleGenerator) generators.get(namespaceUri); if (generator != null) { generator.generate(module, element); } @@ -62,8 +62,8 @@ public class ModuleGenerators extends PluginManager { if (_allNamespaces==null) { _allNamespaces = new HashSet(); List mUris = getModuleNamespaces(); - for (int i=0;i<mUris.size();i++) { - ModuleGenerator mGen = getGenerator((String)mUris.get(i)); + for (Object mUri : mUris) { + ModuleGenerator mGen = getGenerator((String) mUri); _allNamespaces.addAll(mGen.getNamespaces()); } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/ModuleParsers.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/ModuleParsers.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/ModuleParsers.java index ac895fb..447c393 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/ModuleParsers.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/ModuleParsers.java @@ -43,8 +43,8 @@ public class ModuleParsers extends PluginManager { public List parseModules(Element root) { List parsers = getPlugins(); List modules = null; - for (int i=0;i<parsers.size();i++) { - ModuleParser parser = (ModuleParser) parsers.get(i); + for (Object parser1 : parsers) { + ModuleParser parser = (ModuleParser) parser1; String namespaceUri = parser.getNamespaceUri(); Namespace namespace = Namespace.getNamespace(namespaceUri); if (hasElementsFrom(root, namespace)) { http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/NumberParser.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/NumberParser.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/NumberParser.java index 6076b7b..58c8ff3 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/NumberParser.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/NumberParser.java @@ -33,7 +33,7 @@ public class NumberParser { public static Long parseLong(String str) { if (null != str) { try { - return new Long(Long.parseLong(str.trim())); + return Long.parseLong(str.trim()); } catch (Exception e) { // :IGNORE: } @@ -51,7 +51,7 @@ public class NumberParser { public static Integer parseInt(String str) { if (null != str) { try { - return new Integer(Integer.parseInt(str.trim())); + return Integer.parseInt(str.trim()); } catch (Exception e) { // :IGNORE: } @@ -68,7 +68,7 @@ public class NumberParser { public static Float parseFloat(String str) { if (null != str) { try { - return new Float(Float.parseFloat(str.trim())); + return Float.parseFloat(str.trim()); } catch (Exception e) { // :IGNORE: } @@ -85,7 +85,7 @@ public class NumberParser { */ public static float parseFloat(String str, float def) { Float result = parseFloat(str); - return (result == null) ? def : result.floatValue(); + return (result == null) ? def : result; } /** @@ -97,7 +97,7 @@ public class NumberParser { */ public static long parseLong(String str, long def) { Long ret = parseLong(str); - return (null == ret) ? def : ret.longValue(); + return (null == ret) ? def : ret; } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/PluginManager.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/PluginManager.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/PluginManager.java index f10e5cc..b4d46a7 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/PluginManager.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/PluginManager.java @@ -85,9 +85,9 @@ public abstract class PluginManager { String className = null; try { Class[] classes = getClasses(); - for (int i=0;i<classes.length;i++) { - className = classes[i].getName(); - Object plugin = classes[i].newInstance(); + for (Class aClass : classes) { + className = aClass.getName(); + Object plugin = aClass.newInstance(); if (plugin instanceof DelegatingModuleParser) { ((DelegatingModuleParser) plugin).setFeedParser(_parentParser); } @@ -111,10 +111,8 @@ public abstract class PluginManager { } } } - catch (Exception ex) { + catch (Exception | ExceptionInInitializerError ex) { throw new RuntimeException("could not instantiate plugin "+className,ex); - }catch (ExceptionInInitializerError er) { - throw new RuntimeException("could not instantiate plugin "+className,er); } } @@ -131,9 +129,9 @@ public abstract class PluginManager { private Class[] getClasses() throws ClassNotFoundException { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); List classes = new ArrayList(); - boolean useLoadClass = Boolean.valueOf(System.getProperty("rome.pluginmanager.useloadclass", "false")).booleanValue(); - for (int i = 0; i <_propertyValues.length; i++) { - Class mClass = (useLoadClass ? classLoader.loadClass(_propertyValues[i]) : Class.forName(_propertyValues[i], true, classLoader)); + boolean useLoadClass = Boolean.valueOf(System.getProperty("rome.pluginmanager.useloadclass", "false")); + for (String _propertyValue : _propertyValues) { + Class mClass = (useLoadClass ? classLoader.loadClass(_propertyValue) : Class.forName(_propertyValue, true, classLoader)); classes.add(mClass); } Class[] array = new Class[classes.size()]; http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/PropertiesLoader.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/PropertiesLoader.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/PropertiesLoader.java index 2954bed..0ac7c4a 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/PropertiesLoader.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/PropertiesLoader.java @@ -116,10 +116,10 @@ public class PropertiesLoader { */ public String[] getTokenizedProperty(String key,String separator) { List entriesList = new ArrayList(); - for (int i=0;i<_properties.length;i++) { - String values = _properties[i].getProperty(key); - if (values!=null) { - StringTokenizer st = new StringTokenizer(values,separator); + for (Properties _property : _properties) { + String values = _property.getProperty(key); + if (values != null) { + StringTokenizer st = new StringTokenizer(values, separator); while (st.hasMoreTokens()) { String token = st.nextToken(); entriesList.add(token); @@ -141,9 +141,9 @@ public class PropertiesLoader { */ public String[] getProperty(String key) { List entriesList = new ArrayList(); - for (int i=0;i<_properties.length;i++) { - String values = _properties[i].getProperty(key); - if (values!=null) { + for (Properties _property : _properties) { + String values = _property.getProperty(key); + if (values != null) { entriesList.add(values); } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS090Parser.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS090Parser.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS090Parser.java index 94a85f1..b53b3bb 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS090Parser.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS090Parser.java @@ -258,9 +258,9 @@ public class RSS090Parser extends BaseWireFeedParser { Collection eItems = getItems(rssRoot); List items = new ArrayList(); - for (Iterator i=eItems.iterator();i.hasNext();) { - Element eItem = (Element) i.next(); - items.add(parseItem(rssRoot,eItem)); + for (Object eItem1 : eItems) { + Element eItem = (Element) eItem1; + items.add(parseItem(rssRoot, eItem)); } return items; } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS091UserlandGenerator.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS091UserlandGenerator.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS091UserlandGenerator.java index d83cb05..463ea68 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS091UserlandGenerator.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS091UserlandGenerator.java @@ -21,7 +21,6 @@ import com.sun.syndication.feed.rss.Description; import com.sun.syndication.feed.rss.Image; import com.sun.syndication.feed.rss.Item; import com.sun.syndication.io.FeedException; - import org.jdom2.Attribute; import org.jdom2.Document; import org.jdom2.Element; @@ -96,8 +95,8 @@ public class RSS091UserlandGenerator extends RSS090Generator { if (skipHours != null) { List hours = skipHours.getChildren(); - for (int i = 0; i < hours.size(); i++) { - Element hour = (Element) hours.get(i); + for (Object hour1 : hours) { + Element hour = (Element) hour1; int value = Integer.parseInt(hour.getText().trim()); if (isHourFormat24()) { @@ -157,8 +156,8 @@ public class RSS091UserlandGenerator extends RSS090Generator { protected Element generateSkipDaysElement(List days) { Element skipDaysElement = new Element("skipDays"); - for (int i = 0; i < days.size(); i++) { - skipDaysElement.addContent(generateSimpleElement("day", days.get(i).toString())); + for (Object day : days) { + skipDaysElement.addContent(generateSimpleElement("day", day.toString())); } return skipDaysElement; @@ -167,8 +166,8 @@ public class RSS091UserlandGenerator extends RSS090Generator { protected Element generateSkipHoursElement(List hours) { Element skipHoursElement = new Element("skipHours", getFeedNamespace()); - for (int i = 0; i < hours.size(); i++) { - skipHoursElement.addContent(generateSimpleElement("hour", hours.get(i).toString())); + for (Object hour : hours) { + skipHoursElement.addContent(generateSimpleElement("hour", hour.toString())); } return skipHoursElement; http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS091UserlandParser.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS091UserlandParser.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS091UserlandParser.java index 86a0157..257831b 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS091UserlandParser.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS091UserlandParser.java @@ -17,17 +17,15 @@ package com.sun.syndication.io.impl; import com.sun.syndication.feed.WireFeed; -import com.sun.syndication.feed.rss.Channel; -import com.sun.syndication.feed.rss.Content; -import com.sun.syndication.feed.rss.Description; -import com.sun.syndication.feed.rss.Image; -import com.sun.syndication.feed.rss.Item; +import com.sun.syndication.feed.rss.*; import org.jdom2.Attribute; import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.Namespace; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** */ @@ -125,8 +123,8 @@ public class RSS091UserlandParser extends RSS090Parser { if (e!=null) { List skipHours = new ArrayList(); List eHours = e.getChildren("hour",getRSSNamespace()); - for (int i=0;i<eHours.size();i++) { - Element eHour = (Element) eHours.get(i); + for (Object eHour1 : eHours) { + Element eHour = (Element) eHour1; skipHours.add(new Integer(eHour.getText().trim())); } channel.setSkipHours(skipHours); @@ -136,8 +134,8 @@ public class RSS091UserlandParser extends RSS090Parser { if (e!=null) { List skipDays = new ArrayList(); List eDays = e.getChildren("day",getRSSNamespace()); - for (int i=0;i<eDays.size();i++) { - Element eDay = (Element) eDays.get(i); + for (Object eDay1 : eDays) { + Element eDay = (Element) eDay1; skipDays.add(eDay.getText().trim()); } channel.setSkipDays(skipDays); @@ -163,14 +161,14 @@ public class RSS091UserlandParser extends RSS090Parser { if (e!=null) { Integer val = NumberParser.parseInt(e.getText()); if (val != null) { - image.setWidth(val.intValue()); + image.setWidth(val); } } e = eImage.getChild("height",getRSSNamespace()); if (e!=null) { Integer val = NumberParser.parseInt(e.getText()); if (val != null) { - image.setHeight(val.intValue()); + image.setHeight(val); } } e = eImage.getChild("description",getRSSNamespace()); http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS092Generator.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS092Generator.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS092Generator.java index 12a03d5..9f3cd18 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS092Generator.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS092Generator.java @@ -95,8 +95,8 @@ public class RSS092Generator extends RSS091UserlandGenerator { } List categories = item.getCategories(); - for(int i = 0; i < categories.size(); i++) { - eItem.addContent(generateCategoryElement((Category)categories.get(i))); + for (Object category : categories) { + eItem.addContent(generateCategoryElement((Category) category)); } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS092Parser.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS092Parser.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS092Parser.java index 9eacee7..b46d0a8 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS092Parser.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS092Parser.java @@ -17,13 +17,7 @@ package com.sun.syndication.io.impl; import com.sun.syndication.feed.WireFeed; -import com.sun.syndication.feed.rss.Category; -import com.sun.syndication.feed.rss.Channel; -import com.sun.syndication.feed.rss.Cloud; -import com.sun.syndication.feed.rss.Description; -import com.sun.syndication.feed.rss.Enclosure; -import com.sun.syndication.feed.rss.Item; -import com.sun.syndication.feed.rss.Source; +import com.sun.syndication.feed.rss.*; import org.jdom2.Element; import java.util.ArrayList; @@ -94,19 +88,19 @@ public class RSS092Parser extends RSS091UserlandParser { List eEnclosures = eItem.getChildren("enclosure");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (eEnclosures.size()>0) { List enclosures = new ArrayList(); - for (int i=0;i<eEnclosures.size();i++) { - e = (Element) eEnclosures.get(i); + for (Object eEnclosure : eEnclosures) { + e = (Element) eEnclosure; Enclosure enclosure = new Enclosure(); String att = e.getAttributeValue("url");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK - if (att!=null) { + if (att != null) { enclosure.setUrl(att); } att = e.getAttributeValue("length");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK - enclosure.setLength(NumberParser.parseLong(att,0L)); + enclosure.setLength(NumberParser.parseLong(att, 0L)); att = e.getAttributeValue("type");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK - if (att!=null) { + if (att != null) { enclosure.setType(att); } enclosures.add(enclosure); @@ -124,11 +118,11 @@ public class RSS092Parser extends RSS091UserlandParser { List cats = null; if (eCats.size()>0) { cats = new ArrayList(); - for (int i=0;i<eCats.size();i++) { + for (Object eCat : eCats) { Category cat = new Category(); - Element e = (Element) eCats.get(i); + Element e = (Element) eCat; String att = e.getAttributeValue("domain");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK - if (att!=null) { + if (att != null) { cat.setDomain(att); } cat.setValue(e.getText()); http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS094Parser.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS094Parser.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS094Parser.java index a95b924..439a07f 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS094Parser.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS094Parser.java @@ -57,7 +57,7 @@ public class RSS094Parser extends RSS093Parser { //let it go by } if (ttlValue != null) { - channel.setTtl(ttlValue.intValue()); + channel.setTtl(ttlValue); } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS10Generator.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS10Generator.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS10Generator.java index 9ffdc7d..88d0ebb 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS10Generator.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS10Generator.java @@ -16,9 +16,9 @@ */ package com.sun.syndication.io.impl; +import com.sun.syndication.feed.rss.Channel; import com.sun.syndication.feed.rss.Description; import com.sun.syndication.feed.rss.Item; -import com.sun.syndication.feed.rss.Channel; import com.sun.syndication.io.FeedException; import org.jdom2.Element; import org.jdom2.Namespace; @@ -59,12 +59,12 @@ public class RSS10Generator extends RSS090Generator { if (items.size()>0) { Element eItems = new Element("items",getFeedNamespace()); Element eSeq = new Element("Seq",getRDFNamespace()); - for (int i=0;i<items.size();i++) { - Item item = (Item) items.get(i); - Element eLi = new Element("li",getRDFNamespace()); + for (Object item1 : items) { + Item item = (Item) item1; + Element eLi = new Element("li", getRDFNamespace()); String uri = item.getUri(); - if (uri!=null) { - eLi.setAttribute("resource",uri,getRDFNamespace()); + if (uri != null) { + eLi.setAttribute("resource", uri, getRDFNamespace()); } eSeq.addContent(eLi); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS20Generator.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS20Generator.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS20Generator.java index 14e23ab..b133a87 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS20Generator.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/RSS20Generator.java @@ -57,8 +57,8 @@ public class RSS20Generator extends RSS094Generator { } List categories = channel.getCategories(); - for(int i = 0; i < categories.size(); i++) { - eChannel.addContent(generateCategoryElement((Category)categories.get(i))); + for (Object category : categories) { + eChannel.addContent(generateCategoryElement((Category) category)); } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/XmlFixerReader.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/XmlFixerReader.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/XmlFixerReader.java index 88a98b2..621027b 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/XmlFixerReader.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/io/impl/XmlFixerReader.java @@ -20,8 +20,8 @@ import java.io.IOException; import java.io.Reader; import java.util.HashMap; import java.util.Map; -import java.util.regex.Pattern; import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @author Alejandro Abdelnur @@ -621,7 +621,7 @@ public class XmlFixerReader extends Reader { if (s.indexOf('&')==-1) { return s; } - StringBuffer sb = new StringBuffer(s.length()); + StringBuilder sb = new StringBuilder(s.length()); int pos = 0; while (pos<s.length()) { String chunck = s.substring(pos); http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/CustomTagGenerator.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/CustomTagGenerator.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/CustomTagGenerator.java index 090c212..5ea15cb 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/CustomTagGenerator.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/CustomTagGenerator.java @@ -20,6 +20,8 @@ package org.rometools.feed.module.base.io; import com.sun.syndication.feed.module.Module; +import com.sun.syndication.io.ModuleGenerator; +import org.jdom2.Element; import org.rometools.feed.module.base.CustomTag; import org.rometools.feed.module.base.CustomTagImpl; import org.rometools.feed.module.base.CustomTags; @@ -27,15 +29,10 @@ import org.rometools.feed.module.base.types.DateTimeRange; import org.rometools.feed.module.base.types.FloatUnit; import org.rometools.feed.module.base.types.IntUnit; import org.rometools.feed.module.base.types.ShortDate; -import com.sun.syndication.io.ModuleGenerator; - -import org.jdom2.Element; import java.net.URL; - import java.util.Date; import java.util.HashSet; -import java.util.Iterator; import java.util.List; @@ -68,61 +65,60 @@ public class CustomTagGenerator implements ModuleGenerator { } List tags = ((CustomTags)module).getValues(); - Iterator it = tags.iterator(); - while(it.hasNext()) { - CustomTag tag = (CustomTag)it.next(); + for (Object tag1 : tags) { + CustomTag tag = (CustomTag) tag1; - if(tag.getValue() instanceof DateTimeRange) { - DateTimeRange dtr = (DateTimeRange)tag.getValue(); - Element newTag = new Element(tag.getName(),CustomTagParser.NS); - newTag.setAttribute("type","dateTimeRange"); - newTag.addContent(this.generateSimpleElement("start",GoogleBaseParser.LONG_DT_FMT.format(dtr.getStart()))); - newTag.addContent(this.generateSimpleElement("end",GoogleBaseParser.LONG_DT_FMT.format(dtr.getEnd()))); + if (tag.getValue() instanceof DateTimeRange) { + DateTimeRange dtr = (DateTimeRange) tag.getValue(); + Element newTag = new Element(tag.getName(), CustomTagParser.NS); + newTag.setAttribute("type", "dateTimeRange"); + newTag.addContent(this.generateSimpleElement("start", GoogleBaseParser.LONG_DT_FMT.format(dtr.getStart()))); + newTag.addContent(this.generateSimpleElement("end", GoogleBaseParser.LONG_DT_FMT.format(dtr.getEnd()))); element.addContent(newTag); - } else if(tag.getValue() instanceof ShortDate) { - ShortDate sd = (ShortDate)tag.getValue(); - Element newTag = this.generateSimpleElement(tag.getName(),GoogleBaseParser.SHORT_DT_FMT.format(sd)); - newTag.setAttribute("type","date"); + } else if (tag.getValue() instanceof ShortDate) { + ShortDate sd = (ShortDate) tag.getValue(); + Element newTag = this.generateSimpleElement(tag.getName(), GoogleBaseParser.SHORT_DT_FMT.format(sd)); + newTag.setAttribute("type", "date"); element.addContent(newTag); - } else if(tag.getValue() instanceof Date) { - Date d = (Date)tag.getValue(); - Element newTag = this.generateSimpleElement(tag.getName(),GoogleBaseParser.SHORT_DT_FMT.format(d)); - newTag.setAttribute("type","dateTime"); + } else if (tag.getValue() instanceof Date) { + Date d = (Date) tag.getValue(); + Element newTag = this.generateSimpleElement(tag.getName(), GoogleBaseParser.SHORT_DT_FMT.format(d)); + newTag.setAttribute("type", "dateTime"); element.addContent(newTag); - } else if(tag.getValue() instanceof Integer) { - Element newTag = this.generateSimpleElement(tag.getName(),tag.getValue().toString()); - newTag.setAttribute("type","int"); + } else if (tag.getValue() instanceof Integer) { + Element newTag = this.generateSimpleElement(tag.getName(), tag.getValue().toString()); + newTag.setAttribute("type", "int"); element.addContent(newTag); - } else if(tag.getValue() instanceof IntUnit) { - Element newTag = this.generateSimpleElement(tag.getName(),tag.getValue().toString()); - newTag.setAttribute("type","intUnit"); + } else if (tag.getValue() instanceof IntUnit) { + Element newTag = this.generateSimpleElement(tag.getName(), tag.getValue().toString()); + newTag.setAttribute("type", "intUnit"); element.addContent(newTag); - } else if(tag.getValue() instanceof Float) { - Element newTag = this.generateSimpleElement(tag.getName(),tag.getValue().toString()); - newTag.setAttribute("type","float"); + } else if (tag.getValue() instanceof Float) { + Element newTag = this.generateSimpleElement(tag.getName(), tag.getValue().toString()); + newTag.setAttribute("type", "float"); element.addContent(newTag); - } else if(tag.getValue() instanceof FloatUnit) { - Element newTag = this.generateSimpleElement(tag.getName(),tag.getValue().toString()); - newTag.setAttribute("type","floatUnit"); + } else if (tag.getValue() instanceof FloatUnit) { + Element newTag = this.generateSimpleElement(tag.getName(), tag.getValue().toString()); + newTag.setAttribute("type", "floatUnit"); element.addContent(newTag); - } else if(tag.getValue() instanceof String) { - Element newTag = this.generateSimpleElement(tag.getName(),tag.getValue().toString()); - newTag.setAttribute("type","string"); + } else if (tag.getValue() instanceof String) { + Element newTag = this.generateSimpleElement(tag.getName(), tag.getValue().toString()); + newTag.setAttribute("type", "string"); element.addContent(newTag); - } else if(tag.getValue() instanceof URL) { - Element newTag = this.generateSimpleElement(tag.getName(),tag.getValue().toString()); - newTag.setAttribute("type","url"); + } else if (tag.getValue() instanceof URL) { + Element newTag = this.generateSimpleElement(tag.getName(), tag.getValue().toString()); + newTag.setAttribute("type", "url"); element.addContent(newTag); - } else if(tag.getValue() instanceof Boolean) { - Element newTag = this.generateSimpleElement(tag.getName(),tag.getValue().toString()); - newTag.setAttribute("type","boolean"); + } else if (tag.getValue() instanceof Boolean) { + Element newTag = this.generateSimpleElement(tag.getName(), tag.getValue().toString()); + newTag.setAttribute("type", "boolean"); element.addContent(newTag); - } else if( tag.getValue() instanceof CustomTagImpl.Location ){ - Element newTag = this.generateSimpleElement(tag.getName(),tag.getValue().toString()); - newTag.setAttribute("type","location"); + } else if (tag.getValue() instanceof CustomTagImpl.Location) { + Element newTag = this.generateSimpleElement(tag.getName(), tag.getValue().toString()); + newTag.setAttribute("type", "location"); element.addContent(newTag); - } + } } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/CustomTagParser.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/CustomTagParser.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/CustomTagParser.java index 033cc85..7cf0af8 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/CustomTagParser.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/CustomTagParser.java @@ -21,6 +21,9 @@ package org.rometools.feed.module.base.io; import com.sun.syndication.feed.module.Module; +import com.sun.syndication.io.ModuleParser; +import org.jdom2.Element; +import org.jdom2.Namespace; import org.rometools.feed.module.base.CustomTagImpl; import org.rometools.feed.module.base.CustomTags; import org.rometools.feed.module.base.CustomTagsImpl; @@ -28,18 +31,14 @@ import org.rometools.feed.module.base.types.DateTimeRange; import org.rometools.feed.module.base.types.FloatUnit; import org.rometools.feed.module.base.types.IntUnit; import org.rometools.feed.module.base.types.ShortDate; -import com.sun.syndication.io.ModuleParser; import java.net.MalformedURLException; import java.net.URL; import java.text.ParseException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import org.jdom2.Element; -import org.jdom2.Namespace; /** * @version $Revision: 1.4 $ @@ -58,60 +57,59 @@ public class CustomTagParser implements ModuleParser { CustomTags module = new CustomTagsImpl(); ArrayList tags = new ArrayList(); List elements = element.getChildren(); - Iterator it = elements.iterator(); - while( it.hasNext() ){ - Element child = (Element) it.next(); - if( child.getNamespace().equals( NS ) ){ - String type = child.getAttributeValue( "type" ); - try{ - if( type == null ){ - continue; - } else if( type.equals( "string") ){ - tags.add( new CustomTagImpl( child.getName(), child.getText() ) ); - } else if( type.equals( "int") ){ - tags.add( new CustomTagImpl( child.getName(), new Integer( child.getTextTrim() ))); - } else if( type.equals( "float") ){ - tags.add( new CustomTagImpl( child.getName(), new Float( child.getTextTrim() ) ) ); - } else if( type.equals("intUnit") ){ - tags.add( new CustomTagImpl( child.getName(), new IntUnit( child.getTextTrim()) ) ); - } else if( type.equals( "floatUnit") ){ - tags.add( new CustomTagImpl( child.getName(), new FloatUnit( child.getTextTrim()) ) ); - } else if( type.equals( "date") ){ - try{ - tags.add( new CustomTagImpl( child.getName(), new ShortDate( GoogleBaseParser.SHORT_DT_FMT.parse( child.getTextTrim()))) ); - } catch( ParseException e ){ - log.log( Level.WARNING, "Unable to parse date type on "+child.getName(), e ); - } - } else if( type.equals( "dateTime") ){ - try{ - tags.add( new CustomTagImpl( child.getName(), GoogleBaseParser.LONG_DT_FMT.parse( child.getTextTrim() ))); - } catch(ParseException e){ - log.log( Level.WARNING, "Unable to parse date type on "+child.getName(), e ); - } - } else if( type.equals( "dateTimeRange") ){ - 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())))); - } catch(Exception e){ - log.log( Level.WARNING, "Unable to parse date type on "+child.getName(), e ); - } - } else if( type.equals( "url") ){ - try{ - tags.add( new CustomTagImpl( child.getName(), new URL( child.getTextTrim() )) ); - } catch( MalformedURLException e){ - log.log( Level.WARNING, "Unable to parse URL type on "+child.getName(), e ); - } - } else if( type.equals( "boolean") ){ - tags.add( new CustomTagImpl( child.getName(), new Boolean( child.getTextTrim().toLowerCase()) )); - } else if( type.equals( "location") ) { - tags.add( new CustomTagImpl( child.getName(), new CustomTagImpl.Location( child.getText() ))); - } else { - throw new Exception( "Unknown type: "+ type ); - } - } catch(Exception e){ - log.log( Level.WARNING, "Unable to parse type on "+child.getName(), e ); - } - } - } + for (Object element1 : elements) { + Element child = (Element) element1; + if (child.getNamespace().equals(NS)) { + String type = child.getAttributeValue("type"); + try { + if (type == null) { + continue; + } else if (type.equals("string")) { + tags.add(new CustomTagImpl(child.getName(), child.getText())); + } else if (type.equals("int")) { + tags.add(new CustomTagImpl(child.getName(), new Integer(child.getTextTrim()))); + } else if (type.equals("float")) { + tags.add(new CustomTagImpl(child.getName(), new Float(child.getTextTrim()))); + } else if (type.equals("intUnit")) { + tags.add(new CustomTagImpl(child.getName(), new IntUnit(child.getTextTrim()))); + } else if (type.equals("floatUnit")) { + tags.add(new CustomTagImpl(child.getName(), new FloatUnit(child.getTextTrim()))); + } else if (type.equals("date")) { + try { + tags.add(new CustomTagImpl(child.getName(), new ShortDate(GoogleBaseParser.SHORT_DT_FMT.parse(child.getTextTrim())))); + } catch (ParseException e) { + log.log(Level.WARNING, "Unable to parse date type on " + child.getName(), e); + } + } else if (type.equals("dateTime")) { + try { + tags.add(new CustomTagImpl(child.getName(), GoogleBaseParser.LONG_DT_FMT.parse(child.getTextTrim()))); + } catch (ParseException e) { + log.log(Level.WARNING, "Unable to parse date type on " + child.getName(), e); + } + } else if (type.equals("dateTimeRange")) { + 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())))); + } catch (Exception e) { + log.log(Level.WARNING, "Unable to parse date type on " + child.getName(), e); + } + } else if (type.equals("url")) { + try { + tags.add(new CustomTagImpl(child.getName(), new URL(child.getTextTrim()))); + } catch (MalformedURLException e) { + log.log(Level.WARNING, "Unable to parse URL type on " + child.getName(), e); + } + } else if (type.equals("boolean")) { + tags.add(new CustomTagImpl(child.getName(), Boolean.valueOf(child.getTextTrim().toLowerCase()))); + } else if (type.equals("location")) { + tags.add(new CustomTagImpl(child.getName(), new CustomTagImpl.Location(child.getText()))); + } else { + throw new Exception("Unknown type: " + type); + } + } catch (Exception e) { + log.log(Level.WARNING, "Unable to parse type on " + child.getName(), e); + } + } + } module.setValues( tags ); return module; } http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/GoogleBaseGenerator.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/GoogleBaseGenerator.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/GoogleBaseGenerator.java index 825aed4..708ffcd 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/GoogleBaseGenerator.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/GoogleBaseGenerator.java @@ -41,28 +41,14 @@ package org.rometools.feed.module.base.io; import com.sun.syndication.feed.module.Module; import com.sun.syndication.io.ModuleGenerator; - -import org.rometools.feed.module.base.GoogleBase; -import org.rometools.feed.module.base.GoogleBaseImpl; -import org.rometools.feed.module.base.types.CurrencyEnumeration; -import org.rometools.feed.module.base.types.DateTimeRange; -import org.rometools.feed.module.base.types.FloatUnit; -import org.rometools.feed.module.base.types.GenderEnumeration; -import org.rometools.feed.module.base.types.IntUnit; -import org.rometools.feed.module.base.types.PaymentTypeEnumeration; -import org.rometools.feed.module.base.types.PriceTypeEnumeration; -import org.rometools.feed.module.base.types.ShippingType; -import org.rometools.feed.module.base.types.ShortDate; -import org.rometools.feed.module.base.types.Size; -import org.rometools.feed.module.base.types.YearType; - import org.jdom2.Element; import org.jdom2.Namespace; +import org.rometools.feed.module.base.GoogleBase; +import org.rometools.feed.module.base.GoogleBaseImpl; +import org.rometools.feed.module.base.types.*; import java.beans.PropertyDescriptor; - import java.net.URL; - import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -97,34 +83,34 @@ public class GoogleBaseGenerator implements ModuleGenerator { GoogleBaseImpl mod = (GoogleBaseImpl)module; HashMap props2tags = new HashMap(GoogleBaseParser.PROPS2TAGS); PropertyDescriptor[] pds = GoogleBaseParser.pds; - - for(int i = 0; i < pds.length; i++) { - String tagName = (String)props2tags.get(pds[i].getName()); - - if(tagName == null) { - continue; - } - - Object[] values = null; - - try { - if(pds[i].getPropertyType().isArray()) { - values = (Object[])pds[i].getReadMethod().invoke(mod,(Object[])null); - } else { - values = new Object[] { - pds[i].getReadMethod().invoke(mod,(Object[])null) - }; - } - - for(int j = 0; (values != null)&&(j < values.length); j++) { - if(values[j] != null) { - element.addContent(this.generateTag(values[j],tagName)); - } - } - } catch(Exception e) { - e.printStackTrace(); - } - } + + for (PropertyDescriptor pd : pds) { + String tagName = (String) props2tags.get(pd.getName()); + + if (tagName == null) { + continue; + } + + Object[] values = null; + + try { + if (pd.getPropertyType().isArray()) { + values = (Object[]) pd.getReadMethod().invoke(mod, (Object[]) null); + } else { + values = new Object[]{ + pd.getReadMethod().invoke(mod, (Object[]) null) + }; + } + + for (int j = 0; (values != null) && (j < values.length); j++) { + if (values[j] != null) { + element.addContent(this.generateTag(values[j], tagName)); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } } public Element generateTag(Object o,String tagName) { http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/GoogleBaseParser.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/GoogleBaseParser.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/GoogleBaseParser.java index cb7ca9c..6fbf45a 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/GoogleBaseParser.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/io/GoogleBaseParser.java @@ -40,38 +40,22 @@ package org.rometools.feed.module.base.io; import com.sun.syndication.feed.module.Module; -import org.rometools.feed.module.base.GoogleBase; -import org.rometools.feed.module.base.GoogleBaseImpl; import com.sun.syndication.io.ModuleParser; -import org.rometools.feed.module.base.types.CurrencyEnumeration; -import org.rometools.feed.module.base.types.DateTimeRange; -import org.rometools.feed.module.base.types.FloatUnit; -import org.rometools.feed.module.base.types.GenderEnumeration; -import org.rometools.feed.module.base.types.IntUnit; -import org.rometools.feed.module.base.types.PaymentTypeEnumeration; -import org.rometools.feed.module.base.types.PriceTypeEnumeration; -import org.rometools.feed.module.base.types.ShippingType; -import org.rometools.feed.module.base.types.Size; -import org.rometools.feed.module.base.types.YearType; - import org.jdom2.Element; import org.jdom2.Namespace; +import org.rometools.feed.module.base.GoogleBase; +import org.rometools.feed.module.base.GoogleBaseImpl; +import org.rometools.feed.module.base.types.*; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; - import java.io.IOException; - import java.lang.reflect.Array; - import java.net.URL; - import java.text.SimpleDateFormat; - import java.util.Date; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.logging.Level; @@ -119,14 +103,13 @@ public class GoogleBaseParser implements ModuleParser { GoogleBaseImpl module = new GoogleBaseImpl(); try { - for(int i = 0; i < pds.length; i++) { - PropertyDescriptor pd = pds[i]; + for (PropertyDescriptor pd : pds) { String tagName = GoogleBaseParser.PROPS2TAGS.getProperty(pd.getName()); - if(tagName == null) { - log.log(Level.FINE,"Property: " + pd.getName() + " doesn't have a tag mapping. "); + if (tagName == null) { + log.log(Level.FINE, "Property: " + pd.getName() + " doesn't have a tag mapping. "); } else { - tag2pd.put(tagName,pd); + tag2pd.put(tagName, pd); } } } catch(Exception e) { @@ -134,19 +117,18 @@ public class GoogleBaseParser implements ModuleParser { } List children = element.getChildren(); - Iterator it = children.iterator(); - while(it.hasNext()) { - Element child = (Element)it.next(); + for (Object aChildren : children) { + Element child = (Element) aChildren; - if(child.getNamespace().equals(GoogleBaseParser.NS)) { - PropertyDescriptor pd = (PropertyDescriptor)tag2pd.get(child.getName()); + if (child.getNamespace().equals(GoogleBaseParser.NS)) { + PropertyDescriptor pd = (PropertyDescriptor) tag2pd.get(child.getName()); - if(pd != null) { + if (pd != null) { try { - this.handleTag(child,pd,module); - } catch(Exception e) { - log.log(Level.WARNING,"Unable to handle tag: " + child.getName(),e); + this.handleTag(child, pd, module); + } catch (Exception e) { + log.log(Level.WARNING, "Unable to handle tag: " + child.getName(), e); e.printStackTrace(); } } @@ -157,12 +139,12 @@ public class GoogleBaseParser implements ModuleParser { } public static String stripNonValidCharacters(char[] validCharacters,String input) { - StringBuffer newString = new StringBuffer(); + StringBuilder newString = new StringBuilder(); for(int i = 0; i < input.length(); i++) { - for(int j = 0; j < validCharacters.length; j++) { - if(input.charAt(i) == validCharacters[j]) { - newString.append(validCharacters[j]); + for (char validCharacter : validCharacters) { + if (input.charAt(i) == validCharacter) { + newString.append(validCharacter); } } } @@ -186,7 +168,7 @@ public class GoogleBaseParser implements ModuleParser { } else if((pd.getPropertyType() == URL.class)||(pd.getPropertyType().getComponentType() == URL.class)) { tagValue = new URL(tag.getText().trim()); } else if((pd.getPropertyType() == Boolean.class)||(pd.getPropertyType().getComponentType() == Boolean.class)) { - tagValue = new Boolean(tag.getText().trim()); + tagValue = Boolean.valueOf(tag.getText().trim()); } else if((pd.getPropertyType() == Date.class)||(pd.getPropertyType().getComponentType() == Date.class)) { String text = tag.getText().trim(); http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/types/FloatUnit.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/types/FloatUnit.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/types/FloatUnit.java index e3a064c..79f04d2 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/types/FloatUnit.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/types/FloatUnit.java @@ -65,8 +65,8 @@ public class FloatUnit implements CloneableType { * @return boolean indicating presence. */ private boolean inCharArray( char find, char[] array ){ - for( int i=0; i < array.length; i++ ){ - if( find == array[i]) + for (char anArray : array) { + if (find == anArray) return true; } return false; http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/types/IntUnit.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/types/IntUnit.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/types/IntUnit.java index bb424b2..523e7df 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/types/IntUnit.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/base/types/IntUnit.java @@ -51,8 +51,8 @@ public class IntUnit implements CloneableType { private String units; private int value; private boolean inCharArray( char find, char[] array ){ - for( int i=0; i < array.length; i++ ){ - if( find == array[i]) + for (char anArray : array) { + if (find == anArray) return true; } return false; http://git-wip-us.apache.org/repos/asf/marmotta/blob/f45e3ddd/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/cc/io/CCModuleGenerator.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/cc/io/CCModuleGenerator.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/cc/io/CCModuleGenerator.java index 114def9..ed397a2 100644 --- a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/cc/io/CCModuleGenerator.java +++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/org/rometools/feed/module/cc/io/CCModuleGenerator.java @@ -42,13 +42,14 @@ package org.rometools.feed.module.cc.io; import com.sun.syndication.feed.module.Module; import com.sun.syndication.io.ModuleGenerator; +import org.jdom2.Element; +import org.jdom2.Namespace; import org.rometools.feed.module.cc.CreativeCommons; import org.rometools.feed.module.cc.CreativeCommonsImpl; import org.rometools.feed.module.cc.types.License; + import java.util.HashSet; import java.util.Set; -import org.jdom2.Element; -import org.jdom2.Namespace; /** * @version $Revision: 1.1 $ @@ -101,33 +102,33 @@ public class CCModuleGenerator implements ModuleGenerator{ if( element.getName().equals("channel")){ // Do all licenses list. License[] all = module.getAllLicenses(); - for( int i=0; i < all.length ; i++){ - Element license = new Element( "License", RSS1 ); - license.setAttribute( "about", all[i].getValue(), RDF ); - License.Behaviour[] permits = all[i].getPermits(); - for( int j=0; permits != null && j < permits.length; j++ ){ - Element permit = new Element( "permits", RSS1 ); - permit.setAttribute( "resource", permits[j].toString(), RDF); - license.addContent( permit ); - } - License.Behaviour[] requires = all[i].getPermits(); - for( int j=0; requires != null && j < requires.length; j++ ){ - Element permit = new Element( "requires", RSS1 ); - permit.setAttribute( "resource", permits[j].toString(), RDF); - license.addContent( permit ); - } - System.out.println("Is Root?"+element.getParentElement()); - element.getParentElement().addContent( license ); - } + for (License anAll : all) { + Element license = new Element("License", RSS1); + license.setAttribute("about", anAll.getValue(), RDF); + License.Behaviour[] permits = anAll.getPermits(); + for (int j = 0; permits != null && j < permits.length; j++) { + Element permit = new Element("permits", RSS1); + permit.setAttribute("resource", permits[j].toString(), RDF); + license.addContent(permit); + } + License.Behaviour[] requires = anAll.getPermits(); + for (int j = 0; requires != null && j < requires.length; j++) { + Element permit = new Element("requires", RSS1); + permit.setAttribute("resource", permits[j].toString(), RDF); + license.addContent(permit); + } + System.out.println("Is Root?" + element.getParentElement()); + element.getParentElement().addContent(license); + } } //Do local licenses License[] licenses = module.getLicenses(); - for( int i=0; i < licenses.length; i++ ){ - Element license = new Element( "license", RSS1 ); - license.setAttribute( "resource", licenses[i].getValue(), RDF); - element.addContent( license ); - } + for (License license1 : licenses) { + Element license = new Element("license", RSS1); + license.setAttribute("resource", license1.getValue(), RDF); + element.addContent(license); + } }
