Refactored some code

This commit is contained in:
Patrick Gotthard 2016-01-08 18:29:50 +01:00
parent ac9dc0df5c
commit f9576b8d00
9 changed files with 1215 additions and 1333 deletions

View file

@ -31,13 +31,8 @@ public class Attribute implements Cloneable, Serializable {
private static final long serialVersionUID = 1L;
private String _name;
private String _value;
/** Creates a new instance of Attribute */
public Attribute() {
super();
}
private String name;
private String value;
/**
* Creates a new instance of Attribute.
@ -53,62 +48,40 @@ public class Attribute implements Cloneable, Serializable {
setValue(value);
}
/**
* name of the attribute.
*
* @param name name of the attribute.
*/
public void setName(final String name) {
_name = name;
this.name = name;
}
/**
* name of the attribute.
*
* @return name of the attribute.
*/
public String getName() {
return _name;
return name;
}
/**
* value of the attribute.
*
* @param value value of the attribute.
*/
public void setValue(final String value) {
_value = value;
this.value = value;
}
/**
* value of the attribute.
*
* @return value of the attribute.
*/
public String getValue() {
return _value;
return value;
}
@Override
public Object clone() {
return new Attribute(_name, _value);
return new Attribute(name, value);
}
@Override
public boolean equals(final Object obj) {
final EqualsBean eBean = new EqualsBean(Attribute.class, this);
return eBean.beanEquals(obj);
return new EqualsBean(Attribute.class, this).beanEquals(obj);
}
@Override
public int hashCode() {
final EqualsBean equals = new EqualsBean(Attribute.class, this);
return equals.beanHashCode();
return new EqualsBean(Attribute.class, this).beanHashCode();
}
@Override
public String toString() {
final ToStringBean tsBean = new ToStringBean(Attribute.class, this);
return tsBean.toString();
return new ToStringBean(Attribute.class, this).toString();
}
}

View file

@ -24,8 +24,8 @@ import java.util.List;
import com.rometools.rome.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.
*
* @author <a href="mailto:cooper@screaming-penguin.com"> Robert "kebernet" Cooper</a>
*/
@ -33,25 +33,20 @@ public class Opml extends WireFeed {
private static final long serialVersionUID = 1L;
private Date _created;
private Date _modified;
private Integer _verticalScrollState;
private Integer _windowBottom;
private Integer _windowLeft;
private Integer _windowRight;
private Integer _windowTop;
private List<Outline> _outlines;
private String _docs;
private String _ownerEmail;
private String _ownerId;
private String _ownerName;
private String _title;
private int[] _expansionState;
/** Creates a new instance of Opml */
public Opml() {
super();
}
private Date created;
private Date modified;
private Integer verticalScrollState;
private Integer windowBottom;
private Integer windowLeft;
private Integer windowRight;
private Integer windowTop;
private List<Outline> outlines;
private String docs;
private String ownerEmail;
private String ownerId;
private String ownerName;
private String title;
private int[] expansionState;
/**
* <dateCreated> is a date-time, indicating when the document was created.
@ -59,7 +54,7 @@ public class Opml extends WireFeed {
* @param created date-time, indicating when the document was created.
*/
public void setCreated(final Date created) {
_created = created;
this.created = created;
}
/**
@ -68,53 +63,51 @@ public class Opml extends WireFeed {
* @return date-time, indicating when the document was created.
*/
public Date getCreated() {
return _created;
return created;
}
/**
* (OPML 2) &lt;docs&gt; is the http address of documentation for the format used in the OPML
* file. It's probably a pointer to <a href="http://www.opml.org/spec2">this page</a> for people
* who might stumble across the file on a web server 25 years from now and wonder what it is.
* (OPML 2) &lt;docs&gt; is the http address of documentation for the format used in the OPML file. It's probably a
* pointer to <a href="http://www.opml.org/spec2">this page</a> for people who might stumble across the file on a
* web server 25 years from now and wonder what it is.
*
* @param docs http address of documentation for the format used
*/
public void setDocs(final String docs) {
_docs = docs;
this.docs = docs;
}
/**
* (OPML 2) &lt;docs&gt; is the http address of documentation for the format used in the OPML
* file. It's probably a pointer to <a href="http://www.opml.org/spec2">this page</a> for people
* who might stumble across the file on a web server 25 years from now and wonder what it is.
* (OPML 2) &lt;docs&gt; is the http address of documentation for the format used in the OPML file. It's probably a
* pointer to <a href="http://www.opml.org/spec2">this page</a> for people who might stumble across the file on a
* web server 25 years from now and wonder what it is.
*
* @return http address of documentation for the format used
*/
public String getDocs() {
return _docs;
return docs;
}
/**
* &lt;expansionState&gt;is a comma-separated list of line numbers that are expanded. The line
* numbers in the list tell you which headlines to expand. The order is important. For each
* element in the list, X, starting at the first summit, navigate flatdown X times and expand.
* Repeat for each element in the list.
* &lt;expansionState&gt;is a comma-separated list of line numbers that are expanded. The line numbers in the list
* tell you which headlines to expand. The order is important. For each element in the list, X, starting at the
* first summit, navigate flatdown X times and expand. Repeat for each element in the list.
*
* @param expansionState int array containing expanded elements.
*/
public void setExpansionState(final int[] expansionState) {
_expansionState = expansionState;
this.expansionState = expansionState;
}
/**
* &lt;expansionState&gt; is a comma-separated list of line numbers that are expanded. The line
* numbers in the list tell you which headlines to expand. The order is important. For each
* element in the list, X, starting at the first summit, navigate flatdown X times and expand.
* Repeat for each element in the list.
* &lt;expansionState&gt; is a comma-separated list of line numbers that are expanded. The line numbers in the list
* tell you which headlines to expand. The order is important. For each element in the list, X, starting at the
* first summit, navigate flatdown X times and expand. Repeat for each element in the list.
*
* @return int array containing expanded elements.
*/
public int[] getExpansionState() {
return _expansionState;
return expansionState;
}
/**
@ -123,7 +116,7 @@ public class Opml extends WireFeed {
* @param modified date-time, indicating when the document was last modified.
*/
public void setModified(final Date modified) {
_modified = modified;
this.modified = modified;
}
/**
@ -132,7 +125,7 @@ public class Opml extends WireFeed {
* @return date-time, indicating when the document was last modified.
*/
public Date getModified() {
return _modified;
return modified;
}
/**
@ -141,7 +134,7 @@ public class Opml extends WireFeed {
* @param outlines Root level Outline object that should appear in the &lt;body&gt;
*/
public void setOutlines(final List<Outline> outlines) {
_outlines = outlines;
this.outlines = outlines;
}
/**
@ -150,11 +143,11 @@ public class Opml extends WireFeed {
* @return Root level Outline object that should appear in the &lt;body&gt;
*/
public List<Outline> getOutlines() {
if (_outlines == null) {
_outlines = new ArrayList<Outline>();
if (outlines == null) {
outlines = new ArrayList<Outline>();
}
return _outlines;
return outlines;
}
/**
@ -163,7 +156,7 @@ public class Opml extends WireFeed {
* @param ownerEmail the email address of the owner of the document.
*/
public void setOwnerEmail(final String ownerEmail) {
_ownerEmail = ownerEmail;
this.ownerEmail = ownerEmail;
}
/**
@ -172,33 +165,29 @@ public class Opml extends WireFeed {
* @return the email address of the owner of the document.
*/
public String getOwnerEmail() {
return _ownerEmail;
return ownerEmail;
}
/**
* (OPML 2) &lt;ownerId&gt; is the 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.
* (OPML 2) &lt;ownerId&gt; is the 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.
*
* @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.
* @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(final String ownerId) {
_ownerId = ownerId;
this.ownerId = ownerId;
}
/**
* (OPML 2) &lt;ownerId&gt; is the 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.
* (OPML 2) &lt;ownerId&gt; is the 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.
*
* @return 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.
* @return 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 String getOwnerId() {
return _ownerId;
return ownerId;
}
/**
@ -207,7 +196,7 @@ public class Opml extends WireFeed {
* @param ownerName the owner of the document.
*/
public void setOwnerName(final String ownerName) {
_ownerName = ownerName;
this.ownerName = ownerName;
}
/**
@ -216,7 +205,7 @@ public class Opml extends WireFeed {
* @return the owner of the document.
*/
public String getOwnerName() {
return _ownerName;
return ownerName;
}
/**
@ -225,7 +214,7 @@ public class Opml extends WireFeed {
* @param title title of the document.
*/
public void setTitle(final String title) {
_title = title;
this.title = title;
}
/**
@ -234,29 +223,28 @@ public class Opml extends WireFeed {
* @return title of the document.
*/
public String getTitle() {
return _title;
return title;
}
/**
* &lt;vertScrollState&gt; is a number, saying which line of the outline is displayed on the top
* line of the window. This number is calculated with the expansion state already applied.
* &lt;vertScrollState&gt; is a number, saying which line of the outline is displayed on the top line of the window.
* This number is calculated with the expansion state already applied.
*
* @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(final Integer verticalScrollState) {
_verticalScrollState = verticalScrollState;
this.verticalScrollState = verticalScrollState;
}
/**
* &lt;vertScrollState&gt; is a number, saying which line of the outline is displayed on the top
* line of the window. This number is calculated with the expansion state already applied.
* &lt;vertScrollState&gt; is a number, saying which line of the outline is displayed on the top line of the window.
* This number is calculated with the expansion state already applied.
*
* @return which line of the outline is displayed on the top line of the window. This number is
* calculated with the expansion state already applied.
* @return which line of the outline is displayed on the top line of the window. This number is calculated with the
* expansion state already applied.
*/
public Integer getVerticalScrollState() {
return _verticalScrollState;
return verticalScrollState;
}
/**
@ -265,7 +253,7 @@ public class Opml extends WireFeed {
* @param windowBottom the pixel location of the bottom edge of the window.
*/
public void setWindowBottom(final Integer windowBottom) {
_windowBottom = windowBottom;
this.windowBottom = windowBottom;
}
/**
@ -274,7 +262,7 @@ public class Opml extends WireFeed {
* @return the pixel location of the bottom edge of the window.
*/
public Integer getWindowBottom() {
return _windowBottom;
return windowBottom;
}
/**
@ -283,7 +271,7 @@ public class Opml extends WireFeed {
* @param windowLeft the pixel location of the left edge of the window.
*/
public void setWindowLeft(final Integer windowLeft) {
_windowLeft = windowLeft;
this.windowLeft = windowLeft;
}
/**
@ -292,7 +280,7 @@ public class Opml extends WireFeed {
* @return the pixel location of the left edge of the window.
*/
public Integer getWindowLeft() {
return _windowLeft;
return windowLeft;
}
/**
@ -301,7 +289,7 @@ public class Opml extends WireFeed {
* @param windowRight the pixel location of the right edge of the window.
*/
public void setWindowRight(final Integer windowRight) {
_windowRight = windowRight;
this.windowRight = windowRight;
}
/**
@ -310,7 +298,7 @@ public class Opml extends WireFeed {
* @return the pixel location of the right edge of the window.
*/
public Integer getWindowRight() {
return _windowRight;
return windowRight;
}
/**
@ -319,7 +307,7 @@ public class Opml extends WireFeed {
* @param windowTop the pixel location of the top edge of the window.
*/
public void setWindowTop(final Integer windowTop) {
_windowTop = windowTop;
this.windowTop = windowTop;
}
/**
@ -328,6 +316,7 @@ public class Opml extends WireFeed {
* @return the pixel location of the top edge of the window.
*/
public Integer getWindowTop() {
return _windowTop;
return windowTop;
}
}

View file

@ -37,20 +37,18 @@ public class Outline implements Cloneable, Serializable {
private static final long serialVersionUID = 1L;
private Date _created;
private List<Attribute> _attributes;
private List<String> _categories;
private List<Outline> _children;
private List<Module> _modules;
private String _text;
private String _title;
private String _type;
private boolean _breakpoint;
private boolean _comment;
private Date created;
private List<Attribute> attributes;
private List<String> categories;
private List<Outline> children;
private List<Module> modules;
private String text;
private String title;
private String type;
private boolean breakpoint;
private boolean comment;
/** Creates a new instance of Outline */
public Outline() {
super();
}
/**
@ -60,14 +58,13 @@ public class Outline implements Cloneable, Serializable {
* @param text text attribute value
*/
public Outline(final String type, final String text) {
super();
setType(type);
setText(text);
}
/**
* Creates an outline with the given title, xmlUrl and htmlUrl. This is traditionally used for
* aggregator feed lists and will get a type of "rss".
* Creates an outline with the given title, xmlUrl and htmlUrl. This is traditionally used for aggregator feed lists
* and will get a type of "rss".
*
* @param title Title of the entry.
* @param xmlUrl link to XML file.
@ -94,7 +91,7 @@ public class Outline implements Cloneable, Serializable {
* @param attributes List of attributes on this outline.
*/
public void setAttributes(final List<Attribute> attributes) {
_attributes = attributes;
this.attributes = attributes;
}
/**
@ -103,33 +100,31 @@ public class Outline implements Cloneable, Serializable {
* @return List of attributes on this outline.
*/
public List<Attribute> getAttributes() {
if (_attributes == null) {
_attributes = new ArrayList<Attribute>();
if (attributes == null) {
attributes = new ArrayList<Attribute>();
}
return _attributes;
return attributes;
}
/**
* isBreakpoint is a string, either "true" or "false", indicating whether a breakpoint is set on
* this outline. This attribute is mainly necessary for outlines used to edit scripts. If it's
* not present, the value is false.
* isBreakpoint is a string, either "true" or "false", indicating whether a breakpoint is set on this outline. This
* attribute is mainly necessary for outlines used to edit scripts. If it's not present, the value is false.
*
* @param breakpoint whether a breakpoint is set on this outline.
*/
public void setBreakpoint(final boolean breakpoint) {
_breakpoint = breakpoint;
this.breakpoint = breakpoint;
}
/**
* isBreakpoint is a string, either "true" or "false", indicating whether a breakpoint is set on
* this outline. This attribute is mainly necessary for outlines used to edit scripts. If it's
* not present, the value is false.
* isBreakpoint is a string, either "true" or "false", indicating whether a breakpoint is set on this outline. This
* attribute is mainly necessary for outlines used to edit scripts. If it's not present, the value is false.
*
* @return whether a breakpoint is set on this outline
*/
public boolean isBreakpoint() {
return _breakpoint;
return breakpoint;
}
/**
@ -138,7 +133,7 @@ public class Outline implements Cloneable, Serializable {
* @param categories (OPML 2) A List of Strings indicating values in the category attribute.
*/
public void setCategories(final List<String> categories) {
_categories = categories;
this.categories = categories;
}
/**
@ -147,11 +142,11 @@ public class Outline implements Cloneable, Serializable {
* @return (OPML 2) A List of Strings indicating values in the category attribute.
*/
public List<String> getCategories() {
if (_categories == null) {
_categories = new ArrayList<String>();
if (categories == null) {
categories = new ArrayList<String>();
}
return _categories;
return categories;
}
/**
@ -160,7 +155,7 @@ public class Outline implements Cloneable, Serializable {
* @param children A list of sub-outlines for this entry.
*/
public void setChildren(final List<Outline> children) {
_children = children;
this.children = children;
}
/**
@ -169,33 +164,33 @@ public class Outline implements Cloneable, Serializable {
* @return A list of sub-outlines for this entry.
*/
public List<Outline> getChildren() {
if (_children == null) {
_children = new ArrayList<Outline>();
if (children == null) {
children = new ArrayList<Outline>();
}
return _children;
return children;
}
/**
* isComment is a string, either "true" or "false", indicating whether the outline is commented
* or not. By convention if an outline is commented, all subordinate outlines are considered to
* also be commented. If it's not present, the value is false.
* isComment is a string, either "true" or "false", indicating whether the outline is commented or not. By
* convention if an outline is commented, all subordinate outlines are considered to also be commented. If it's not
* present, the value is false.
*
* @param comment whether the outline is commented
*/
public void setComment(final boolean comment) {
_comment = comment;
this.comment = comment;
}
/**
* isComment is a string, either "true" or "false", indicating whether the outline is commented
* or not. By convention if an outline is commented, all subordinate outlines are considered to
* also be commented. If it's not present, the value is false.
* isComment is a string, either "true" or "false", indicating whether the outline is commented or not. By
* convention if an outline is commented, all subordinate outlines are considered to also be commented. If it's not
* present, the value is false.
*
* @return whether the outline is commented
*/
public boolean isComment() {
return _comment;
return comment;
}
/**
@ -204,7 +199,7 @@ public class Outline implements Cloneable, Serializable {
* @param created date-time that the outline node was created.
*/
public void setCreated(final Date created) {
_created = created;
this.created = created;
}
/**
@ -213,7 +208,7 @@ public class Outline implements Cloneable, Serializable {
* @return date-time that the outline node was created.
*/
public Date getCreated() {
return _created;
return created;
}
/**
@ -235,15 +230,15 @@ public class Outline implements Cloneable, Serializable {
}
public void setModules(final List<Module> modules) {
_modules = modules;
this.modules = modules;
}
public List<Module> getModules() {
if (_modules == null) {
_modules = new ArrayList<Module>();
if (modules == null) {
modules = new ArrayList<Module>();
}
return _modules;
return modules;
}
/**
@ -252,7 +247,7 @@ public class Outline implements Cloneable, Serializable {
* @param text The "text" attribute of the outline.
*/
public void setText(final String text) {
_text = text;
this.text = text;
}
/**
@ -261,7 +256,7 @@ public class Outline implements Cloneable, Serializable {
* @return The "text" attribute of the outline.
*/
public String getText() {
return _text;
return text;
}
/**
@ -270,7 +265,7 @@ public class Outline implements Cloneable, Serializable {
* @param title The "title" attribute of the outline.
*/
public void setTitle(final String title) {
_title = title;
this.title = title;
}
/**
@ -279,7 +274,7 @@ public class Outline implements Cloneable, Serializable {
* @return The "title" attribute of the outline.
*/
public String getTitle() {
return _title;
return title;
}
/**
@ -288,7 +283,7 @@ public class Outline implements Cloneable, Serializable {
* @param type The "type" attribute of the outline.
*/
public void setType(final String type) {
_type = type;
this.type = type;
}
/**
@ -297,7 +292,7 @@ public class Outline implements Cloneable, Serializable {
* @return The "type" attribute of the outline.
*/
public String getType() {
return _type;
return type;
}
/**
@ -333,7 +328,7 @@ public class Outline implements Cloneable, Serializable {
o.setBreakpoint(isBreakpoint());
o.setCategories(new ArrayList<String>(getCategories()));
o.setComment(isComment());
o.setCreated(_created != null ? (Date) _created.clone() : null);
o.setCreated(created != null ? (Date) created.clone() : null);
o.setModules(new ArrayList<Module>(getModules()));
o.setText(getText());
o.setTitle(getTitle());
@ -341,13 +336,13 @@ public class Outline implements Cloneable, Serializable {
final ArrayList<Outline> children = new ArrayList<Outline>();
for (int i = 0; i < getChildren().size(); i++) {
children.add((Outline) _children.get(i).clone());
children.add((Outline) this.children.get(i).clone());
}
o.setChildren(children);
final ArrayList<Attribute> attributes = new ArrayList<Attribute>();
for (int i = 0; i < getAttributes().size(); i++) {
attributes.add((Attribute) _attributes.get(i).clone());
attributes.add((Attribute) this.attributes.get(i).clone());
}
o.setAttributes(attributes);
@ -356,22 +351,17 @@ public class Outline implements Cloneable, Serializable {
@Override
public boolean equals(final Object obj) {
final EqualsBean eBean = new EqualsBean(Outline.class, this);
return eBean.beanEquals(obj);
return new EqualsBean(Outline.class, this).beanEquals(obj);
}
@Override
public int hashCode() {
final EqualsBean equals = new EqualsBean(Outline.class, this);
return equals.beanHashCode();
return new EqualsBean(Outline.class, this).beanHashCode();
}
@Override
public String toString() {
final ToStringBean tsBean = new ToStringBean(Outline.class, this);
return tsBean.toString();
return new ToStringBean(Outline.class, this).toString();
}
}

View file

@ -44,7 +44,6 @@ import com.rometools.rome.feed.synd.SyndPerson;
import com.rometools.rome.feed.synd.SyndPersonImpl;
/**
*
* @author cooper
*/
public class ConverterForOPML10 implements Converter {
@ -54,11 +53,6 @@ public class ConverterForOPML10 implements Converter {
public static final String URI_TREE = "urn:rome.tree";
public static final String URI_ATTRIBUTE = "urn:rome.attribute#";
/** Creates a new instance of ConverterForOPML10 */
public ConverterForOPML10() {
super();
}
protected void addOwner(final Opml opml, final SyndFeed syndFeed) {
if (opml.getOwnerEmail() != null || opml.getOwnerName() != null) {
final List<SyndPerson> authors = new ArrayList<SyndPerson>();
@ -77,8 +71,7 @@ public class ConverterForOPML10 implements Converter {
* <p>
*
* @param feed real feed to copy/convert.
* @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
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
@ -90,10 +83,10 @@ public class ConverterForOPML10 implements Converter {
syndFeed.setModules(opml.getModules());
syndFeed.setFeedType(getType());
createEntries(new TreeContext(), syndFeed.getEntries(), opml.getOutlines());
createEntries(new Stack<Integer>(), syndFeed.getEntries(), opml.getOutlines());
}
protected void createEntries(final TreeContext context, final List<SyndEntry> allEntries, final List<Outline> outlines) {
protected void createEntries(final Stack<Integer> context, final List<SyndEntry> allEntries, final List<Outline> outlines) {
final List<Outline> so = Collections.synchronizedList(outlines);
for (int i = 0; i < so.size(); i++) {
@ -101,7 +94,7 @@ public class ConverterForOPML10 implements Converter {
}
}
protected SyndEntry createEntry(final TreeContext context, final List<SyndEntry> allEntries, final Outline outline) {
protected SyndEntry createEntry(final Stack<Integer> context, final List<SyndEntry> allEntries, final Outline outline) {
final SyndEntry entry = new SyndEntryImpl();
if (outline.getType() != null && outline.getType().equals("rss")) {
@ -197,7 +190,6 @@ public class ConverterForOPML10 implements Converter {
*
* @param syndFeed SyndFeedImpl to copy/convert value from.
* @return a real feed with copied/converted values of the SyndFeedImpl.
*
*/
@Override
public WireFeed createRealFeed(final SyndFeed syndFeed) {
@ -333,11 +325,9 @@ public class ConverterForOPML10 implements Converter {
/**
* Returns the type (version) of the real feed this converter handles.
* <p>
*
* @return the real feed type.
* @see WireFeed for details on the format of this string.
* <p>
*/
@Override
public String getType() {
@ -345,21 +335,15 @@ public class ConverterForOPML10 implements Converter {
}
private static class OutlineHolder {
Outline outline;
String parent;
private final Outline outline;
private final String parent;
public OutlineHolder(final Outline outline, final String parent) {
this.outline = outline;
this.parent = parent;
}
}
private static class TreeContext extends Stack<Integer> {
private static final long serialVersionUID = 1L;
TreeContext() {
super();
}
}
}

View file

@ -1,25 +1,12 @@
/*
* ConverterForOPML20.java
*
* Created on April 25, 2006, 5:29 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.rometools.opml.feed.synd.impl;
import com.rometools.rome.feed.WireFeed;
import com.rometools.rome.feed.synd.SyndFeed;
/**
*
* @author cooper
*/
public class ConverterForOPML20 extends ConverterForOPML10 {
/** Creates a new instance of ConverterForOPML20 */
public ConverterForOPML20() {
super();
}
/**
* Returns the type (version) of the real feed this converter handles.
@ -41,8 +28,7 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
* <p>
*
* @param feed real feed to copy/convert.
* @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
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
@ -58,10 +44,7 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
*/
@Override
public WireFeed createRealFeed(final SyndFeed syndFeed) {
WireFeed retValue;
retValue = super.createRealFeed(syndFeed);
return retValue;
return super.createRealFeed(syndFeed);
}
}

View file

@ -1,30 +1,15 @@
/*
* TreeCategoryImpl.java
*
* Created on April 27, 2006, 3:44 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.rometools.opml.feed.synd.impl;
import com.rometools.rome.feed.synd.SyndCategory;
import com.rometools.rome.feed.synd.SyndCategoryImpl;
/**
*
* @author cooper
*/
public class TreeCategoryImpl extends SyndCategoryImpl {
private static final long serialVersionUID = 1L;
/** Creates a new instance of TreeCategoryImpl */
public TreeCategoryImpl() {
super();
}
@Override
public boolean equals(final Object o) {
final SyndCategory c = (SyndCategory) o;

View file

@ -35,11 +35,10 @@ import com.rometools.rome.io.impl.BaseWireFeedGenerator;
import com.rometools.rome.io.impl.DateParser;
/**
*
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/
public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGenerator {
/** Creates a new instance of Opml10Generator */
public OPML10Generator() {
super("opml_1.0");
}
@ -50,16 +49,16 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
/**
* Creates an XML document (JDOM) for the given feed bean.
* <p>
*
* @param feed the feed bean to generate the XML document from.
* @return the generated XML document (JDOM).
* @throws IllegalArgumentException thrown if the type of the given feed bean does not match
* with the type of the WireFeedGenerator.
* @throws IllegalArgumentException thrown if the type of the given feed bean does not match with the type of the
* WireFeedGenerator.
* @throws FeedException thrown if the XML Document could not be created.
*/
@Override
public Document generate(final WireFeed feed) throws IllegalArgumentException, FeedException {
if (!(feed instanceof Opml)) {
throw new IllegalArgumentException("Not an OPML file");
}
@ -88,9 +87,7 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
if (target == null || name == null || value == null) {
return false;
}
target.setAttribute(name, value.toString());
return true;
}

View file

@ -37,14 +37,12 @@ import com.rometools.rome.io.impl.BaseWireFeedParser;
import com.rometools.rome.io.impl.DateParser;
/**
*
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/
public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
private static Logger LOG = LoggerFactory.getLogger(OPML10Parser.class);
/** Creates a new instance of Opml10Parser */
public OPML10Parser() {
super("opml_1.0", null);
}
@ -111,7 +109,6 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
opml.setWindowBottom(readInteger(head.getChildText("windowBottom")));
} catch (final NumberFormatException nfe) {
LOG.warn("Unable to parse windowBottom", nfe);
if (validate) {
throw new FeedException("Unable to parse windowBottom", nfe);
}
@ -121,13 +118,15 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
opml.setWindowLeft(readInteger(head.getChildText("windowLeft")));
} catch (final NumberFormatException nfe) {
LOG.warn("Unable to parse windowLeft", nfe);
if (validate) {
throw new FeedException("Unable to parse windowLeft", nfe);
}
}
try {
opml.setWindowRight(readInteger(head.getChildText("windowRight")));
} catch (final NumberFormatException nfe) {
LOG.warn("Unable to parse windowRight", nfe);
if (validate) {
throw new FeedException("Unable to parse windowRight", nfe);
}
@ -137,7 +136,6 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
opml.setWindowLeft(readInteger(head.getChildText("windowLeft")));
} catch (final NumberFormatException nfe) {
LOG.warn("Unable to parse windowLeft", nfe);
if (validate) {
throw new FeedException("Unable to parse windowLeft", nfe);
}
@ -147,7 +145,6 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
opml.setWindowTop(readInteger(head.getChildText("windowTop")));
} catch (final NumberFormatException nfe) {
LOG.warn("Unable to parse windowTop", nfe);
if (validate) {
throw new FeedException("Unable to parse windowTop", nfe);
}
@ -157,7 +154,6 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
opml.setExpansionState(readIntArray(head.getChildText("expansionState")));
} catch (final NumberFormatException nfe) {
LOG.warn("Unable to parse expansionState", nfe);
if (validate) {
throw new FeedException("Unable to parse expansionState", nfe);
}

View file

@ -1,11 +1,3 @@
/*
* OPML20Generator.java
*
* Created on April 25, 2006, 5:31 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.rometools.opml.io.impl;
import java.util.Locale;
@ -20,21 +12,18 @@ import com.rometools.rome.io.FeedException;
import com.rometools.rome.io.impl.DateParser;
/**
*
* @author cooper
*/
public class OPML20Generator extends OPML10Generator {
/** Creates a new instance of OPML20Generator */
public OPML20Generator() {
}
/**
* Returns the type of feed the generator creates.
* <p>
*
* @return the type of feed the generator creates.
* @see WireFeed for details on the format of this string.
* <p>
*/
@Override
public String getType() {
@ -43,47 +32,43 @@ public class OPML20Generator extends OPML10Generator {
/**
* Creates an XML document (JDOM) for the given feed bean.
* <p>
*
* @param feed the feed bean to generate the XML document from.
* @return the generated XML document (JDOM).
* @throws IllegalArgumentException thrown if the type of the given feed bean does not match
* with the type of the WireFeedGenerator.
* @throws IllegalArgumentException thrown if the type of the given feed bean does not match with the type of the
* WireFeedGenerator.
* @throws FeedException thrown if the XML Document could not be created.
*/
@Override
public Document generate(final WireFeed feed) throws IllegalArgumentException, FeedException {
Document retValue;
retValue = super.generate(feed);
final Document retValue = super.generate(feed);
retValue.getRootElement().setAttribute("version", "2.0");
return retValue;
}
@Override
protected Element generateHead(final Opml opml) {
Element retValue;
retValue = super.generateHead(opml);
final Element docs = new Element("docs");
docs.setText(opml.getDocs());
retValue.addContent(docs);
final Element retValue = super.generateHead(opml);
retValue.addContent(docs);
return retValue;
}
@Override
protected Element generateOutline(final Outline outline) {
Element retValue;
retValue = super.generateOutline(outline);
final Element retValue = super.generateOutline(outline);
if (outline.getCreated() != null) {
retValue.setAttribute("created", DateParser.formatRFC822(outline.getCreated(), Locale.US));
}
return retValue;
}
}