Merge remote-tracking branch 'origin/master'

Conflicts:
	src/main/java/com/sun/syndication/feed/atom/Entry.java
	src/main/java/com/sun/syndication/feed/atom/Feed.java
	src/main/java/com/sun/syndication/feed/impl/CloneableBean.java
	src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java
	src/main/java/com/sun/syndication/feed/impl/ToStringBean.java
	src/main/java/com/sun/syndication/io/impl/PluginManager.java
This commit is contained in:
Martin Kurz 2013-10-04 16:18:44 +02:00
commit 648a1f04cf
36 changed files with 865 additions and 307 deletions

3
.gitignore vendored
View file

@ -1,4 +1,5 @@
/target
/.checkstyle
/.classpath
/.project
/.settings
/target

115
checkstyle.xml Normal file
View file

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!--
This configuration file was written by the eclipse-cs plugin configuration editor
-->
<!--
Checkstyle-Configuration: ROME
Description:
CheckStyle configuration for the ROME project
-->
<module name="Checker">
<property name="severity" value="warning"/>
<module name="TreeWalker">
<property name="tabWidth" value="4"/>
<module name="JavadocMethod">
<property name="allowMissingPropertyJavadoc" value="true"/>
<property name="suppressLoadErrors" value="true"/>
</module>
<module name="JavadocType"/>
<module name="JavadocVariable">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
<module name="JavadocStyle"/>
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<module name="LineLength">
<property name="max" value="160"/>
<property name="tabWidth" value="4"/>
</module>
<module name="MethodLength"/>
<module name="ParameterNumber"/>
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter">
<property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
</module>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
<module name="AvoidInlineConditionals"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows">
<property name="suppressLoadErrors" value="true"/>
</module>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="DesignForExtension">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>
<module name="ArrayTypeStyle"/>
<module name="FinalParameters"/>
<module name="TodoComment">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
<module name="UpperEll"/>
</module>
<module name="JavadocPackage">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
<module name="NewlineAtEndOfFile">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
<module name="Translation"/>
<module name="FileLength"/>
<module name="FileTabCharacter">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
<module name="RegexpSingleline">
<property name="severity" value="ignore"/>
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
</module>

273
pom.xml
View file

@ -7,7 +7,7 @@
<groupId>org.rometools</groupId>
<artifactId>rome</artifactId>
<version>2.0.0-SNAPSHOT</version>
<name>ROME, RSS and atOM utilitiEs for Java</name>
<description>All Roads Lead to ROME. ROME is a set of Atom/RSS Java utilities that make it
@ -23,6 +23,7 @@
<url>http://rometools.github.io/rome/</url>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/rometools/rome/issues</url>
</issueManagement>
@ -98,6 +99,119 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<distributionManagement>
<repository>
<id>central.staging</id>
<url>http://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<snapshotRepository>
<id>sonatype.snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-Xlint</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<configuration>
<port>9000</port>
<tempWebappDirectory>${basedir}/target/site/tempdir</tempWebappDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-markdown</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-confluence</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-publish-plugin</artifactId>
<version>1.0-beta-2</version>
<configuration>
<scmBranch>gh-pages</scmBranch>
<pubScmUrl>scm:git:git@github.com:rometools/rome.git</pubScmUrl>
<content>${project.build.directory}/site</content>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<reportSets>
<reportSet>
<reports>
<report>javadoc</report>
<report>test-javadoc</report>
</reports>
</reportSet>
<reportSet>
<id>aggregate</id>
<inherited>false</inherited>
<reports>
<report>aggregate</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>org.jdom</groupId>
@ -112,161 +226,4 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.8.1</version>
<configuration>
<goals>install</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-Xlint</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<configuration>
<port>9000</port>
<tempWebappDirectory>${basedir}/target/site/tempdir</tempWebappDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-markdown</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-confluence</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-publish-plugin</artifactId>
<version>1.0-beta-2</version>
<configuration>
<scmBranch>gh-pages</scmBranch>
<pubScmUrl>scm:git:git@github.com:rometools/rome.git</pubScmUrl>
<content>${project.build.directory}/site</content>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<distributionManagement>
<repository>
<id>central.staging</id>
<name>Nexus Release Repository</name>
<url>http://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<snapshotRepository>
<id>sonatype.snapshots</id>
<name>My Nexus Snapshots Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<reportSets>
<reportSet>
<reports>
<report>javadoc</report>
<report>test-javadoc</report>
</reports>
</reportSet>
<reportSet>
<id>aggregate</id>
<inherited>false</inherited>
<reports>
<report>aggregate</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project>

View file

@ -196,7 +196,10 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
*/
@Override
public List<Module> getModules() {
return modules == null ? (modules = new ArrayList<Module>()) : modules;
if (modules == null) {
modules = new ArrayList<Module>();
}
return modules;
}
/**
@ -232,7 +235,10 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
*
*/
public List<Element> getForeignMarkup() {
return foreignMarkup == null ? (foreignMarkup = new ArrayList<Element>()) : foreignMarkup;
if (foreignMarkup == null) {
foreignMarkup = new ArrayList<Element>();
}
return foreignMarkup;
}
/**

View file

@ -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;
}
}
/**

View file

@ -175,7 +175,9 @@ public class Content implements Cloneable, Serializable {
* @param mode the content mode, <b>null</b> 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 + "]");
}

View file

@ -85,7 +85,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
* list if none.
*/
public List<Link> getAlternateLinks() {
return alternateLinks == null ? (alternateLinks = new ArrayList<Link>()) : alternateLinks;
if (alternateLinks == null) {
alternateLinks = new ArrayList<Link>();
}
return alternateLinks;
}
/**
@ -107,7 +110,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
*
*/
public List<SyndPerson> getAuthors() {
return authors == null ? (authors = new ArrayList<SyndPerson>()) : authors;
if (authors == null) {
authors = new ArrayList<SyndPerson>();
}
return authors;
}
/**
@ -129,7 +135,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
* @since Atom 1.0
*/
public List<Category> getCategories() {
return categories == null ? (categories = new ArrayList<Category>()) : categories;
if (categories == null) {
categories = new ArrayList<Category>();
}
return categories;
}
/**
@ -151,7 +160,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
* if none.
*/
public List<Content> getContents() {
return contents == null ? (contents = new ArrayList<Content>()) : contents;
if (contents == null) {
contents = new ArrayList<Content>();
}
return contents;
}
/**
@ -175,7 +187,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
*
*/
public List<SyndPerson> getContributors() {
return contributors == null ? (contributors = new ArrayList<SyndPerson>()) : contributors;
if (contributors == null) {
contributors = new ArrayList<SyndPerson>();
}
return contributors;
}
/**
@ -195,7 +210,11 @@ public class Entry implements Cloneable, Serializable, Extendable {
* @return the entry created date, <b>null</b> 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<Element> getForeignMarkup() {
return foreignMarkup == null ? (foreignMarkup = new ArrayList<Element>()) : foreignMarkup;
if (foreignMarkup == null) {
foreignMarkup = new ArrayList<Element>();
}
return foreignMarkup;
}
/**
@ -250,7 +272,11 @@ public class Entry implements Cloneable, Serializable, Extendable {
* @param issued the entry issued date, <b>null</b> 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, <b>null</b> 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, <b>null</b> 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, <b>null</b> 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<Module> getModules() {
return modules == null ? (modules = new ArrayList<Module>()) : modules;
if (modules == null) {
modules = new ArrayList<Module>();
}
return modules;
}
/**
@ -363,7 +404,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
* set, an empty list if none.
*/
public List<Link> getOtherLinks() {
return otherLinks == null ? (otherLinks = new ArrayList<Link>()) : otherLinks;
if (otherLinks == null) {
otherLinks = new ArrayList<Link>();
}
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());
}
}
/**

View file

@ -201,7 +201,10 @@ public class Feed extends WireFeed {
*
*/
public List<SyndPerson> getAuthors() {
return authors == null ? (authors = new ArrayList<SyndPerson>()) : authors;
if (authors == null) {
authors = new ArrayList<SyndPerson>();
}
return authors;
}
/**
@ -224,7 +227,10 @@ public class Feed extends WireFeed {
*
*/
public List<SyndPerson> getContributors() {
return contributors == null ? (contributors = new ArrayList<SyndPerson>()) : contributors;
if (contributors == null) {
contributors = new ArrayList<SyndPerson>();
}
return contributors;
}
/**

View file

@ -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;
}
}
/**

View file

@ -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<Module> getModules() {
return modules == null ? (modules = new ArrayList<Module>()) : modules;
if (modules == null) {
modules = new ArrayList<Module>();
}
return modules;
}
/**

View file

@ -106,7 +106,11 @@ public class CloneableBean implements Serializable, Cloneable {
*/
public CloneableBean(final Object obj, final Set<String> ignoreProperties) {
this.obj = obj;
this.ignoreProperties = ignoreProperties != null ? ignoreProperties : Collections.<String>emptySet();
if (ignoreProperties == null) {
this.ignoreProperties = Collections.<String>emptySet();
} else {
this.ignoreProperties = ignoreProperties;
}
}
/**

View file

@ -118,7 +118,9 @@ public class CopyFromHelper {
if (value instanceof CopyFrom<?>) {
final CopyFrom<T> source = (CopyFrom<T>) value;
CopyFrom<T> target = (CopyFrom<T>) createInstance(source.getInterface());
target = target == null ? (CopyFrom<T>) value.getClass().newInstance() : target;
if (target == null) {
target = (CopyFrom<T>) value.getClass().newInstance();
}
target.copyFrom(source);
value = (T) target;
} else {
@ -143,7 +145,12 @@ public class CopyFromHelper {
private <T> Collection<T> doCopyCollection(final Collection<T> collection, final Class<?> baseInterface) throws Exception {
// expecting SETs or LISTs only, going default implementation of them
final Collection<T> newColl = collection instanceof Set ? new HashSet<T>() : new ArrayList<T>();
final Collection<T> newColl;
if (collection instanceof Set) {
newColl = new HashSet<T>();
} else {
newColl = new ArrayList<T>();
}
final Iterator<T> i = collection.iterator();
while (i.hasNext()) {
newColl.add(this.<T>doCopy(i.next(), baseInterface));

View file

@ -115,8 +115,13 @@ public class ToStringBean implements Serializable {
@Override
public String toString() {
final Stack<String[]> 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);

View file

@ -109,7 +109,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/
@Override
public List<String> getTitles() {
return title == null ? (title = new ArrayList<String>()) : title;
if (title == null) {
title = new ArrayList<String>();
}
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<String> getCreators() {
return creator == null ? (creator = new ArrayList<String>()) : creator;
if (creator == null) {
creator = new ArrayList<String>();
}
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<DCSubject> getSubjects() {
return subject == null ? (subject = new ArrayList<DCSubject>()) : subject;
if (subject == null) {
subject = new ArrayList<DCSubject>();
}
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<String> getDescriptions() {
return description == null ? (description = new ArrayList<String>()) : description;
if (description == null) {
description = new ArrayList<String>();
}
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<String> getPublishers() {
return publisher == null ? (publisher = new ArrayList<String>()) : publisher;
if (publisher == null) {
publisher = new ArrayList<String>();
}
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<String> getContributors() {
return contributors == null ? (contributors = new ArrayList<String>()) : contributors;
if (contributors == null) {
contributors = new ArrayList<String>();
}
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<Date> getDates() {
return date == null ? (date = new ArrayList<Date>()) : date;
if (date == null) {
date = new ArrayList<Date>();
}
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<String> getTypes() {
return type == null ? (type = new ArrayList<String>()) : type;
if (type == null) {
type = new ArrayList<String>();
}
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<String> getFormats() {
return format == null ? (format = new ArrayList<String>()) : format;
if (format == null) {
format = new ArrayList<String>();
}
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<String> getIdentifiers() {
return identifier == null ? (identifier = new ArrayList<String>()) : identifier;
if (identifier == null) {
identifier = new ArrayList<String>();
}
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<String> getSources() {
return source == null ? (source = new ArrayList<String>()) : source;
if (source == null) {
source = new ArrayList<String>();
}
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<String> getLanguages() {
return language == null ? (language = new ArrayList<String>()) : language;
if (language == null) {
language = new ArrayList<String>();
}
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<String> getRelations() {
return relation == null ? (relation = new ArrayList<String>()) : relation;
if (relation == null) {
relation = new ArrayList<String>();
}
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<String> getCoverages() {
return coverage == null ? (coverage = new ArrayList<String>()) : coverage;
if (coverage == null) {
coverage = new ArrayList<String>();
}
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<String> getRightsList() {
return rights == null ? (rights = new ArrayList<String>()) : rights;
if (rights == null) {
rights = new ArrayList<String>();
}
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;
}
}
/**

View file

@ -221,7 +221,10 @@ public class Channel extends WireFeed {
*
*/
public List<Item> getItems() {
return items == null ? (items = new ArrayList<Item>()) : items;
if (items == null) {
items = new ArrayList<Item>();
}
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<Integer> getSkipHours() {
return skipHours != null ? skipHours : new ArrayList<Integer>();
if (skipHours != null) {
return skipHours;
} else {
return new ArrayList<Integer>();
}
}
/**
@ -482,7 +505,11 @@ public class Channel extends WireFeed {
*
*/
public List<String> getSkipDays() {
return skipDays != null ? skipDays : new ArrayList<String>();
if (skipDays != null) {
return skipDays;
} else {
return new ArrayList<String>();
}
}
/**
@ -542,7 +569,10 @@ public class Channel extends WireFeed {
*
*/
public List<Category> getCategories() {
return categories == null ? (categories = new ArrayList<Category>()) : categories;
if (categories == null) {
categories = new ArrayList<Category>();
}
return categories;
}
/**
@ -611,7 +641,10 @@ public class Channel extends WireFeed {
*/
@Override
public List<Module> getModules() {
return modules == null ? (modules = new ArrayList<Module>()) : modules;
if (modules == null) {
modules = new ArrayList<Module>();
}
return modules;
}
/**

View file

@ -271,7 +271,10 @@ public class Item implements Cloneable, Serializable, Extendable {
*
*/
public List<Enclosure> getEnclosures() {
return enclosures == null ? (enclosures = new ArrayList<Enclosure>()) : enclosures;
if (enclosures == null) {
enclosures = new ArrayList<Enclosure>();
}
return enclosures;
}
/**
@ -295,7 +298,10 @@ public class Item implements Cloneable, Serializable, Extendable {
*
*/
public List<Category> getCategories() {
return categories == null ? (categories = new ArrayList<Category>()) : categories;
if (categories == null) {
categories = new ArrayList<Category>();
}
return categories;
}
/**
@ -386,7 +392,10 @@ public class Item implements Cloneable, Serializable, Extendable {
*/
@Override
public List<Module> getModules() {
return modules == null ? (modules = new ArrayList<Module>()) : modules;
if (modules == null) {
modules = new ArrayList<Module>();
}
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<Element> getForeignMarkup() {
return foreignMarkup == null ? (foreignMarkup = new ArrayList<Element>()) : foreignMarkup;
if (foreignMarkup == null) {
foreignMarkup = new ArrayList<Element>();
}
return foreignMarkup;
}
/**

View file

@ -254,9 +254,18 @@ class SyndCategoryListFacade extends AbstractList<SyndCategory> {
@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<SyndCategory> {
@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<SyndCategory> {
@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;
}
}
/**

View file

@ -327,7 +327,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
*/
@Override
public List<SyndContent> getContents() {
return contents == null ? (contents = new ArrayList<SyndContent>()) : contents;
if (contents == null) {
contents = new ArrayList<SyndContent>();
}
return contents;
}
/**
@ -353,7 +356,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
*/
@Override
public List<SyndEnclosure> getEnclosures() {
return enclosures == null ? (enclosures = new ArrayList<SyndEnclosure>()) : enclosures;
if (enclosures == null) {
enclosures = new ArrayList<SyndEnclosure>();
}
return enclosures;
}
/**
@ -523,7 +529,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
*/
@Override
public List<SyndLink> getLinks() {
return links == null ? (links = new ArrayList<SyndLink>()) : links;
if (links == null) {
links = new ArrayList<SyndLink>();
}
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<SyndPerson> getAuthors() {
return authors == null ? (authors = new ArrayList<SyndPerson>()) : authors;
if (authors == null) {
authors = new ArrayList<SyndPerson>();
}
return authors;
}
/*
@ -625,14 +641,12 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
@Override
public List<SyndPerson> getContributors() {
return contributors == null ? (contributors = new ArrayList<SyndPerson>()) : contributors;
if (contributors == null) {
contributors = new ArrayList<SyndPerson>();
}
return contributors;
}
/*
* (non-Javadoc)
* @see
* com.sun.syndication.feed.synd.SyndEntry#setContributors(java.util.List)
*/
@Override
public void setContributors(final List<SyndPerson> contributors) {
this.contributors = contributors;
@ -658,7 +672,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
*/
@Override
public List<Element> getForeignMarkup() {
return foreignMarkup == null ? (foreignMarkup = new ArrayList<Element>()) : foreignMarkup;
if (foreignMarkup == null) {
foreignMarkup = new ArrayList<Element>();
}
return foreignMarkup;
}
/**

View file

@ -679,7 +679,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
*/
@Override
public List<SyndEntry> getEntries() {
return entries == null ? (entries = new ArrayList<SyndEntry>()) : entries;
if (entries == null) {
entries = new ArrayList<SyndEntry>();
}
return entries;
}
/**
@ -822,7 +825,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
*/
@Override
public List<SyndLink> getLinks() {
return links == null ? (links = new ArrayList<SyndLink>()) : links;
if (links == null) {
links = new ArrayList<SyndLink>();
}
return links;
}
/**
@ -838,7 +844,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
@Override
public List<SyndPerson> getAuthors() {
return authors == null ? (authors = new ArrayList<SyndPerson>()) : authors;
if (authors == null) {
authors = new ArrayList<SyndPerson>();
}
return authors;
}
@Override
@ -878,7 +887,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
@Override
public List<SyndPerson> getContributors() {
return contributors == null ? (contributors = new ArrayList<SyndPerson>()) : contributors;
if (contributors == null) {
contributors = new ArrayList<SyndPerson>();
}
return contributors;
}
@Override
@ -895,7 +907,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
*/
@Override
public List<Element> getForeignMarkup() {
return foreignMarkup == null ? (foreignMarkup = new ArrayList<Element>()) : foreignMarkup;
if (foreignMarkup == null) {
foreignMarkup = new ArrayList<Element>();
}
return foreignMarkup;
}
/**

View file

@ -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;
}
}
}

View file

@ -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);
//

View file

@ -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);
}

View file

@ -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);
}
}

View file

@ -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) {

View file

@ -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<Link> parseOtherLinks(final Feed feed, final Entry entry, final String baseURI, final List<Element> 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;

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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;
}
}
}

View file

@ -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;
}
}
/**

View file

@ -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++) {

View file

@ -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();
}
}
}

View file

@ -140,16 +140,20 @@ public abstract class PluginManager<T> {
* failure is ON.
*
*/
@SuppressWarnings("unchecked")
private Class<T>[] getClasses() throws ClassNotFoundException {
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final List<Class<T>> classes = new ArrayList<Class<T>>();
final boolean useLoadClass = Boolean.valueOf(System.getProperty("rome.pluginmanager.useloadclass", "false")).booleanValue();
for (final String _propertyValue : propertyValues) {
@SuppressWarnings("unchecked")
final Class<T> mClass = (Class<T>) (useLoadClass ? classLoader.loadClass(_propertyValue) : Class.forName(_propertyValue, true, classLoader));
for (final String propertyValue : propertyValues) {
final Class<T> mClass;
if (useLoadClass) {
mClass = (Class<T>) classLoader.loadClass(propertyValue);
} else {
mClass = (Class<T>) Class.forName(propertyValue, true, classLoader);
}
classes.add(mClass);
}
@SuppressWarnings("unchecked")
final Class<T>[] array = (Class<T>[]) new Class[classes.size()];
classes.toArray(array);
return array;

View file

@ -197,7 +197,11 @@ public class RSS091UserlandParser extends RSS090Parser {
protected List<Element> getItems(final Element rssRoot) {
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
final List<Element> 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;
}
}
/**

View file

@ -84,7 +84,11 @@ public class RSS092Generator extends RSS091UserlandGenerator {
// Another one to thanks DW for
protected int getNumberOfEnclosures(final List<Enclosure> enclosures) {
return enclosures.size() > 0 ? 1 : 0;
if (enclosures.size() > 0) {
return 1;
} else {
return 0;
}
}
@Override

View file

@ -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;
}
}
}

View file

@ -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);
}