From 7fba97122f92ca3ccc8855b8c78dae08812b1a61 Mon Sep 17 00:00:00 2001 From: Patrick Gotthard Date: Fri, 4 Oct 2013 08:42:17 +0200 Subject: [PATCH 1/6] Enhanced POM --- pom.xml | 273 ++++++++++++++++++++++++-------------------------------- 1 file changed, 115 insertions(+), 158 deletions(-) diff --git a/pom.xml b/pom.xml index 0b9ba97..a3bc52f 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.rometools rome 2.0.0-SNAPSHOT - + ROME, RSS and atOM utilitiEs for Java All Roads Lead to ROME. ROME is a set of Atom/RSS Java utilities that make it @@ -23,6 +23,7 @@ http://rometools.github.io/rome/ + GitHub https://github.com/rometools/rome/issues @@ -98,6 +99,119 @@ UTF-8 + + + central.staging + http://oss.sonatype.org/service/local/staging/deploy/maven2 + + + sonatype.snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.6 + 1.6 + -Xlint + + + + org.apache.maven.plugins + maven-site-plugin + 3.3 + + 9000 + ${basedir}/target/site/tempdir + + + + org.apache.maven.doxia + doxia-module-markdown + 1.4 + + + org.apache.maven.doxia + doxia-module-confluence + 1.4 + + + + + org.apache.maven.plugins + maven-scm-publish-plugin + 1.0-beta-2 + + gh-pages + scm:git:git@github.com:rometools/rome.git + ${project.build.directory}/site + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadocs + + jar + + + + + + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.7 + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + + javadoc + test-javadoc + + + + aggregate + false + + aggregate + + + + + + + org.jdom @@ -112,161 +226,4 @@ - - - - org.apache.maven.plugins - maven-scm-plugin - 1.8.1 - - install - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.6 - 1.6 - -Xlint - - - - org.apache.maven.plugins - maven-resources-plugin - 2.6 - - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-site-plugin - 3.3 - - 9000 - ${basedir}/target/site/tempdir - - - - org.apache.maven.doxia - doxia-module-markdown - 1.4 - - - org.apache.maven.doxia - doxia-module-confluence - 1.4 - - - - - org.apache.maven.plugins - maven-scm-publish-plugin - 1.0-beta-2 - - gh-pages - scm:git:git@github.com:rometools/rome.git - ${project.build.directory}/site - - - - - - - - release - - - performRelease - true - - - - - central.staging - Nexus Release Repository - http://oss.sonatype.org/service/local/staging/deploy/maven2 - - - sonatype.snapshots - My Nexus Snapshots Repository - https://oss.sonatype.org/content/repositories/snapshots/ - - - - - - org.apache.maven.plugins - maven-gpg-plugin - - - sign-artifacts - verify - - sign - - - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - attach-javadocs - - jar - - - - - - - - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.6 - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9 - - - - javadoc - test-javadoc - - - - aggregate - false - - aggregate - - - - - - - From b43bbb8bb209e89a92d29a0b35588eb5242b0e22 Mon Sep 17 00:00:00 2001 From: Patrick Gotthard Date: Fri, 4 Oct 2013 08:49:50 +0200 Subject: [PATCH 2/6] Fixes #169 (Uppercase problem in XMLReader) --- src/main/java/com/sun/syndication/io/XmlReader.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sun/syndication/io/XmlReader.java b/src/main/java/com/sun/syndication/io/XmlReader.java index 76a7669..665141a 100644 --- a/src/main/java/com/sun/syndication/io/XmlReader.java +++ b/src/main/java/com/sun/syndication/io/XmlReader.java @@ -29,6 +29,7 @@ import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import java.text.MessageFormat; +import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -558,7 +559,7 @@ public class XmlReader extends Reader { final String postMime = httpContentType.substring(i + 1); final Matcher m = CHARSET_PATTERN.matcher(postMime); encoding = m.find() ? m.group(1) : null; - encoding = encoding != null ? encoding.toUpperCase() : null; + encoding = encoding != null ? encoding.toUpperCase(Locale.ENGLISH) : null; } if (encoding != null && (encoding.startsWith("\"") && encoding.endsWith("\"") || encoding.startsWith("'") && encoding.endsWith("'"))) { encoding = encoding.substring(1, encoding.length() - 1); @@ -655,7 +656,7 @@ public class XmlReader extends Reader { } final Matcher m = ENCODING_PATTERN.matcher(prolog); if (m.find()) { - encoding = m.group(1).toUpperCase(); + encoding = m.group(1).toUpperCase(Locale.ENGLISH); encoding = encoding.substring(1, encoding.length() - 1); } } From 1249adbaf91bcc6f1870b884ef9f1492d1046346 Mon Sep 17 00:00:00 2001 From: Patrick Gotthard Date: Fri, 4 Oct 2013 10:06:06 +0200 Subject: [PATCH 3/6] Refactored ternary operators --- .../com/sun/syndication/feed/WireFeed.java | 10 +- .../sun/syndication/feed/atom/Category.java | 6 +- .../com/sun/syndication/feed/atom/Entry.java | 70 ++++++-- .../com/sun/syndication/feed/atom/Feed.java | 35 +++- .../com/sun/syndication/feed/atom/Link.java | 6 +- .../com/sun/syndication/feed/atom/Person.java | 11 +- .../syndication/feed/module/DCModuleImpl.java | 165 ++++++++++++++---- .../com/sun/syndication/feed/rss/Channel.java | 39 ++++- .../com/sun/syndication/feed/rss/Item.java | 32 +++- .../feed/synd/SyndCategoryImpl.java | 12 +- .../syndication/feed/synd/SyndEntryImpl.java | 41 +++-- .../syndication/feed/synd/SyndFeedImpl.java | 25 ++- .../syndication/io/ParsingFeedException.java | 12 +- .../sun/syndication/io/impl/Atom03Parser.java | 18 +- .../sun/syndication/io/impl/Atom10Parser.java | 30 +++- .../io/impl/BaseWireFeedParser.java | 6 +- .../syndication/io/impl/DCModuleParser.java | 7 +- .../sun/syndication/io/impl/NumberParser.java | 12 +- .../io/impl/RSS091UserlandParser.java | 18 +- .../syndication/io/impl/RSS092Generator.java | 6 +- .../syndication/io/impl/SyModuleParser.java | 6 +- 21 files changed, 459 insertions(+), 108 deletions(-) diff --git a/src/main/java/com/sun/syndication/feed/WireFeed.java b/src/main/java/com/sun/syndication/feed/WireFeed.java index 0a050e4..3f72e5d 100644 --- a/src/main/java/com/sun/syndication/feed/WireFeed.java +++ b/src/main/java/com/sun/syndication/feed/WireFeed.java @@ -195,7 +195,10 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable { */ @Override public List getModules() { - return modules == null ? (modules = new ArrayList()) : modules; + if (modules == null) { + modules = new ArrayList(); + } + return modules; } /** @@ -231,7 +234,10 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable { * */ public List getForeignMarkup() { - return foreignMarkup == null ? (foreignMarkup = new ArrayList()) : foreignMarkup; + if (foreignMarkup == null) { + foreignMarkup = new ArrayList(); + } + return foreignMarkup; } /** diff --git a/src/main/java/com/sun/syndication/feed/atom/Category.java b/src/main/java/com/sun/syndication/feed/atom/Category.java index 5cf0e73..7c1f81b 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Category.java +++ b/src/main/java/com/sun/syndication/feed/atom/Category.java @@ -146,7 +146,11 @@ public class Category implements Cloneable, Serializable { } public String getSchemeResolved() { - return schemeResolved != null ? schemeResolved : scheme; + if (schemeResolved != null) { + return schemeResolved; + } else { + return scheme; + } } /** diff --git a/src/main/java/com/sun/syndication/feed/atom/Entry.java b/src/main/java/com/sun/syndication/feed/atom/Entry.java index d2ab156..ecfafde 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Entry.java +++ b/src/main/java/com/sun/syndication/feed/atom/Entry.java @@ -83,7 +83,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * list if none. */ public List getAlternateLinks() { - return alternateLinks == null ? (alternateLinks = new ArrayList()) : alternateLinks; + if (alternateLinks == null) { + alternateLinks = new ArrayList(); + } + return alternateLinks; } /** @@ -105,7 +108,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * */ public List getAuthors() { - return authors == null ? (authors = new ArrayList()) : authors; + if (authors == null) { + authors = new ArrayList(); + } + return authors; } /** @@ -127,7 +133,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * @since Atom 1.0 */ public List getCategories() { - return categories == null ? (categories = new ArrayList()) : categories; + if (categories == null) { + categories = new ArrayList(); + } + return categories; } /** @@ -149,7 +158,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * if none. */ public List getContents() { - return contents == null ? (contents = new ArrayList()) : contents; + if (contents == null) { + contents = new ArrayList(); + } + return contents; } /** @@ -173,7 +185,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * */ public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + if (contributors == null) { + contributors = new ArrayList(); + } + return contributors; } /** @@ -193,7 +208,11 @@ public class Entry implements Cloneable, Serializable, Extendable { * @return the entry created date, null if none. */ public Date getCreated() { - return created == null ? null : new Date(created.getTime()); + if (created == null) { + return null; + } else { + return new Date(created.getTime()); + } } /** @@ -215,7 +234,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * */ public List getForeignMarkup() { - return foreignMarkup == null ? (foreignMarkup = new ArrayList()) : foreignMarkup; + if (foreignMarkup == null) { + foreignMarkup = new ArrayList(); + } + return foreignMarkup; } /** @@ -259,7 +281,11 @@ public class Entry implements Cloneable, Serializable, Extendable { * @return the entry issued date, null if none. */ public Date getIssued() { - return published == null ? null : new Date(published.getTime()); + if (published == null) { + return null; + } else { + return new Date(published.getTime()); + } } /** @@ -301,7 +327,11 @@ public class Entry implements Cloneable, Serializable, Extendable { * @return the entry modified date, null if none. */ public Date getModified() { - return updated == null ? null : new Date(updated.getTime()); + if (updated == null) { + return null; + } else { + return new Date(updated.getTime()); + } } /** @@ -339,7 +369,10 @@ public class Entry implements Cloneable, Serializable, Extendable { */ @Override public List getModules() { - return modules == null ? (modules = new ArrayList()) : modules; + if (modules == null) { + modules = new ArrayList(); + } + return modules; } /** @@ -361,7 +394,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * set, an empty list if none. */ public List getOtherLinks() { - return otherLinks == null ? (otherLinks = new ArrayList()) : otherLinks; + if (otherLinks == null) { + otherLinks = new ArrayList(); + } + return otherLinks; } /** @@ -383,7 +419,11 @@ public class Entry implements Cloneable, Serializable, Extendable { * @since Atom 1.0 */ public Date getPublished() { - return published == null ? null : new Date(published.getTime()); + if (published == null) { + return null; + } else { + return new Date(published.getTime()); + } } /** @@ -521,7 +561,11 @@ public class Entry implements Cloneable, Serializable, Extendable { * @since Atom 1.0 */ public Date getUpdated() { - return updated == null ? null : new Date(updated.getTime()); + if (updated == null) { + return null; + } else { + return new Date(updated.getTime()); + } } /** diff --git a/src/main/java/com/sun/syndication/feed/atom/Feed.java b/src/main/java/com/sun/syndication/feed/atom/Feed.java index a9b4d74..eabfc16 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Feed.java +++ b/src/main/java/com/sun/syndication/feed/atom/Feed.java @@ -155,7 +155,10 @@ public class Feed extends WireFeed { * list if none. */ public List getAlternateLinks() { - return alternateLinks == null ? (alternateLinks = new ArrayList()) : alternateLinks; + if (alternateLinks == null) { + alternateLinks = new ArrayList(); + } + return alternateLinks; } /** @@ -177,7 +180,10 @@ public class Feed extends WireFeed { * ones), an empty list if none. */ public List getOtherLinks() { - return otherLinks == null ? (otherLinks = new ArrayList()) : otherLinks; + if (otherLinks == null) { + otherLinks = new ArrayList(); + } + return otherLinks; } /** @@ -200,7 +206,10 @@ public class Feed extends WireFeed { * */ public List getAuthors() { - return authors == null ? (authors = new ArrayList()) : authors; + if (authors == null) { + authors = new ArrayList(); + } + return authors; } /** @@ -223,7 +232,10 @@ public class Feed extends WireFeed { * */ public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + if (contributors == null) { + contributors = new ArrayList(); + } + return contributors; } /** @@ -374,7 +386,10 @@ public class Feed extends WireFeed { * */ public List getEntries() { - return entries == null ? (entries = new ArrayList()) : entries; + if (entries == null) { + entries = new ArrayList(); + } + return entries; } /** @@ -399,7 +414,10 @@ public class Feed extends WireFeed { */ @Override public List getModules() { - return modules == null ? (modules = new ArrayList()) : modules; + if (modules == null) { + modules = new ArrayList(); + } + return modules; } /** @@ -435,7 +453,10 @@ public class Feed extends WireFeed { * @since Atom 1.0 */ public List getCategories() { - return categories == null ? (categories = new ArrayList()) : categories; + if (categories == null) { + categories = new ArrayList(); + } + return categories; } /** diff --git a/src/main/java/com/sun/syndication/feed/atom/Link.java b/src/main/java/com/sun/syndication/feed/atom/Link.java index 72fa493..c95175f 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Link.java +++ b/src/main/java/com/sun/syndication/feed/atom/Link.java @@ -174,7 +174,11 @@ public class Link implements Cloneable, Serializable { } public String getHrefResolved() { - return hrefResolved != null ? hrefResolved : href; + if (hrefResolved != null) { + return hrefResolved; + } else { + return href; + } } /** diff --git a/src/main/java/com/sun/syndication/feed/atom/Person.java b/src/main/java/com/sun/syndication/feed/atom/Person.java index 76bbc71..dbece38 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Person.java +++ b/src/main/java/com/sun/syndication/feed/atom/Person.java @@ -152,7 +152,11 @@ public class Person implements Cloneable, Serializable, Extendable { } public String getUriResolved(final String resolveURI) { - return uriResolved != null ? uriResolved : uri; + if (uriResolved != null) { + return uriResolved; + } else { + return uri; + } } /** @@ -209,7 +213,10 @@ public class Person implements Cloneable, Serializable, Extendable { */ @Override public List getModules() { - return modules == null ? (modules = new ArrayList()) : modules; + if (modules == null) { + modules = new ArrayList(); + } + return modules; } /** diff --git a/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java b/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java index d659de9..932e974 100644 --- a/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java +++ b/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java @@ -108,7 +108,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getTitles() { - return title == null ? (title = new ArrayList()) : title; + if (title == null) { + title = new ArrayList(); + } + return title; } /** @@ -133,7 +136,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getTitle() { - return title != null && title.size() > 0 ? (String) title.get(0) : null; + if (title != null && title.size() > 0) { + return title.get(0); + } else { + return null; + } } /** @@ -160,7 +167,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getCreators() { - return creator == null ? (creator = new ArrayList()) : creator; + if (creator == null) { + creator = new ArrayList(); + } + return creator; } /** @@ -185,7 +195,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getCreator() { - return creator != null && creator.size() > 0 ? (String) creator.get(0) : null; + if (creator != null && creator.size() > 0) { + return creator.get(0); + } else { + return null; + } } /** @@ -212,7 +226,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getSubjects() { - return subject == null ? (subject = new ArrayList()) : subject; + if (subject == null) { + subject = new ArrayList(); + } + return subject; } /** @@ -237,7 +254,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public DCSubject getSubject() { - return subject != null && subject.size() > 0 ? (DCSubject) subject.get(0) : null; + if (subject != null && subject.size() > 0) { + return subject.get(0); + } else { + return null; + } } /** @@ -264,7 +285,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getDescriptions() { - return description == null ? (description = new ArrayList()) : description; + if (description == null) { + description = new ArrayList(); + } + return description; } /** @@ -289,7 +313,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getDescription() { - return description != null && description.size() > 0 ? (String) description.get(0) : null; + if (description != null && description.size() > 0) { + return description.get(0); + } else { + return null; + } } /** @@ -317,7 +345,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getPublishers() { - return publisher == null ? (publisher = new ArrayList()) : publisher; + if (publisher == null) { + publisher = new ArrayList(); + } + return publisher; } /** @@ -342,7 +373,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getPublisher() { - return publisher != null && publisher.size() > 0 ? (String) publisher.get(0) : null; + if (publisher != null && publisher.size() > 0) { + return publisher.get(0); + } else { + return null; + } } /** @@ -370,7 +405,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + if (contributors == null) { + contributors = new ArrayList(); + } + return contributors; } /** @@ -395,7 +433,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getContributor() { - return contributors != null && contributors.size() > 0 ? (String) contributors.get(0) : null; + if (contributors != null && contributors.size() > 0) { + return contributors.get(0); + } else { + return null; + } } /** @@ -423,7 +465,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getDates() { - return date == null ? (date = new ArrayList()) : date; + if (date == null) { + date = new ArrayList(); + } + return date; } /** @@ -448,7 +493,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public Date getDate() { - return date != null && date.size() > 0 ? (Date) date.get(0) : null; + if (date != null && date.size() > 0) { + return date.get(0); + } else { + return null; + } } /** @@ -475,7 +524,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getTypes() { - return type == null ? (type = new ArrayList()) : type; + if (type == null) { + type = new ArrayList(); + } + return type; } /** @@ -500,7 +552,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getType() { - return type != null && type.size() > 0 ? (String) type.get(0) : null; + if (type != null && type.size() > 0) { + return type.get(0); + } else { + return null; + } } /** @@ -527,7 +583,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getFormats() { - return format == null ? (format = new ArrayList()) : format; + if (format == null) { + format = new ArrayList(); + } + return format; } /** @@ -552,7 +611,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getFormat() { - return format != null && format.size() > 0 ? (String) format.get(0) : null; + if (format != null && format.size() > 0) { + return format.get(0); + } else { + return null; + } } /** @@ -579,7 +642,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getIdentifiers() { - return identifier == null ? (identifier = new ArrayList()) : identifier; + if (identifier == null) { + identifier = new ArrayList(); + } + return identifier; } /** @@ -604,7 +670,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getIdentifier() { - return identifier != null && identifier.size() > 0 ? (String) identifier.get(0) : null; + if (identifier != null && identifier.size() > 0) { + return identifier.get(0); + } else { + return null; + } } /** @@ -632,7 +702,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getSources() { - return source == null ? (source = new ArrayList()) : source; + if (source == null) { + source = new ArrayList(); + } + return source; } /** @@ -657,7 +730,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getSource() { - return source != null && source.size() > 0 ? (String) source.get(0) : null; + if (source != null && source.size() > 0) { + return source.get(0); + } else { + return null; + } } /** @@ -684,7 +761,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getLanguages() { - return language == null ? (language = new ArrayList()) : language; + if (language == null) { + language = new ArrayList(); + } + return language; } /** @@ -709,7 +789,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getLanguage() { - return language != null && language.size() > 0 ? (String) language.get(0) : null; + if (language != null && language.size() > 0) { + return language.get(0); + } else { + return null; + } } /** @@ -737,7 +821,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getRelations() { - return relation == null ? (relation = new ArrayList()) : relation; + if (relation == null) { + relation = new ArrayList(); + } + return relation; } /** @@ -762,7 +849,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getRelation() { - return relation != null && relation.size() > 0 ? (String) relation.get(0) : null; + if (relation != null && relation.size() > 0) { + return relation.get(0); + } else { + return null; + } } /** @@ -790,7 +881,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getCoverages() { - return coverage == null ? (coverage = new ArrayList()) : coverage; + if (coverage == null) { + coverage = new ArrayList(); + } + return coverage; } /** @@ -815,7 +909,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getCoverage() { - return coverage != null && coverage.size() > 0 ? (String) coverage.get(0) : null; + if (coverage != null && coverage.size() > 0) { + return coverage.get(0); + } else { + return null; + } } /** @@ -843,7 +941,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getRightsList() { - return rights == null ? (rights = new ArrayList()) : rights; + if (rights == null) { + rights = new ArrayList(); + } + return rights; } /** @@ -868,7 +969,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public String getRights() { - return rights != null && rights.size() > 0 ? (String) rights.get(0) : null; + if (rights != null && rights.size() > 0) { + return rights.get(0); + } else { + return null; + } } /** diff --git a/src/main/java/com/sun/syndication/feed/rss/Channel.java b/src/main/java/com/sun/syndication/feed/rss/Channel.java index 08b96ac..30ae6c1 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Channel.java +++ b/src/main/java/com/sun/syndication/feed/rss/Channel.java @@ -220,7 +220,10 @@ public class Channel extends WireFeed { * */ public List getItems() { - return items == null ? (items = new ArrayList()) : items; + if (items == null) { + items = new ArrayList(); + } + return items; } /** @@ -331,7 +334,11 @@ public class Channel extends WireFeed { * */ public Date getPubDate() { - return pubDate == null ? null : new Date(pubDate.getTime()); + if (pubDate == null) { + return null; + } else { + return new Date(pubDate.getTime()); + } } /** @@ -353,7 +360,11 @@ public class Channel extends WireFeed { * */ public Date getLastBuildDate() { - return lastBuildDate == null ? null : new Date(lastBuildDate.getTime()); + if (lastBuildDate == null) { + return null; + } else { + return new Date(lastBuildDate.getTime()); + } } /** @@ -444,7 +455,11 @@ public class Channel extends WireFeed { * */ public List getSkipHours() { - return skipHours != null ? skipHours : new ArrayList(); + if (skipHours != null) { + return skipHours; + } else { + return new ArrayList(); + } } /** @@ -481,7 +496,11 @@ public class Channel extends WireFeed { * */ public List getSkipDays() { - return skipDays != null ? skipDays : new ArrayList(); + if (skipDays != null) { + return skipDays; + } else { + return new ArrayList(); + } } /** @@ -541,7 +560,10 @@ public class Channel extends WireFeed { * */ public List getCategories() { - return categories == null ? (categories = new ArrayList()) : categories; + if (categories == null) { + categories = new ArrayList(); + } + return categories; } /** @@ -610,7 +632,10 @@ public class Channel extends WireFeed { */ @Override public List getModules() { - return modules == null ? (modules = new ArrayList()) : modules; + if (modules == null) { + modules = new ArrayList(); + } + return modules; } /** diff --git a/src/main/java/com/sun/syndication/feed/rss/Item.java b/src/main/java/com/sun/syndication/feed/rss/Item.java index c878441..e9f17c2 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Item.java +++ b/src/main/java/com/sun/syndication/feed/rss/Item.java @@ -270,7 +270,10 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public List getEnclosures() { - return enclosures == null ? (enclosures = new ArrayList()) : enclosures; + if (enclosures == null) { + enclosures = new ArrayList(); + } + return enclosures; } /** @@ -294,7 +297,10 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public List getCategories() { - return categories == null ? (categories = new ArrayList()) : categories; + if (categories == null) { + categories = new ArrayList(); + } + return categories; } /** @@ -385,7 +391,10 @@ public class Item implements Cloneable, Serializable, Extendable { */ @Override public List getModules() { - return modules == null ? (modules = new ArrayList()) : modules; + if (modules == null) { + modules = new ArrayList(); + } + return modules; } /** @@ -421,7 +430,11 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public Date getPubDate() { - return pubDate == null ? null : new Date(pubDate.getTime()); + if (pubDate == null) { + return null; + } else { + return new Date(pubDate.getTime()); + } } /** @@ -443,7 +456,11 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public Date getExpirationDate() { - return expirationDate == null ? null : new Date(expirationDate.getTime()); + if (expirationDate == null) { + return null; + } else { + return new Date(expirationDate.getTime()); + } } /** @@ -466,7 +483,10 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public List getForeignMarkup() { - return foreignMarkup == null ? (foreignMarkup = new ArrayList()) : foreignMarkup; + if (foreignMarkup == null) { + foreignMarkup = new ArrayList(); + } + return foreignMarkup; } /** diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java index 0bb5192..3951f31 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java @@ -255,7 +255,11 @@ class SyndCategoryListFacade extends AbstractList { final SyndCategoryImpl sCat = (SyndCategoryImpl) obj; DCSubject subject = sCat != null ? sCat.getSubject() : null; subject = subjects.set(index, subject); - return subject != null ? new SyndCategoryImpl(subject) : null; + if (subject != null) { + return new SyndCategoryImpl(subject); + } else { + return null; + } } /** @@ -285,7 +289,11 @@ class SyndCategoryListFacade extends AbstractList { @Override public SyndCategory remove(final int index) { final DCSubject subject = subjects.remove(index); - return subject != null ? new SyndCategoryImpl(subject) : null; + if (subject != null) { + return new SyndCategoryImpl(subject); + } else { + return null; + } } /** diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java index 0b91e87..c9d6112 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java @@ -326,7 +326,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry { */ @Override public List getContents() { - return contents == null ? (contents = new ArrayList()) : contents; + if (contents == null) { + contents = new ArrayList(); + } + return contents; } /** @@ -352,7 +355,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry { */ @Override public List getEnclosures() { - return enclosures == null ? (enclosures = new ArrayList()) : enclosures; + if (enclosures == null) { + enclosures = new ArrayList(); + } + return enclosures; } /** @@ -522,7 +528,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry { */ @Override public List getLinks() { - return links == null ? (links = new ArrayList()) : links; + if (links == null) { + links = new ArrayList(); + } + return links; } /** @@ -544,7 +553,11 @@ public class SyndEntryImpl implements Serializable, SyndEntry { */ @Override public Date getUpdatedDate() { - return updatedDate == null ? null : new Date(updatedDate.getTime()); + if (updatedDate == null) { + return null; + } else { + return new Date(updatedDate.getTime()); + } } /** @@ -560,7 +573,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry { @Override public List getAuthors() { - return authors == null ? (authors = new ArrayList()) : authors; + if (authors == null) { + authors = new ArrayList(); + } + return authors; } /* @@ -624,14 +640,12 @@ public class SyndEntryImpl implements Serializable, SyndEntry { @Override public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + if (contributors == null) { + contributors = new ArrayList(); + } + return contributors; } - /* - * (non-Javadoc) - * @see - * com.sun.syndication.feed.synd.SyndEntry#setContributors(java.util.List) - */ @Override public void setContributors(final List contributors) { this.contributors = contributors; @@ -657,7 +671,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry { */ @Override public List getForeignMarkup() { - return foreignMarkup == null ? (foreignMarkup = new ArrayList()) : foreignMarkup; + if (foreignMarkup == null) { + foreignMarkup = new ArrayList(); + } + return foreignMarkup; } /** diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java index 335f86e..8016aab 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java @@ -678,7 +678,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed { */ @Override public List getEntries() { - return entries == null ? (entries = new ArrayList()) : entries; + if (entries == null) { + entries = new ArrayList(); + } + return entries; } /** @@ -821,7 +824,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed { */ @Override public List getLinks() { - return links == null ? (links = new ArrayList()) : links; + if (links == null) { + links = new ArrayList(); + } + return links; } /** @@ -837,7 +843,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed { @Override public List getAuthors() { - return authors == null ? (authors = new ArrayList()) : authors; + if (authors == null) { + authors = new ArrayList(); + } + return authors; } @Override @@ -877,7 +886,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed { @Override public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + if (contributors == null) { + contributors = new ArrayList(); + } + return contributors; } @Override @@ -894,7 +906,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed { */ @Override public List getForeignMarkup() { - return foreignMarkup == null ? (foreignMarkup = new ArrayList()) : foreignMarkup; + if (foreignMarkup == null) { + foreignMarkup = new ArrayList(); + } + return foreignMarkup; } /** diff --git a/src/main/java/com/sun/syndication/io/ParsingFeedException.java b/src/main/java/com/sun/syndication/io/ParsingFeedException.java index d4acf0f..4ca164b 100644 --- a/src/main/java/com/sun/syndication/io/ParsingFeedException.java +++ b/src/main/java/com/sun/syndication/io/ParsingFeedException.java @@ -61,7 +61,11 @@ public class ParsingFeedException extends FeedException { * is not available. */ public int getLineNumber() { - return getCause() instanceof JDOMParseException ? ((JDOMParseException) getCause()).getLineNumber() : -1; + if (getCause() instanceof JDOMParseException) { + return ((JDOMParseException) getCause()).getLineNumber(); + } else { + return -1; + } } /** @@ -75,7 +79,11 @@ public class ParsingFeedException extends FeedException { * information is not available. */ public int getColumnNumber() { - return getCause() instanceof JDOMParseException ? ((JDOMParseException) getCause()).getColumnNumber() : -1; + if (getCause() instanceof JDOMParseException) { + return ((JDOMParseException) getCause()).getColumnNumber(); + } else { + return -1; + } } } diff --git a/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java b/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java index 6a3cb0a..3557f76 100644 --- a/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java +++ b/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java @@ -189,7 +189,11 @@ public class Atom03Parser extends BaseWireFeedParser { } } } - return links.size() > 0 ? links : null; + if (links.size() > 0) { + return links; + } else { + return null; + } } // List(Elements) -> List(Link) @@ -225,7 +229,11 @@ public class Atom03Parser extends BaseWireFeedParser { for (int i = 0; i < ePersons.size(); i++) { persons.add(parsePerson(ePersons.get(i))); } - return persons.size() > 0 ? persons : null; + if (persons.size() > 0) { + return persons; + } else { + return null; + } } private Content parseContent(final Element e) { @@ -270,7 +278,11 @@ public class Atom03Parser extends BaseWireFeedParser { for (int i = 0; i < eEntries.size(); i++) { entries.add(parseEntry(eEntries.get(i))); } - return entries.size() > 0 ? entries : null; + if (entries.size() > 0) { + return entries; + } else { + return null; + } } private Entry parseEntry(final Element eEntry) { diff --git a/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java b/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java index 4f68894..45931e1 100644 --- a/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java +++ b/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java @@ -256,7 +256,11 @@ public class Atom10Parser extends BaseWireFeedParser { links.add(link); } } - return links.size() > 0 ? links : null; + if (links.size() > 0) { + return links; + } else { + return null; + } } private List parseOtherLinks(final Feed feed, final Entry entry, final String baseURI, final List eLinks) { @@ -268,7 +272,11 @@ public class Atom10Parser extends BaseWireFeedParser { links.add(link); } } - return links.size() > 0 ? links : null; + if (links.size() > 0) { + return links; + } else { + return null; + } } private Person parsePerson(final String baseURI, final Element ePerson) { @@ -298,7 +306,11 @@ public class Atom10Parser extends BaseWireFeedParser { for (int i = 0; i < ePersons.size(); i++) { persons.add(parsePerson(baseURI, ePersons.get(i))); } - return persons.size() > 0 ? persons : null; + if (persons.size() > 0) { + return persons; + } else { + return null; + } } private Content parseContent(final Element e) { @@ -344,7 +356,11 @@ public class Atom10Parser extends BaseWireFeedParser { for (int i = 0; i < eEntries.size(); i++) { entries.add(this.parseEntry(feed, eEntries.get(i), baseURI)); } - return entries.size() > 0 ? entries : null; + if (entries.size() > 0) { + return entries; + } else { + return null; + } } protected Entry parseEntry(final Feed feed, final Element eEntry, final String baseURI) { @@ -433,7 +449,11 @@ public class Atom10Parser extends BaseWireFeedParser { final Element eCategory = eCategories.get(i); cats.add(parseCategory(baseURI, eCategory)); } - return cats.size() > 0 ? cats : null; + if (cats.size() > 0) { + return cats; + } else { + return null; + } } private Category parseCategory(final String baseURI, final Element eCategory) { diff --git a/src/main/java/com/sun/syndication/io/impl/BaseWireFeedParser.java b/src/main/java/com/sun/syndication/io/impl/BaseWireFeedParser.java index a00e190..036ac86 100644 --- a/src/main/java/com/sun/syndication/io/impl/BaseWireFeedParser.java +++ b/src/main/java/com/sun/syndication/io/impl/BaseWireFeedParser.java @@ -110,7 +110,11 @@ public abstract class BaseWireFeedParser implements WireFeedParser { protected String getAttributeValue(final Element e, final String attributeName) { final Attribute attr = getAttribute(e, attributeName); - return attr != null ? attr.getValue() : null; + if (attr != null) { + return attr.getValue(); + } else { + return null; + } } } diff --git a/src/main/java/com/sun/syndication/io/impl/DCModuleParser.java b/src/main/java/com/sun/syndication/io/impl/DCModuleParser.java index 8d1997c..40d03f4 100644 --- a/src/main/java/com/sun/syndication/io/impl/DCModuleParser.java +++ b/src/main/java/com/sun/syndication/io/impl/DCModuleParser.java @@ -147,8 +147,11 @@ public class DCModuleParser implements ModuleParser { foundSomething = true; dcm.setRightsList(parseElementList(eList)); } - - return foundSomething ? dcm : null; + if (foundSomething) { + return dcm; + } else { + return null; + } } /** diff --git a/src/main/java/com/sun/syndication/io/impl/NumberParser.java b/src/main/java/com/sun/syndication/io/impl/NumberParser.java index ec955a1..234a82d 100644 --- a/src/main/java/com/sun/syndication/io/impl/NumberParser.java +++ b/src/main/java/com/sun/syndication/io/impl/NumberParser.java @@ -85,7 +85,11 @@ public class NumberParser { */ public static float parseFloat(final String str, final float def) { final Float result = parseFloat(str); - return result == null ? def : result.floatValue(); + if (result == null) { + return def; + } else { + return result.floatValue(); + } } /** @@ -98,7 +102,11 @@ public class NumberParser { */ public static long parseLong(final String str, final long def) { final Long ret = parseLong(str); - return null == ret ? def : ret.longValue(); + if (null == ret) { + return def; + } else { + return ret.longValue(); + } } } diff --git a/src/main/java/com/sun/syndication/io/impl/RSS091UserlandParser.java b/src/main/java/com/sun/syndication/io/impl/RSS091UserlandParser.java index 4a7d7fd..eac91c2 100644 --- a/src/main/java/com/sun/syndication/io/impl/RSS091UserlandParser.java +++ b/src/main/java/com/sun/syndication/io/impl/RSS091UserlandParser.java @@ -197,7 +197,11 @@ public class RSS091UserlandParser extends RSS090Parser { protected List getItems(final Element rssRoot) { final Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); final List emptyList = Collections.emptyList(); - return eChannel != null ? eChannel.getChildren("item", getRSSNamespace()) : emptyList; + if (eChannel != null) { + return eChannel.getChildren("item", getRSSNamespace()); + } else { + return emptyList; + } } /** @@ -206,7 +210,11 @@ public class RSS091UserlandParser extends RSS090Parser { @Override protected Element getImage(final Element rssRoot) { final Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); - return eChannel != null ? eChannel.getChild("image", getRSSNamespace()) : null; + if (eChannel != null) { + return eChannel.getChild("image", getRSSNamespace()); + } else { + return null; + } } /** @@ -223,7 +231,11 @@ public class RSS091UserlandParser extends RSS090Parser { protected Element getTextInput(final Element rssRoot) { final String elementName = getTextInputLabel(); final Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); - return eChannel != null ? eChannel.getChild(elementName, getRSSNamespace()) : null; + if (eChannel != null) { + return eChannel.getChild(elementName, getRSSNamespace()); + } else { + return null; + } } /** diff --git a/src/main/java/com/sun/syndication/io/impl/RSS092Generator.java b/src/main/java/com/sun/syndication/io/impl/RSS092Generator.java index 14633e5..12debc3 100644 --- a/src/main/java/com/sun/syndication/io/impl/RSS092Generator.java +++ b/src/main/java/com/sun/syndication/io/impl/RSS092Generator.java @@ -84,7 +84,11 @@ public class RSS092Generator extends RSS091UserlandGenerator { // Another one to thanks DW for protected int getNumberOfEnclosures(final List enclosures) { - return enclosures.size() > 0 ? 1 : 0; + if (enclosures.size() > 0) { + return 1; + } else { + return 0; + } } @Override diff --git a/src/main/java/com/sun/syndication/io/impl/SyModuleParser.java b/src/main/java/com/sun/syndication/io/impl/SyModuleParser.java index 012b5b0..a44a2c8 100644 --- a/src/main/java/com/sun/syndication/io/impl/SyModuleParser.java +++ b/src/main/java/com/sun/syndication/io/impl/SyModuleParser.java @@ -56,7 +56,11 @@ public class SyModuleParser implements ModuleParser { foundSomething = true; sm.setUpdateBase(DateParser.parseDate(e.getText())); } - return foundSomething ? sm : null; + if (foundSomething) { + return sm; + } else { + return null; + } } } From 2e87f7206d15b3ecb9d5aba30b614677e2f8adec Mon Sep 17 00:00:00 2001 From: Patrick Gotthard Date: Fri, 4 Oct 2013 10:33:03 +0200 Subject: [PATCH 4/6] Removed underscores from variable names --- .gitignore | 3 ++- .../com/sun/syndication/io/impl/BaseWireFeedGenerator.java | 4 ++-- src/main/java/com/sun/syndication/io/impl/PluginManager.java | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 7075a2f..5966e2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -/target +/.checkstyle /.classpath /.project /.settings +/target \ No newline at end of file diff --git a/src/main/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java b/src/main/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java index 4d7fb69..a9ee8e9 100644 --- a/src/main/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java +++ b/src/main/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java @@ -65,8 +65,8 @@ public abstract class BaseWireFeedGenerator implements WireFeedGenerator { } protected void generateModuleNamespaceDefs(final Element root) { - for (final Namespace _allModuleNamespace : allModuleNamespaces) { - root.addNamespaceDeclaration(_allModuleNamespace); + for (final Namespace allModuleNamespace : allModuleNamespaces) { + root.addNamespaceDeclaration(allModuleNamespace); } } diff --git a/src/main/java/com/sun/syndication/io/impl/PluginManager.java b/src/main/java/com/sun/syndication/io/impl/PluginManager.java index 6f41d0d..7e4bf17 100644 --- a/src/main/java/com/sun/syndication/io/impl/PluginManager.java +++ b/src/main/java/com/sun/syndication/io/impl/PluginManager.java @@ -144,8 +144,8 @@ public abstract class PluginManager { final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); final List classes = new ArrayList(); final boolean useLoadClass = Boolean.valueOf(System.getProperty("rome.pluginmanager.useloadclass", "false")).booleanValue(); - for (final String _propertyValue : propertyValues) { - final Class mClass = useLoadClass ? classLoader.loadClass(_propertyValue) : Class.forName(_propertyValue, true, classLoader); + for (final String propertyValue : propertyValues) { + final Class mClass = useLoadClass ? classLoader.loadClass(propertyValue) : Class.forName(propertyValue, true, classLoader); classes.add(mClass); } final Class[] array = new Class[classes.size()]; From 1c792aef1b04261f8b28cebdb5c8bc9f2f488bfe Mon Sep 17 00:00:00 2001 From: Patrick Gotthard Date: Fri, 4 Oct 2013 11:23:02 +0200 Subject: [PATCH 5/6] Refactored ternary operators --- .../sun/syndication/feed/atom/Content.java | 4 +- .../com/sun/syndication/feed/atom/Entry.java | 24 ++++++++-- .../syndication/feed/impl/CloneableBean.java | 6 ++- .../syndication/feed/impl/CopyFromHelper.java | 11 ++++- .../syndication/feed/impl/ToStringBean.java | 25 ++++++++--- .../com/sun/syndication/feed/rss/Channel.java | 12 ++++- .../com/sun/syndication/feed/rss/Item.java | 12 ++++- .../feed/synd/SyndCategoryImpl.java | 14 +++++- .../com/sun/syndication/io/WireFeedInput.java | 7 ++- .../sun/syndication/io/WireFeedOutput.java | 14 +++++- .../com/sun/syndication/io/XmlReader.java | 44 +++++++++++++++---- .../sun/syndication/io/impl/Atom03Parser.java | 4 +- .../sun/syndication/io/impl/Atom10Parser.java | 8 +++- .../com/sun/syndication/io/impl/Base64.java | 12 ++++- .../sun/syndication/io/impl/DateParser.java | 4 +- .../syndication/io/impl/PluginManager.java | 7 ++- .../syndication/unittest/TestXmlReader.java | 35 ++++++++++++--- 17 files changed, 201 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/sun/syndication/feed/atom/Content.java b/src/main/java/com/sun/syndication/feed/atom/Content.java index 88bd8ee..ae97cb7 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Content.java +++ b/src/main/java/com/sun/syndication/feed/atom/Content.java @@ -174,7 +174,9 @@ public class Content implements Cloneable, Serializable { * @param mode the content mode, null if none. */ public void setMode(String mode) { - mode = mode != null ? mode.toLowerCase() : null; + if (mode != null) { + mode = mode.toLowerCase(); + } if (mode == null || !MODES.contains(mode)) { throw new IllegalArgumentException("Invalid mode [" + mode + "]"); } diff --git a/src/main/java/com/sun/syndication/feed/atom/Entry.java b/src/main/java/com/sun/syndication/feed/atom/Entry.java index ecfafde..6420371 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Entry.java +++ b/src/main/java/com/sun/syndication/feed/atom/Entry.java @@ -270,7 +270,11 @@ public class Entry implements Cloneable, Serializable, Extendable { * @param issued the entry issued date, null if none. */ public void setIssued(final Date issued) { - published = issued == null ? null : new Date(issued.getTime()); + if (issued == null) { + published = null; + } else { + published = new Date(issued.getTime()); + } } /** @@ -316,7 +320,11 @@ public class Entry implements Cloneable, Serializable, Extendable { * @param modified the entry modified date, null if none. */ public void setModified(final Date modified) { - updated = modified == null ? null : new Date(modified.getTime()); + if (modified == null) { + updated = null; + } else { + updated = new Date(modified.getTime()); + } } /** @@ -408,7 +416,11 @@ public class Entry implements Cloneable, Serializable, Extendable { * @since Atom 1.0 */ public void setPublished(final Date published) { - this.published = published == null ? null : new Date(published.getTime()); + if (published == null) { + this.published = null; + } else { + this.published = new Date(published.getTime()); + } } /** @@ -550,7 +562,11 @@ public class Entry implements Cloneable, Serializable, Extendable { * @since Atom 1.0 */ public void setUpdated(final Date updated) { - this.updated = updated == null ? null : new Date(updated.getTime()); + if (updated == null) { + this.updated = null; + } else { + this.updated = new Date(updated.getTime()); + } } /** diff --git a/src/main/java/com/sun/syndication/feed/impl/CloneableBean.java b/src/main/java/com/sun/syndication/feed/impl/CloneableBean.java index afc9dc6..f4d13ed 100644 --- a/src/main/java/com/sun/syndication/feed/impl/CloneableBean.java +++ b/src/main/java/com/sun/syndication/feed/impl/CloneableBean.java @@ -105,7 +105,11 @@ public class CloneableBean implements Serializable, Cloneable { */ public CloneableBean(final Object obj, final Set ignoreProperties) { this.obj = obj; - this.ignoreProperties = ignoreProperties != null ? ignoreProperties : Collections.EMPTY_SET; + if (ignoreProperties == null) { + this.ignoreProperties = Collections.emptySet(); + } else { + this.ignoreProperties = ignoreProperties; + } } /** diff --git a/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java b/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java index 084fa6a..7967d15 100644 --- a/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java +++ b/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java @@ -116,7 +116,9 @@ public class CopyFromHelper { if (value instanceof CopyFrom) { final CopyFrom source = (CopyFrom) value; CopyFrom target = createInstance(source.getInterface()); - target = target == null ? (CopyFrom) value.getClass().newInstance() : target; + if (target == null) { + target = (CopyFrom) value.getClass().newInstance(); + } target.copyFrom(source); value = target; } else { @@ -140,7 +142,12 @@ public class CopyFromHelper { private Object doCopyCollection(final Collection collection, final Class baseInterface) throws Exception { // expecting SETs or LISTs only, going default implementation of them - final Collection newColl = collection instanceof Set ? (Collection) new HashSet() : (Collection) new ArrayList(); + final Collection newColl; + if (collection instanceof Set) { + newColl = new HashSet(); + } else { + newColl = new ArrayList(); + } final Iterator i = collection.iterator(); while (i.hasNext()) { final Object element = doCopy(i.next(), baseInterface); diff --git a/src/main/java/com/sun/syndication/feed/impl/ToStringBean.java b/src/main/java/com/sun/syndication/feed/impl/ToStringBean.java index 33dd9f0..2010ac1 100644 --- a/src/main/java/com/sun/syndication/feed/impl/ToStringBean.java +++ b/src/main/java/com/sun/syndication/feed/impl/ToStringBean.java @@ -111,9 +111,14 @@ public class ToStringBean implements Serializable { */ @Override public String toString() { - final Stack stack = (Stack) PREFIX_TL.get(); - final String[] tsInfo = (String[]) (stack.isEmpty() ? null : stack.peek()); - String prefix; + final Stack stack = (Stack) PREFIX_TL.get(); + final String[] tsInfo; + if (stack.isEmpty()) { + tsInfo = null; + } else { + tsInfo = stack.peek(); + } + final String prefix; if (tsInfo == null) { final String className = obj.getClass().getName(); prefix = className.substring(className.lastIndexOf(".") + 1); @@ -181,7 +186,12 @@ public class ToStringBean implements Serializable { tsInfo[0] = ePrefix; final Stack stack = (Stack) PREFIX_TL.get(); stack.push(tsInfo); - final String s = eValue != null ? eValue.toString() : "null"; + final String s; + if (eValue != null) { + s = eValue.toString(); + } else { + s = "null"; + } stack.pop(); if (tsInfo[1] == null) { sb.append(ePrefix).append("=").append(s).append("\n"); @@ -206,7 +216,12 @@ public class ToStringBean implements Serializable { tsInfo[0] = cPrefix; final Stack stack = (Stack) PREFIX_TL.get(); stack.push(tsInfo); - final String s = cValue != null ? cValue.toString() : "null"; + final String s; + if (cValue != null) { + s = cValue.toString(); + } else { + s = "null"; + } stack.pop(); if (tsInfo[1] == null) { sb.append(cPrefix).append("=").append(s).append("\n"); diff --git a/src/main/java/com/sun/syndication/feed/rss/Channel.java b/src/main/java/com/sun/syndication/feed/rss/Channel.java index 30ae6c1..cf4f55e 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Channel.java +++ b/src/main/java/com/sun/syndication/feed/rss/Channel.java @@ -349,7 +349,11 @@ public class Channel extends WireFeed { * */ public void setPubDate(final Date pubDate) { - this.pubDate = pubDate == null ? null : new Date(pubDate.getTime()); + if (pubDate == null) { + this.pubDate = null; + } else { + this.pubDate = new Date(pubDate.getTime()); + } } /** @@ -376,7 +380,11 @@ public class Channel extends WireFeed { * */ public void setLastBuildDate(final Date lastBuildDate) { - this.lastBuildDate = lastBuildDate == null ? null : new Date(lastBuildDate.getTime()); + if (lastBuildDate == null) { + this.lastBuildDate = null; + } else { + this.lastBuildDate = new Date(lastBuildDate.getTime()); + } } /** diff --git a/src/main/java/com/sun/syndication/feed/rss/Item.java b/src/main/java/com/sun/syndication/feed/rss/Item.java index e9f17c2..0a1b235 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Item.java +++ b/src/main/java/com/sun/syndication/feed/rss/Item.java @@ -445,7 +445,11 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public void setPubDate(final Date pubDate) { - this.pubDate = pubDate == null ? null : new Date(pubDate.getTime()); + if (pubDate == null) { + this.pubDate = null; + } else { + this.pubDate = new Date(pubDate.getTime()); + } } /** @@ -472,7 +476,11 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public void setExpirationDate(final Date expirationDate) { - this.expirationDate = expirationDate == null ? null : new Date(expirationDate.getTime()); + if (expirationDate == null) { + this.expirationDate = null; + } else { + this.expirationDate = new Date(expirationDate.getTime()); + } } /** diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java index 3951f31..4f22f1f 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java @@ -253,7 +253,12 @@ class SyndCategoryListFacade extends AbstractList { @Override public SyndCategory set(final int index, final SyndCategory obj) { final SyndCategoryImpl sCat = (SyndCategoryImpl) obj; - DCSubject subject = sCat != null ? sCat.getSubject() : null; + DCSubject subject; + if (sCat != null) { + subject = sCat.getSubject(); + } else { + subject = null; + } subject = subjects.set(index, subject); if (subject != null) { return new SyndCategoryImpl(subject); @@ -273,7 +278,12 @@ class SyndCategoryListFacade extends AbstractList { @Override public void add(final int index, final SyndCategory obj) { final SyndCategoryImpl sCat = (SyndCategoryImpl) obj; - final DCSubject subject = sCat != null ? sCat.getSubject() : null; + DCSubject subject; + if (sCat != null) { + subject = sCat.getSubject(); + } else { + subject = null; + } subjects.add(index, subject); } diff --git a/src/main/java/com/sun/syndication/io/WireFeedInput.java b/src/main/java/com/sun/syndication/io/WireFeedInput.java index 86edee4..c1ec6b0 100644 --- a/src/main/java/com/sun/syndication/io/WireFeedInput.java +++ b/src/main/java/com/sun/syndication/io/WireFeedInput.java @@ -306,7 +306,12 @@ public class WireFeedInput { * @return a new org.jdom2.input.SAXBuilder object */ protected SAXBuilder createSAXBuilder() { - final SAXBuilder saxBuilder = new SAXBuilder(validate ? XMLReaders.DTDVALIDATING : XMLReaders.NONVALIDATING); + SAXBuilder saxBuilder; + if (validate) { + saxBuilder = new SAXBuilder(XMLReaders.DTDVALIDATING); + } else { + saxBuilder = new SAXBuilder(XMLReaders.NONVALIDATING); + } saxBuilder.setEntityResolver(RESOLVER); // diff --git a/src/main/java/com/sun/syndication/io/WireFeedOutput.java b/src/main/java/com/sun/syndication/io/WireFeedOutput.java index d5c4038..bdf4853 100644 --- a/src/main/java/com/sun/syndication/io/WireFeedOutput.java +++ b/src/main/java/com/sun/syndication/io/WireFeedOutput.java @@ -132,7 +132,12 @@ public class WireFeedOutput { public String outputString(final WireFeed feed, final boolean prettyPrint) throws IllegalArgumentException, FeedException { final Document doc = outputJDom(feed); final String encoding = feed.getEncoding(); - final Format format = prettyPrint ? Format.getPrettyFormat() : Format.getCompactFormat(); + Format format; + if (prettyPrint) { + format = Format.getPrettyFormat(); + } else { + format = Format.getCompactFormat(); + } if (encoding != null) { format.setEncoding(encoding); } @@ -257,7 +262,12 @@ public class WireFeedOutput { public void output(final WireFeed feed, final Writer writer, final boolean prettyPrint) throws IllegalArgumentException, IOException, FeedException { final Document doc = outputJDom(feed); final String encoding = feed.getEncoding(); - final Format format = prettyPrint ? Format.getPrettyFormat() : Format.getCompactFormat(); + Format format; + if (prettyPrint) { + format = Format.getPrettyFormat(); + } else { + format = Format.getCompactFormat(); + } if (encoding != null) { format.setEncoding(encoding); } diff --git a/src/main/java/com/sun/syndication/io/XmlReader.java b/src/main/java/com/sun/syndication/io/XmlReader.java index 665141a..bb33f94 100644 --- a/src/main/java/com/sun/syndication/io/XmlReader.java +++ b/src/main/java/com/sun/syndication/io/XmlReader.java @@ -168,7 +168,11 @@ public class XmlReader extends Reader { * */ public XmlReader(final InputStream is, final boolean lenient, final String defaultEncoding) throws IOException, XmlReaderException { - this.defaultEncoding = defaultEncoding == null ? staticDefaultEncoding : defaultEncoding; + if (defaultEncoding == null) { + this.defaultEncoding = staticDefaultEncoding; + } else { + this.defaultEncoding = defaultEncoding; + } try { doRawStream(is, lenient); } catch (final XmlReaderException ex) { @@ -339,7 +343,11 @@ public class XmlReader extends Reader { */ public XmlReader(final InputStream is, final String httpContentType, final boolean lenient, final String defaultEncoding) throws IOException, XmlReaderException { - this.defaultEncoding = defaultEncoding == null ? staticDefaultEncoding : defaultEncoding; + if (defaultEncoding == null) { + this.defaultEncoding = staticDefaultEncoding; + } else { + this.defaultEncoding = defaultEncoding; + } try { doHttpStream(is, httpContentType, lenient); } catch (final XmlReaderException ex) { @@ -408,7 +416,11 @@ public class XmlReader extends Reader { encoding = ex.getContentTypeEncoding(); } if (encoding == null) { - encoding = defaultEncoding == null ? UTF_8 : defaultEncoding; + if (defaultEncoding == null) { + encoding = UTF_8; + } else { + encoding = defaultEncoding; + } } prepareReader(ex.getInputStream(), encoding); } @@ -472,7 +484,11 @@ public class XmlReader extends Reader { String encoding; if (bomEnc == null) { if (xmlGuessEnc == null || xmlEnc == null) { - encoding = defaultEncoding == null ? UTF_8 : defaultEncoding; + if (defaultEncoding == null) { + encoding = UTF_8; + } else { + encoding = defaultEncoding; + } } else if (xmlEnc.equals(UTF_16) && (xmlGuessEnc.equals(UTF_16BE) || xmlGuessEnc.equals(UTF_16LE))) { encoding = xmlGuessEnc; } else { @@ -514,7 +530,11 @@ public class XmlReader extends Reader { if (appXml) { encoding = calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc, is); } else { - encoding = defaultEncoding == null ? US_ASCII : defaultEncoding; + if (defaultEncoding == null) { + encoding = US_ASCII; + } else { + encoding = defaultEncoding; + } } } else if (bomEnc != null && (cTEnc.equals(UTF_16BE) || cTEnc.equals(UTF_16LE))) { throw new XmlReaderException(HTTP_EX_1.format(new Object[] { cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc }), cTMime, cTEnc, bomEnc, @@ -542,7 +562,11 @@ public class XmlReader extends Reader { String mime = null; if (httpContentType != null) { final int i = httpContentType.indexOf(";"); - mime = (i == -1 ? httpContentType : httpContentType.substring(0, i)).trim(); + if (i == -1) { + mime = httpContentType.trim(); + } else { + mime = httpContentType.substring(0, i).trim(); + } } return mime; } @@ -558,8 +582,12 @@ public class XmlReader extends Reader { if (i > -1) { final String postMime = httpContentType.substring(i + 1); final Matcher m = CHARSET_PATTERN.matcher(postMime); - encoding = m.find() ? m.group(1) : null; - encoding = encoding != null ? encoding.toUpperCase(Locale.ENGLISH) : null; + if (m.find()) { + encoding = m.group(1); + } + if (encoding != null) { + encoding = encoding.toUpperCase(Locale.ENGLISH); + } } if (encoding != null && (encoding.startsWith("\"") && encoding.endsWith("\"") || encoding.startsWith("'") && encoding.endsWith("'"))) { encoding = encoding.substring(1, encoding.length() - 1); diff --git a/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java b/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java index 3557f76..c266d41 100644 --- a/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java +++ b/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java @@ -239,7 +239,9 @@ public class Atom03Parser extends BaseWireFeedParser { private Content parseContent(final Element e) { String value = null; String type = getAttributeValue(e, "type"); - type = type != null ? type : "text/plain"; + if (type == null) { + type = "text/plain"; + } String mode = getAttributeValue(e, "mode"); if (mode == null) { mode = Content.XML; // default to xml content diff --git a/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java b/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java index 45931e1..175da2d 100644 --- a/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java +++ b/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java @@ -327,7 +327,9 @@ public class Atom10Parser extends BaseWireFeedParser { private String parseTextConstructToString(final Element e) { String value = null; String type = getAttributeValue(e, "type"); - type = type != null ? type : Content.TEXT; + if (type == null) { + type = Content.TEXT; + } if (type.equals(Content.XHTML) || type.indexOf("/xml") != -1 || type.indexOf("+xml") != -1) { // XHTML content needs special handling final XMLOutputter outputter = new XMLOutputter(); @@ -508,7 +510,9 @@ public class Atom10Parser extends BaseWireFeedParser { return url; } if (isRelativeURI(url)) { - url = !".".equals(url) && !"./".equals(url) ? url : ""; + if (".".equals(url) || "./".equals(url)) { + url = ""; + } if (url.startsWith("/") && baseURI != null) { String base = null; diff --git a/src/main/java/com/sun/syndication/io/impl/Base64.java b/src/main/java/com/sun/syndication/io/impl/Base64.java index c6dbc68..76b8e8a 100644 --- a/src/main/java/com/sun/syndication/io/impl/Base64.java +++ b/src/main/java/com/sun/syndication/io/impl/Base64.java @@ -114,8 +114,16 @@ public class Base64 { eData[eIndex++] = (byte) e1; eData[eIndex++] = (byte) e2; - eData[eIndex++] = pad < 2 ? (byte) e3 : (byte) '='; - eData[eIndex++] = pad < 1 ? (byte) e4 : (byte) '='; + if (pad < 2) { + eData[eIndex++] = (byte) e3; + } else { + eData[eIndex++] = (byte) '='; + } + if (pad < 1) { + eData[eIndex++] = (byte) e4; + } else { + eData[eIndex++] = (byte) '='; + } } return eData; diff --git a/src/main/java/com/sun/syndication/io/impl/DateParser.java b/src/main/java/com/sun/syndication/io/impl/DateParser.java index 0252a75..51cfa45 100644 --- a/src/main/java/com/sun/syndication/io/impl/DateParser.java +++ b/src/main/java/com/sun/syndication/io/impl/DateParser.java @@ -105,7 +105,9 @@ public class DateParser { * */ private static Date parseUsingMask(final String[] masks, String sDate) { - sDate = sDate != null ? sDate.trim() : null; + if (sDate != null) { + sDate = sDate.trim(); + } ParsePosition pp = null; Date d = null; for (int i = 0; d == null && i < masks.length; i++) { diff --git a/src/main/java/com/sun/syndication/io/impl/PluginManager.java b/src/main/java/com/sun/syndication/io/impl/PluginManager.java index 7e4bf17..8d91cc4 100644 --- a/src/main/java/com/sun/syndication/io/impl/PluginManager.java +++ b/src/main/java/com/sun/syndication/io/impl/PluginManager.java @@ -145,7 +145,12 @@ public abstract class PluginManager { final List classes = new ArrayList(); final boolean useLoadClass = Boolean.valueOf(System.getProperty("rome.pluginmanager.useloadclass", "false")).booleanValue(); for (final String propertyValue : propertyValues) { - final Class mClass = useLoadClass ? classLoader.loadClass(propertyValue) : Class.forName(propertyValue, true, classLoader); + final Class mClass; + if (useLoadClass) { + mClass = classLoader.loadClass(propertyValue); + } else { + mClass = Class.forName(propertyValue, true, classLoader); + } classes.add(mClass); } final Class[] array = new Class[classes.size()]; diff --git a/src/test/java/com/sun/syndication/unittest/TestXmlReader.java b/src/test/java/com/sun/syndication/unittest/TestXmlReader.java index 60f3cba..5bdc8cb 100644 --- a/src/test/java/com/sun/syndication/unittest/TestXmlReader.java +++ b/src/test/java/com/sun/syndication/unittest/TestXmlReader.java @@ -186,14 +186,24 @@ public class TestXmlReader extends TestCase { public void testAlternateDefaultEncoding(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String alternateEnc) throws Exception { try { - final InputStream is = getXmlStream(bomEnc, prologEnc == null ? XML1 : XML3, streamEnc, prologEnc); + final InputStream is; + if (prologEnc == null) { + is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc); + } else { + is = getXmlStream(bomEnc, XML3, streamEnc, prologEnc); + } XmlReader.setDefaultEncoding(alternateEnc); final XmlReader xmlReader = new XmlReader(is, cT, false); if (!streamEnc.equals("UTF-16")) { // we can not assert things here becuase UTF-8, US-ASCII and // ISO-8859-1 look alike for the chars used for detection } else { - final String enc = alternateEnc != null ? alternateEnc : streamEnc; + final String enc; + if (alternateEnc != null) { + enc = alternateEnc; + } else { + enc = streamEnc; + } assertEquals(xmlReader.getEncoding().substring(0, streamEnc.length()), streamEnc); } } finally { @@ -202,7 +212,12 @@ public class TestXmlReader extends TestCase { } public void testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { - final InputStream is = getXmlStream(bomEnc, prologEnc == null ? XML1 : XML3, streamEnc, prologEnc); + final InputStream is; + if (prologEnc == null) { + is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc); + } else { + is = getXmlStream(bomEnc, XML3, streamEnc, prologEnc); + } final XmlReader xmlReader = new XmlReader(is, cT, false); if (!streamEnc.equals("UTF-16")) { // we can not assert things here becuase UTF-8, US-ASCII and @@ -213,7 +228,12 @@ public class TestXmlReader extends TestCase { } protected void testHttpInvalid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { - final InputStream is = getXmlStream(bomEnc, prologEnc == null ? XML2 : XML3, streamEnc, prologEnc); + final InputStream is; + if (prologEnc == null) { + is = getXmlStream(bomEnc, XML2, streamEnc, prologEnc); + } else { + is = getXmlStream(bomEnc, XML3, streamEnc, prologEnc); + } try { new XmlReader(is, cT, false); fail("It should have failed for HTTP Content-type " + cT + ", BOM " + bomEnc + ", streamEnc " + streamEnc + " and prologEnc " + prologEnc); @@ -224,7 +244,12 @@ public class TestXmlReader extends TestCase { protected void testHttpLenient(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String shouldbe) throws Exception { - final InputStream is = getXmlStream(bomEnc, prologEnc == null ? XML2 : XML3, streamEnc, prologEnc); + final InputStream is; + if (prologEnc == null) { + is = getXmlStream(bomEnc, XML2, streamEnc, prologEnc); + } else { + is = getXmlStream(bomEnc, XML3, streamEnc, prologEnc); + } final XmlReader xmlReader = new XmlReader(is, cT, true); assertEquals(xmlReader.getEncoding(), shouldbe); } From a2d3689d9f7bd66f27c956210747c9d61c82355a Mon Sep 17 00:00:00 2001 From: Patrick Gotthard Date: Fri, 4 Oct 2013 11:35:00 +0200 Subject: [PATCH 6/6] Added initial CheckStyle configuration --- checkstyle.xml | 115 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 checkstyle.xml diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 0000000..2a344a7 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +