Formatted code
Added Eclipse formatter and cleanup configuration
This commit is contained in:
parent
d3509f97ca
commit
c71113f197
11 changed files with 264 additions and 276 deletions
|
@ -17,11 +17,11 @@
|
|||
*/
|
||||
package com.sun.syndication.feed.opml;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sun.syndication.feed.impl.EqualsBean;
|
||||
import com.sun.syndication.feed.impl.ToStringBean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 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 value value of the attribute.
|
||||
*/
|
||||
public Attribute(String name, String value) {
|
||||
if ((name == null) || (value == null)) {
|
||||
public Attribute(final String name, final String value) {
|
||||
if (name == null || value == null) {
|
||||
throw new NullPointerException("Name and value are required.");
|
||||
}
|
||||
|
||||
this.setName(name);
|
||||
this.setValue(value);
|
||||
setName(name);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,8 +55,8 @@ public class Attribute implements Cloneable, Serializable {
|
|||
*
|
||||
* @param name name of the attribute.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this._name = name;
|
||||
public void setName(final String name) {
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,8 +73,8 @@ public class Attribute implements Cloneable, Serializable {
|
|||
*
|
||||
* @param value value of the attribute.
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this._value = value;
|
||||
public void setValue(final String value) {
|
||||
_value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,27 +88,24 @@ public class Attribute implements Cloneable, Serializable {
|
|||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new Attribute(this._name, this._value);
|
||||
return new Attribute(_name, _value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
EqualsBean eBean = new EqualsBean(Attribute.class, this);
|
||||
|
||||
public boolean equals(final Object obj) {
|
||||
final EqualsBean eBean = new EqualsBean(Attribute.class, this);
|
||||
return eBean.beanEquals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
EqualsBean equals = new EqualsBean(Attribute.class, this);
|
||||
|
||||
final EqualsBean equals = new EqualsBean(Attribute.class, this);
|
||||
return equals.beanHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringBean tsBean = new ToStringBean(Attribute.class, this);
|
||||
|
||||
final ToStringBean tsBean = new ToStringBean(Attribute.class, this);
|
||||
return tsBean.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
*/
|
||||
package com.sun.syndication.feed.opml;
|
||||
|
||||
import com.sun.syndication.feed.WireFeed;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
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.
|
||||
*
|
||||
|
@ -54,8 +54,8 @@ public class Opml extends WireFeed {
|
|||
*
|
||||
* @param created date-time, indicating when the document was created.
|
||||
*/
|
||||
public void setCreated(Date created) {
|
||||
this._created = created;
|
||||
public void setCreated(final Date created) {
|
||||
_created = created;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,8 +73,8 @@ public class Opml extends WireFeed {
|
|||
*
|
||||
* @param docs http address of documentation for the format used
|
||||
*/
|
||||
public void setDocs(String docs) {
|
||||
this._docs = docs;
|
||||
public void setDocs(final String docs) {
|
||||
_docs = docs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,8 +94,8 @@ public class Opml extends WireFeed {
|
|||
*
|
||||
* @param expansionState int array containing expanded elements.
|
||||
*/
|
||||
public void setExpansionState(int[] expansionState) {
|
||||
this._expansionState = expansionState;
|
||||
public void setExpansionState(final int[] expansionState) {
|
||||
_expansionState = expansionState;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,8 +114,8 @@ public class Opml extends WireFeed {
|
|||
*
|
||||
* @param modified date-time, indicating when the document was last modified.
|
||||
*/
|
||||
public void setModified(Date modified) {
|
||||
this._modified = modified;
|
||||
public void setModified(final Date modified) {
|
||||
_modified = modified;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,8 +132,8 @@ public class Opml extends WireFeed {
|
|||
*
|
||||
* @param outlines Root level Outline object that should appear in the <body>
|
||||
*/
|
||||
public void setOutlines(List outlines) {
|
||||
this._outlines = outlines;
|
||||
public void setOutlines(final List outlines) {
|
||||
_outlines = outlines;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,8 +154,8 @@ public class Opml extends WireFeed {
|
|||
*
|
||||
* @param ownerEmail the email address of the owner of the document.
|
||||
*/
|
||||
public void setOwnerEmail(String ownerEmail) {
|
||||
this._ownerEmail = ownerEmail;
|
||||
public void setOwnerEmail(final String 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
|
||||
* document via email or other means.
|
||||
*/
|
||||
public void setOwnerId(String ownerId) {
|
||||
this._ownerId = ownerId;
|
||||
public void setOwnerId(final String ownerId) {
|
||||
_ownerId = ownerId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,8 +194,8 @@ public class Opml extends WireFeed {
|
|||
*
|
||||
* @param ownerName the owner of the document.
|
||||
*/
|
||||
public void setOwnerName(String ownerName) {
|
||||
this._ownerName = ownerName;
|
||||
public void setOwnerName(final String ownerName) {
|
||||
_ownerName = ownerName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,8 +212,8 @@ public class Opml extends WireFeed {
|
|||
*
|
||||
* @param title title of the document.
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this._title = title;
|
||||
public void setTitle(final String 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.
|
||||
*/
|
||||
public void setVerticalScrollState(Integer verticalScrollState) {
|
||||
this._verticalScrollState = verticalScrollState;
|
||||
public void setVerticalScrollState(final Integer verticalScrollState) {
|
||||
_verticalScrollState = verticalScrollState;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,8 +250,8 @@ public class Opml extends WireFeed {
|
|||
*
|
||||
* @param windowBottom the pixel location of the bottom edge of the window.
|
||||
*/
|
||||
public void setWindowBottom(Integer windowBottom) {
|
||||
this._windowBottom = windowBottom;
|
||||
public void setWindowBottom(final Integer windowBottom) {
|
||||
_windowBottom = windowBottom;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,8 +268,8 @@ public class Opml extends WireFeed {
|
|||
*
|
||||
* @param windowLeft the pixel location of the left edge of the window.
|
||||
*/
|
||||
public void setWindowLeft(Integer windowLeft) {
|
||||
this._windowLeft = windowLeft;
|
||||
public void setWindowLeft(final Integer windowLeft) {
|
||||
_windowLeft = windowLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -286,8 +286,8 @@ public class Opml extends WireFeed {
|
|||
*
|
||||
* @param windowRight the pixel location of the right edge of the window.
|
||||
*/
|
||||
public void setWindowRight(Integer windowRight) {
|
||||
this._windowRight = windowRight;
|
||||
public void setWindowRight(final Integer windowRight) {
|
||||
_windowRight = windowRight;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -304,8 +304,8 @@ public class Opml extends WireFeed {
|
|||
*
|
||||
* @param windowTop the pixel location of the top edge of the window.
|
||||
*/
|
||||
public void setWindowTop(Integer windowTop) {
|
||||
this._windowTop = windowTop;
|
||||
public void setWindowTop(final Integer windowTop) {
|
||||
_windowTop = windowTop;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,18 +17,16 @@
|
|||
*/
|
||||
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.net.URL;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
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.
|
||||
*
|
||||
|
@ -57,10 +55,10 @@ public class Outline implements Cloneable, Serializable {
|
|||
* @param type type attribute value/
|
||||
* @param text text attribute value
|
||||
*/
|
||||
public Outline(String type, String text) {
|
||||
public Outline(final String type, final String text) {
|
||||
super();
|
||||
this.setType(type);
|
||||
this.setText(text);
|
||||
setType(type);
|
||||
setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,11 +68,11 @@ public class Outline implements Cloneable, Serializable {
|
|||
* @param xmlUrl link to XML file.
|
||||
* @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();
|
||||
this.setType("rss");
|
||||
this.setTitle(title);
|
||||
this.setAttributes(new ArrayList());
|
||||
setType("rss");
|
||||
setTitle(title);
|
||||
setAttributes(new ArrayList());
|
||||
|
||||
if (xmlUrl != null) {
|
||||
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.
|
||||
*/
|
||||
public void setAttributes(List attributes) {
|
||||
this._attributes = attributes;
|
||||
public void setAttributes(final List attributes) {
|
||||
_attributes = attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,8 +98,8 @@ public class Outline implements Cloneable, Serializable {
|
|||
* @return List of attributes on this outline.
|
||||
*/
|
||||
public List getAttributes() {
|
||||
if (this._attributes == null) {
|
||||
this._attributes = new ArrayList();
|
||||
if (_attributes == null) {
|
||||
_attributes = new ArrayList();
|
||||
}
|
||||
|
||||
return _attributes;
|
||||
|
@ -113,8 +111,8 @@ public class Outline implements Cloneable, Serializable {
|
|||
*
|
||||
* @param breakpoint whether a breakpoint is set on this outline.
|
||||
*/
|
||||
public void setBreakpoint(boolean breakpoint) {
|
||||
this._breakpoint = breakpoint;
|
||||
public void setBreakpoint(final boolean 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.
|
||||
*/
|
||||
public void setCategories(List categories) {
|
||||
this._categories = categories;
|
||||
public void setCategories(final List categories) {
|
||||
_categories = categories;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,8 +152,8 @@ public class Outline implements Cloneable, Serializable {
|
|||
*
|
||||
* @param children A list of sub-outlines for this entry.
|
||||
*/
|
||||
public void setChildren(List children) {
|
||||
this._children = children;
|
||||
public void setChildren(final List children) {
|
||||
_children = children;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -177,8 +175,8 @@ public class Outline implements Cloneable, Serializable {
|
|||
*
|
||||
* @param comment whether the outline is commented
|
||||
*/
|
||||
public void setComment(boolean comment) {
|
||||
this._comment = comment;
|
||||
public void setComment(final boolean comment) {
|
||||
_comment = comment;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,8 +194,8 @@ public class Outline implements Cloneable, Serializable {
|
|||
*
|
||||
* @param created date-time that the outline node was created.
|
||||
*/
|
||||
public void setCreated(Date created) {
|
||||
this._created = created;
|
||||
public void setCreated(final Date created) {
|
||||
_created = created;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,13 +225,13 @@ public class Outline implements Cloneable, Serializable {
|
|||
return getAttributeValue("htmlUrl");
|
||||
}
|
||||
|
||||
public void setModules(List modules) {
|
||||
this._modules = modules;
|
||||
public void setModules(final List modules) {
|
||||
_modules = modules;
|
||||
}
|
||||
|
||||
public List getModules() {
|
||||
if (this._modules == null) {
|
||||
this._modules = new ArrayList();
|
||||
if (_modules == null) {
|
||||
_modules = new ArrayList();
|
||||
}
|
||||
|
||||
return _modules;
|
||||
|
@ -244,8 +242,8 @@ public class Outline implements Cloneable, Serializable {
|
|||
*
|
||||
* @param text The "text" attribute of the outline.
|
||||
*/
|
||||
public void setText(String text) {
|
||||
this._text = text;
|
||||
public void setText(final String text) {
|
||||
_text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,8 +260,8 @@ public class Outline implements Cloneable, Serializable {
|
|||
*
|
||||
* @param title The "title" attribute of the outline.
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this._title = title;
|
||||
public void setTitle(final String title) {
|
||||
_title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -280,8 +278,8 @@ public class Outline implements Cloneable, Serializable {
|
|||
*
|
||||
* @param type The "type" attribute of the outline.
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this._type = type;
|
||||
public void setType(final String type) {
|
||||
_type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -307,13 +305,13 @@ public class Outline implements Cloneable, Serializable {
|
|||
*
|
||||
* @param name name of the attribute.
|
||||
*/
|
||||
public String getAttributeValue(String name) {
|
||||
List attributes = Collections.synchronizedList(this.getAttributes());
|
||||
public String getAttributeValue(final String name) {
|
||||
final List attributes = Collections.synchronizedList(getAttributes());
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -323,28 +321,28 @@ public class Outline implements Cloneable, Serializable {
|
|||
|
||||
@Override
|
||||
public Object clone() {
|
||||
Outline o = new Outline();
|
||||
o.setBreakpoint(this.isBreakpoint());
|
||||
o.setCategories(new ArrayList(this.getCategories()));
|
||||
o.setComment(this.isComment());
|
||||
o.setCreated((this._created != null) ? (Date) this._created.clone() : null);
|
||||
o.setModules(new ArrayList(this.getModules()));
|
||||
o.setText(this.getText());
|
||||
o.setTitle(this.getTitle());
|
||||
o.setType(this.getType());
|
||||
final Outline o = new Outline();
|
||||
o.setBreakpoint(isBreakpoint());
|
||||
o.setCategories(new ArrayList(getCategories()));
|
||||
o.setComment(isComment());
|
||||
o.setCreated(_created != null ? (Date) _created.clone() : null);
|
||||
o.setModules(new ArrayList(getModules()));
|
||||
o.setText(getText());
|
||||
o.setTitle(getTitle());
|
||||
o.setType(getType());
|
||||
|
||||
ArrayList children = new ArrayList();
|
||||
final ArrayList children = new ArrayList();
|
||||
|
||||
for (int i = 0; i < this.getChildren().size(); i++) {
|
||||
children.add(((Outline) this._children.get(i)).clone());
|
||||
for (int i = 0; i < getChildren().size(); i++) {
|
||||
children.add(((Outline) _children.get(i)).clone());
|
||||
}
|
||||
|
||||
o.setChildren(children);
|
||||
|
||||
ArrayList attributes = new ArrayList();
|
||||
final ArrayList attributes = new ArrayList();
|
||||
|
||||
for (int i = 0; i < this.getAttributes().size(); i++) {
|
||||
attributes.add(((Attribute) this._attributes.get(i)).clone());
|
||||
for (int i = 0; i < getAttributes().size(); i++) {
|
||||
attributes.add(((Attribute) _attributes.get(i)).clone());
|
||||
}
|
||||
|
||||
o.setAttributes(attributes);
|
||||
|
@ -353,22 +351,22 @@ public class Outline implements Cloneable, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
EqualsBean eBean = new EqualsBean(Outline.class, this);
|
||||
public boolean equals(final Object obj) {
|
||||
final EqualsBean eBean = new EqualsBean(Outline.class, this);
|
||||
|
||||
return eBean.beanEquals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
EqualsBean equals = new EqualsBean(Outline.class, this);
|
||||
final EqualsBean equals = new EqualsBean(Outline.class, this);
|
||||
|
||||
return equals.beanHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringBean tsBean = new ToStringBean(Outline.class, this);
|
||||
final ToStringBean tsBean = new ToStringBean(Outline.class, this);
|
||||
|
||||
return tsBean.toString();
|
||||
}
|
||||
|
|
|
@ -55,10 +55,10 @@ public class ConverterForOPML10 implements Converter {
|
|||
super();
|
||||
}
|
||||
|
||||
protected void addOwner(Opml opml, SyndFeed syndFeed) {
|
||||
if ((opml.getOwnerEmail() != null) || (opml.getOwnerName() != null)) {
|
||||
List authors = new ArrayList();
|
||||
SyndPerson person = new SyndPersonImpl();
|
||||
protected void addOwner(final Opml opml, final SyndFeed syndFeed) {
|
||||
if (opml.getOwnerEmail() != null || opml.getOwnerName() != null) {
|
||||
final List authors = new ArrayList();
|
||||
final SyndPerson person = new SyndPersonImpl();
|
||||
person.setEmail(opml.getOwnerEmail());
|
||||
person.setName(opml.getOwnerName());
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public void copyInto(WireFeed feed, SyndFeed syndFeed) {
|
||||
Opml opml = (Opml) feed;
|
||||
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
|
||||
final Opml opml = (Opml) feed;
|
||||
syndFeed.setTitle(opml.getTitle());
|
||||
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.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());
|
||||
}
|
||||
|
||||
protected void createEntries(TreeContext context, List allEntries, List outlines) {
|
||||
List so = Collections.synchronizedList(outlines);
|
||||
protected void createEntries(final TreeContext context, final List allEntries, final List outlines) {
|
||||
final List so = Collections.synchronizedList(outlines);
|
||||
|
||||
for (int i = 0; i < so.size(); i++) {
|
||||
createEntry(context, allEntries, (Outline) so.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
protected SyndEntry createEntry(TreeContext context, List allEntries, Outline outline) {
|
||||
SyndEntry entry = new SyndEntryImpl();
|
||||
protected SyndEntry createEntry(final TreeContext context, final List allEntries, final Outline outline) {
|
||||
final SyndEntry entry = new SyndEntryImpl();
|
||||
|
||||
if ((outline.getType() != null) && outline.getType().equals("rss")) {
|
||||
entry.setLink((outline.getHtmlUrl() != null) ? outline.getHtmlUrl() : outline.getXmlUrl());
|
||||
} else if ((outline.getType() != null) && outline.getType().equals("link")) {
|
||||
if (outline.getType() != null && outline.getType().equals("rss")) {
|
||||
entry.setLink(outline.getHtmlUrl() != null ? outline.getHtmlUrl() : outline.getXmlUrl());
|
||||
} else if (outline.getType() != null && outline.getType().equals("link")) {
|
||||
entry.setLink(outline.getUrl());
|
||||
}
|
||||
|
||||
if (outline.getHtmlUrl() != null) {
|
||||
SyndLink link = new SyndLinkImpl();
|
||||
final SyndLink link = new SyndLinkImpl();
|
||||
link.setRel("alternate");
|
||||
link.setType("text/html");
|
||||
link.setHref(outline.getHtmlUrl());
|
||||
|
@ -115,8 +115,8 @@ public class ConverterForOPML10 implements Converter {
|
|||
entry.setLink(outline.getHtmlUrl());
|
||||
}
|
||||
|
||||
if ((outline.getXmlUrl() != null) && (outline.getType() != null) && outline.getType().equalsIgnoreCase("rss")) {
|
||||
SyndLink link = new SyndLinkImpl();
|
||||
if (outline.getXmlUrl() != null && outline.getType() != null && outline.getType().equalsIgnoreCase("rss")) {
|
||||
final SyndLink link = new SyndLinkImpl();
|
||||
link.setRel("alternate");
|
||||
link.setType("application/rss+xml");
|
||||
link.setHref(outline.getXmlUrl());
|
||||
|
@ -127,8 +127,8 @@ public class ConverterForOPML10 implements Converter {
|
|||
}
|
||||
}
|
||||
|
||||
if ((outline.getXmlUrl() != null) && (outline.getType() != null) && outline.getType().equalsIgnoreCase("atom")) {
|
||||
SyndLink link = new SyndLinkImpl();
|
||||
if (outline.getXmlUrl() != null && outline.getType() != null && outline.getType().equalsIgnoreCase("atom")) {
|
||||
final SyndLink link = new SyndLinkImpl();
|
||||
link.setRel("alternate");
|
||||
link.setType("application/atom+xml");
|
||||
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());
|
||||
} else {
|
||||
entry.setTitle(outline.getText());
|
||||
}
|
||||
|
||||
if ((outline.getText() == null) && (entry.getTitle() != null)) {
|
||||
SyndContent c = new SyndContentImpl();
|
||||
if (outline.getText() == null && entry.getTitle() != null) {
|
||||
final SyndContent c = new SyndContentImpl();
|
||||
c.setValue(outline.getText());
|
||||
entry.setDescription(c);
|
||||
}
|
||||
|
||||
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.setName(nodeName);
|
||||
entry.getCategories().add(cat);
|
||||
|
||||
if (context.size() > 0) {
|
||||
Integer parent = (Integer) context.peek();
|
||||
SyndCategory pcat = new TreeCategoryImpl();
|
||||
final Integer parent = (Integer) context.peek();
|
||||
final SyndCategory pcat = new TreeCategoryImpl();
|
||||
pcat.setTaxonomyUri(URI_TREE);
|
||||
pcat.setName("parent." + parent);
|
||||
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++) {
|
||||
Attribute a = (Attribute) attributes.get(i);
|
||||
SyndCategory acat = new SyndCategoryImpl();
|
||||
final Attribute a = (Attribute) attributes.get(i);
|
||||
final SyndCategory acat = new SyndCategoryImpl();
|
||||
acat.setName(a.getValue());
|
||||
acat.setTaxonomyUri(URI_ATTRIBUTE + a.getName());
|
||||
entry.getCategories().add(acat);
|
||||
|
@ -196,33 +196,33 @@ public class ConverterForOPML10 implements Converter {
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public WireFeed createRealFeed(SyndFeed syndFeed) {
|
||||
List entries = Collections.synchronizedList(syndFeed.getEntries());
|
||||
public WireFeed createRealFeed(final SyndFeed syndFeed) {
|
||||
final List entries = Collections.synchronizedList(syndFeed.getEntries());
|
||||
|
||||
HashMap entriesByNode = new HashMap();
|
||||
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 HashMap entriesByNode = new HashMap();
|
||||
final ArrayList doAfterPass = new ArrayList(); // this will hold entries that we can't parent the first time.
|
||||
final ArrayList root = new ArrayList(); // this holds root level outlines;
|
||||
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
SyndEntry entry = (SyndEntry) entries.get(i);
|
||||
Outline o = new Outline();
|
||||
final SyndEntry entry = (SyndEntry) entries.get(i);
|
||||
final Outline o = new Outline();
|
||||
|
||||
List cats = Collections.synchronizedList(entry.getCategories());
|
||||
final List cats = Collections.synchronizedList(entry.getCategories());
|
||||
boolean parentFound = false;
|
||||
StringBuffer category = new StringBuffer();
|
||||
final StringBuffer category = new StringBuffer();
|
||||
|
||||
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)) {
|
||||
String nodeVal = cat.getName().substring(cat.getName().lastIndexOf("."), cat.getName().length());
|
||||
if (cat.getTaxonomyUri() != null && cat.getTaxonomyUri().equals(URI_TREE)) {
|
||||
final String nodeVal = cat.getName().substring(cat.getName().lastIndexOf("."), cat.getName().length());
|
||||
|
||||
if (cat.getName().startsWith("node.")) {
|
||||
entriesByNode.put(nodeVal, o);
|
||||
} else if (cat.getName().startsWith("parent.")) {
|
||||
parentFound = true;
|
||||
|
||||
Outline parent = (Outline) entriesByNode.get(nodeVal);
|
||||
final Outline parent = (Outline) entriesByNode.get(nodeVal);
|
||||
|
||||
if (parent != null) {
|
||||
parent.getChildren().add(o);
|
||||
|
@ -230,8 +230,8 @@ public class ConverterForOPML10 implements Converter {
|
|||
doAfterPass.add(new OutlineHolder(o, nodeVal));
|
||||
}
|
||||
}
|
||||
} else if ((cat.getTaxonomyUri() != null) && cat.getTaxonomyUri().startsWith(URI_ATTRIBUTE)) {
|
||||
String name = cat.getTaxonomyUri().substring(cat.getTaxonomyUri().indexOf("#") + 1, cat.getTaxonomyUri().length());
|
||||
} else if (cat.getTaxonomyUri() != null && cat.getTaxonomyUri().startsWith(URI_ATTRIBUTE)) {
|
||||
final String name = cat.getTaxonomyUri().substring(cat.getTaxonomyUri().indexOf("#") + 1, cat.getTaxonomyUri().length());
|
||||
o.getAttributes().add(new Attribute(name, cat.getName()));
|
||||
} else {
|
||||
if (category.length() > 0) {
|
||||
|
@ -250,21 +250,21 @@ public class ConverterForOPML10 implements Converter {
|
|||
o.getAttributes().add(new Attribute("category", category.toString()));
|
||||
}
|
||||
|
||||
List links = Collections.synchronizedList(entry.getLinks());
|
||||
String entryLink = entry.getLink();
|
||||
final List links = Collections.synchronizedList(entry.getLinks());
|
||||
final String entryLink = entry.getLink();
|
||||
|
||||
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.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"))) {
|
||||
o.setType("rss");
|
||||
|
||||
if (o.getXmlUrl() == null) {
|
||||
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) {
|
||||
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());
|
||||
|
||||
} else {
|
||||
o.setTitle(entry.getTitle());
|
||||
}
|
||||
|
||||
if ((o.getText() == null) && (entry.getDescription() != null)) {
|
||||
if (o.getText() == null && entry.getDescription() != null) {
|
||||
o.setText(entry.getDescription().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// Do back and parenting for things we missed.
|
||||
for (int i = 0; i < doAfterPass.size(); i++) {
|
||||
OutlineHolder o = (OutlineHolder) doAfterPass.get(i);
|
||||
Outline parent = (Outline) entriesByNode.get(o.parent);
|
||||
final OutlineHolder o = (OutlineHolder) doAfterPass.get(i);
|
||||
final Outline parent = (Outline) entriesByNode.get(o.parent);
|
||||
|
||||
if (parent == null) {
|
||||
root.add(o.outline);
|
||||
|
@ -300,17 +300,17 @@ public class ConverterForOPML10 implements Converter {
|
|||
}
|
||||
}
|
||||
|
||||
Opml opml = new Opml();
|
||||
opml.setFeedType(this.getType());
|
||||
final Opml opml = new Opml();
|
||||
opml.setFeedType(getType());
|
||||
opml.setCreated(syndFeed.getPublishedDate());
|
||||
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++) {
|
||||
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.setOwnerEmail(p.getEmail());
|
||||
opml.setOwnerId(p.getUri());
|
||||
|
@ -339,7 +339,7 @@ public class ConverterForOPML10 implements Converter {
|
|||
Outline outline;
|
||||
String parent;
|
||||
|
||||
public OutlineHolder(Outline outline, String parent) {
|
||||
public OutlineHolder(final Outline outline, final String parent) {
|
||||
this.outline = outline;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
|
|||
* @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
|
||||
*/
|
||||
@Override
|
||||
public void copyInto(WireFeed feed, SyndFeed syndFeed) {
|
||||
public void copyInto(final WireFeed feed, final SyndFeed 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.
|
||||
*/
|
||||
@Override
|
||||
public WireFeed createRealFeed(SyndFeed syndFeed) {
|
||||
public WireFeed createRealFeed(final SyndFeed syndFeed) {
|
||||
WireFeed retValue;
|
||||
|
||||
retValue = super.createRealFeed(syndFeed);
|
||||
|
|
|
@ -24,12 +24,13 @@ public class TreeCategoryImpl extends SyndCategoryImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
SyndCategory c = (SyndCategory) o;
|
||||
if (c.getTaxonomyUri() != null && c.getTaxonomyUri().equals(this.getTaxonomyUri()))
|
||||
public boolean equals(final Object o) {
|
||||
final SyndCategory c = (SyndCategory) o;
|
||||
if (c.getTaxonomyUri() != null && c.getTaxonomyUri().equals(getTaxonomyUri())) {
|
||||
return true;
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,21 +17,19 @@
|
|||
*/
|
||||
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.opml.Attribute;
|
||||
import com.sun.syndication.feed.opml.Opml;
|
||||
import com.sun.syndication.feed.opml.Outline;
|
||||
import com.sun.syndication.io.FeedException;
|
||||
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");
|
||||
}
|
||||
|
||||
public OPML10Generator(String type) {
|
||||
public OPML10Generator(final String 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.
|
||||
*/
|
||||
@Override
|
||||
public Document generate(WireFeed feed) throws IllegalArgumentException, FeedException {
|
||||
public Document generate(final WireFeed feed) throws IllegalArgumentException, FeedException {
|
||||
if (!(feed instanceof Opml)) {
|
||||
throw new IllegalArgumentException("Not an OPML file");
|
||||
}
|
||||
|
||||
Opml opml = (Opml) feed;
|
||||
Document doc = new Document();
|
||||
Element root = new Element("opml");
|
||||
final Opml opml = (Opml) feed;
|
||||
final Document doc = new Document();
|
||||
final Element root = new Element("opml");
|
||||
doc.addContent(root);
|
||||
|
||||
Element head = generateHead(opml);
|
||||
final Element head = generateHead(opml);
|
||||
|
||||
if (head != null) {
|
||||
root.addContent(head);
|
||||
}
|
||||
|
||||
Element body = new Element("body");
|
||||
final Element body = new Element("body");
|
||||
root.addContent(body);
|
||||
super.generateFeedModules(opml.getModules(), root);
|
||||
body.addContent(generateOutlines(opml.getOutlines()));
|
||||
|
@ -81,8 +79,8 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
|
|||
return doc;
|
||||
}
|
||||
|
||||
protected boolean addNotNullAttribute(Element target, String name, Object value) {
|
||||
if ((target == null) || (name == null) || (value == null)) {
|
||||
protected boolean addNotNullAttribute(final Element target, final String name, final Object value) {
|
||||
if (target == null || name == null || value == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -91,20 +89,20 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
|
|||
return true;
|
||||
}
|
||||
|
||||
protected boolean addNotNullSimpleElement(Element target, String name, Object value) {
|
||||
if ((target == null) || (name == null) || (value == null)) {
|
||||
protected boolean addNotNullSimpleElement(final Element target, final String name, final Object value) {
|
||||
if (target == null || name == null || value == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Element e = new Element(name);
|
||||
final Element e = new Element(name);
|
||||
e.addContent(value.toString());
|
||||
target.addContent(e);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Element generateHead(Opml opml) {
|
||||
Element head = new Element("head");
|
||||
protected Element generateHead(final Opml opml) {
|
||||
final Element head = new Element("head");
|
||||
boolean hasHead = false;
|
||||
|
||||
if (opml.getCreated() != null) {
|
||||
|
@ -133,8 +131,8 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
|
|||
}
|
||||
}
|
||||
|
||||
protected Element generateOutline(Outline outline) {
|
||||
Element e = new Element("outline");
|
||||
protected Element generateOutline(final Outline outline) {
|
||||
final Element e = new Element("outline");
|
||||
addNotNullAttribute(e, "text", outline.getText());
|
||||
addNotNullAttribute(e, "type", outline.getType());
|
||||
addNotNullAttribute(e, "title", outline.getTitle());
|
||||
|
@ -147,10 +145,10 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
|
|||
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++) {
|
||||
Attribute att = (Attribute) atts.get(i);
|
||||
final Attribute att = (Attribute) atts.get(i);
|
||||
addNotNullAttribute(e, att.getName(), att.getValue());
|
||||
}
|
||||
|
||||
|
@ -160,22 +158,22 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
|
|||
return e;
|
||||
}
|
||||
|
||||
protected List generateOutlines(List outlines) {
|
||||
ArrayList elements = new ArrayList();
|
||||
protected List generateOutlines(final List outlines) {
|
||||
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)));
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
protected String intArrayToCsvString(int[] value) {
|
||||
if ((value == null) || (value.length == 0)) {
|
||||
protected String intArrayToCsvString(final int[] value) {
|
||||
if (value == null || value.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
sb.append(value[0]);
|
||||
|
||||
for (int i = 1; i < value.length; i++) {
|
||||
|
|
|
@ -17,23 +17,21 @@
|
|||
*/
|
||||
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.opml.Attribute;
|
||||
import com.sun.syndication.feed.opml.Opml;
|
||||
import com.sun.syndication.feed.opml.Outline;
|
||||
import com.sun.syndication.io.FeedException;
|
||||
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);
|
||||
}
|
||||
|
||||
public OPML10Parser(String type) {
|
||||
public OPML10Parser(final String type) {
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public boolean isMyType(Document document) {
|
||||
Element e = document.getRootElement();
|
||||
public boolean isMyType(final Document document) {
|
||||
final Element e = document.getRootElement();
|
||||
|
||||
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"))) {
|
||||
|
@ -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).
|
||||
*/
|
||||
@Override
|
||||
public WireFeed parse(Document document, boolean validate) throws IllegalArgumentException, FeedException {
|
||||
Opml opml = new Opml();
|
||||
public WireFeed parse(final Document document, final boolean validate) throws IllegalArgumentException, FeedException {
|
||||
final Opml opml = new Opml();
|
||||
opml.setFeedType("opml_1.0");
|
||||
|
||||
Element root = document.getRootElement();
|
||||
Element head = root.getChild("head");
|
||||
final Element root = document.getRootElement();
|
||||
final Element head = root.getChild("head");
|
||||
|
||||
if (head != null) {
|
||||
opml.setTitle(head.getChildText("title"));
|
||||
|
@ -108,7 +106,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
|||
|
||||
try {
|
||||
opml.setWindowBottom(readInteger(head.getChildText("windowBottom")));
|
||||
} catch (NumberFormatException nfe) {
|
||||
} catch (final NumberFormatException nfe) {
|
||||
LOG.log(Level.WARNING, "Unable to parse windowBottom", nfe);
|
||||
|
||||
if (validate) {
|
||||
|
@ -118,13 +116,13 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
|||
|
||||
try {
|
||||
opml.setWindowLeft(readInteger(head.getChildText("windowLeft")));
|
||||
} catch (NumberFormatException nfe) {
|
||||
} catch (final NumberFormatException nfe) {
|
||||
LOG.log(Level.WARNING, "Unable to parse windowLeft", nfe);
|
||||
}
|
||||
|
||||
try {
|
||||
opml.setWindowRight(readInteger(head.getChildText("windowRight")));
|
||||
} catch (NumberFormatException nfe) {
|
||||
} catch (final NumberFormatException nfe) {
|
||||
LOG.log(Level.WARNING, "Unable to parse windowRight", nfe);
|
||||
|
||||
if (validate) {
|
||||
|
@ -134,7 +132,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
|||
|
||||
try {
|
||||
opml.setWindowLeft(readInteger(head.getChildText("windowLeft")));
|
||||
} catch (NumberFormatException nfe) {
|
||||
} catch (final NumberFormatException nfe) {
|
||||
LOG.log(Level.WARNING, "Unable to parse windowLeft", nfe);
|
||||
|
||||
if (validate) {
|
||||
|
@ -144,7 +142,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
|||
|
||||
try {
|
||||
opml.setWindowTop(readInteger(head.getChildText("windowTop")));
|
||||
} catch (NumberFormatException nfe) {
|
||||
} catch (final NumberFormatException nfe) {
|
||||
LOG.log(Level.WARNING, "Unable to parse windowTop", nfe);
|
||||
|
||||
if (validate) {
|
||||
|
@ -154,7 +152,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
|||
|
||||
try {
|
||||
opml.setExpansionState(readIntArray(head.getChildText("expansionState")));
|
||||
} catch (NumberFormatException nfe) {
|
||||
} catch (final NumberFormatException nfe) {
|
||||
LOG.log(Level.WARNING, "Unable to parse expansionState", nfe);
|
||||
|
||||
if (validate) {
|
||||
|
@ -163,26 +161,26 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
|||
}
|
||||
|
||||
opml.setOutlines(parseOutlines(root.getChild("body").getChildren("outline"), validate));
|
||||
opml.setModules(this.parseFeedModules(root));
|
||||
opml.setModules(parseFeedModules(root));
|
||||
|
||||
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")) {
|
||||
throw new RuntimeException("Not an outline element.");
|
||||
}
|
||||
|
||||
Outline outline = new Outline();
|
||||
final Outline outline = new Outline();
|
||||
outline.setText(e.getAttributeValue("text"));
|
||||
outline.setType(e.getAttributeValue("type"));
|
||||
outline.setTitle(e.getAttributeValue("title"));
|
||||
|
||||
List jAttributes = e.getAttributes();
|
||||
ArrayList attributes = new ArrayList();
|
||||
final List jAttributes = e.getAttributes();
|
||||
final ArrayList attributes = new ArrayList();
|
||||
|
||||
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")
|
||||
&& !a.getName().equals("type")) {
|
||||
|
@ -194,7 +192,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
|||
|
||||
try {
|
||||
outline.setBreakpoint(readBoolean(e.getAttributeValue("isBreakpoint")));
|
||||
} catch (Exception ex) {
|
||||
} catch (final Exception ex) {
|
||||
LOG.log(Level.WARNING, "Unable to parse isBreakpoint value", ex);
|
||||
|
||||
if (validate) {
|
||||
|
@ -204,7 +202,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
|||
|
||||
try {
|
||||
outline.setComment(readBoolean(e.getAttributeValue("isComment")));
|
||||
} catch (Exception ex) {
|
||||
} catch (final Exception ex) {
|
||||
LOG.log(Level.WARNING, "Unable to parse isComment value", ex);
|
||||
|
||||
if (validate) {
|
||||
|
@ -212,15 +210,15 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
|||
}
|
||||
}
|
||||
|
||||
List children = e.getChildren("outline");
|
||||
outline.setModules(this.parseItemModules(e));
|
||||
final List children = e.getChildren("outline");
|
||||
outline.setModules(parseItemModules(e));
|
||||
outline.setChildren(parseOutlines(children, validate));
|
||||
|
||||
return outline;
|
||||
}
|
||||
|
||||
protected List parseOutlines(List elements, boolean validate) throws FeedException {
|
||||
ArrayList results = new ArrayList();
|
||||
protected List parseOutlines(final List elements, final boolean validate) throws FeedException {
|
||||
final ArrayList results = new ArrayList();
|
||||
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
results.add(parseOutline((Element) elements.get(i), validate));
|
||||
|
@ -229,7 +227,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
|
|||
return results;
|
||||
}
|
||||
|
||||
protected boolean readBoolean(String value) {
|
||||
protected boolean readBoolean(final String value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
} 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) {
|
||||
return null;
|
||||
} else {
|
||||
StringTokenizer tok = new StringTokenizer(value, ",");
|
||||
int[] result = new int[tok.countTokens()];
|
||||
final StringTokenizer tok = new StringTokenizer(value, ",");
|
||||
final int[] result = new int[tok.countTokens()];
|
||||
int count = 0;
|
||||
|
||||
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) {
|
||||
return new Integer(value);
|
||||
} else {
|
||||
|
|
|
@ -8,14 +8,13 @@
|
|||
*/
|
||||
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.opml.Opml;
|
||||
import com.sun.syndication.feed.opml.Outline;
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public Document generate(WireFeed feed) throws IllegalArgumentException, FeedException {
|
||||
public Document generate(final WireFeed feed) throws IllegalArgumentException, FeedException {
|
||||
Document retValue;
|
||||
|
||||
retValue = super.generate(feed);
|
||||
|
@ -59,19 +58,19 @@ public class OPML20Generator extends OPML10Generator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Element generateHead(Opml opml) {
|
||||
protected Element generateHead(final Opml opml) {
|
||||
Element retValue;
|
||||
|
||||
retValue = super.generateHead(opml);
|
||||
|
||||
Element docs = new Element("docs", opml.getDocs());
|
||||
final Element docs = new Element("docs", opml.getDocs());
|
||||
retValue.addContent(docs);
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Element generateOutline(Outline outline) {
|
||||
protected Element generateOutline(final Outline outline) {
|
||||
Element retValue;
|
||||
|
||||
retValue = super.generateOutline(outline);
|
||||
|
|
|
@ -17,17 +17,16 @@
|
|||
*/
|
||||
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.opml.Attribute;
|
||||
import com.sun.syndication.feed.opml.Opml;
|
||||
import com.sun.syndication.feed.opml.Outline;
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public boolean isMyType(Document document) {
|
||||
Element e = document.getRootElement();
|
||||
public boolean isMyType(final Document document) {
|
||||
final Element e = document.getRootElement();
|
||||
|
||||
if (e.getName().equals("opml")
|
||||
&& (((e.getChild("head") != null) && (e.getChild("head").getChild("docs") != null))
|
||||
|| ((e.getAttributeValue("version") != null) && e.getAttributeValue("version").equals("2.0")) || ((e.getChild("head") != null) && (e
|
||||
.getChild("head").getChild("ownerId") != null)))) {
|
||||
&& (e.getChild("head") != null && e.getChild("head").getChild("docs") != null || e.getAttributeValue("version") != null
|
||||
&& e.getAttributeValue("version").equals("2.0") || e.getChild("head") != null && e.getChild("head").getChild("ownerId") != null)) {
|
||||
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).
|
||||
*/
|
||||
@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) super.parse(document, validate);
|
||||
|
||||
Element head = document.getRootElement().getChild("head");
|
||||
final Element head = document.getRootElement().getChild("head");
|
||||
|
||||
if (head != null) {
|
||||
opml.setOwnerId(head.getChildTextTrim("ownerId"));
|
||||
|
@ -94,7 +92,7 @@ public class OPML20Parser extends OPML10Parser {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Outline parseOutline(Element e, boolean validate) throws FeedException {
|
||||
protected Outline parseOutline(final Element e, final boolean validate) throws FeedException {
|
||||
Outline retValue;
|
||||
|
||||
retValue = super.parseOutline(e, validate);
|
||||
|
@ -103,10 +101,10 @@ public class OPML20Parser extends OPML10Parser {
|
|||
retValue.setCreated(DateParser.parseRFC822(e.getAttributeValue("created")));
|
||||
}
|
||||
|
||||
List atts = retValue.getAttributes();
|
||||
final List atts = retValue.getAttributes();
|
||||
|
||||
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")) {
|
||||
retValue.getAttributes().remove(a);
|
||||
|
|
|
@ -13,11 +13,11 @@ package com.sun.syndication;
|
|||
public abstract class SyndFeedTest extends FeedTest {
|
||||
private String _prefix = null;
|
||||
|
||||
protected SyndFeedTest(String feedType) {
|
||||
protected SyndFeedTest(final String feedType) {
|
||||
this(feedType, feedType + ".xml");
|
||||
}
|
||||
|
||||
protected SyndFeedTest(String feedType, String feedFileName) {
|
||||
protected SyndFeedTest(final String feedType, final String feedFileName) {
|
||||
super(feedFileName);
|
||||
_prefix = feedType;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public abstract class SyndFeedTest extends FeedTest {
|
|||
return _prefix;
|
||||
}
|
||||
|
||||
protected void assertProperty(String property, String value) {
|
||||
protected void assertProperty(final String property, final String value) {
|
||||
assertEquals(property, getPrefix() + "." + value);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue