catched NPEs in OpenSearchModule (fixes #23 and fixes #18) and cleaned

up source format
This commit is contained in:
Martin Kurz 2013-10-11 17:18:31 +02:00
parent 80ab8834b2
commit e7a81c4444
6 changed files with 144 additions and 93 deletions

View file

@ -29,20 +29,24 @@ import com.sun.syndication.feed.atom.Link;
public interface OpenSearchResponse { public interface OpenSearchResponse {
/** /**
* # totalResults the maximum number of results available for these search terms * # totalResults the maximum number of results available for these search
* terms
* *
* * Restrictions: An integer greater than or equal to 0. * Default: The number of items that were returned in this set of results. * Requirements: May * * Restrictions: An integer greater than or equal to 0. * Default: The
* appear zero or one time. * number of items that were returned in this set of results. *
* Requirements: May appear zero or one time.
* *
* @param totalResults A positive integer value. * @param totalResults A positive integer value.
*/ */
public void setTotalResults(int totalResults); public void setTotalResults(int totalResults);
/** /**
* # totalResults the maximum number of results available for these search terms * # totalResults the maximum number of results available for these search
* terms
* *
* * Restrictions: An integer greater than or equal to 0. * Default: The number of items that were returned in this set of results. * Requirements: May * * Restrictions: An integer greater than or equal to 0. * Default: The
* appear zero or one time. * number of items that were returned in this set of results. *
* Requirements: May appear zero or one time.
* *
* @return a positive integer value. * @return a positive integer value.
*/ */
@ -51,7 +55,8 @@ public interface OpenSearchResponse {
/** /**
* # startIndex the index of the first item returned in the result. * # startIndex the index of the first item returned in the result.
* *
* * Restrictions: An integer greater than or equal to 1. * Note: The first result is 1. * Default: 1 * Requirements: May appear zero or one time. * * Restrictions: An integer greater than or equal to 1. * Note: The first
* result is 1. * Default: 1 * Requirements: May appear zero or one time.
* *
* @param startIndex int value >= 1. * @param startIndex int value >= 1.
*/ */
@ -60,27 +65,32 @@ public interface OpenSearchResponse {
/** /**
* # startIndex the index of the first item returned in the result. * # startIndex the index of the first item returned in the result.
* *
* * Restrictions: An integer greater than or equal to 1. * Note: The first result is 1. * Default: 1 * Requirements: May appear zero or one time. * * Restrictions: An integer greater than or equal to 1. * Note: The first
* result is 1. * Default: 1 * Requirements: May appear zero or one time.
* *
* @return int value >= 1. * @return int value >= 1.
*/ */
public int getStartIndex(); public int getStartIndex();
/** /**
* # itemsPerPage the maximum number of items that can appear in one page of results. * # itemsPerPage the maximum number of items that can appear in one page
* of results.
* *
* * Restrictions: An integer greater than or equal to 1. * Default: The number of items that were returned in this set of results. * Requirements: May * * Restrictions: An integer greater than or equal to 1. * Default: The
* appear zero or one time. * number of items that were returned in this set of results. *
* Requirements: May appear zero or one time.
* *
* @param itemsPerPage int value >= 1. * @param itemsPerPage int value >= 1.
*/ */
public void setItemsPerPage(int itemsPerPage); public void setItemsPerPage(int itemsPerPage);
/** /**
* # itemsPerPage the maximum number of items that can appear in one page of results. * # itemsPerPage the maximum number of items that can appear in one page
* of results.
* *
* * Restrictions: An integer greater than or equal to 1. * Default: The number of items that were returned in this set of results. * Requirements: May * * Restrictions: An integer greater than or equal to 1. * Default: The
* appear zero or one time. * number of items that were returned in this set of results. *
* Requirements: May appear zero or one time.
* *
* @return int value >= 1 * @return int value >= 1
*/ */
@ -89,8 +99,10 @@ public interface OpenSearchResponse {
/** /**
* # link a reference back to the OpenSearch Description file * # link a reference back to the OpenSearch Description file
* *
* * Attributes: This is a clone of the link element in Atom, including href, hreflang, rel, and type attributes. * Restrictions: The rel attribute must * * Attributes: This is a clone of the link element in Atom, including
* equal search. * Note: New in version 1.1. * Requirements: May appear zero or one time. * href, hreflang, rel, and type attributes. * Restrictions: The rel
* attribute must equal search. * Note: New in version 1.1. * Requirements:
* May appear zero or one time.
* *
* @param link link to the open search spec. * @param link link to the open search spec.
*/ */
@ -99,8 +111,10 @@ public interface OpenSearchResponse {
/** /**
* # link a reference back to the OpenSearch Description file * # link a reference back to the OpenSearch Description file
* *
* * Attributes: This is a clone of the link element in Atom, including href, hreflang, rel, and type attributes. * Restrictions: The rel attribute must * * Attributes: This is a clone of the link element in Atom, including
* equal search. * Note: New in version 1.1. * Requirements: May appear zero or one time. * href, hreflang, rel, and type attributes. * Restrictions: The rel
* attribute must equal search. * Note: New in version 1.1. * Requirements:
* May appear zero or one time.
* *
* @return link to the opensearch spec. * @return link to the opensearch spec.
*/ */
@ -108,26 +122,30 @@ public interface OpenSearchResponse {
// list of OSResponseQuery interfaces // list of OSResponseQuery interfaces
/** /**
* <code>Query</code> in an OpenSearch Response, can be used both to echo back the original query and to suggest new searches. Please see the <a * <code>Query</code> in an OpenSearch Response, can be used both to echo
* back the original query and to suggest new searches. Please see the <a
* href="../query/">OpenSearch Query specification</a> for more information. * href="../query/">OpenSearch Query specification</a> for more information.
* <ul> * <ul>
* <li>Note: <em>New in version 1.1.</em></li> * <li>Note: <em>New in version 1.1.</em></li>
* <li>Requirements: May appear zero or more times. Note that the Q is capitalized.</li> * <li>Requirements: May appear zero or more times. Note that the Q is
* capitalized.</li>
* *
* @param query List of OSQuery objects. * @param query List of OSQuery objects.
*/ */
public void setQueries(List query); public void setQueries(List<OSQuery> query);
/** /**
* <code>Query</code> in an OpenSearch Response, can be used both to echo back the original query and to suggest new searches. Please see the <a * <code>Query</code> in an OpenSearch Response, can be used both to echo
* back the original query and to suggest new searches. Please see the <a
* href="../query/">OpenSearch Query specification</a> for more information. * href="../query/">OpenSearch Query specification</a> for more information.
* <ul> * <ul>
* <li>Note: <em>New in version 1.1.</em></li> * <li>Note: <em>New in version 1.1.</em></li>
* <li>Requirements: May appear zero or more times. Note that the Q is capitalized.</li> * <li>Requirements: May appear zero or more times. Note that the Q is
* capitalized.</li>
* *
* @return A list of OSQuery objects. * @return A list of OSQuery objects.
*/ */
public List getQueries(); public List<OSQuery> getQueries();
// convenience method // convenience method
/** /**

View file

@ -19,20 +19,18 @@ package org.rometools.feed.module.opensearch;
* @author Michael W. Nassif (enrouteinc@gmail.com) * @author Michael W. Nassif (enrouteinc@gmail.com)
*/ */
public class RequiredAttributeMissingException extends RuntimeException { public class RequiredAttributeMissingException extends RuntimeException {
private static final long serialVersionUID = -7678987346283611492L;
public RequiredAttributeMissingException(final String arg0, final Throwable arg1) { public RequiredAttributeMissingException(final String arg0, final Throwable arg1) {
super(arg0, arg1); super(arg0, arg1);
// TODO Auto-generated constructor stub
} }
public RequiredAttributeMissingException(final String arg0) { public RequiredAttributeMissingException(final String arg0) {
super(arg0); super(arg0);
// TODO Auto-generated constructor stub
} }
public RequiredAttributeMissingException(final Throwable arg0) { public RequiredAttributeMissingException(final Throwable arg0) {
super(arg0); super(arg0);
// TODO Auto-generated constructor stub
} }
} }

View file

@ -20,9 +20,11 @@ import java.io.Serializable;
import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.impl.ObjectBean;
/** /**
* @author Michael W. Nassif (enrouteinc@gmail.com) Class representation of the Query object (Response portion so far) * @author Michael W. Nassif (enrouteinc@gmail.com) Class representation of the
* Query object (Response portion so far)
*/ */
public class OSQuery implements Cloneable, Serializable { public class OSQuery implements Cloneable, Serializable {
private static final long serialVersionUID = 3818092699440612477L;
ObjectBean _objBean = null; ObjectBean _objBean = null;
@ -47,7 +49,8 @@ public class OSQuery implements Cloneable, Serializable {
* <p> * <p>
* *
* @return a clone of the object. * @return a clone of the object.
* @throws CloneNotSupportedException thrown if an element of the object cannot be cloned. * @throws CloneNotSupportedException thrown if an element of the object
* cannot be cloned.
* *
*/ */
@Override @Override
@ -56,7 +59,8 @@ public class OSQuery implements Cloneable, Serializable {
} }
/** /**
* Indicates whether some other object is "equal to" this one as defined by the Object equals() method. * Indicates whether some other object is "equal to" this one as defined by
* the Object equals() method.
* <p> * <p>
* *
* @param other he reference object with which to compare. * @param other he reference object with which to compare.

View file

@ -17,7 +17,6 @@ package org.rometools.feed.module.opensearch.impl;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -33,37 +32,44 @@ import com.sun.syndication.feed.module.Module;
import com.sun.syndication.io.ModuleGenerator; import com.sun.syndication.io.ModuleGenerator;
/** /**
* @author Michael W. Nassif (enrouteinc@gmail.com) OpenSearch implementation of ModuleGenerator * @author Michael W. Nassif (enrouteinc@gmail.com) OpenSearch implementation of
* ModuleGenerator
*/ */
public class OpenSearchModuleGenerator implements ModuleGenerator { public class OpenSearchModuleGenerator implements ModuleGenerator {
private static final Namespace OS_NS = Namespace.getNamespace("opensearch", OpenSearchModule.URI); private static final Namespace OS_NS = Namespace.getNamespace("opensearch", OpenSearchModule.URI);
@Override
public String getNamespaceUri() { public String getNamespaceUri() {
return OpenSearchModule.URI; return OpenSearchModule.URI;
} }
private static final Set NAMESPACES; private static final Set<Namespace> NAMESPACES;
static { static {
final Set nss = new HashSet(); final Set<Namespace> nss = new HashSet<Namespace>();
nss.add(OS_NS); nss.add(OS_NS);
NAMESPACES = Collections.unmodifiableSet(nss); NAMESPACES = Collections.unmodifiableSet(nss);
} }
/** /**
* Returns a set with all the URIs (JDOM Namespace elements) this module generator uses. * Returns a set with all the URIs (JDOM Namespace elements) this module
* generator uses.
* <p/> * <p/>
* It is used by the the feed generators to add their namespace definition in the root element of the generated document (forward-missing of Java 5.0 * It is used by the the feed generators to add their namespace definition
* Generics). * in the root element of the generated document (forward-missing of Java
* 5.0 Generics).
* <p/> * <p/>
* *
* @return a set with all the URIs (JDOM Namespace elements) this module generator uses. * @return a set with all the URIs (JDOM Namespace elements) this module
* generator uses.
*/ */
public Set getNamespaces() { @Override
public Set<Namespace> getNamespaces() {
return NAMESPACES; return NAMESPACES;
} }
@Override
public void generate(final Module module, final Element element) { public void generate(final Module module, final Element element) {
final OpenSearchModule osm = (OpenSearchModule) module; final OpenSearchModule osm = (OpenSearchModule) module;
@ -81,10 +87,9 @@ public class OpenSearchModuleGenerator implements ModuleGenerator {
if (osm.getQueries() != null) { if (osm.getQueries() != null) {
final List queries = osm.getQueries(); final List<OSQuery> queries = osm.getQueries();
for (final Iterator iter = queries.iterator(); iter.hasNext();) { for (OSQuery query : queries) {
final OSQuery query = (OSQuery) iter.next();
if (query != null) { if (query != null) {
element.addContent(generateQueryElement(query)); element.addContent(generateQueryElement(query));
} }

View file

@ -23,17 +23,20 @@ import org.rometools.feed.module.opensearch.entity.OSQuery;
import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.CopyFrom;
import com.sun.syndication.feed.atom.Link; import com.sun.syndication.feed.atom.Link;
import com.sun.syndication.feed.module.Module;
import com.sun.syndication.feed.module.ModuleImpl; import com.sun.syndication.feed.module.ModuleImpl;
/** /**
* @author Michael W. Nassif (enrouteinc@gmail.com) OpenSearch Module implementation * @author Michael W. Nassif (enrouteinc@gmail.com) OpenSearch Module
* implementation
*/ */
public class OpenSearchModuleImpl extends ModuleImpl implements OpenSearchModule, Serializable { public class OpenSearchModuleImpl extends ModuleImpl implements OpenSearchModule, Serializable {
private static final long serialVersionUID = -5257107642509731500L;
private int totalResults = -1; private int totalResults = -1;
private int startIndex = 1; private int startIndex = 1;
private int itemsPerPage = -1; private int itemsPerPage = -1;
private Link link; private Link link;
private List queries; private List<OSQuery> queries;
public OpenSearchModuleImpl() { public OpenSearchModuleImpl() {
super(OpenSearchModuleImpl.class, OpenSearchModule.URI); super(OpenSearchModuleImpl.class, OpenSearchModule.URI);
@ -42,6 +45,7 @@ public class OpenSearchModuleImpl extends ModuleImpl implements OpenSearchModule
/** /**
* @return Returns the itemsPerPage. * @return Returns the itemsPerPage.
*/ */
@Override
public int getItemsPerPage() { public int getItemsPerPage() {
return itemsPerPage; return itemsPerPage;
} }
@ -49,6 +53,7 @@ public class OpenSearchModuleImpl extends ModuleImpl implements OpenSearchModule
/** /**
* @param itemsPerPage The itemsPerPage to set. * @param itemsPerPage The itemsPerPage to set.
*/ */
@Override
public void setItemsPerPage(final int itemsPerPage) { public void setItemsPerPage(final int itemsPerPage) {
this.itemsPerPage = itemsPerPage; this.itemsPerPage = itemsPerPage;
} }
@ -56,6 +61,7 @@ public class OpenSearchModuleImpl extends ModuleImpl implements OpenSearchModule
/** /**
* @return Returns the link. * @return Returns the link.
*/ */
@Override
public Link getLink() { public Link getLink() {
return link; return link;
} }
@ -63,6 +69,7 @@ public class OpenSearchModuleImpl extends ModuleImpl implements OpenSearchModule
/** /**
* @param link The link to set. * @param link The link to set.
*/ */
@Override
public void setLink(final Link link) { public void setLink(final Link link) {
this.link = link; this.link = link;
} }
@ -70,31 +77,31 @@ public class OpenSearchModuleImpl extends ModuleImpl implements OpenSearchModule
/** /**
* @return Returns the queries. * @return Returns the queries.
*/ */
public List getQueries() { @Override
queries = queries == null ? new LinkedList() : queries; public List<OSQuery> getQueries() {
if (queries == null) {
queries = new LinkedList<OSQuery>();
}
return queries; return queries;
} }
/** /**
* @param queries The queries to set. * @param queries The queries to set.
*/ */
public void setQueries(final List queries) { @Override
public void setQueries(final List<OSQuery> queries) {
this.queries = queries; this.queries = queries;
} }
@Override
public void addQuery(final OSQuery query) { public void addQuery(final OSQuery query) {
if (queries != null) { getQueries().add(query);
queries.add(query);
} else {
queries = new LinkedList();
queries.add(query);
}
} }
/** /**
* @return Returns the startIndex. * @return Returns the startIndex.
*/ */
@Override
public int getStartIndex() { public int getStartIndex() {
return startIndex; return startIndex;
} }
@ -102,6 +109,7 @@ public class OpenSearchModuleImpl extends ModuleImpl implements OpenSearchModule
/** /**
* @param startIndex The startIndex to set. * @param startIndex The startIndex to set.
*/ */
@Override
public void setStartIndex(final int startIndex) { public void setStartIndex(final int startIndex) {
this.startIndex = startIndex; this.startIndex = startIndex;
} }
@ -109,6 +117,7 @@ public class OpenSearchModuleImpl extends ModuleImpl implements OpenSearchModule
/** /**
* @return Returns the totalResults. * @return Returns the totalResults.
*/ */
@Override
public int getTotalResults() { public int getTotalResults() {
return totalResults; return totalResults;
} }
@ -116,33 +125,37 @@ public class OpenSearchModuleImpl extends ModuleImpl implements OpenSearchModule
/** /**
* @param totalResults The totalResults to set. * @param totalResults The totalResults to set.
*/ */
@Override
public void setTotalResults(final int totalResults) { public void setTotalResults(final int totalResults) {
this.totalResults = totalResults; this.totalResults = totalResults;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
*
* @see com.sun.syndication.feed.CopyFrom#copyFrom(java.lang.Object) * @see com.sun.syndication.feed.CopyFrom#copyFrom(java.lang.Object)
*/ */
public void copyFrom(final CopyFrom obj) { @Override
final OpenSearchModule osm = (OpenSearchModuleImpl) obj; public void copyFrom(final CopyFrom<? extends Module> obj) {
final OpenSearchModule osm = (OpenSearchModule) obj;
setTotalResults(osm.getTotalResults()); setTotalResults(osm.getTotalResults());
setItemsPerPage(osm.getItemsPerPage()); setItemsPerPage(osm.getItemsPerPage());
setStartIndex(osm.getStartIndex()); setStartIndex(osm.getStartIndex());
setLink(osm.getLink()); setLink(osm.getLink());
for (final OSQuery q : osm.getQueries()) {
// setQueries(osm.getQueries()); try {
getQueries().add((OSQuery) q.clone());
} catch (final CloneNotSupportedException e) {
e.printStackTrace();
}
}
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
*
* @see com.sun.syndication.feed.CopyFrom#getInterface() * @see com.sun.syndication.feed.CopyFrom#getInterface()
*/ */
public Class getInterface() { @Override
// TODO Auto-generated method stub public Class<OpenSearchModule> getInterface() {
return OpenSearchModule.class; return OpenSearchModule.class;
} }
} }

View file

@ -33,16 +33,19 @@ import com.sun.syndication.feed.module.Module;
import com.sun.syndication.io.ModuleParser; import com.sun.syndication.io.ModuleParser;
/** /**
* @author Michael W. Nassif (enrouteinc@gmail.com) OpenSearch implementation of the ModuleParser class * @author Michael W. Nassif (enrouteinc@gmail.com) OpenSearch implementation of
* the ModuleParser class
*/ */
public class OpenSearchModuleParser implements ModuleParser { public class OpenSearchModuleParser implements ModuleParser {
private static final Namespace OS_NS = Namespace.getNamespace("opensearch", OpenSearchModule.URI); private static final Namespace OS_NS = Namespace.getNamespace("opensearch", OpenSearchModule.URI);
@Override
public String getNamespaceUri() { public String getNamespaceUri() {
return OpenSearchModule.URI; return OpenSearchModule.URI;
} }
@Override
public Module parse(final Element dcRoot) { public Module parse(final Element dcRoot) {
final URL baseURI = findBaseURI(dcRoot); final URL baseURI = findBaseURI(dcRoot);
@ -53,11 +56,9 @@ public class OpenSearchModuleParser implements ModuleParser {
Element e = dcRoot.getChild("totalResults", OS_NS); Element e = dcRoot.getChild("totalResults", OS_NS);
if (e != null) { if (e != null) {
foundSomething = true;
try { try {
osm.setTotalResults(Integer.parseInt(e.getText())); osm.setTotalResults(Integer.parseInt(e.getText()));
foundSomething = true;
} catch (final NumberFormatException ex) { } catch (final NumberFormatException ex) {
// Ignore setting the field and post a warning // Ignore setting the field and post a warning
System.err.println("Warning: The element totalResults must be an integer value: " + ex.getMessage()); System.err.println("Warning: The element totalResults must be an integer value: " + ex.getMessage());
@ -65,32 +66,36 @@ public class OpenSearchModuleParser implements ModuleParser {
} }
e = dcRoot.getChild("itemsPerPage", OS_NS); e = dcRoot.getChild("itemsPerPage", OS_NS);
if (e != null) {
try { try {
osm.setItemsPerPage(Integer.parseInt(e.getText())); osm.setItemsPerPage(Integer.parseInt(e.getText()));
} catch (final NumberFormatException ex) { foundSomething = true;
// Ignore setting the field and post a warning } catch (final NumberFormatException ex) {
System.err.println("Warning: The element itemsPerPage must be an integer value: " + ex.getMessage()); // Ignore setting the field and post a warning
System.err.println("Warning: The element itemsPerPage must be an integer value: " + ex.getMessage());
}
} }
e = dcRoot.getChild("startIndex", OS_NS); e = dcRoot.getChild("startIndex", OS_NS);
if (e != null) {
try { try {
osm.setStartIndex(Integer.parseInt(e.getText())); osm.setStartIndex(Integer.parseInt(e.getText()));
} catch (final NumberFormatException ex) { foundSomething = true;
// Ignore setting the field and post a warning } catch (final NumberFormatException ex) {
System.err.println("Warning: The element startIndex must be an integer value: " + ex.getMessage()); // Ignore setting the field and post a warning
System.err.println("Warning: The element startIndex must be an integer value: " + ex.getMessage());
}
} }
final List queries = dcRoot.getChildren("Query", OS_NS); final List<Element> queries = dcRoot.getChildren("Query", OS_NS);
if (queries != null && queries.size() > 0) { if (queries != null && queries.size() > 0) {
// Create the OSQuery list // Create the OSQuery list
final List osqList = new LinkedList(); final List<OSQuery> osqList = new LinkedList<OSQuery>();
for (final Iterator iter = queries.iterator(); iter.hasNext();) { for (final Iterator<Element> iter = queries.iterator(); iter.hasNext();) {
e = (Element) iter.next(); e = iter.next();
osqList.add(parseQuery(e)); osqList.add(parseQuery(e));
} }
@ -124,7 +129,8 @@ public class OpenSearchModuleParser implements ModuleParser {
try { try {
// someones mistake should not cause the parser to fail, since these are only optional attributes // someones mistake should not cause the parser to fail, since these
// are only optional attributes
att = e.getAttributeValue("totalResults"); att = e.getAttributeValue("totalResults");
if (att != null) { if (att != null) {
@ -147,19 +153,22 @@ public class OpenSearchModuleParser implements ModuleParser {
final Link link = new Link(); final Link link = new Link();
String att = e.getAttributeValue("rel");// getAtomNamespace()); DONT KNOW WHY DOESN'T WORK String att = e.getAttributeValue("rel");// getAtomNamespace()); DONT
// KNOW WHY DOESN'T WORK
if (att != null) { if (att != null) {
link.setRel(att); link.setRel(att);
} }
att = e.getAttributeValue("type");// getAtomNamespace()); DONT KNOW WHY DOESN'T WORK att = e.getAttributeValue("type");// getAtomNamespace()); DONT KNOW WHY
// DOESN'T WORK
if (att != null) { if (att != null) {
link.setType(att); link.setType(att);
} }
att = e.getAttributeValue("href");// getAtomNamespace()); DONT KNOW WHY DOESN'T WORK att = e.getAttributeValue("href");// getAtomNamespace()); DONT KNOW WHY
// DOESN'T WORK
if (att != null) { if (att != null) {
@ -170,13 +179,15 @@ public class OpenSearchModuleParser implements ModuleParser {
} }
} }
att = e.getAttributeValue("hreflang");// getAtomNamespace()); DONT KNOW WHY DOESN'T WORK att = e.getAttributeValue("hreflang");// getAtomNamespace()); DONT KNOW
// WHY DOESN'T WORK
if (att != null) { if (att != null) {
link.setHreflang(att); link.setHreflang(att);
} }
att = e.getAttributeValue("length");// getAtomNamespace()); DONT KNOW WHY DOESN'T WORK att = e.getAttributeValue("length");// getAtomNamespace()); DONT KNOW
// WHY DOESN'T WORK
return link; return link;
} }
@ -188,7 +199,9 @@ public class OpenSearchModuleParser implements ModuleParser {
return true; return true;
} }
/** Use xml:base attributes at feed and entry level to resolve relative links */ /**
* Use xml:base attributes at feed and entry level to resolve relative links
*/
private static String resolveURI(final URL baseURI, final Parent parent, String url) { private static String resolveURI(final URL baseURI, final Parent parent, String url) {
url = url.equals(".") || url.equals("./") ? "" : url; url = url.equals(".") || url.equals("./") ? "" : url;
if (isRelativeURI(url) && parent != null && parent instanceof Element) { if (isRelativeURI(url) && parent != null && parent instanceof Element) {
@ -213,10 +226,10 @@ public class OpenSearchModuleParser implements ModuleParser {
/** Use feed links and/or xml:base attribute to determine baseURI of feed */ /** Use feed links and/or xml:base attribute to determine baseURI of feed */
private static URL findBaseURI(final Element root) { private static URL findBaseURI(final Element root) {
URL baseURI = null; URL baseURI = null;
final List linksList = root.getChildren("link", OS_NS); final List<Element> linksList = root.getChildren("link", OS_NS);
if (linksList != null) { if (linksList != null) {
for (final Iterator links = linksList.iterator(); links.hasNext();) { for (final Element element : linksList) {
final Element link = (Element) links.next(); final Element link = element;
if (!root.equals(link.getParent())) { if (!root.equals(link.getParent())) {
break; break;
} }