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

View file

@ -24,8 +24,8 @@ import java.util.List;
import com.rometools.rome.feed.WireFeed; 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 * This class represents the root of an OPML 1/2 feed and contains the elements that may appear in the <head> tag
* the <head> tag of the feed. * of the feed.
* *
* @author <a href="mailto:cooper@screaming-penguin.com"> Robert "kebernet" Cooper</a> * @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 static final long serialVersionUID = 1L;
private Date _created; private Date created;
private Date _modified; private Date modified;
private Integer _verticalScrollState; private Integer verticalScrollState;
private Integer _windowBottom; private Integer windowBottom;
private Integer _windowLeft; private Integer windowLeft;
private Integer _windowRight; private Integer windowRight;
private Integer _windowTop; private Integer windowTop;
private List<Outline> _outlines; private List<Outline> outlines;
private String _docs; private String docs;
private String _ownerEmail; private String ownerEmail;
private String _ownerId; private String ownerId;
private String _ownerName; private String ownerName;
private String _title; private String title;
private int[] _expansionState; private int[] expansionState;
/** Creates a new instance of Opml */
public Opml() {
super();
}
/** /**
* <dateCreated> is a date-time, indicating when the document was created. * <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. * @param created date-time, indicating when the document was created.
*/ */
public void setCreated(final Date 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. * @return date-time, indicating when the document was created.
*/ */
public Date getCreated() { 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 * (OPML 2) &lt;docs&gt; is the http address of documentation for the format used in the OPML file. It's probably a
* file. It's probably a pointer to <a href="http://www.opml.org/spec2">this page</a> for people * pointer to <a href="http://www.opml.org/spec2">this page</a> for people who might stumble across the file on a
* who might stumble across the file on a web server 25 years from now and wonder what it is. * web server 25 years from now and wonder what it is.
* *
* @param docs http address of documentation for the format used * @param docs http address of documentation for the format used
*/ */
public void setDocs(final String docs) { 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 * (OPML 2) &lt;docs&gt; is the http address of documentation for the format used in the OPML file. It's probably a
* file. It's probably a pointer to <a href="http://www.opml.org/spec2">this page</a> for people * pointer to <a href="http://www.opml.org/spec2">this page</a> for people who might stumble across the file on a
* who might stumble across the file on a web server 25 years from now and wonder what it is. * web server 25 years from now and wonder what it is.
* *
* @return http address of documentation for the format used * @return http address of documentation for the format used
*/ */
public String getDocs() { public String getDocs() {
return _docs; return docs;
} }
/** /**
* &lt;expansionState&gt;is a comma-separated list of line numbers that are expanded. The line * &lt;expansionState&gt;is a comma-separated list of line numbers that are expanded. The line numbers in the list
* numbers in the list tell you which headlines to expand. The order is important. For each * tell you which headlines to expand. The order is important. For each element in the list, X, starting at the
* element in the list, X, starting at the first summit, navigate flatdown X times and expand. * first summit, navigate flatdown X times and expand. Repeat for each element in the list.
* Repeat for each element in the list.
* *
* @param expansionState int array containing expanded elements. * @param expansionState int array containing expanded elements.
*/ */
public void setExpansionState(final int[] expansionState) { 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 * &lt;expansionState&gt; is a comma-separated list of line numbers that are expanded. The line numbers in the list
* numbers in the list tell you which headlines to expand. The order is important. For each * tell you which headlines to expand. The order is important. For each element in the list, X, starting at the
* element in the list, X, starting at the first summit, navigate flatdown X times and expand. * first summit, navigate flatdown X times and expand. Repeat for each element in the list.
* Repeat for each element in the list.
* *
* @return int array containing expanded elements. * @return int array containing expanded elements.
*/ */
public int[] getExpansionState() { 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. * @param modified date-time, indicating when the document was last modified.
*/ */
public void setModified(final Date 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. * @return date-time, indicating when the document was last modified.
*/ */
public Date getModified() { 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; * @param outlines Root level Outline object that should appear in the &lt;body&gt;
*/ */
public void setOutlines(final List<Outline> outlines) { 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; * @return Root level Outline object that should appear in the &lt;body&gt;
*/ */
public List<Outline> getOutlines() { public List<Outline> getOutlines() {
if (_outlines == null) { if (outlines == null) {
_outlines = new ArrayList<Outline>(); 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. * @param ownerEmail the email address of the owner of the document.
*/ */
public void setOwnerEmail(final String ownerEmail) { 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. * @return the email address of the owner of the document.
*/ */
public String getOwnerEmail() { public String getOwnerEmail() {
return _ownerEmail; return ownerEmail;
} }
/** /**
* (OPML 2) &lt;ownerId&gt; is the http address of a web page that contains <strike>an * (OPML 2) &lt;ownerId&gt; is the http address of a web page that contains <strike>an HTML</strike> a form that
* HTML</strike> a form that allows a human reader to communicate with the author of the * allows a human reader to communicate with the author of the document via email or other means.
* document via email or other means.
* *
* @param ownerId http address of a web page that contains <strike>an HTML</strike> a form that * @param ownerId http address of a web page that contains <strike>an HTML</strike> a form that allows a human
* allows a human reader to communicate with the author of the document via email or * reader to communicate with the author of the document via email or other means.
* other means.
*/ */
public void setOwnerId(final String ownerId) { 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 * (OPML 2) &lt;ownerId&gt; is the http address of a web page that contains <strike>an HTML</strike> a form that
* HTML</strike> a form that allows a human reader to communicate with the author of the * allows a human reader to communicate with the author of the document via email or other means.
* document via email or other means.
* *
* @return http address of a web page that contains <strike>an HTML</strike> a form that allows * @return http address of a web page that contains <strike>an HTML</strike> a form that allows a human reader to
* a human reader to communicate with the author of the document via email or other * communicate with the author of the document via email or other means.
* means.
*/ */
public String getOwnerId() { public String getOwnerId() {
return _ownerId; return ownerId;
} }
/** /**
@ -207,7 +196,7 @@ public class Opml extends WireFeed {
* @param ownerName the owner of the document. * @param ownerName the owner of the document.
*/ */
public void setOwnerName(final String ownerName) { 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. * @return the owner of the document.
*/ */
public String getOwnerName() { public String getOwnerName() {
return _ownerName; return ownerName;
} }
/** /**
@ -225,7 +214,7 @@ public class Opml extends WireFeed {
* @param title title of the document. * @param title title of the document.
*/ */
public void setTitle(final String title) { 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. * @return title of the document.
*/ */
public String getTitle() { public String getTitle() {
return _title; return title;
} }
/** /**
* &lt;vertScrollState&gt; is a number, saying which line of the outline is displayed on the top * &lt;vertScrollState&gt; is a number, saying which line of the outline is displayed on the top line of the window.
* line of the window. This number is calculated with the expansion state already applied. * 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 * @param verticalScrollState which line of the outline is displayed on the top line of the window.
* window.
*/ */
public void setVerticalScrollState(final Integer verticalScrollState) { 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 * &lt;vertScrollState&gt; is a number, saying which line of the outline is displayed on the top line of the window.
* line of the window. This number is calculated with the expansion state already applied. * 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 * @return which line of the outline is displayed on the top line of the window. This number is calculated with the
* calculated with the expansion state already applied. * expansion state already applied.
*/ */
public Integer getVerticalScrollState() { 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. * @param windowBottom the pixel location of the bottom edge of the window.
*/ */
public void setWindowBottom(final Integer windowBottom) { 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. * @return the pixel location of the bottom edge of the window.
*/ */
public Integer getWindowBottom() { 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. * @param windowLeft the pixel location of the left edge of the window.
*/ */
public void setWindowLeft(final Integer windowLeft) { 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. * @return the pixel location of the left edge of the window.
*/ */
public Integer getWindowLeft() { 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. * @param windowRight the pixel location of the right edge of the window.
*/ */
public void setWindowRight(final Integer windowRight) { 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. * @return the pixel location of the right edge of the window.
*/ */
public Integer getWindowRight() { 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. * @param windowTop the pixel location of the top edge of the window.
*/ */
public void setWindowTop(final Integer windowTop) { 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. * @return the pixel location of the top edge of the window.
*/ */
public Integer getWindowTop() { 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 static final long serialVersionUID = 1L;
private Date _created; private Date created;
private List<Attribute> _attributes; private List<Attribute> attributes;
private List<String> _categories; private List<String> categories;
private List<Outline> _children; private List<Outline> children;
private List<Module> _modules; private List<Module> modules;
private String _text; private String text;
private String _title; private String title;
private String _type; private String type;
private boolean _breakpoint; private boolean breakpoint;
private boolean _comment; private boolean comment;
/** Creates a new instance of Outline */
public Outline() { public Outline() {
super();
} }
/** /**
@ -60,14 +58,13 @@ public class Outline implements Cloneable, Serializable {
* @param text text attribute value * @param text text attribute value
*/ */
public Outline(final String type, final String text) { public Outline(final String type, final String text) {
super();
setType(type); setType(type);
setText(text); setText(text);
} }
/** /**
* Creates an outline with the given title, xmlUrl and htmlUrl. This is traditionally used for * Creates an outline with the given title, xmlUrl and htmlUrl. This is traditionally used for aggregator feed lists
* aggregator feed lists and will get a type of "rss". * and will get a type of "rss".
* *
* @param title Title of the entry. * @param title Title of the entry.
* @param xmlUrl link to XML file. * @param xmlUrl link to XML file.
@ -94,7 +91,7 @@ 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(final List<Attribute> attributes) { 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. * @return List of attributes on this outline.
*/ */
public List<Attribute> getAttributes() { public List<Attribute> getAttributes() {
if (_attributes == null) { if (attributes == null) {
_attributes = new ArrayList<Attribute>(); attributes = new ArrayList<Attribute>();
} }
return _attributes; return attributes;
} }
/** /**
* isBreakpoint is a string, either "true" or "false", indicating whether a breakpoint is set on * isBreakpoint is a string, either "true" or "false", indicating whether a breakpoint is set on this outline. This
* this outline. This attribute is mainly necessary for outlines used to edit scripts. If it's * attribute is mainly necessary for outlines used to edit scripts. If it's not present, the value is false.
* not present, the value is false.
* *
* @param breakpoint whether a breakpoint is set on this outline. * @param breakpoint whether a breakpoint is set on this outline.
*/ */
public void setBreakpoint(final boolean breakpoint) { 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 * isBreakpoint is a string, either "true" or "false", indicating whether a breakpoint is set on this outline. This
* this outline. This attribute is mainly necessary for outlines used to edit scripts. If it's * attribute is mainly necessary for outlines used to edit scripts. If it's not present, the value is false.
* not present, the value is false.
* *
* @return whether a breakpoint is set on this outline * @return whether a breakpoint is set on this outline
*/ */
public boolean isBreakpoint() { 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. * @param categories (OPML 2) A List of Strings indicating values in the category attribute.
*/ */
public void setCategories(final List<String> categories) { 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. * @return (OPML 2) A List of Strings indicating values in the category attribute.
*/ */
public List<String> getCategories() { public List<String> getCategories() {
if (_categories == null) { if (categories == null) {
_categories = new ArrayList<String>(); 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. * @param children A list of sub-outlines for this entry.
*/ */
public void setChildren(final List<Outline> children) { 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. * @return A list of sub-outlines for this entry.
*/ */
public List<Outline> getChildren() { public List<Outline> getChildren() {
if (_children == null) { if (children == null) {
_children = new ArrayList<Outline>(); children = new ArrayList<Outline>();
} }
return _children; return children;
} }
/** /**
* isComment is a string, either "true" or "false", indicating whether the outline is commented * isComment is a string, either "true" or "false", indicating whether the outline is commented or not. By
* or not. By convention if an outline is commented, all subordinate outlines are considered to * convention if an outline is commented, all subordinate outlines are considered to also be commented. If it's not
* also be commented. If it's not present, the value is false. * present, the value is false.
* *
* @param comment whether the outline is commented * @param comment whether the outline is commented
*/ */
public void setComment(final boolean comment) { 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 * isComment is a string, either "true" or "false", indicating whether the outline is commented or not. By
* or not. By convention if an outline is commented, all subordinate outlines are considered to * convention if an outline is commented, all subordinate outlines are considered to also be commented. If it's not
* also be commented. If it's not present, the value is false. * present, the value is false.
* *
* @return whether the outline is commented * @return whether the outline is commented
*/ */
public boolean isComment() { 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. * @param created date-time that the outline node was created.
*/ */
public void setCreated(final Date 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. * @return date-time that the outline node was created.
*/ */
public Date getCreated() { public Date getCreated() {
return _created; return created;
} }
/** /**
@ -235,15 +230,15 @@ public class Outline implements Cloneable, Serializable {
} }
public void setModules(final List<Module> modules) { public void setModules(final List<Module> modules) {
_modules = modules; this.modules = modules;
} }
public List<Module> getModules() { public List<Module> getModules() {
if (_modules == null) { if (modules == null) {
_modules = new ArrayList<Module>(); 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. * @param text The "text" attribute of the outline.
*/ */
public void setText(final String text) { 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. * @return The "text" attribute of the outline.
*/ */
public String getText() { 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. * @param title The "title" attribute of the outline.
*/ */
public void setTitle(final String title) { 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. * @return The "title" attribute of the outline.
*/ */
public String getTitle() { 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. * @param type The "type" attribute of the outline.
*/ */
public void setType(final String type) { 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. * @return The "type" attribute of the outline.
*/ */
public String getType() { public String getType() {
return _type; return type;
} }
/** /**
@ -333,7 +328,7 @@ public class Outline implements Cloneable, Serializable {
o.setBreakpoint(isBreakpoint()); o.setBreakpoint(isBreakpoint());
o.setCategories(new ArrayList<String>(getCategories())); o.setCategories(new ArrayList<String>(getCategories()));
o.setComment(isComment()); 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.setModules(new ArrayList<Module>(getModules()));
o.setText(getText()); o.setText(getText());
o.setTitle(getTitle()); o.setTitle(getTitle());
@ -341,13 +336,13 @@ public class Outline implements Cloneable, Serializable {
final ArrayList<Outline> children = new ArrayList<Outline>(); final ArrayList<Outline> children = new ArrayList<Outline>();
for (int i = 0; i < getChildren().size(); i++) { 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); o.setChildren(children);
final ArrayList<Attribute> attributes = new ArrayList<Attribute>(); final ArrayList<Attribute> attributes = new ArrayList<Attribute>();
for (int i = 0; i < getAttributes().size(); i++) { 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); o.setAttributes(attributes);
@ -356,22 +351,17 @@ public class Outline implements Cloneable, Serializable {
@Override @Override
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
final EqualsBean eBean = new EqualsBean(Outline.class, this); return new EqualsBean(Outline.class, this).beanEquals(obj);
return eBean.beanEquals(obj);
} }
@Override @Override
public int hashCode() { public int hashCode() {
final EqualsBean equals = new EqualsBean(Outline.class, this); return new EqualsBean(Outline.class, this).beanHashCode();
return equals.beanHashCode();
} }
@Override @Override
public String toString() { public String toString() {
final ToStringBean tsBean = new ToStringBean(Outline.class, this); return new ToStringBean(Outline.class, this).toString();
return tsBean.toString();
} }
} }

View file

@ -44,7 +44,6 @@ import com.rometools.rome.feed.synd.SyndPerson;
import com.rometools.rome.feed.synd.SyndPersonImpl; import com.rometools.rome.feed.synd.SyndPersonImpl;
/** /**
*
* @author cooper * @author cooper
*/ */
public class ConverterForOPML10 implements Converter { 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_TREE = "urn:rome.tree";
public static final String URI_ATTRIBUTE = "urn:rome.attribute#"; 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) { protected void addOwner(final Opml opml, final SyndFeed syndFeed) {
if (opml.getOwnerEmail() != null || opml.getOwnerName() != null) { if (opml.getOwnerEmail() != null || opml.getOwnerName() != null) {
final List<SyndPerson> authors = new ArrayList<SyndPerson>(); final List<SyndPerson> authors = new ArrayList<SyndPerson>();
@ -77,8 +71,7 @@ public class ConverterForOPML10 implements Converter {
* <p> * <p>
* *
* @param feed real feed to copy/convert. * @param feed real feed to copy/convert.
* @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real * @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
* feed.
*/ */
@Override @Override
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) { public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
@ -90,10 +83,10 @@ public class ConverterForOPML10 implements Converter {
syndFeed.setModules(opml.getModules()); syndFeed.setModules(opml.getModules());
syndFeed.setFeedType(getType()); 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); final List<Outline> so = Collections.synchronizedList(outlines);
for (int i = 0; i < so.size(); i++) { 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(); final SyndEntry entry = new SyndEntryImpl();
if (outline.getType() != null && outline.getType().equals("rss")) { 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. * @param syndFeed SyndFeedImpl to copy/convert value from.
* @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(final SyndFeed syndFeed) { 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. * Returns the type (version) of the real feed this converter handles.
* <p>
* *
* @return the real feed type. * @return the real feed type.
* @see WireFeed for details on the format of this string. * @see WireFeed for details on the format of this string.
* <p>
*/ */
@Override @Override
public String getType() { public String getType() {
@ -345,21 +335,15 @@ public class ConverterForOPML10 implements Converter {
} }
private static class OutlineHolder { private static class OutlineHolder {
Outline outline;
String parent; private final Outline outline;
private final String parent;
public OutlineHolder(final Outline outline, final String parent) { public OutlineHolder(final Outline outline, final String parent) {
this.outline = outline; this.outline = outline;
this.parent = parent; 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; package com.rometools.opml.feed.synd.impl;
import com.rometools.rome.feed.WireFeed; import com.rometools.rome.feed.WireFeed;
import com.rometools.rome.feed.synd.SyndFeed; import com.rometools.rome.feed.synd.SyndFeed;
/** /**
*
* @author cooper * @author cooper
*/ */
public class ConverterForOPML20 extends ConverterForOPML10 { 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. * Returns the type (version) of the real feed this converter handles.
@ -41,8 +28,7 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
* <p> * <p>
* *
* @param feed real feed to copy/convert. * @param feed real feed to copy/convert.
* @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real * @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
* feed.
*/ */
@Override @Override
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) { public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
@ -58,10 +44,7 @@ public class ConverterForOPML20 extends ConverterForOPML10 {
*/ */
@Override @Override
public WireFeed createRealFeed(final SyndFeed syndFeed) { public WireFeed createRealFeed(final SyndFeed syndFeed) {
WireFeed retValue; return super.createRealFeed(syndFeed);
retValue = super.createRealFeed(syndFeed);
return retValue;
} }
} }

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; package com.rometools.opml.feed.synd.impl;
import com.rometools.rome.feed.synd.SyndCategory; import com.rometools.rome.feed.synd.SyndCategory;
import com.rometools.rome.feed.synd.SyndCategoryImpl; import com.rometools.rome.feed.synd.SyndCategoryImpl;
/** /**
*
* @author cooper * @author cooper
*/ */
public class TreeCategoryImpl extends SyndCategoryImpl { public class TreeCategoryImpl extends SyndCategoryImpl {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** Creates a new instance of TreeCategoryImpl */
public TreeCategoryImpl() {
super();
}
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
final SyndCategory c = (SyndCategory) 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; import com.rometools.rome.io.impl.DateParser;
/** /**
*
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGenerator { public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGenerator {
/** Creates a new instance of Opml10Generator */
public OPML10Generator() { public OPML10Generator() {
super("opml_1.0"); 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. * Creates an XML document (JDOM) for the given feed bean.
* <p>
* *
* @param feed the feed bean to generate the XML document from. * @param feed the feed bean to generate the XML document from.
* @return the generated XML document (JDOM). * @return the generated XML document (JDOM).
* @throws IllegalArgumentException thrown if the type of the given feed bean does not match * @throws IllegalArgumentException thrown if the type of the given feed bean does not match with the type of the
* with the type of the WireFeedGenerator. * WireFeedGenerator.
* @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(final 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");
} }
@ -88,9 +87,7 @@ public class OPML10Generator extends BaseWireFeedGenerator implements WireFeedGe
if (target == null || name == null || value == null) { if (target == null || name == null || value == null) {
return false; return false;
} }
target.setAttribute(name, value.toString()); target.setAttribute(name, value.toString());
return true; return true;
} }

View file

@ -37,14 +37,12 @@ import com.rometools.rome.io.impl.BaseWireFeedParser;
import com.rometools.rome.io.impl.DateParser; import com.rometools.rome.io.impl.DateParser;
/** /**
*
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser { public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
private static Logger LOG = LoggerFactory.getLogger(OPML10Parser.class); private static Logger LOG = LoggerFactory.getLogger(OPML10Parser.class);
/** Creates a new instance of Opml10Parser */
public OPML10Parser() { public OPML10Parser() {
super("opml_1.0", null); super("opml_1.0", null);
} }
@ -111,7 +109,6 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser {
opml.setWindowBottom(readInteger(head.getChildText("windowBottom"))); opml.setWindowBottom(readInteger(head.getChildText("windowBottom")));
} catch (final NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
LOG.warn("Unable to parse windowBottom", nfe); LOG.warn("Unable to parse windowBottom", nfe);
if (validate) { if (validate) {
throw new FeedException("Unable to parse windowBottom", nfe); 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"))); opml.setWindowLeft(readInteger(head.getChildText("windowLeft")));
} catch (final NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
LOG.warn("Unable to parse windowLeft", nfe); LOG.warn("Unable to parse windowLeft", nfe);
if (validate) {
throw new FeedException("Unable to parse windowLeft", nfe);
}
} }
try { try {
opml.setWindowRight(readInteger(head.getChildText("windowRight"))); opml.setWindowRight(readInteger(head.getChildText("windowRight")));
} catch (final NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
LOG.warn("Unable to parse windowRight", nfe); LOG.warn("Unable to parse windowRight", nfe);
if (validate) { if (validate) {
throw new FeedException("Unable to parse windowRight", nfe); 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"))); opml.setWindowLeft(readInteger(head.getChildText("windowLeft")));
} catch (final NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
LOG.warn("Unable to parse windowLeft", nfe); LOG.warn("Unable to parse windowLeft", nfe);
if (validate) { if (validate) {
throw new FeedException("Unable to parse windowLeft", nfe); 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"))); opml.setWindowTop(readInteger(head.getChildText("windowTop")));
} catch (final NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
LOG.warn("Unable to parse windowTop", nfe); LOG.warn("Unable to parse windowTop", nfe);
if (validate) { if (validate) {
throw new FeedException("Unable to parse windowTop", nfe); 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"))); opml.setExpansionState(readIntArray(head.getChildText("expansionState")));
} catch (final NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
LOG.warn("Unable to parse expansionState", nfe); LOG.warn("Unable to parse expansionState", nfe);
if (validate) { if (validate) {
throw new FeedException("Unable to parse expansionState", nfe); 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; package com.rometools.opml.io.impl;
import java.util.Locale; import java.util.Locale;
@ -20,21 +12,18 @@ import com.rometools.rome.io.FeedException;
import com.rometools.rome.io.impl.DateParser; import com.rometools.rome.io.impl.DateParser;
/** /**
*
* @author cooper * @author cooper
*/ */
public class OPML20Generator extends OPML10Generator { public class OPML20Generator extends OPML10Generator {
/** Creates a new instance of OPML20Generator */
public OPML20Generator() { public OPML20Generator() {
} }
/** /**
* Returns the type of feed the generator creates. * Returns the type of feed the generator creates.
* <p>
* *
* @return the type of feed the generator creates. * @return the type of feed the generator creates.
* @see WireFeed for details on the format of this string. * @see WireFeed for details on the format of this string.
* <p>
*/ */
@Override @Override
public String getType() { public String getType() {
@ -43,47 +32,43 @@ public class OPML20Generator extends OPML10Generator {
/** /**
* Creates an XML document (JDOM) for the given feed bean. * Creates an XML document (JDOM) for the given feed bean.
* <p>
* *
* @param feed the feed bean to generate the XML document from. * @param feed the feed bean to generate the XML document from.
* @return the generated XML document (JDOM). * @return the generated XML document (JDOM).
* @throws IllegalArgumentException thrown if the type of the given feed bean does not match * @throws IllegalArgumentException thrown if the type of the given feed bean does not match with the type of the
* with the type of the WireFeedGenerator. * WireFeedGenerator.
* @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(final WireFeed feed) throws IllegalArgumentException, FeedException { public Document generate(final WireFeed feed) throws IllegalArgumentException, FeedException {
Document retValue; final Document retValue = super.generate(feed);
retValue = super.generate(feed);
retValue.getRootElement().setAttribute("version", "2.0"); retValue.getRootElement().setAttribute("version", "2.0");
return retValue; return retValue;
} }
@Override @Override
protected Element generateHead(final Opml opml) { protected Element generateHead(final Opml opml) {
Element retValue;
retValue = super.generateHead(opml);
final Element docs = new Element("docs"); final Element docs = new Element("docs");
docs.setText(opml.getDocs()); docs.setText(opml.getDocs());
retValue.addContent(docs);
final Element retValue = super.generateHead(opml);
retValue.addContent(docs);
return retValue; return retValue;
} }
@Override @Override
protected Element generateOutline(final Outline outline) { protected Element generateOutline(final Outline outline) {
Element retValue;
retValue = super.generateOutline(outline); final Element retValue = super.generateOutline(outline);
if (outline.getCreated() != null) { if (outline.getCreated() != null) {
retValue.setAttribute("created", DateParser.formatRFC822(outline.getCreated(), Locale.US)); retValue.setAttribute("created", DateParser.formatRFC822(outline.getCreated(), Locale.US));
} }
return retValue; return retValue;
} }
} }