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/checkstyle.xml b/checkstyle.xml new file mode 100644 index 0000000..2a344a7 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 - - - - - - - diff --git a/src/main/java/com/sun/syndication/feed/WireFeed.java b/src/main/java/com/sun/syndication/feed/WireFeed.java index 81e4722..d0b9b45 100644 --- a/src/main/java/com/sun/syndication/feed/WireFeed.java +++ b/src/main/java/com/sun/syndication/feed/WireFeed.java @@ -196,7 +196,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; } /** @@ -232,7 +235,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 1ce3de9..6c230a7 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Category.java +++ b/src/main/java/com/sun/syndication/feed/atom/Category.java @@ -147,7 +147,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/Content.java b/src/main/java/com/sun/syndication/feed/atom/Content.java index dd549d9..03dd259 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Content.java +++ b/src/main/java/com/sun/syndication/feed/atom/Content.java @@ -175,7 +175,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 b989f5d..378f362 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Entry.java +++ b/src/main/java/com/sun/syndication/feed/atom/Entry.java @@ -85,7 +85,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; } /** @@ -107,7 +110,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; } /** @@ -129,7 +135,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; } /** @@ -151,7 +160,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; } /** @@ -175,7 +187,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; } /** @@ -195,7 +210,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()); + } } /** @@ -217,7 +236,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; } /** @@ -250,7 +272,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()); + } } /** @@ -261,7 +287,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()); + } } /** @@ -292,7 +322,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()); + } } /** @@ -303,7 +337,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()); + } } /** @@ -341,7 +379,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; } /** @@ -363,7 +404,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; } /** @@ -374,7 +418,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()); + } } /** @@ -385,7 +433,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()); + } } /** @@ -512,7 +564,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()); + } } /** @@ -523,7 +579,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 706f708..6803bda 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Feed.java +++ b/src/main/java/com/sun/syndication/feed/atom/Feed.java @@ -201,7 +201,10 @@ public class Feed extends WireFeed { * */ public List getAuthors() { - return authors == null ? (authors = new ArrayList()) : authors; + if (authors == null) { + authors = new ArrayList(); + } + return authors; } /** @@ -224,7 +227,10 @@ public class Feed extends WireFeed { * */ public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + if (contributors == null) { + contributors = new ArrayList(); + } + return contributors; } /** 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 e42c951..7ad5e67 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Link.java +++ b/src/main/java/com/sun/syndication/feed/atom/Link.java @@ -175,7 +175,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 a9055d3..85ba553 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Person.java +++ b/src/main/java/com/sun/syndication/feed/atom/Person.java @@ -155,7 +155,11 @@ public class Person implements SyndPerson, Cloneable, Serializable, Extendable { } public String getUriResolved(final String resolveURI) { - return uriResolved != null ? uriResolved : uri; + if (uriResolved != null) { + return uriResolved; + } else { + return uri; + } } /** @@ -212,7 +216,10 @@ public class Person implements SyndPerson, 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/impl/CloneableBean.java b/src/main/java/com/sun/syndication/feed/impl/CloneableBean.java index b2ad189..534fd3e 100644 --- a/src/main/java/com/sun/syndication/feed/impl/CloneableBean.java +++ b/src/main/java/com/sun/syndication/feed/impl/CloneableBean.java @@ -106,7 +106,11 @@ public class CloneableBean implements Serializable, Cloneable { */ public CloneableBean(final Object obj, final Set ignoreProperties) { this.obj = obj; - this.ignoreProperties = ignoreProperties != null ? ignoreProperties : Collections.emptySet(); + 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 11607f6..40c9c55 100644 --- a/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java +++ b/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java @@ -118,7 +118,9 @@ public class CopyFromHelper { if (value instanceof CopyFrom) { final CopyFrom source = (CopyFrom) value; CopyFrom target = (CopyFrom) createInstance(source.getInterface()); - target = target == null ? (CopyFrom) value.getClass().newInstance() : target; + if (target == null) { + target = (CopyFrom) value.getClass().newInstance(); + } target.copyFrom(source); value = (T) target; } else { @@ -143,7 +145,12 @@ public class CopyFromHelper { private Collection 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 ? new HashSet() : new ArrayList(); + final Collection newColl; + if (collection instanceof Set) { + newColl = new HashSet(); + } else { + newColl = new ArrayList(); + } final Iterator i = collection.iterator(); while (i.hasNext()) { newColl.add(this.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 e5d2ce7..3a99120 100644 --- a/src/main/java/com/sun/syndication/feed/impl/ToStringBean.java +++ b/src/main/java/com/sun/syndication/feed/impl/ToStringBean.java @@ -115,8 +115,13 @@ public class ToStringBean implements Serializable { @Override public String toString() { final Stack stack = PREFIX_TL.get(); - final String[] tsInfo = (stack.isEmpty() ? null : stack.peek()); - String prefix; + 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); 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 5b7017a..5894ba3 100644 --- a/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java +++ b/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java @@ -109,7 +109,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; } /** @@ -134,7 +137,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; + } } /** @@ -161,7 +168,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; } /** @@ -186,7 +196,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; + } } /** @@ -213,7 +227,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; } /** @@ -238,7 +255,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; + } } /** @@ -265,7 +286,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; } /** @@ -290,7 +314,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; + } } /** @@ -318,7 +346,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; } /** @@ -343,7 +374,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; + } } /** @@ -371,7 +406,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; } /** @@ -396,7 +434,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; + } } /** @@ -424,7 +466,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; } /** @@ -449,7 +494,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; + } } /** @@ -476,7 +525,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; } /** @@ -501,7 +553,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; + } } /** @@ -528,7 +584,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; } /** @@ -553,7 +612,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; + } } /** @@ -580,7 +643,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; } /** @@ -605,7 +671,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; + } } /** @@ -633,7 +703,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; } /** @@ -658,7 +731,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; + } } /** @@ -685,7 +762,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; } /** @@ -710,7 +790,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; + } } /** @@ -738,7 +822,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; } /** @@ -763,7 +850,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; + } } /** @@ -791,7 +882,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; } /** @@ -816,7 +910,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; + } } /** @@ -844,7 +942,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; } /** @@ -869,7 +970,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 3583ee5..f2aedbb 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Channel.java +++ b/src/main/java/com/sun/syndication/feed/rss/Channel.java @@ -221,7 +221,10 @@ public class Channel extends WireFeed { * */ public List getItems() { - return items == null ? (items = new ArrayList()) : items; + if (items == null) { + items = new ArrayList(); + } + return items; } /** @@ -332,7 +335,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()); + } } /** @@ -343,7 +350,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()); + } } /** @@ -354,7 +365,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()); + } } /** @@ -366,7 +381,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()); + } } /** @@ -445,7 +464,11 @@ public class Channel extends WireFeed { * */ public List getSkipHours() { - return skipHours != null ? skipHours : new ArrayList(); + if (skipHours != null) { + return skipHours; + } else { + return new ArrayList(); + } } /** @@ -482,7 +505,11 @@ public class Channel extends WireFeed { * */ public List getSkipDays() { - return skipDays != null ? skipDays : new ArrayList(); + if (skipDays != null) { + return skipDays; + } else { + return new ArrayList(); + } } /** @@ -542,7 +569,10 @@ public class Channel extends WireFeed { * */ public List getCategories() { - return categories == null ? (categories = new ArrayList()) : categories; + if (categories == null) { + categories = new ArrayList(); + } + return categories; } /** @@ -611,7 +641,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 c872342..bbca90f 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Item.java +++ b/src/main/java/com/sun/syndication/feed/rss/Item.java @@ -271,7 +271,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; } /** @@ -295,7 +298,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; } /** @@ -386,7 +392,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; } /** @@ -422,7 +431,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()); + } } /** @@ -433,7 +446,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()); + } } /** @@ -444,7 +461,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()); + } } /** @@ -456,7 +477,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()); + } } /** @@ -467,7 +492,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 eca8da1..12a0e61 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java @@ -254,9 +254,18 @@ 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); - return subject != null ? new SyndCategoryImpl(subject) : null; + if (subject != null) { + return new SyndCategoryImpl(subject); + } else { + return null; + } } /** @@ -270,7 +279,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); } @@ -286,7 +300,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 b5d02f2..0075ee4 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java @@ -327,7 +327,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; } /** @@ -353,7 +356,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; } /** @@ -523,7 +529,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; } /** @@ -545,7 +554,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()); + } } /** @@ -561,7 +574,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; } /* @@ -625,14 +641,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; @@ -658,7 +672,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 4881d4b..ef8efee 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java @@ -679,7 +679,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; } /** @@ -822,7 +825,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; } /** @@ -838,7 +844,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 @@ -878,7 +887,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 @@ -895,7 +907,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 1175eb8..ea8c189 100644 --- a/src/main/java/com/sun/syndication/io/ParsingFeedException.java +++ b/src/main/java/com/sun/syndication/io/ParsingFeedException.java @@ -63,7 +63,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; + } } /** @@ -77,7 +81,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/WireFeedInput.java b/src/main/java/com/sun/syndication/io/WireFeedInput.java index 34a215b..1828946 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 ca5628e..e68bc3d 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 76a7669..bb33f94 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; @@ -167,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) { @@ -338,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) { @@ -407,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); } @@ -471,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 { @@ -513,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, @@ -541,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; } @@ -557,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() : 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); @@ -655,7 +684,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); } } 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 e4acb45..7d431db 100644 --- a/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java +++ b/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java @@ -190,7 +190,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) @@ -226,13 +230,19 @@ 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) { 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 @@ -271,7 +281,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 ee535f1..3c5c765 100644 --- a/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java +++ b/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java @@ -257,7 +257,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) { @@ -269,7 +273,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) { @@ -299,7 +307,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) { @@ -316,7 +328,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(); @@ -345,7 +359,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) { @@ -434,7 +452,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) { @@ -489,7 +511,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/BaseWireFeedGenerator.java b/src/main/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java index c8d534b..4137d35 100644 --- a/src/main/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java +++ b/src/main/java/com/sun/syndication/io/impl/BaseWireFeedGenerator.java @@ -67,8 +67,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/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/DateParser.java b/src/main/java/com/sun/syndication/io/impl/DateParser.java index 81de157..9efdd3b 100644 --- a/src/main/java/com/sun/syndication/io/impl/DateParser.java +++ b/src/main/java/com/sun/syndication/io/impl/DateParser.java @@ -106,7 +106,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/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/PluginManager.java b/src/main/java/com/sun/syndication/io/impl/PluginManager.java index 8082ce5..23f00cd 100644 --- a/src/main/java/com/sun/syndication/io/impl/PluginManager.java +++ b/src/main/java/com/sun/syndication/io/impl/PluginManager.java @@ -140,16 +140,20 @@ public abstract class PluginManager { * failure is ON. * */ + @SuppressWarnings("unchecked") private Class[] getClasses() throws ClassNotFoundException { 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) { - @SuppressWarnings("unchecked") - final Class mClass = (Class) (useLoadClass ? classLoader.loadClass(_propertyValue) : Class.forName(_propertyValue, true, classLoader)); + for (final String propertyValue : propertyValues) { + final Class mClass; + if (useLoadClass) { + mClass = (Class) classLoader.loadClass(propertyValue); + } else { + mClass = (Class) Class.forName(propertyValue, true, classLoader); + } classes.add(mClass); } - @SuppressWarnings("unchecked") final Class[] array = (Class[]) new Class[classes.size()]; classes.toArray(array); return array; 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; + } } } 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); }