Formatted code

Added Eclipse formatter and cleanup configuration
This commit is contained in:
Patrick Gotthard 2013-10-12 00:12:08 +02:00
parent d3509f97ca
commit c71113f197
11 changed files with 264 additions and 276 deletions

View file

@ -17,11 +17,11 @@
*/ */
package com.sun.syndication.feed.opml; package com.sun.syndication.feed.opml;
import java.io.Serializable;
import com.sun.syndication.feed.impl.EqualsBean; import com.sun.syndication.feed.impl.EqualsBean;
import com.sun.syndication.feed.impl.ToStringBean; import com.sun.syndication.feed.impl.ToStringBean;
import java.io.Serializable;
/** /**
* This is a simple name-value pair attribute for outlines. * This is a simple name-value pair attribute for outlines.
* *
@ -42,13 +42,12 @@ public class Attribute implements Cloneable, Serializable {
* @param name name of the attribute. * @param name name of the attribute.
* @param value value of the attribute. * @param value value of the attribute.
*/ */
public Attribute(String name, String value) { public Attribute(final String name, final String value) {
if ((name == null) || (value == null)) { if (name == null || value == null) {
throw new NullPointerException("Name and value are required."); throw new NullPointerException("Name and value are required.");
} }
setName(name);
this.setName(name); setValue(value);
this.setValue(value);
} }
/** /**
@ -56,8 +55,8 @@ public class Attribute implements Cloneable, Serializable {
* *
* @param name name of the attribute. * @param name name of the attribute.
*/ */
public void setName(String name) { public void setName(final String name) {
this._name = name; _name = name;
} }
/** /**
@ -74,8 +73,8 @@ public class Attribute implements Cloneable, Serializable {
* *
* @param value value of the attribute. * @param value value of the attribute.
*/ */
public void setValue(String value) { public void setValue(final String value) {
this._value = value; _value = value;
} }
/** /**
@ -89,27 +88,24 @@ public class Attribute implements Cloneable, Serializable {
@Override @Override
public Object clone() { public Object clone() {
return new Attribute(this._name, this._value); return new Attribute(_name, _value);
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(final Object obj) {
EqualsBean eBean = new EqualsBean(Attribute.class, this); final EqualsBean eBean = new EqualsBean(Attribute.class, this);
return eBean.beanEquals(obj); return eBean.beanEquals(obj);
} }
@Override @Override
public int hashCode() { public int hashCode() {
EqualsBean equals = new EqualsBean(Attribute.class, this); final EqualsBean equals = new EqualsBean(Attribute.class, this);
return equals.beanHashCode(); return equals.beanHashCode();
} }
@Override @Override
public String toString() { public String toString() {
ToStringBean tsBean = new ToStringBean(Attribute.class, this); final ToStringBean tsBean = new ToStringBean(Attribute.class, this);
return tsBean.toString(); return tsBean.toString();
} }
} }

View file

@ -17,12 +17,12 @@
*/ */
package com.sun.syndication.feed.opml; package com.sun.syndication.feed.opml;
import com.sun.syndication.feed.WireFeed;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.sun.syndication.feed.WireFeed;
/** /**
* This class represents the root of an OPML 1/2 feed and contains the elements that may appear in the <head> tag of the feed. * This class represents the root of an OPML 1/2 feed and contains the elements that may appear in the <head> tag of the feed.
* *
@ -54,8 +54,8 @@ public class Opml extends WireFeed {
* *
* @param created date-time, indicating when the document was created. * @param created date-time, indicating when the document was created.
*/ */
public void setCreated(Date created) { public void setCreated(final Date created) {
this._created = created; _created = created;
} }
/** /**
@ -73,8 +73,8 @@ public class Opml extends WireFeed {
* *
* @param docs http address of documentation for the format used * @param docs http address of documentation for the format used
*/ */
public void setDocs(String docs) { public void setDocs(final String docs) {
this._docs = docs; _docs = docs;
} }
/** /**
@ -94,8 +94,8 @@ public class Opml extends WireFeed {
* *
* @param expansionState int array containing expanded elements. * @param expansionState int array containing expanded elements.
*/ */
public void setExpansionState(int[] expansionState) { public void setExpansionState(final int[] expansionState) {
this._expansionState = expansionState; _expansionState = expansionState;
} }
/** /**
@ -114,8 +114,8 @@ public class Opml extends WireFeed {
* *
* @param modified date-time, indicating when the document was last modified. * @param modified date-time, indicating when the document was last modified.
*/ */
public void setModified(Date modified) { public void setModified(final Date modified) {
this._modified = modified; _modified = modified;
} }
/** /**
@ -132,8 +132,8 @@ public class Opml extends WireFeed {
* *
* @param outlines Root level Outline object that should appear in the <body> * @param outlines Root level Outline object that should appear in the <body>
*/ */
public void setOutlines(List outlines) { public void setOutlines(final List outlines) {
this._outlines = outlines; _outlines = outlines;
} }
/** /**
@ -154,8 +154,8 @@ public class Opml extends WireFeed {
* *
* @param ownerEmail the email address of the owner of the document. * @param ownerEmail the email address of the owner of the document.
*/ */
public void setOwnerEmail(String ownerEmail) { public void setOwnerEmail(final String ownerEmail) {
this._ownerEmail = ownerEmail; _ownerEmail = ownerEmail;
} }
/** /**
@ -174,8 +174,8 @@ public class Opml extends WireFeed {
* @param ownerId http address of a web page that contains <strike>an HTML</strike> a form that allows a human reader to communicate with the author of the * @param ownerId http address of a web page that contains <strike>an HTML</strike> a form that allows a human reader to communicate with the author of the
* document via email or other means. * document via email or other means.
*/ */
public void setOwnerId(String ownerId) { public void setOwnerId(final String ownerId) {
this._ownerId = ownerId; _ownerId = ownerId;
} }
/** /**
@ -194,8 +194,8 @@ public class Opml extends WireFeed {
* *
* @param ownerName the owner of the document. * @param ownerName the owner of the document.
*/ */
public void setOwnerName(String ownerName) { public void setOwnerName(final String ownerName) {
this._ownerName = ownerName; _ownerName = ownerName;
} }
/** /**
@ -212,8 +212,8 @@ public class Opml extends WireFeed {
* *
* @param title title of the document. * @param title title of the document.
*/ */
public void setTitle(String title) { public void setTitle(final String title) {
this._title = title; _title = title;
} }
/** /**
@ -231,8 +231,8 @@ public class Opml extends WireFeed {
* *
* @param verticalScrollState which line of the outline is displayed on the top line of the window. * @param verticalScrollState which line of the outline is displayed on the top line of the window.
*/ */
public void setVerticalScrollState(Integer verticalScrollState) { public void setVerticalScrollState(final Integer verticalScrollState) {
this._verticalScrollState = verticalScrollState; _verticalScrollState = verticalScrollState;
} }
/** /**
@ -250,8 +250,8 @@ public class Opml extends WireFeed {
* *
* @param windowBottom the pixel location of the bottom edge of the window. * @param windowBottom the pixel location of the bottom edge of the window.
*/ */
public void setWindowBottom(Integer windowBottom) { public void setWindowBottom(final Integer windowBottom) {
this._windowBottom = windowBottom; _windowBottom = windowBottom;
} }
/** /**
@ -268,8 +268,8 @@ public class Opml extends WireFeed {
* *
* @param windowLeft the pixel location of the left edge of the window. * @param windowLeft the pixel location of the left edge of the window.
*/ */
public void setWindowLeft(Integer windowLeft) { public void setWindowLeft(final Integer windowLeft) {
this._windowLeft = windowLeft; _windowLeft = windowLeft;
} }
/** /**
@ -286,8 +286,8 @@ public class Opml extends WireFeed {
* *
* @param windowRight the pixel location of the right edge of the window. * @param windowRight the pixel location of the right edge of the window.
*/ */
public void setWindowRight(Integer windowRight) { public void setWindowRight(final Integer windowRight) {
this._windowRight = windowRight; _windowRight = windowRight;
} }
/** /**
@ -304,8 +304,8 @@ public class Opml extends WireFeed {
* *
* @param windowTop the pixel location of the top edge of the window. * @param windowTop the pixel location of the top edge of the window.
*/ */
public void setWindowTop(Integer windowTop) { public void setWindowTop(final Integer windowTop) {
this._windowTop = windowTop; _windowTop = windowTop;
} }
/** /**

View file

@ -17,18 +17,16 @@
*/ */
package com.sun.syndication.feed.opml; package com.sun.syndication.feed.opml;
import com.sun.syndication.feed.impl.EqualsBean;
import com.sun.syndication.feed.impl.ToStringBean;
import java.io.Serializable; import java.io.Serializable;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.sun.syndication.feed.impl.EqualsBean;
import com.sun.syndication.feed.impl.ToStringBean;
/** /**
* This class represents an OPML outline element. * This class represents an OPML outline element.
* *
@ -57,10 +55,10 @@ public class Outline implements Cloneable, Serializable {
* @param type type attribute value/ * @param type type attribute value/
* @param text text attribute value * @param text text attribute value
*/ */
public Outline(String type, String text) { public Outline(final String type, final String text) {
super(); super();
this.setType(type); setType(type);
this.setText(text); setText(text);
} }
/** /**
@ -70,11 +68,11 @@ public class Outline implements Cloneable, Serializable {
* @param xmlUrl link to XML file. * @param xmlUrl link to XML file.
* @param htmlUrl link to html page. * @param htmlUrl link to html page.
*/ */
public Outline(String title, URL xmlUrl, URL htmlUrl) { public Outline(final String title, final URL xmlUrl, final URL htmlUrl) {
super(); super();
this.setType("rss"); setType("rss");
this.setTitle(title); setTitle(title);
this.setAttributes(new ArrayList()); setAttributes(new ArrayList());
if (xmlUrl != null) { if (xmlUrl != null) {
getAttributes().add(new Attribute("xmlUrl", xmlUrl.toString())); getAttributes().add(new Attribute("xmlUrl", xmlUrl.toString()));
@ -90,8 +88,8 @@ public class Outline implements Cloneable, Serializable {
* *
* @param attributes List of attributes on this outline. * @param attributes List of attributes on this outline.
*/ */
public void setAttributes(List attributes) { public void setAttributes(final List attributes) {
this._attributes = attributes; _attributes = attributes;
} }
/** /**
@ -100,8 +98,8 @@ public class Outline implements Cloneable, Serializable {
* @return List of attributes on this outline. * @return List of attributes on this outline.
*/ */
public List getAttributes() { public List getAttributes() {
if (this._attributes == null) { if (_attributes == null) {
this._attributes = new ArrayList(); _attributes = new ArrayList();
} }
return _attributes; return _attributes;
@ -113,8 +111,8 @@ public class Outline implements Cloneable, Serializable {
* *
* @param breakpoint whether a breakpoint is set on this outline. * @param breakpoint whether a breakpoint is set on this outline.
*/ */
public void setBreakpoint(boolean breakpoint) { public void setBreakpoint(final boolean breakpoint) {
this._breakpoint = breakpoint; _breakpoint = breakpoint;
} }
/** /**
@ -132,8 +130,8 @@ public class Outline implements Cloneable, Serializable {
* *
* @param categories (OPML 2) A List of Strings indicating values in the category attribute. * @param categories (OPML 2) A List of Strings indicating values in the category attribute.
*/ */
public void setCategories(List categories) { public void setCategories(final List categories) {
this._categories = categories; _categories = categories;
} }
/** /**
@ -154,8 +152,8 @@ public class Outline implements Cloneable, Serializable {
* *
* @param children A list of sub-outlines for this entry. * @param children A list of sub-outlines for this entry.
*/ */
public void setChildren(List children) { public void setChildren(final List children) {
this._children = children; _children = children;
} }
/** /**
@ -177,8 +175,8 @@ public class Outline implements Cloneable, Serializable {
* *
* @param comment whether the outline is commented * @param comment whether the outline is commented
*/ */
public void setComment(boolean comment) { public void setComment(final boolean comment) {
this._comment = comment; _comment = comment;
} }
/** /**
@ -196,8 +194,8 @@ public class Outline implements Cloneable, Serializable {
* *
* @param created date-time that the outline node was created. * @param created date-time that the outline node was created.
*/ */
public void setCreated(Date created) { public void setCreated(final Date created) {
this._created = created; _created = created;
} }
/** /**
@ -227,13 +225,13 @@ public class Outline implements Cloneable, Serializable {
return getAttributeValue("htmlUrl"); return getAttributeValue("htmlUrl");
} }
public void setModules(List modules) { public void setModules(final List modules) {
this._modules = modules; _modules = modules;
} }
public List getModules() { public List getModules() {
if (this._modules == null) { if (_modules == null) {
this._modules = new ArrayList(); _modules = new ArrayList();
} }
return _modules; return _modules;
@ -244,8 +242,8 @@ public class Outline implements Cloneable, Serializable {
* *
* @param text The "text" attribute of the outline. * @param text The "text" attribute of the outline.
*/ */
public void setText(String text) { public void setText(final String text) {
this._text = text; _text = text;
} }
/** /**
@ -262,8 +260,8 @@ public class Outline implements Cloneable, Serializable {
* *
* @param title The "title" attribute of the outline. * @param title The "title" attribute of the outline.
*/ */
public void setTitle(String title) { public void setTitle(final String title) {
this._title = title; _title = title;
} }
/** /**
@ -280,8 +278,8 @@ public class Outline implements Cloneable, Serializable {
* *
* @param type The "type" attribute of the outline. * @param type The "type" attribute of the outline.
*/ */
public void setType(String type) { public void setType(final String type) {
this._type = type; _type = type;
} }
/** /**
@ -307,13 +305,13 @@ public class Outline implements Cloneable, Serializable {
* *
* @param name name of the attribute. * @param name name of the attribute.
*/ */
public String getAttributeValue(String name) { public String getAttributeValue(final String name) {
List attributes = Collections.synchronizedList(this.getAttributes()); final List attributes = Collections.synchronizedList(getAttributes());
for (int i = 0; i < attributes.size(); i++) { for (int i = 0; i < attributes.size(); i++) {
Attribute a = (Attribute) attributes.get(i); final Attribute a = (Attribute) attributes.get(i);
if ((a.getName() != null) && a.getName().equals(name)) { if (a.getName() != null && a.getName().equals(name)) {
return a.getValue(); return a.getValue();
} }
} }
@ -323,28 +321,28 @@ public class Outline implements Cloneable, Serializable {
@Override @Override
public Object clone() { public Object clone() {
Outline o = new Outline(); final Outline o = new Outline();
o.setBreakpoint(this.isBreakpoint()); o.setBreakpoint(isBreakpoint());
o.setCategories(new ArrayList(this.getCategories())); o.setCategories(new ArrayList(getCategories()));
o.setComment(this.isComment()); o.setComment(isComment());
o.setCreated((this._created != null) ? (Date) this._created.clone() : null); o.setCreated(_created != null ? (Date) _created.clone() : null);
o.setModules(new ArrayList(this.getModules())); o.setModules(new ArrayList(getModules()));
o.setText(this.getText()); o.setText(getText());
o.setTitle(this.getTitle()); o.setTitle(getTitle());
o.setType(this.getType()); o.setType(getType());
ArrayList children = new ArrayList(); final ArrayList children = new ArrayList();
for (int i = 0; i < this.getChildren().size(); i++) { for (int i = 0; i < getChildren().size(); i++) {
children.add(((Outline) this._children.get(i)).clone()); children.add(((Outline) _children.get(i)).clone());
} }
o.setChildren(children); o.setChildren(children);
ArrayList attributes = new ArrayList(); final ArrayList attributes = new ArrayList();
for (int i = 0; i < this.getAttributes().size(); i++) { for (int i = 0; i < getAttributes().size(); i++) {
attributes.add(((Attribute) this._attributes.get(i)).clone()); attributes.add(((Attribute) _attributes.get(i)).clone());
} }
o.setAttributes(attributes); o.setAttributes(attributes);
@ -353,22 +351,22 @@ public class Outline implements Cloneable, Serializable {
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(final Object obj) {
EqualsBean eBean = new EqualsBean(Outline.class, this); final EqualsBean eBean = new EqualsBean(Outline.class, this);
return eBean.beanEquals(obj); return eBean.beanEquals(obj);
} }
@Override @Override
public int hashCode() { public int hashCode() {
EqualsBean equals = new EqualsBean(Outline.class, this); final EqualsBean equals = new EqualsBean(Outline.class, this);
return equals.beanHashCode(); return equals.beanHashCode();
} }
@Override @Override
public String toString() { public String toString() {
ToStringBean tsBean = new ToStringBean(Outline.class, this); final ToStringBean tsBean = new ToStringBean(Outline.class, this);
return tsBean.toString(); return tsBean.toString();
} }

View file

@ -55,10 +55,10 @@ public class ConverterForOPML10 implements Converter {
super(); super();
} }
protected void addOwner(Opml opml, SyndFeed syndFeed) { protected void addOwner(final Opml opml, final SyndFeed syndFeed) {
if ((opml.getOwnerEmail() != null) || (opml.getOwnerName() != null)) { if (opml.getOwnerEmail() != null || opml.getOwnerName() != null) {
List authors = new ArrayList(); final List authors = new ArrayList();
SyndPerson person = new SyndPersonImpl(); final SyndPerson person = new SyndPersonImpl();
person.setEmail(opml.getOwnerEmail()); person.setEmail(opml.getOwnerEmail());
person.setName(opml.getOwnerName()); person.setName(opml.getOwnerName());
authors.add(person); authors.add(person);
@ -76,38 +76,38 @@ public class ConverterForOPML10 implements Converter {
* @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed. * @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
*/ */
@Override @Override
public void copyInto(WireFeed feed, SyndFeed syndFeed) { public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
Opml opml = (Opml) feed; final Opml opml = (Opml) feed;
syndFeed.setTitle(opml.getTitle()); syndFeed.setTitle(opml.getTitle());
addOwner(opml, syndFeed); addOwner(opml, syndFeed);
syndFeed.setPublishedDate((opml.getModified() != null) ? opml.getModified() : opml.getCreated()); syndFeed.setPublishedDate(opml.getModified() != null ? opml.getModified() : opml.getCreated());
syndFeed.setFeedType(opml.getFeedType()); syndFeed.setFeedType(opml.getFeedType());
syndFeed.setModules(opml.getModules()); syndFeed.setModules(opml.getModules());
syndFeed.setFeedType(this.getType()); syndFeed.setFeedType(getType());
ArrayList entries = new ArrayList(); final ArrayList entries = new ArrayList();
createEntries(new TreeContext(), syndFeed.getEntries(), opml.getOutlines()); createEntries(new TreeContext(), syndFeed.getEntries(), opml.getOutlines());
} }
protected void createEntries(TreeContext context, List allEntries, List outlines) { protected void createEntries(final TreeContext context, final List allEntries, final List outlines) {
List so = Collections.synchronizedList(outlines); final List so = Collections.synchronizedList(outlines);
for (int i = 0; i < so.size(); i++) { for (int i = 0; i < so.size(); i++) {
createEntry(context, allEntries, (Outline) so.get(i)); createEntry(context, allEntries, (Outline) so.get(i));
} }
} }
protected SyndEntry createEntry(TreeContext context, List allEntries, Outline outline) { protected SyndEntry createEntry(final TreeContext context, final List allEntries, final Outline outline) {
SyndEntry entry = new SyndEntryImpl(); final SyndEntry entry = new SyndEntryImpl();
if ((outline.getType() != null) && outline.getType().equals("rss")) { if (outline.getType() != null && outline.getType().equals("rss")) {
entry.setLink((outline.getHtmlUrl() != null) ? outline.getHtmlUrl() : outline.getXmlUrl()); entry.setLink(outline.getHtmlUrl() != null ? outline.getHtmlUrl() : outline.getXmlUrl());
} else if ((outline.getType() != null) && outline.getType().equals("link")) { } else if (outline.getType() != null && outline.getType().equals("link")) {
entry.setLink(outline.getUrl()); entry.setLink(outline.getUrl());
} }
if (outline.getHtmlUrl() != null) { if (outline.getHtmlUrl() != null) {
SyndLink link = new SyndLinkImpl(); final SyndLink link = new SyndLinkImpl();
link.setRel("alternate"); link.setRel("alternate");
link.setType("text/html"); link.setType("text/html");
link.setHref(outline.getHtmlUrl()); link.setHref(outline.getHtmlUrl());
@ -115,8 +115,8 @@ public class ConverterForOPML10 implements Converter {
entry.setLink(outline.getHtmlUrl()); entry.setLink(outline.getHtmlUrl());
} }
if ((outline.getXmlUrl() != null) && (outline.getType() != null) && outline.getType().equalsIgnoreCase("rss")) { if (outline.getXmlUrl() != null && outline.getType() != null && outline.getType().equalsIgnoreCase("rss")) {
SyndLink link = new SyndLinkImpl(); final SyndLink link = new SyndLinkImpl();
link.setRel("alternate"); link.setRel("alternate");
link.setType("application/rss+xml"); link.setType("application/rss+xml");
link.setHref(outline.getXmlUrl()); link.setHref(outline.getXmlUrl());
@ -127,8 +127,8 @@ public class ConverterForOPML10 implements Converter {
} }
} }
if ((outline.getXmlUrl() != null) && (outline.getType() != null) && outline.getType().equalsIgnoreCase("atom")) { if (outline.getXmlUrl() != null && outline.getType() != null && outline.getType().equalsIgnoreCase("atom")) {
SyndLink link = new SyndLinkImpl(); final SyndLink link = new SyndLinkImpl();
link.setRel("alternate"); link.setRel("alternate");
link.setType("application/atom+xml"); link.setType("application/atom+xml");
link.setHref(outline.getXmlUrl()); link.setHref(outline.getXmlUrl());
@ -139,40 +139,40 @@ public class ConverterForOPML10 implements Converter {
} }
} }
if ((outline.getType() != null) && outline.getType().equals("rss")) { if (outline.getType() != null && outline.getType().equals("rss")) {
entry.setTitle(outline.getTitle()); entry.setTitle(outline.getTitle());
} else { } else {
entry.setTitle(outline.getText()); entry.setTitle(outline.getText());
} }
if ((outline.getText() == null) && (entry.getTitle() != null)) { if (outline.getText() == null && entry.getTitle() != null) {
SyndContent c = new SyndContentImpl(); final SyndContent c = new SyndContentImpl();
c.setValue(outline.getText()); c.setValue(outline.getText());
entry.setDescription(c); entry.setDescription(c);
} }
entry.setPublishedDate(outline.getCreated()); entry.setPublishedDate(outline.getCreated());
String nodeName = "node." + outline.hashCode(); final String nodeName = "node." + outline.hashCode();
SyndCategory cat = new TreeCategoryImpl(); final SyndCategory cat = new TreeCategoryImpl();
cat.setTaxonomyUri(URI_TREE); cat.setTaxonomyUri(URI_TREE);
cat.setName(nodeName); cat.setName(nodeName);
entry.getCategories().add(cat); entry.getCategories().add(cat);
if (context.size() > 0) { if (context.size() > 0) {
Integer parent = (Integer) context.peek(); final Integer parent = (Integer) context.peek();
SyndCategory pcat = new TreeCategoryImpl(); final SyndCategory pcat = new TreeCategoryImpl();
pcat.setTaxonomyUri(URI_TREE); pcat.setTaxonomyUri(URI_TREE);
pcat.setName("parent." + parent); pcat.setName("parent." + parent);
entry.getCategories().add(pcat); entry.getCategories().add(pcat);
} }
List attributes = Collections.synchronizedList(outline.getAttributes()); final List attributes = Collections.synchronizedList(outline.getAttributes());
for (int i = 0; i < attributes.size(); i++) { for (int i = 0; i < attributes.size(); i++) {
Attribute a = (Attribute) attributes.get(i); final Attribute a = (Attribute) attributes.get(i);
SyndCategory acat = new SyndCategoryImpl(); final SyndCategory acat = new SyndCategoryImpl();
acat.setName(a.getValue()); acat.setName(a.getValue());
acat.setTaxonomyUri(URI_ATTRIBUTE + a.getName()); acat.setTaxonomyUri(URI_ATTRIBUTE + a.getName());
entry.getCategories().add(acat); entry.getCategories().add(acat);
@ -196,33 +196,33 @@ public class ConverterForOPML10 implements Converter {
* *
*/ */
@Override @Override
public WireFeed createRealFeed(SyndFeed syndFeed) { public WireFeed createRealFeed(final SyndFeed syndFeed) {
List entries = Collections.synchronizedList(syndFeed.getEntries()); final List entries = Collections.synchronizedList(syndFeed.getEntries());
HashMap entriesByNode = new HashMap(); final HashMap entriesByNode = new HashMap();
ArrayList doAfterPass = new ArrayList(); // this will hold entries that we can't parent the first time. final ArrayList doAfterPass = new ArrayList(); // this will hold entries that we can't parent the first time.
ArrayList root = new ArrayList(); // this holds root level outlines; final ArrayList root = new ArrayList(); // this holds root level outlines;
for (int i = 0; i < entries.size(); i++) { for (int i = 0; i < entries.size(); i++) {
SyndEntry entry = (SyndEntry) entries.get(i); final SyndEntry entry = (SyndEntry) entries.get(i);
Outline o = new Outline(); final Outline o = new Outline();
List cats = Collections.synchronizedList(entry.getCategories()); final List cats = Collections.synchronizedList(entry.getCategories());
boolean parentFound = false; boolean parentFound = false;
StringBuffer category = new StringBuffer(); final StringBuffer category = new StringBuffer();
for (int j = 0; j < cats.size(); j++) { for (int j = 0; j < cats.size(); j++) {
SyndCategory cat = (SyndCategory) cats.get(j); final SyndCategory cat = (SyndCategory) cats.get(j);
if ((cat.getTaxonomyUri() != null) && cat.getTaxonomyUri().equals(URI_TREE)) { if (cat.getTaxonomyUri() != null && cat.getTaxonomyUri().equals(URI_TREE)) {
String nodeVal = cat.getName().substring(cat.getName().lastIndexOf("."), cat.getName().length()); final String nodeVal = cat.getName().substring(cat.getName().lastIndexOf("."), cat.getName().length());
if (cat.getName().startsWith("node.")) { if (cat.getName().startsWith("node.")) {
entriesByNode.put(nodeVal, o); entriesByNode.put(nodeVal, o);
} else if (cat.getName().startsWith("parent.")) { } else if (cat.getName().startsWith("parent.")) {
parentFound = true; parentFound = true;
Outline parent = (Outline) entriesByNode.get(nodeVal); final Outline parent = (Outline) entriesByNode.get(nodeVal);
if (parent != null) { if (parent != null) {
parent.getChildren().add(o); parent.getChildren().add(o);
@ -230,8 +230,8 @@ public class ConverterForOPML10 implements Converter {
doAfterPass.add(new OutlineHolder(o, nodeVal)); doAfterPass.add(new OutlineHolder(o, nodeVal));
} }
} }
} else if ((cat.getTaxonomyUri() != null) && cat.getTaxonomyUri().startsWith(URI_ATTRIBUTE)) { } else if (cat.getTaxonomyUri() != null && cat.getTaxonomyUri().startsWith(URI_ATTRIBUTE)) {
String name = cat.getTaxonomyUri().substring(cat.getTaxonomyUri().indexOf("#") + 1, cat.getTaxonomyUri().length()); final String name = cat.getTaxonomyUri().substring(cat.getTaxonomyUri().indexOf("#") + 1, cat.getTaxonomyUri().length());
o.getAttributes().add(new Attribute(name, cat.getName())); o.getAttributes().add(new Attribute(name, cat.getName()));
} else { } else {
if (category.length() > 0) { if (category.length() > 0) {
@ -250,21 +250,21 @@ public class ConverterForOPML10 implements Converter {
o.getAttributes().add(new Attribute("category", category.toString())); o.getAttributes().add(new Attribute("category", category.toString()));
} }
List links = Collections.synchronizedList(entry.getLinks()); final List links = Collections.synchronizedList(entry.getLinks());
String entryLink = entry.getLink(); final String entryLink = entry.getLink();
for (int j = 0; j < links.size(); j++) { for (int j = 0; j < links.size(); j++) {
SyndLink link = (SyndLink) links.get(j); final SyndLink link = (SyndLink) links.get(j);
// if(link.getHref().equals(entryLink)) { // if(link.getHref().equals(entryLink)) {
if (((link.getType() != null) && (link.getRel() != null) && link.getRel().equals("alternate")) if (link.getType() != null && link.getRel() != null && link.getRel().equals("alternate")
&& (link.getType().equals("application/rss+xml") || link.getType().equals("application/atom+xml"))) { && (link.getType().equals("application/rss+xml") || link.getType().equals("application/atom+xml"))) {
o.setType("rss"); o.setType("rss");
if (o.getXmlUrl() == null) { if (o.getXmlUrl() == null) {
o.getAttributes().add(new Attribute("xmlUrl", link.getHref())); o.getAttributes().add(new Attribute("xmlUrl", link.getHref()));
} }
} else if ((link.getType() != null) && (link.getType().equals("text/html"))) { } else if (link.getType() != null && link.getType().equals("text/html")) {
if (o.getHtmlUrl() == null) { if (o.getHtmlUrl() == null) {
o.getAttributes().add(new Attribute("htmlUrl", link.getHref())); o.getAttributes().add(new Attribute("htmlUrl", link.getHref()));
} }
@ -275,22 +275,22 @@ public class ConverterForOPML10 implements Converter {
// } // }
} }
if ((o.getType() == null) || o.getType().equals("link")) { if (o.getType() == null || o.getType().equals("link")) {
o.setText(entry.getTitle()); o.setText(entry.getTitle());
} else { } else {
o.setTitle(entry.getTitle()); o.setTitle(entry.getTitle());
} }
if ((o.getText() == null) && (entry.getDescription() != null)) { if (o.getText() == null && entry.getDescription() != null) {
o.setText(entry.getDescription().getValue()); o.setText(entry.getDescription().getValue());
} }
} }
// Do back and parenting for things we missed. // Do back and parenting for things we missed.
for (int i = 0; i < doAfterPass.size(); i++) { for (int i = 0; i < doAfterPass.size(); i++) {
OutlineHolder o = (OutlineHolder) doAfterPass.get(i); final OutlineHolder o = (OutlineHolder) doAfterPass.get(i);
Outline parent = (Outline) entriesByNode.get(o.parent); final Outline parent = (Outline) entriesByNode.get(o.parent);
if (parent == null) { if (parent == null) {
root.add(o.outline); root.add(o.outline);
@ -300,17 +300,17 @@ public class ConverterForOPML10 implements Converter {
} }
} }
Opml opml = new Opml(); final Opml opml = new Opml();
opml.setFeedType(this.getType()); opml.setFeedType(getType());
opml.setCreated(syndFeed.getPublishedDate()); opml.setCreated(syndFeed.getPublishedDate());
opml.setTitle(syndFeed.getTitle()); opml.setTitle(syndFeed.getTitle());
List authors = Collections.synchronizedList(syndFeed.getAuthors()); final List authors = Collections.synchronizedList(syndFeed.getAuthors());
for (int i = 0; i < authors.size(); i++) { for (int i = 0; i < authors.size(); i++) {
SyndPerson p = (SyndPerson) authors.get(i); final SyndPerson p = (SyndPerson) authors.get(i);
if ((syndFeed.getAuthor() == null) || syndFeed.getAuthor().equals(p.getName())) { if (syndFeed.getAuthor() == null || syndFeed.getAuthor().equals(p.getName())) {
opml.setOwnerName(p.getName()); opml.setOwnerName(p.getName());
opml.setOwnerEmail(p.getEmail()); opml.setOwnerEmail(p.getEmail());
opml.setOwnerId(p.getUri()); opml.setOwnerId(p.getUri());
@ -339,7 +339,7 @@ public class ConverterForOPML10 implements Converter {
Outline outline; Outline outline;
String parent; String parent;
public OutlineHolder(Outline outline, String parent) { public OutlineHolder(final Outline outline, final String parent) {
this.outline = outline; this.outline = outline;
this.parent = parent; this.parent = parent;
} }

View file

@ -44,7 +44,7 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
* @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed. * @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
*/ */
@Override @Override
public void copyInto(WireFeed feed, SyndFeed syndFeed) { public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
super.copyInto(feed, syndFeed); super.copyInto(feed, syndFeed);
} }
@ -56,7 +56,7 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
* @return a real feed with copied/converted values of the SyndFeedImpl. * @return a real feed with copied/converted values of the SyndFeedImpl.
*/ */
@Override @Override
public WireFeed createRealFeed(SyndFeed syndFeed) { public WireFeed createRealFeed(final SyndFeed syndFeed) {
WireFeed retValue; WireFeed retValue;
retValue = super.createRealFeed(syndFeed); retValue = super.createRealFeed(syndFeed);

View file

@ -24,12 +24,13 @@ public class TreeCategoryImpl extends SyndCategoryImpl {
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(final Object o) {
SyndCategory c = (SyndCategory) o; final SyndCategory c = (SyndCategory) o;
if (c.getTaxonomyUri() != null && c.getTaxonomyUri().equals(this.getTaxonomyUri())) if (c.getTaxonomyUri() != null && c.getTaxonomyUri().equals(getTaxonomyUri())) {
return true; return true;
else } else {
return false; return false;
}
} }
} }

View file

@ -17,21 +17,19 @@
*/ */
package com.sun.syndication.io.impl; package com.sun.syndication.io.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.jdom2.Document;
import org.jdom2.Element;
import com.sun.syndication.feed.WireFeed; import com.sun.syndication.feed.WireFeed;
import com.sun.syndication.feed.opml.Attribute; import com.sun.syndication.feed.opml.Attribute;
import com.sun.syndication.feed.opml.Opml; import com.sun.syndication.feed.opml.Opml;
import com.sun.syndication.feed.opml.Outline; import com.sun.syndication.feed.opml.Outline;
import com.sun.syndication.io.FeedException; import com.sun.syndication.io.FeedException;
import com.sun.syndication.io.WireFeedGenerator; import com.sun.syndication.io.WireFeedGenerator;
import com.sun.syndication.io.impl.BaseWireFeedGenerator;
import com.sun.syndication.io.impl.DateParser;
import org.jdom2.Document;
import org.jdom2.Element;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* *
@ -43,7 +41,7 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
super("opml_1.0"); super("opml_1.0");
} }
public OPML10Generator(String type) { public OPML10Generator(final String type) {
super(type); super(type);
} }
@ -57,23 +55,23 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
* @throws FeedException thrown if the XML Document could not be created. * @throws FeedException thrown if the XML Document could not be created.
*/ */
@Override @Override
public Document generate(WireFeed feed) throws IllegalArgumentException, FeedException { public Document generate(final WireFeed feed) throws IllegalArgumentException, FeedException {
if (!(feed instanceof Opml)) { if (!(feed instanceof Opml)) {
throw new IllegalArgumentException("Not an OPML file"); throw new IllegalArgumentException("Not an OPML file");
} }
Opml opml = (Opml) feed; final Opml opml = (Opml) feed;
Document doc = new Document(); final Document doc = new Document();
Element root = new Element("opml"); final Element root = new Element("opml");
doc.addContent(root); doc.addContent(root);
Element head = generateHead(opml); final Element head = generateHead(opml);
if (head != null) { if (head != null) {
root.addContent(head); root.addContent(head);
} }
Element body = new Element("body"); final Element body = new Element("body");
root.addContent(body); root.addContent(body);
super.generateFeedModules(opml.getModules(), root); super.generateFeedModules(opml.getModules(), root);
body.addContent(generateOutlines(opml.getOutlines())); body.addContent(generateOutlines(opml.getOutlines()));
@ -81,8 +79,8 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
return doc; return doc;
} }
protected boolean addNotNullAttribute(Element target, String name, Object value) { protected boolean addNotNullAttribute(final Element target, final String name, final Object value) {
if ((target == null) || (name == null) || (value == null)) { if (target == null || name == null || value == null) {
return false; return false;
} }
@ -91,20 +89,20 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
return true; return true;
} }
protected boolean addNotNullSimpleElement(Element target, String name, Object value) { protected boolean addNotNullSimpleElement(final Element target, final String name, final Object value) {
if ((target == null) || (name == null) || (value == null)) { if (target == null || name == null || value == null) {
return false; return false;
} }
Element e = new Element(name); final Element e = new Element(name);
e.addContent(value.toString()); e.addContent(value.toString());
target.addContent(e); target.addContent(e);
return true; return true;
} }
protected Element generateHead(Opml opml) { protected Element generateHead(final Opml opml) {
Element head = new Element("head"); final Element head = new Element("head");
boolean hasHead = false; boolean hasHead = false;
if (opml.getCreated() != null) { if (opml.getCreated() != null) {
@ -133,8 +131,8 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
} }
} }
protected Element generateOutline(Outline outline) { protected Element generateOutline(final Outline outline) {
Element e = new Element("outline"); final Element e = new Element("outline");
addNotNullAttribute(e, "text", outline.getText()); addNotNullAttribute(e, "text", outline.getText());
addNotNullAttribute(e, "type", outline.getType()); addNotNullAttribute(e, "type", outline.getType());
addNotNullAttribute(e, "title", outline.getTitle()); addNotNullAttribute(e, "title", outline.getTitle());
@ -147,10 +145,10 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
addNotNullAttribute(e, "isComment", "true"); addNotNullAttribute(e, "isComment", "true");
} }
List atts = Collections.synchronizedList(outline.getAttributes()); final List atts = Collections.synchronizedList(outline.getAttributes());
for (int i = 0; i < atts.size(); i++) { for (int i = 0; i < atts.size(); i++) {
Attribute att = (Attribute) atts.get(i); final Attribute att = (Attribute) atts.get(i);
addNotNullAttribute(e, att.getName(), att.getValue()); addNotNullAttribute(e, att.getName(), att.getValue());
} }
@ -160,22 +158,22 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
return e; return e;
} }
protected List generateOutlines(List outlines) { protected List generateOutlines(final List outlines) {
ArrayList elements = new ArrayList(); final ArrayList elements = new ArrayList();
for (int i = 0; (outlines != null) && (i < outlines.size()); i++) { for (int i = 0; outlines != null && i < outlines.size(); i++) {
elements.add(generateOutline((Outline) outlines.get(i))); elements.add(generateOutline((Outline) outlines.get(i)));
} }
return elements; return elements;
} }
protected String intArrayToCsvString(int[] value) { protected String intArrayToCsvString(final int[] value) {
if ((value == null) || (value.length == 0)) { if (value == null || value.length == 0) {
return null; return null;
} }
StringBuffer sb = new StringBuffer(); final StringBuffer sb = new StringBuffer();
sb.append(value[0]); sb.append(value[0]);
for (int i = 1; i < value.length; i++) { for (int i = 1; i < value.length; i++) {

View file

@ -17,23 +17,21 @@
*/ */
package com.sun.syndication.io.impl; package com.sun.syndication.io.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdom2.Document;
import org.jdom2.Element;
import com.sun.syndication.feed.WireFeed; import com.sun.syndication.feed.WireFeed;
import com.sun.syndication.feed.opml.Attribute; import com.sun.syndication.feed.opml.Attribute;
import com.sun.syndication.feed.opml.Opml; import com.sun.syndication.feed.opml.Opml;
import com.sun.syndication.feed.opml.Outline; import com.sun.syndication.feed.opml.Outline;
import com.sun.syndication.io.FeedException; import com.sun.syndication.io.FeedException;
import com.sun.syndication.io.WireFeedParser; import com.sun.syndication.io.WireFeedParser;
import com.sun.syndication.io.impl.BaseWireFeedParser;
import com.sun.syndication.io.impl.DateParser;
import org.jdom2.Document;
import org.jdom2.Element;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* *
@ -47,7 +45,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
super("opml_1.0", null); super("opml_1.0", null);
} }
public OPML10Parser(String type) { public OPML10Parser(final String type) {
super(type, null); super(type, null);
} }
@ -61,8 +59,8 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
* @return <b>true</b> if the parser know how to parser this feed, <b>false</b> otherwise. * @return <b>true</b> if the parser know how to parser this feed, <b>false</b> otherwise.
*/ */
@Override @Override
public boolean isMyType(Document document) { public boolean isMyType(final Document document) {
Element e = document.getRootElement(); final Element e = document.getRootElement();
if (e.getName().equals("opml") && (e.getChild("head") == null || e.getChild("head").getChild("docs") == null) if (e.getName().equals("opml") && (e.getChild("head") == null || e.getChild("head").getChild("docs") == null)
&& (e.getAttributeValue("version") == null || e.getAttributeValue("version").equals("1.0"))) { && (e.getAttributeValue("version") == null || e.getAttributeValue("version").equals("1.0"))) {
@ -83,12 +81,12 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
* @throws FeedException thrown if a feed bean cannot be created out of the XML document (JDOM). * @throws FeedException thrown if a feed bean cannot be created out of the XML document (JDOM).
*/ */
@Override @Override
public WireFeed parse(Document document, boolean validate) throws IllegalArgumentException, FeedException { public WireFeed parse(final Document document, final boolean validate) throws IllegalArgumentException, FeedException {
Opml opml = new Opml(); final Opml opml = new Opml();
opml.setFeedType("opml_1.0"); opml.setFeedType("opml_1.0");
Element root = document.getRootElement(); final Element root = document.getRootElement();
Element head = root.getChild("head"); final Element head = root.getChild("head");
if (head != null) { if (head != null) {
opml.setTitle(head.getChildText("title")); opml.setTitle(head.getChildText("title"));
@ -108,7 +106,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
try { try {
opml.setWindowBottom(readInteger(head.getChildText("windowBottom"))); opml.setWindowBottom(readInteger(head.getChildText("windowBottom")));
} catch (NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
LOG.log(Level.WARNING, "Unable to parse windowBottom", nfe); LOG.log(Level.WARNING, "Unable to parse windowBottom", nfe);
if (validate) { if (validate) {
@ -118,13 +116,13 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
try { try {
opml.setWindowLeft(readInteger(head.getChildText("windowLeft"))); opml.setWindowLeft(readInteger(head.getChildText("windowLeft")));
} catch (NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
LOG.log(Level.WARNING, "Unable to parse windowLeft", nfe); LOG.log(Level.WARNING, "Unable to parse windowLeft", nfe);
} }
try { try {
opml.setWindowRight(readInteger(head.getChildText("windowRight"))); opml.setWindowRight(readInteger(head.getChildText("windowRight")));
} catch (NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
LOG.log(Level.WARNING, "Unable to parse windowRight", nfe); LOG.log(Level.WARNING, "Unable to parse windowRight", nfe);
if (validate) { if (validate) {
@ -134,7 +132,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
try { try {
opml.setWindowLeft(readInteger(head.getChildText("windowLeft"))); opml.setWindowLeft(readInteger(head.getChildText("windowLeft")));
} catch (NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
LOG.log(Level.WARNING, "Unable to parse windowLeft", nfe); LOG.log(Level.WARNING, "Unable to parse windowLeft", nfe);
if (validate) { if (validate) {
@ -144,7 +142,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
try { try {
opml.setWindowTop(readInteger(head.getChildText("windowTop"))); opml.setWindowTop(readInteger(head.getChildText("windowTop")));
} catch (NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
LOG.log(Level.WARNING, "Unable to parse windowTop", nfe); LOG.log(Level.WARNING, "Unable to parse windowTop", nfe);
if (validate) { if (validate) {
@ -154,7 +152,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
try { try {
opml.setExpansionState(readIntArray(head.getChildText("expansionState"))); opml.setExpansionState(readIntArray(head.getChildText("expansionState")));
} catch (NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
LOG.log(Level.WARNING, "Unable to parse expansionState", nfe); LOG.log(Level.WARNING, "Unable to parse expansionState", nfe);
if (validate) { if (validate) {
@ -163,26 +161,26 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
} }
opml.setOutlines(parseOutlines(root.getChild("body").getChildren("outline"), validate)); opml.setOutlines(parseOutlines(root.getChild("body").getChildren("outline"), validate));
opml.setModules(this.parseFeedModules(root)); opml.setModules(parseFeedModules(root));
return opml; return opml;
} }
protected Outline parseOutline(Element e, boolean validate) throws FeedException { protected Outline parseOutline(final Element e, final boolean validate) throws FeedException {
if (!e.getName().equals("outline")) { if (!e.getName().equals("outline")) {
throw new RuntimeException("Not an outline element."); throw new RuntimeException("Not an outline element.");
} }
Outline outline = new Outline(); final Outline outline = new Outline();
outline.setText(e.getAttributeValue("text")); outline.setText(e.getAttributeValue("text"));
outline.setType(e.getAttributeValue("type")); outline.setType(e.getAttributeValue("type"));
outline.setTitle(e.getAttributeValue("title")); outline.setTitle(e.getAttributeValue("title"));
List jAttributes = e.getAttributes(); final List jAttributes = e.getAttributes();
ArrayList attributes = new ArrayList(); final ArrayList attributes = new ArrayList();
for (int i = 0; i < jAttributes.size(); i++) { for (int i = 0; i < jAttributes.size(); i++) {
org.jdom2.Attribute a = (org.jdom2.Attribute) jAttributes.get(i); final org.jdom2.Attribute a = (org.jdom2.Attribute) jAttributes.get(i);
if (!a.getName().equals("isBreakpoint") && !a.getName().equals("isComment") && !a.getName().equals("title") && !a.getName().equals("text") if (!a.getName().equals("isBreakpoint") && !a.getName().equals("isComment") && !a.getName().equals("title") && !a.getName().equals("text")
&& !a.getName().equals("type")) { && !a.getName().equals("type")) {
@ -194,7 +192,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
try { try {
outline.setBreakpoint(readBoolean(e.getAttributeValue("isBreakpoint"))); outline.setBreakpoint(readBoolean(e.getAttributeValue("isBreakpoint")));
} catch (Exception ex) { } catch (final Exception ex) {
LOG.log(Level.WARNING, "Unable to parse isBreakpoint value", ex); LOG.log(Level.WARNING, "Unable to parse isBreakpoint value", ex);
if (validate) { if (validate) {
@ -204,7 +202,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
try { try {
outline.setComment(readBoolean(e.getAttributeValue("isComment"))); outline.setComment(readBoolean(e.getAttributeValue("isComment")));
} catch (Exception ex) { } catch (final Exception ex) {
LOG.log(Level.WARNING, "Unable to parse isComment value", ex); LOG.log(Level.WARNING, "Unable to parse isComment value", ex);
if (validate) { if (validate) {
@ -212,15 +210,15 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
} }
} }
List children = e.getChildren("outline"); final List children = e.getChildren("outline");
outline.setModules(this.parseItemModules(e)); outline.setModules(parseItemModules(e));
outline.setChildren(parseOutlines(children, validate)); outline.setChildren(parseOutlines(children, validate));
return outline; return outline;
} }
protected List parseOutlines(List elements, boolean validate) throws FeedException { protected List parseOutlines(final List elements, final boolean validate) throws FeedException {
ArrayList results = new ArrayList(); final ArrayList results = new ArrayList();
for (int i = 0; i < elements.size(); i++) { for (int i = 0; i < elements.size(); i++) {
results.add(parseOutline((Element) elements.get(i), validate)); results.add(parseOutline((Element) elements.get(i), validate));
@ -229,7 +227,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
return results; return results;
} }
protected boolean readBoolean(String value) { protected boolean readBoolean(final String value) {
if (value == null) { if (value == null) {
return false; return false;
} else { } else {
@ -237,12 +235,12 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
} }
} }
protected int[] readIntArray(String value) { protected int[] readIntArray(final String value) {
if (value == null) { if (value == null) {
return null; return null;
} else { } else {
StringTokenizer tok = new StringTokenizer(value, ","); final StringTokenizer tok = new StringTokenizer(value, ",");
int[] result = new int[tok.countTokens()]; final int[] result = new int[tok.countTokens()];
int count = 0; int count = 0;
while (tok.hasMoreElements()) { while (tok.hasMoreElements()) {
@ -254,7 +252,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
} }
} }
protected Integer readInteger(String value) { protected Integer readInteger(final String value) {
if (value != null) { if (value != null) {
return new Integer(value); return new Integer(value);
} else { } else {

View file

@ -8,14 +8,13 @@
*/ */
package com.sun.syndication.io.impl; package com.sun.syndication.io.impl;
import org.jdom2.Document;
import org.jdom2.Element;
import com.sun.syndication.feed.WireFeed; import com.sun.syndication.feed.WireFeed;
import com.sun.syndication.feed.opml.Opml; import com.sun.syndication.feed.opml.Opml;
import com.sun.syndication.feed.opml.Outline; import com.sun.syndication.feed.opml.Outline;
import com.sun.syndication.io.FeedException; import com.sun.syndication.io.FeedException;
import com.sun.syndication.io.impl.DateParser;
import org.jdom2.Document;
import org.jdom2.Element;
/** /**
* *
@ -49,7 +48,7 @@ public class OPML20Generator extends OPML10Generator {
* @throws FeedException thrown if the XML Document could not be created. * @throws FeedException thrown if the XML Document could not be created.
*/ */
@Override @Override
public Document generate(WireFeed feed) throws IllegalArgumentException, FeedException { public Document generate(final WireFeed feed) throws IllegalArgumentException, FeedException {
Document retValue; Document retValue;
retValue = super.generate(feed); retValue = super.generate(feed);
@ -59,19 +58,19 @@ public class OPML20Generator extends OPML10Generator {
} }
@Override @Override
protected Element generateHead(Opml opml) { protected Element generateHead(final Opml opml) {
Element retValue; Element retValue;
retValue = super.generateHead(opml); retValue = super.generateHead(opml);
Element docs = new Element("docs", opml.getDocs()); final Element docs = new Element("docs", opml.getDocs());
retValue.addContent(docs); retValue.addContent(docs);
return retValue; return retValue;
} }
@Override @Override
protected Element generateOutline(Outline outline) { protected Element generateOutline(final Outline outline) {
Element retValue; Element retValue;
retValue = super.generateOutline(outline); retValue = super.generateOutline(outline);

View file

@ -17,17 +17,16 @@
*/ */
package com.sun.syndication.io.impl; package com.sun.syndication.io.impl;
import java.util.List;
import org.jdom2.Document;
import org.jdom2.Element;
import com.sun.syndication.feed.WireFeed; import com.sun.syndication.feed.WireFeed;
import com.sun.syndication.feed.opml.Attribute; import com.sun.syndication.feed.opml.Attribute;
import com.sun.syndication.feed.opml.Opml; import com.sun.syndication.feed.opml.Opml;
import com.sun.syndication.feed.opml.Outline; import com.sun.syndication.feed.opml.Outline;
import com.sun.syndication.io.FeedException; import com.sun.syndication.io.FeedException;
import com.sun.syndication.io.impl.DateParser;
import org.jdom2.Document;
import org.jdom2.Element;
import java.util.List;
/** /**
* *
@ -49,13 +48,12 @@ public class OPML20Parser extends OPML10Parser {
* @return <b>true</b> if the parser know how to parser this feed, <b>false</b> otherwise. * @return <b>true</b> if the parser know how to parser this feed, <b>false</b> otherwise.
*/ */
@Override @Override
public boolean isMyType(Document document) { public boolean isMyType(final Document document) {
Element e = document.getRootElement(); final Element e = document.getRootElement();
if (e.getName().equals("opml") if (e.getName().equals("opml")
&& (((e.getChild("head") != null) && (e.getChild("head").getChild("docs") != null)) && (e.getChild("head") != null && e.getChild("head").getChild("docs") != null || e.getAttributeValue("version") != null
|| ((e.getAttributeValue("version") != null) && e.getAttributeValue("version").equals("2.0")) || ((e.getChild("head") != null) && (e && e.getAttributeValue("version").equals("2.0") || e.getChild("head") != null && e.getChild("head").getChild("ownerId") != null)) {
.getChild("head").getChild("ownerId") != null)))) {
return true; return true;
} }
@ -73,11 +71,11 @@ public class OPML20Parser extends OPML10Parser {
* @throws FeedException thrown if a feed bean cannot be created out of the XML document (JDOM). * @throws FeedException thrown if a feed bean cannot be created out of the XML document (JDOM).
*/ */
@Override @Override
public WireFeed parse(Document document, boolean validate) throws IllegalArgumentException, FeedException { public WireFeed parse(final Document document, final boolean validate) throws IllegalArgumentException, FeedException {
Opml opml; Opml opml;
opml = (Opml) super.parse(document, validate); opml = (Opml) super.parse(document, validate);
Element head = document.getRootElement().getChild("head"); final Element head = document.getRootElement().getChild("head");
if (head != null) { if (head != null) {
opml.setOwnerId(head.getChildTextTrim("ownerId")); opml.setOwnerId(head.getChildTextTrim("ownerId"));
@ -94,7 +92,7 @@ public class OPML20Parser extends OPML10Parser {
} }
@Override @Override
protected Outline parseOutline(Element e, boolean validate) throws FeedException { protected Outline parseOutline(final Element e, final boolean validate) throws FeedException {
Outline retValue; Outline retValue;
retValue = super.parseOutline(e, validate); retValue = super.parseOutline(e, validate);
@ -103,10 +101,10 @@ public class OPML20Parser extends OPML10Parser {
retValue.setCreated(DateParser.parseRFC822(e.getAttributeValue("created"))); retValue.setCreated(DateParser.parseRFC822(e.getAttributeValue("created")));
} }
List atts = retValue.getAttributes(); final List atts = retValue.getAttributes();
for (int i = 0; i < atts.size(); i++) { for (int i = 0; i < atts.size(); i++) {
Attribute a = (Attribute) atts.get(i); final Attribute a = (Attribute) atts.get(i);
if (a.getName().equals("created")) { if (a.getName().equals("created")) {
retValue.getAttributes().remove(a); retValue.getAttributes().remove(a);

View file

@ -13,11 +13,11 @@ package com.sun.syndication;
public abstract class SyndFeedTest extends FeedTest { public abstract class SyndFeedTest extends FeedTest {
private String _prefix = null; private String _prefix = null;
protected SyndFeedTest(String feedType) { protected SyndFeedTest(final String feedType) {
this(feedType, feedType + ".xml"); this(feedType, feedType + ".xml");
} }
protected SyndFeedTest(String feedType, String feedFileName) { protected SyndFeedTest(final String feedType, final String feedFileName) {
super(feedFileName); super(feedFileName);
_prefix = feedType; _prefix = feedType;
} }
@ -26,7 +26,7 @@ public abstract class SyndFeedTest extends FeedTest {
return _prefix; return _prefix;
} }
protected void assertProperty(String property, String value) { protected void assertProperty(final String property, final String value) {
assertEquals(property, getPrefix() + "." + value); assertEquals(property, getPrefix() + "." + value);
} }