Polishing

This commit is contained in:
Juergen Hoeller
2014-07-24 18:35:49 +02:00
parent fca72f6b65
commit 6e95b2613e
78 changed files with 467 additions and 463 deletions

View File

@@ -21,13 +21,10 @@ import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.api.artifacts.maven.Conf2ScopeMapping
import org.gradle.api.plugins.MavenPlugin
import org.gradle.api.tasks.*
import org.gradle.plugins.ide.eclipse.EclipsePlugin
import org.gradle.plugins.ide.eclipse.model.EclipseClasspath;
import org.gradle.plugins.ide.idea.IdeaPlugin
import org.gradle.api.invocation.*
/**
* Gradle plugin that allows projects to merged together. Primarily developed to
* allow Spring to support multiple incompatible versions of third-party
@@ -76,13 +73,13 @@ class MergePlugin implements Plugin<Project> {
// Hook to perform the actual merge logic
project.afterEvaluate{
if(it.merge.into != null) {
if (it.merge.into != null) {
setup(it)
}
}
// Hook to build runtimeMerge dependencies
if(!attachedProjectsEvaluated) {
if (!attachedProjectsEvaluated) {
project.gradle.projectsEvaluated{
postProcessProjects(it)
}
@@ -102,7 +99,7 @@ class MergePlugin implements Plugin<Project> {
// invoking a task will invoke the task with the same name on 'into' project
["sourcesJar", "jar", "javadocJar", "javadoc", "install", "artifactoryPublish"].each {
def task = project.tasks.findByPath(it)
if(task) {
if (task) {
task.enabled = false
task.dependsOn(project.merge.into.tasks.findByPath(it))
}
@@ -120,7 +117,7 @@ class MergePlugin implements Plugin<Project> {
private void setupMaven(Project project) {
project.configurations.each { configuration ->
Conf2ScopeMapping mapping = project.conf2ScopeMappings.getMapping([configuration])
if(mapping.scope) {
if (mapping.scope) {
Configuration intoConfiguration = project.merge.into.configurations.create(
project.name + "-" + configuration.name)
configuration.excludeRules.each {
@@ -131,7 +128,7 @@ class MergePlugin implements Plugin<Project> {
configuration.dependencies.each {
def intoCompile = project.merge.into.configurations.getByName("compile")
// Protect against changing a compile scope dependency (SPR-10218)
if(!intoCompile.dependencies.contains(it)) {
if (!intoCompile.dependencies.contains(it)) {
intoConfiguration.dependencies.add(it)
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@ import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ProjectDependency;
/**
* Gradle plugin that automatically updates testCompile dependencies to include
* the test source sets of project dependencies.
@@ -43,9 +42,9 @@ class TestSourceSetDependenciesPlugin implements Plugin<Project> {
private void collectProjectDependencies(Set<ProjectDependency> projectDependencies,
Project project) {
for(def configurationName in ["compile", "optional", "provided", "testCompile"]) {
for (def configurationName in ["compile", "optional", "provided", "testCompile"]) {
Configuration configuration = project.getConfigurations().findByName(configurationName)
if(configuration) {
if (configuration) {
configuration.dependencies.findAll { it instanceof ProjectDependency }.each {
projectDependencies.add(it)
collectProjectDependencies(projectDependencies, it.dependencyProject)

View File

@@ -215,8 +215,10 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
// is type-compatible. Note that we can't help if the target sets
// a reference to itself in another returned object.
retVal = proxy;
} else if (retVal == null && returnType != Void.TYPE && returnType.isPrimitive()) {
throw new AopInvocationException("Null return value from advice does not match primitive return type for: " + method);
}
else if (retVal == null && returnType != Void.TYPE && returnType.isPrimitive()) {
throw new AopInvocationException(
"Null return value from advice does not match primitive return type for: " + method);
}
return retVal;
}

View File

@@ -258,7 +258,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
return returnValue;
}
catch (Throwable ex) {
if(stopWatch.isRunning()) {
if (stopWatch.isRunning()) {
stopWatch.stop();
}
exitThroughException = true;
@@ -268,7 +268,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
}
finally {
if (!exitThroughException) {
if(stopWatch.isRunning()) {
if (stopWatch.isRunning()) {
stopWatch.stop();
}
writeToLog(logger,

View File

@@ -46,7 +46,7 @@ public abstract aspect AbstractDependencyInjectionAspect {
* Select join points in beans to be configured prior to construction?
* By default, use post-construction injection matching the default in the Configurable annotation.
*/
public pointcut preConstructionConfiguration() : if(false);
public pointcut preConstructionConfiguration() : if (false);
/**
* Select the most-specific initialization join point
@@ -54,7 +54,7 @@ public abstract aspect AbstractDependencyInjectionAspect {
*/
@CodeGenerationHint(ifNameSuffix="6f1")
public pointcut mostSpecificSubTypeConstruction() :
if(thisJoinPoint.getSignature().getDeclaringType() == thisJoinPoint.getThis().getClass());
if (thisJoinPoint.getSignature().getDeclaringType() == thisJoinPoint.getThis().getClass());
/**
* Select least specific super type that is marked for DI (so that injection occurs only once with pre-construction inejection

View File

@@ -79,7 +79,7 @@ public aspect AnnotationBeanConfigurerAspect
* An intermediary to match preConstructionConfiguration signature (that doesn't expose the annotation object)
*/
@CodeGenerationHint(ifNameSuffix="bb0")
private pointcut preConstructionConfigurationSupport(Configurable c) : @this(c) && if(c.preConstruction());
private pointcut preConstructionConfigurationSupport(Configurable c) : @this(c) && if (c.preConstruction());
/*
* This declaration shouldn't be needed,

View File

@@ -398,7 +398,8 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
if (pd.getReadMethod() != null || pd.getWriteMethod() != null) {
return TypeDescriptor.nested(property(pd), tokens.keys.length);
}
} else {
}
else {
if (pd.getReadMethod() != null || pd.getWriteMethod() != null) {
return new TypeDescriptor(property(pd));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -172,7 +172,8 @@ final class PropertyMatches {
char t_j = s2.charAt(j - 1);
if (s_i == t_j) {
cost = 0;
} else {
}
else {
cost = 1;
}
d[i][j] = Math.min(Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1),

View File

@@ -296,12 +296,12 @@ class TypeConverterDelegate {
convertedValue = enumField.get(null);
}
catch (ClassNotFoundException ex) {
if(logger.isTraceEnabled()) {
if (logger.isTraceEnabled()) {
logger.trace("Enum class [" + enumType + "] cannot be loaded", ex);
}
}
catch (Throwable ex) {
if(logger.isTraceEnabled()) {
if (logger.isTraceEnabled()) {
logger.trace("Field [" + fieldName + "] isn't an enum value for type [" + enumType + "]", ex);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -277,7 +277,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
@Override
public boolean containsSingleton(String beanName) {
return (this.singletonObjects.containsKey(beanName));
return this.singletonObjects.containsKey(beanName);
}
@Override
@@ -330,8 +330,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
* @see #isSingletonCurrentlyInCreation
*/
protected void beforeSingletonCreation(String beanName) {
if (!this.inCreationCheckExclusions.contains(beanName) &&
!this.singletonsCurrentlyInCreation.add(beanName)) {
if (!this.inCreationCheckExclusions.contains(beanName) && !this.singletonsCurrentlyInCreation.add(beanName)) {
throw new BeanCurrentlyInCreationException(beanName);
}
}
@@ -343,8 +342,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
* @see #isSingletonCurrentlyInCreation
*/
protected void afterSingletonCreation(String beanName) {
if (!this.inCreationCheckExclusions.contains(beanName) &&
!this.singletonsCurrentlyInCreation.remove(beanName)) {
if (!this.inCreationCheckExclusions.contains(beanName) && !this.singletonsCurrentlyInCreation.remove(beanName)) {
throw new IllegalStateException("Singleton '" + beanName + "' isn't currently in creation");
}
}

View File

@@ -149,7 +149,7 @@ public abstract class AbstractSimpleBeanDefinitionParser extends AbstractSingleB
*/
protected boolean isEligibleAttribute(Attr attribute, ParserContext parserContext) {
boolean eligible = isEligibleAttribute(attribute);
if(!eligible) {
if (!eligible) {
String fullName = attribute.getName();
eligible = (!fullName.equals("xmlns") && !fullName.startsWith("xmlns:") &&
isEligibleAttribute(parserContext.getDelegate().getLocalName(attribute)));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,29 +13,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.beans.factory.xml;
import java.util.Collection;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
import org.springframework.core.Conventions;
import org.springframework.util.StringUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.core.Conventions;
import org.springframework.util.StringUtils;
/**
* Simple {@code NamespaceHandler} implementation that maps custom
* attributes directly through to bean properties. An important point to note is
* that this {@code NamespaceHandler} does not have a corresponding schema
* since there is no way to know in advance all possible attribute names.
*
* <p>
* An example of the usage of this {@code NamespaceHandler} is shown below:
* <p>An example of the usage of this {@code NamespaceHandler} is shown below:
*
* <pre class="code">
* &lt;bean id=&quot;author&quot; class=&quot;..TestBean&quot; c:name=&quot;Enescu&quot; c:work-ref=&quot;compositions&quot;/&gt;
@@ -51,14 +52,17 @@ import org.w3c.dom.Node;
* support for indexes or types. Further more, the names are used as hints by
* the container which, by default, does type introspection.
*
* @see SimplePropertyNamespaceHandler
* @author Costin Leau
* @since 3.1
* @see SimplePropertyNamespaceHandler
*/
public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
private static final String REF_SUFFIX = "-ref";
private static final String DELIMITER_PREFIX = "_";
@Override
public void init() {
}
@@ -102,7 +106,8 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
int index = -1;
try {
index = Integer.parseInt(arg);
} catch (NumberFormatException ex) {
}
catch (NumberFormatException ex) {
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' specifies an invalid integer", attr);
}
@@ -136,11 +141,8 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
}
private boolean containsArgWithName(String name, ConstructorArgumentValues cvs) {
if (!checkName(name, cvs.getGenericArgumentValues())) {
return checkName(name, cvs.getIndexedArgumentValues().values());
}
return true;
return (checkName(name, cvs.getGenericArgumentValues()) ||
checkName(name, cvs.getIndexedArgumentValues().values()));
}
private boolean checkName(String name, Collection<ValueHolder> values) {
@@ -151,4 +153,5 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
}
return false;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,13 +16,13 @@
package org.springframework.beans.propertyeditors;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import java.beans.PropertyEditorSupport;
import java.util.Locale;
import java.util.ResourceBundle;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* {@link java.beans.PropertyEditor} implementation for
* {@link java.util.ResourceBundle ResourceBundles}.
@@ -87,7 +87,8 @@ public class ResourceBundleEditor extends PropertyEditorSupport {
int indexOfBaseNameSeparator = rawBaseName.indexOf(BASE_NAME_SEPARATOR);
if (indexOfBaseNameSeparator == -1) {
bundle = ResourceBundle.getBundle(rawBaseName);
} else {
}
else {
// it potentially has locale information
String baseName = rawBaseName.substring(0, indexOfBaseNameSeparator);
if (!StringUtils.hasText(baseName)) {

View File

@@ -311,7 +311,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
* reference into the JobDataMap but rather into the SchedulerContext.
* @param schedulerContextAsMap Map with String keys and any objects as
* values (for example Spring-managed beans)
* @see JobDetailBean#setJobDataAsMap
* @see JobDetailFactoryBean#setJobDataAsMap
*/
public void setSchedulerContextAsMap(Map<String, ?> schedulerContextAsMap) {
this.schedulerContextMap = schedulerContextAsMap;
@@ -329,8 +329,8 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
* correspond to a "setApplicationContext" method in that scenario.
* <p>Note that BeanFactory callback interfaces like ApplicationContextAware
* are not automatically applied to Quartz Job instances, because Quartz
* itself is reponsible for the lifecycle of its Jobs.
* @see JobDetailBean#setApplicationContextJobDataKey
* itself is responsible for the lifecycle of its Jobs.
* @see JobDetailFactoryBean#setApplicationContextJobDataKey
* @see org.springframework.context.ApplicationContext
*/
public void setApplicationContextSchedulerContextKey(String applicationContextSchedulerContextKey) {

View File

@@ -20,6 +20,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.TypedStringValue;
import org.springframework.beans.factory.parsing.ReaderContext;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -37,7 +39,6 @@ import org.springframework.cache.interceptor.CacheableOperation;
import org.springframework.cache.interceptor.NameMatchCacheOperationSource;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
/**
* {@link org.springframework.beans.factory.xml.BeanDefinitionParser
@@ -74,7 +75,8 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
// Using attributes source.
List<RootBeanDefinition> attributeSourceDefinitions = parseDefinitionsSources(cacheDefs, parserContext);
builder.addPropertyValue("cacheOperationSources", attributeSourceDefinitions);
} else {
}
else {
// Assume annotations source.
builder.addPropertyValue("cacheOperationSources", new RootBeanDefinition(
AnnotationCacheOperationSource.class));
@@ -177,8 +179,6 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
/**
* Simple, reusable class used for overriding defaults.
*
* @author Costin Leau
*/
private static class Props {
@@ -190,7 +190,6 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
private String[] caches = null;
Props(Element root) {
String defaultCache = root.getAttribute("cache");
key = root.getAttribute("key");
@@ -202,7 +201,6 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
}
}
<T extends CacheOperation> T merge(Element element, ReaderContext readerCtx, T op) {
String cache = element.getAttribute("cache");
@@ -210,7 +208,8 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
String[] localCaches = caches;
if (StringUtils.hasText(cache)) {
localCaches = StringUtils.commaDelimitedListToStringArray(cache.trim());
} else {
}
else {
if (caches == null) {
readerCtx.error("No cache specified specified for " + element.getNodeName(), element);
}
@@ -224,16 +223,16 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
}
String merge(Element element, ReaderContext readerCtx) {
String m = element.getAttribute(METHOD_ATTRIBUTE);
if (StringUtils.hasText(m)) {
return m.trim();
}
String method = element.getAttribute(METHOD_ATTRIBUTE);
if (StringUtils.hasText(method)) {
return method;
return method.trim();
}
if (StringUtils.hasText(this.method)) {
return this.method;
}
readerCtx.error("No method specified for " + element.getNodeName(), element);
return null;
}
}
}

View File

@@ -13,13 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.format;
import java.lang.annotation.Annotation;
import java.util.Set;
/**
* A factory that creates formatters to format values of fields annotated with a particular {@link Annotation}.
* A factory that creates formatters to format values of fields annotated with a particular
* {@link Annotation}.
*
* <p>For example, a {@code DateTimeFormatAnnotationFormatterFactory} might create a formatter
* that formats {@code Date} values set on fields annotated with {@code @DateTimeFormat}.
@@ -36,8 +38,10 @@ public interface AnnotationFormatterFactory<A extends Annotation> {
Set<Class<?>> getFieldTypes();
/**
* Get the Printer to print the value of a field of {@code fieldType} annotated with {@code annotation}.
* If the type &lt;T&gt; the printer accepts is not assignable to {@code fieldType}, a coercion from {@code fieldType} to &lt;T&gt; will be attempted before the Printer is invoked.
* Get the Printer to print the value of a field of {@code fieldType} annotated with
* {@code annotation}.
* <p>If the type T the printer accepts is not assignable to {@code fieldType}, a
* coercion from {@code fieldType} to T will be attempted before the Printer is invoked.
* @param annotation the annotation instance
* @param fieldType the type of field that was annotated
* @return the printer
@@ -45,8 +49,10 @@ public interface AnnotationFormatterFactory<A extends Annotation> {
Printer<?> getPrinter(A annotation, Class<?> fieldType);
/**
* Get the Parser to parse a submitted value for a field of {@code fieldType} annotated with {@code annotation}.
* If the object the parser returns is not assignable to {@code fieldType}, a coercion to {@code fieldType} will be attempted before the field is set.
* Get the Parser to parse a submitted value for a field of {@code fieldType}
* annotated with {@code annotation}.
* <p>If the object the parser returns is not assignable to {@code fieldType},
* a coercion to {@code fieldType} will be attempted before the field is set.
* @param annotation the annotation instance
* @param fieldType the type of field that was annotated
* @return the parser

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -90,7 +90,7 @@ public class FormattingConversionService extends GenericConversionService
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void addFormatterForFieldAnnotation(AnnotationFormatterFactory annotationFormatterFactory) {
final Class<? extends Annotation> annotationType = (Class<? extends Annotation>)
Class<? extends Annotation> annotationType = (Class<? extends Annotation>)
GenericTypeResolver.resolveTypeArgument(annotationFormatterFactory.getClass(), AnnotationFormatterFactory.class);
if (annotationType == null) {
throw new IllegalArgumentException("Unable to extract parameterized Annotation type argument from AnnotationFormatterFactory [" +
@@ -100,7 +100,7 @@ public class FormattingConversionService extends GenericConversionService
((EmbeddedValueResolverAware) annotationFormatterFactory).setEmbeddedValueResolver(this.embeddedValueResolver);
}
Set<Class<?>> fieldTypes = annotationFormatterFactory.getFieldTypes();
for (final Class<?> fieldType : fieldTypes) {
for (Class<?> fieldType : fieldTypes) {
addConverter(new AnnotationPrinterConverter(annotationType, annotationFormatterFactory, fieldType));
addConverter(new AnnotationParserConverter(annotationType, annotationFormatterFactory, fieldType));
}
@@ -109,14 +109,14 @@ public class FormattingConversionService extends GenericConversionService
private static class PrinterConverter implements GenericConverter {
private Class<?> fieldType;
private final Class<?> fieldType;
private TypeDescriptor printerObjectType;
private final TypeDescriptor printerObjectType;
@SuppressWarnings("rawtypes")
private Printer printer;
private final Printer printer;
private ConversionService conversionService;
private final ConversionService conversionService;
public PrinterConverter(Class<?> fieldType, Printer<?> printer, ConversionService conversionService) {
this.fieldType = fieldType;
@@ -155,11 +155,11 @@ public class FormattingConversionService extends GenericConversionService
private static class ParserConverter implements GenericConverter {
private Class<?> fieldType;
private final Class<?> fieldType;
private Parser<?> parser;
private final Parser<?> parser;
private ConversionService conversionService;
private final ConversionService conversionService;
public ParserConverter(Class<?> fieldType, Parser<?> parser, ConversionService conversionService) {
this.fieldType = fieldType;
@@ -204,12 +204,12 @@ public class FormattingConversionService extends GenericConversionService
private class AnnotationPrinterConverter implements ConditionalGenericConverter {
private Class<? extends Annotation> annotationType;
private final Class<? extends Annotation> annotationType;
@SuppressWarnings("rawtypes")
private AnnotationFormatterFactory annotationFormatterFactory;
private final AnnotationFormatterFactory annotationFormatterFactory;
private Class<?> fieldType;
private final Class<?> fieldType;
public AnnotationPrinterConverter(Class<? extends Annotation> annotationType,
AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {
@@ -220,24 +220,24 @@ public class FormattingConversionService extends GenericConversionService
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(fieldType, String.class));
return Collections.singleton(new ConvertiblePair(this.fieldType, String.class));
}
@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
return sourceType.hasAnnotation(annotationType);
return sourceType.hasAnnotation(this.annotationType);
}
@Override
@SuppressWarnings("unchecked")
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
AnnotationConverterKey converterKey =
new AnnotationConverterKey(sourceType.getAnnotation(annotationType), sourceType.getObjectType());
new AnnotationConverterKey(sourceType.getAnnotation(this.annotationType), sourceType.getObjectType());
GenericConverter converter = cachedPrinters.get(converterKey);
if (converter == null) {
Printer<?> printer = annotationFormatterFactory.getPrinter(
Printer<?> printer = this.annotationFormatterFactory.getPrinter(
converterKey.getAnnotation(), converterKey.getFieldType());
converter = new PrinterConverter(fieldType, printer, FormattingConversionService.this);
converter = new PrinterConverter(this.fieldType, printer, FormattingConversionService.this);
cachedPrinters.put(converterKey, converter);
}
return converter.convert(source, sourceType, targetType);
@@ -245,20 +245,20 @@ public class FormattingConversionService extends GenericConversionService
@Override
public String toString() {
return "@" + annotationType.getName() + " " + fieldType.getName() + " -> " +
String.class.getName() + ": " + annotationFormatterFactory;
return "@" + this.annotationType.getName() + " " + this.fieldType.getName() + " -> " +
String.class.getName() + ": " + this.annotationFormatterFactory;
}
}
private class AnnotationParserConverter implements ConditionalGenericConverter {
private Class<? extends Annotation> annotationType;
private final Class<? extends Annotation> annotationType;
@SuppressWarnings("rawtypes")
private AnnotationFormatterFactory annotationFormatterFactory;
private final AnnotationFormatterFactory annotationFormatterFactory;
private Class<?> fieldType;
private final Class<?> fieldType;
public AnnotationParserConverter(Class<? extends Annotation> annotationType,
AnnotationFormatterFactory<?> annotationFormatterFactory, Class<?> fieldType) {
@@ -274,19 +274,19 @@ public class FormattingConversionService extends GenericConversionService
@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
return targetType.hasAnnotation(annotationType);
return targetType.hasAnnotation(this.annotationType);
}
@Override
@SuppressWarnings("unchecked")
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
AnnotationConverterKey converterKey =
new AnnotationConverterKey(targetType.getAnnotation(annotationType), targetType.getObjectType());
new AnnotationConverterKey(targetType.getAnnotation(this.annotationType), targetType.getObjectType());
GenericConverter converter = cachedParsers.get(converterKey);
if (converter == null) {
Parser<?> parser = annotationFormatterFactory.getParser(
Parser<?> parser = this.annotationFormatterFactory.getParser(
converterKey.getAnnotation(), converterKey.getFieldType());
converter = new ParserConverter(fieldType, parser, FormattingConversionService.this);
converter = new ParserConverter(this.fieldType, parser, FormattingConversionService.this);
cachedParsers.put(converterKey, converter);
}
return converter.convert(source, sourceType, targetType);
@@ -294,8 +294,8 @@ public class FormattingConversionService extends GenericConversionService
@Override
public String toString() {
return String.class.getName() + " -> @" + annotationType.getName() + " " +
fieldType.getName() + ": " + annotationFormatterFactory;
return String.class.getName() + " -> @" + this.annotationType.getName() + " " +
this.fieldType.getName() + ": " + this.annotationFormatterFactory;
}
}
@@ -312,25 +312,28 @@ public class FormattingConversionService extends GenericConversionService
}
public Annotation getAnnotation() {
return annotation;
return this.annotation;
}
public Class<?> getFieldType() {
return fieldType;
return this.fieldType;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof AnnotationConverterKey)) {
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationConverterKey)) {
return false;
}
AnnotationConverterKey key = (AnnotationConverterKey) o;
return this.annotation.equals(key.annotation) && this.fieldType.equals(key.fieldType);
AnnotationConverterKey otherKey = (AnnotationConverterKey) other;
return (this.annotation.equals(otherKey.annotation) && this.fieldType.equals(otherKey.fieldType));
}
@Override
public int hashCode() {
return this.annotation.hashCode() + 29 * this.fieldType.hashCode();
return (this.annotation.hashCode() + 29 * this.fieldType.hashCode());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,32 +39,38 @@ class WebLogicClassPreProcessorAdapter implements InvocationHandler {
private final ClassLoader loader;
/**
* Creates a new {@link WebLogicClassPreProcessorAdapter}.
* @param transformer the {@link ClassFileTransformer} to be adapted (must
* not be {@code null})
* @param transformer the {@link ClassFileTransformer} to be adapted
* (must not be {@code null})
*/
public WebLogicClassPreProcessorAdapter(ClassFileTransformer transformer, ClassLoader loader) {
this.transformer = transformer;
this.loader = loader;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
String name = method.getName();
if ("equals".equals(name)) {
return (Boolean.valueOf(proxy == args[0]));
} else if ("hashCode".equals(name)) {
return (proxy == args[0]);
}
else if ("hashCode".equals(name)) {
return hashCode();
} else if ("toString".equals(name)) {
}
else if ("toString".equals(name)) {
return toString();
} else if ("initialize".equals(name)) {
}
else if ("initialize".equals(name)) {
initialize((Hashtable<?, ?>) args[0]);
return null;
} else if ("preProcess".equals(name)) {
}
else if ("preProcess".equals(name)) {
return preProcess((String) args[0], (byte[]) args[1]);
} else {
}
else {
throw new IllegalArgumentException("Unknown method: " + method);
}
}
@@ -76,16 +82,15 @@ class WebLogicClassPreProcessorAdapter implements InvocationHandler {
try {
byte[] result = this.transformer.transform(this.loader, className, null, null, classBytes);
return (result != null ? result : classBytes);
} catch (IllegalClassFormatException ex) {
}
catch (IllegalClassFormatException ex) {
throw new IllegalStateException("Cannot transform due to illegal class format", ex);
}
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder(getClass().getName());
builder.append(" for transformer: ");
builder.append(this.transformer);
return builder.toString();
return getClass().getName() + " for transformer: " + this.transformer;
}
}

View File

@@ -149,7 +149,7 @@ public class AnnotationJmxAttributeSource implements JmxAttributeSource, BeanFac
@Override
public ManagedNotification[] getManagedNotifications(Class<?> clazz) throws InvalidMetadataException {
ManagedNotifications notificationsAnn = clazz.getAnnotation(ManagedNotifications.class);
if(notificationsAnn == null) {
if (notificationsAnn == null) {
return new ManagedNotification[0];
}
Annotation[] notifications = notificationsAnn.value();

View File

@@ -514,7 +514,7 @@ public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBean
MBeanParameterInfo[] info = new MBeanParameterInfo[paramNames.length];
Class<?>[] typeParameters = method.getParameterTypes();
for(int i = 0; i < info.length; i++) {
for (int i = 0; i < info.length; i++) {
info[i] = new MBeanParameterInfo(paramNames[i], typeParameters[i].getName(), paramNames[i]);
}

View File

@@ -153,7 +153,7 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
protected boolean includeOperation(Method method, String beanKey) {
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
if (pd != null) {
if(hasManagedAttribute(method)) {
if (hasManagedAttribute(method)) {
return true;
}
}
@@ -334,7 +334,7 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
*/
@Override
protected void populateAttributeDescriptor(Descriptor desc, Method getter, Method setter, String beanKey) {
if(getter != null && hasManagedMetric(getter)) {
if (getter != null && hasManagedMetric(getter)) {
populateMetricDescriptor(desc, this.attributeSource.getManagedMetric(getter));
}
else {
@@ -376,11 +376,11 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
desc.setField(FIELD_DISPLAY_NAME, metric.getDisplayName());
}
if(StringUtils.hasLength(metric.getUnit())) {
if (StringUtils.hasLength(metric.getUnit())) {
desc.setField(FIELD_UNITS, metric.getUnit());
}
if(StringUtils.hasLength(metric.getCategory())) {
if (StringUtils.hasLength(metric.getCategory())) {
desc.setField(FIELD_METRIC_CATEGORY, metric.getCategory());
}

View File

@@ -247,7 +247,7 @@ public class DefaultMessageCodesResolver implements MessageCodesResolver, Serial
public static String toDelimitedString(String... elements) {
StringBuilder rtn = new StringBuilder();
for (String element : elements) {
if(StringUtils.hasLength(element)) {
if (StringUtils.hasLength(element)) {
rtn.append(rtn.length() == 0 ? "" : CODE_SEPARATOR);
rtn.append(element);
}

View File

@@ -83,7 +83,7 @@ public class MethodValidationPostProcessor extends AbstractAdvisingBeanPostProce
* <p>Default is the default ValidatorFactory's default Validator.
*/
public void setValidator(Validator validator) {
if(validator instanceof LocalValidatorFactoryBean) {
if (validator instanceof LocalValidatorFactoryBean) {
this.validator = ((LocalValidatorFactoryBean) validator).getValidator();
}
else {

View File

@@ -155,7 +155,7 @@ abstract class SerializableTypeWrapper {
return provider.getType();
}
Type cached = cache.get(provider.getType());
if(cached != null) {
if (cached != null) {
return cached;
}
for (Class<?> type : SUPPORTED_SERIALIZABLE_TYPES) {

View File

@@ -118,7 +118,7 @@ public final class Property {
}
Annotation[] getAnnotations() {
if(this.annotations == null) {
if (this.annotations == null) {
this.annotations = resolveAnnotations();
}
return this.annotations;
@@ -192,7 +192,7 @@ public final class Property {
private Annotation[] resolveAnnotations() {
Annotation[] annotations = annotationCache.get(this);
if(annotations == null) {
if (annotations == null) {
Map<Class<? extends Annotation>, Annotation> annotationMap = new LinkedHashMap<Class<? extends Annotation>, Annotation>();
addAnnotationsToMap(annotationMap, getReadMethod());
addAnnotationsToMap(annotationMap, getWriteMethod());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,11 +40,13 @@ final class ArrayToArrayConverter implements ConditionalGenericConverter {
private final ConversionService conversionService;
public ArrayToArrayConverter(ConversionService conversionService) {
this.helperConverter = new CollectionToArrayConverter(conversionService);
this.conversionService = conversionService;
}
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(Object[].class, Object[].class));
@@ -56,12 +58,10 @@ final class ArrayToArrayConverter implements ConditionalGenericConverter {
}
@Override
public Object convert(Object source, TypeDescriptor sourceType,
TypeDescriptor targetType) {
if ((conversionService instanceof GenericConversionService)
&& ((GenericConversionService) conversionService).canBypassConvert(
sourceType.getElementTypeDescriptor(),
targetType.getElementTypeDescriptor())) {
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
if (this.conversionService instanceof GenericConversionService &&
((GenericConversionService) this.conversionService).canBypassConvert(
sourceType.getElementTypeDescriptor(), targetType.getElementTypeDescriptor())) {
return source;
}
List<Object> sourceList = Arrays.asList(ObjectUtils.toObjectArray(source));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,8 @@ import org.springframework.util.ObjectUtils;
/**
* Converts an Array to a comma-delimited String.
* This implementation first adapts the source Array to a List, then delegates to {@link CollectionToStringConverter} to perform the target String conversion.
* This implementation first adapts the source Array to a List,
* then delegates to {@link CollectionToStringConverter} to perform the target String conversion.
*
* @author Keith Donald
* @since 3.0
@@ -36,10 +37,12 @@ final class ArrayToStringConverter implements ConditionalGenericConverter {
private final CollectionToStringConverter helperConverter;
public ArrayToStringConverter(ConversionService conversionService) {
this.helperConverter = new CollectionToStringConverter(conversionService);
}
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(Object[].class, String.class));

View File

@@ -78,7 +78,7 @@ final class MapToMapConverter implements ConditionalGenericConverter {
copyRequired = true;
}
}
if(!copyRequired) {
if (!copyRequired) {
return sourceMap;
}
Map<Object, Object> targetMap = CollectionFactory.createMap(targetType.getType(), sourceMap.size());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,8 @@ import org.springframework.util.StringUtils;
/**
* Converts a comma-delimited String to a Collection.
* If the target collection element type is declared, only matches if String.class can be converted to it.
* If the target collection element type is declared, only matches if
* {@code String.class} can be converted to it.
*
* @author Keith Donald
* @since 3.0
@@ -37,10 +38,12 @@ final class StringToCollectionConverter implements ConditionalGenericConverter {
private final ConversionService conversionService;
public StringToCollectionConverter(ConversionService conversionService) {
this.conversionService = conversionService;
}
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(String.class, Collection.class));
@@ -48,11 +51,8 @@ final class StringToCollectionConverter implements ConditionalGenericConverter {
@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
if (targetType.getElementTypeDescriptor() != null) {
return this.conversionService.canConvert(sourceType, targetType.getElementTypeDescriptor());
} else {
return true;
}
return (targetType.getElementTypeDescriptor() == null ||
this.conversionService.canConvert(sourceType, targetType.getElementTypeDescriptor()));
}
@Override
@@ -67,7 +67,8 @@ final class StringToCollectionConverter implements ConditionalGenericConverter {
for (String field : fields) {
target.add(field.trim());
}
} else {
}
else {
for (String field : fields) {
Object targetElement = this.conversionService.convert(field.trim(), sourceType, targetType.getElementTypeDescriptor());
target.add(targetElement);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.springframework.core.convert.support;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterFactory;
import org.springframework.util.Assert;
/**
* Converts from a String to a java.lang.Enum by calling {@link Enum#valueOf(Class, String)}.
@@ -32,14 +31,16 @@ final class StringToEnumConverterFactory implements ConverterFactory<String, Enu
@Override
public <T extends Enum> Converter<String, T> getConverter(Class<T> targetType) {
Class<?> enumType = targetType;
while(enumType != null && !enumType.isEnum()) {
while (enumType != null && !enumType.isEnum()) {
enumType = enumType.getSuperclass();
}
Assert.notNull(enumType, "The target type " + targetType.getName()
+ " does not refer to an enum");
if (enumType == null) {
throw new IllegalArgumentException("The target type " + targetType.getName() + " does not refer to an enum");
}
return new StringToEnum(enumType);
}
private class StringToEnum<T extends Enum> implements Converter<String, T> {
private final Class<T> enumType;

View File

@@ -31,7 +31,7 @@ final class StringToUUIDConverter implements Converter<String, UUID> {
@Override
public UUID convert(String source) {
if(StringUtils.hasLength(source)) {
if (StringUtils.hasLength(source)) {
return UUID.fromString(source.trim());
}
return null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -129,7 +129,7 @@ public abstract class AbstractResource implements Resource {
long size = 0;
byte[] buf = new byte[255];
int read;
while((read = is.read(buf)) != -1) {
while ((read = is.read(buf)) != -1) {
size += read;
}
return size;

View File

@@ -155,7 +155,7 @@ public abstract class ObjectUtils {
*/
public static <E extends Enum<?>> E caseInsensitiveValueOf(E[] enumValues, String constant) {
for (E candidate : enumValues) {
if(candidate.toString().equalsIgnoreCase(constant)) {
if (candidate.toString().equalsIgnoreCase(constant)) {
return candidate;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,25 +58,18 @@ public abstract class SocketUtils {
/**
* Although {@code SocketUtils} consists solely of static utility methods,
* this constructor is intentionally {@code public}.
*
* <h4>Rationale</h4>
*
* <p>Static methods from this class may be invoked from within XML
* configuration files using the Spring Expression Language (SpEL) and the
* following syntax.
*
* <pre><code>&lt;bean id="bean1" ... p:port="#{T(org.springframework.util.SocketUtils).findAvailableTcpPort(12000)}" /&gt;</code></pre>
*
* If this constructor were {@code private}, you would be required to supply
* the fully qualified class name to SpEL's {@code T()} function for each usage.
* Thus, the fact that this constructor is {@code public} allows you to reduce
* boilerplate configuration with SpEL as can be seen in the following example.
*
* <pre><code>&lt;bean id="socketUtils" class="org.springframework.util.SocketUtils" /&gt;
*
*&lt;bean id="bean1" ... p:port="#{socketUtils.findAvailableTcpPort(12000)}" /&gt;
*
*&lt;bean id="bean2" ... p:port="#{socketUtils.findAvailableTcpPort(30000)}" /&gt;</code></pre>
* &lt;bean id="bean1" ... p:port="#{socketUtils.findAvailableTcpPort(12000)}" /&gt;
* &lt;bean id="bean2" ... p:port="#{socketUtils.findAvailableTcpPort(30000)}" /&gt;</code></pre>
*/
public SocketUtils() {
/* no-op */
@@ -271,7 +264,8 @@ public abstract class SocketUtils {
maxPort, searchCounter));
}
candidatePort = findRandomPort(minPort, maxPort);
} while (!isPortAvailable(candidatePort));
}
while (!isPortAvailable(candidatePort));
return candidatePort;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -229,7 +229,8 @@ public class StopWatch {
sb.append('\n');
if (!this.keepTaskList) {
sb.append("No task info kept");
} else {
}
else {
sb.append("-----------------------------------------\n");
sb.append("ms % Task name\n");
sb.append("-----------------------------------------\n");
@@ -261,7 +262,8 @@ public class StopWatch {
long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
sb.append(" = ").append(percent).append("%");
}
} else {
}
else {
sb.append("; no task info kept");
}
return sb.toString();

View File

@@ -60,7 +60,7 @@ public class InstanceComparator<T> implements Comparator<T> {
}
private int getOrder(T object) {
if(object != null) {
if (object != null) {
for (int i = 0; i < instanceOrder.length; i++) {
if (instanceOrder[i].isInstance(object)) {
return i;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,10 +29,10 @@ import org.springframework.util.Assert;
* #get()} and {@link #get(long, TimeUnit)} call {@link #adapt(Object)} on the adaptee's
* result.
*
* @param <T> the type of this {@code Future}
* @param <S> the type of the adaptee's {@code Future}
* @author Arjen Poutsma
* @since 4.0
* @param <T> the type of this {@code Future}
* @param <S> the type of the adaptee's {@code Future}
*/
public abstract class FutureAdapter<T, S> implements Future<T> {
@@ -44,6 +44,7 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
private final Object mutex = new Object();
/**
* Constructs a new {@code FutureAdapter} with the given adaptee.
* @param adaptee the future to delegate to
@@ -53,6 +54,7 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
this.adaptee = adaptee;
}
/**
* Returns the adaptee.
*/
@@ -81,28 +83,28 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
}
@Override
public T get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return adaptInternal(adaptee.get(timeout, unit));
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
return adaptInternal(this.adaptee.get(timeout, unit));
}
@SuppressWarnings("unchecked")
final T adaptInternal(S adapteeResult) throws ExecutionException {
synchronized (mutex) {
switch (state) {
synchronized (this.mutex) {
switch (this.state) {
case SUCCESS:
return (T) result;
return (T) this.result;
case FAILURE:
throw (ExecutionException) result;
throw (ExecutionException) this.result;
case NEW:
try {
T adapted = adapt(adapteeResult);
result = adapted;
state = State.SUCCESS;
this.result = adapted;
this.state = State.SUCCESS;
return adapted;
} catch (ExecutionException ex) {
result = ex;
state = State.FAILURE;
}
catch (ExecutionException ex) {
this.result = ex;
this.state = State.FAILURE;
throw ex;
}
default:
@@ -117,6 +119,7 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
*/
protected abstract T adapt(S adapteeResult) throws ExecutionException;
private enum State {NEW, SUCCESS, FAILURE}
}

View File

@@ -316,13 +316,15 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
SpelNodeImpl expr = null;
if (peekToken(TokenKind.DOT,TokenKind.SAFE_NAVI)) {
expr = eatDottedNode();
} else {
}
else {
expr = maybeEatNonDottedNode();
}
if (expr==null) {
return false;
} else {
}
else {
push(expr);
return true;
}
@@ -572,7 +574,8 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
List<SpelNodeImpl> listElements = new ArrayList<SpelNodeImpl>();
do {
listElements.add(eatExpression());
} while (peekToken(TokenKind.COMMA,true));
}
while (peekToken(TokenKind.COMMA,true));
closingCurly = eatToken(TokenKind.RCURLY);
expr = new InlineList(toPos(t.startpos,closingCurly.endpos),listElements.toArray(new SpelNodeImpl[listElements.size()]));
@@ -599,7 +602,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
}
nextToken();
SpelNodeImpl expr = eatExpression();
if(expr == null) {
if (expr == null) {
raiseInternalException(toPos(t), SpelMessage.MISSING_SELECTION_EXPRESSION);
}
eatToken(TokenKind.RSQUARE);
@@ -624,13 +627,13 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
Token node = peekToken();
while (isValidQualifiedId(node)) {
nextToken();
if(node.kind != TokenKind.DOT) {
if (node.kind != TokenKind.DOT) {
qualifiedIdPieces.add(new Identifier(node.stringValue(),toPos(node)));
}
node = peekToken();
}
if(qualifiedIdPieces.isEmpty()) {
if(node == null) {
if (qualifiedIdPieces.isEmpty()) {
if (node == null) {
raiseInternalException( this.expressionString.length(), SpelMessage.OOD);
}
raiseInternalException(node.startpos, SpelMessage.NOT_EXPECTED_TOKEN,
@@ -641,10 +644,10 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
}
private boolean isValidQualifiedId(Token node) {
if(node == null || node.kind == TokenKind.LITERAL_STRING) {
if (node == null || node.kind == TokenKind.LITERAL_STRING) {
return false;
}
if(node.kind == TokenKind.DOT || node.kind == TokenKind.IDENTIFIER) {
if (node.kind == TokenKind.DOT || node.kind == TokenKind.IDENTIFIER) {
return true;
}
String value = node.stringValue();
@@ -667,9 +670,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
// TODO what is the end position for a method reference? the name or the last arg?
return true;
}
return false;
}
//constructor
@@ -784,7 +785,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
// | GREATER_THAN_OR_EQUAL | INSTANCEOF | BETWEEN | MATCHES
private Token maybeEatRelationalOperator() {
Token t = peekToken();
if (t==null) {
if (t == null) {
return null;
}
if (t.isNumericRelationalOperator()) {
@@ -807,10 +808,10 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
private Token eatToken(TokenKind expectedKind) {
Token t = nextToken();
if (t==null) {
if (t == null) {
raiseInternalException( this.expressionString.length(), SpelMessage.OOD);
}
if (t.kind!=expectedKind) {
if (t.kind != expectedKind) {
raiseInternalException(t.startpos,SpelMessage.NOT_EXPECTED_TOKEN, expectedKind.toString().toLowerCase(),t.getKind().toString().toLowerCase());
}
return t;
@@ -825,7 +826,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
return false;
}
Token t = peekToken();
if (t.kind==desiredTokenKind) {
if (t.kind == desiredTokenKind) {
if (consumeIfMatched) {
this.tokenStreamPointer++;
}
@@ -835,7 +836,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
if (desiredTokenKind == TokenKind.IDENTIFIER) {
// might be one of the textual forms of the operators (e.g. NE for != ) - in which case we can treat it as an identifier
// The list is represented here: Tokenizer.alternativeOperatorNames and those ones are in order in the TokenKind enum
if (t.kind.ordinal()>=TokenKind.DIV.ordinal() && t.kind.ordinal()<=TokenKind.NOT.ordinal() && t.data!=null) {
if (t.kind.ordinal() >= TokenKind.DIV.ordinal() && t.kind.ordinal() <= TokenKind.NOT.ordinal() && t.data != null) {
// if t.data were null, we'd know it wasn't the textual form, it was the symbol form
return true;
}
@@ -848,7 +849,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
return false;
}
Token t = peekToken();
return t.kind == possible1 || t.kind == possible2;
return (t.kind == possible1 || t.kind == possible2);
}
private boolean peekToken(TokenKind possible1,TokenKind possible2, TokenKind possible3) {
@@ -924,14 +925,14 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
}
/**
* Compress the start and end of a token into a single int
* Compress the start and end of a token into a single int.
*/
private int toPos(Token t) {
return (t.startpos<<16)+t.endpos;
return (t.startpos<<16) + t.endpos;
}
private int toPos(int start,int end) {
return (start<<16)+end;
return (start<<16) + end;
}
}

View File

@@ -117,7 +117,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
else if (isStoresUpperCaseIdentifiers()) {
return procedureName.toUpperCase();
}
else if(isStoresLowerCaseIdentifiers()) {
else if (isStoresLowerCaseIdentifiers()) {
return procedureName.toLowerCase();
}
else {
@@ -133,7 +133,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
else if (isStoresUpperCaseIdentifiers()) {
return catalogName.toUpperCase();
}
else if(isStoresLowerCaseIdentifiers()) {
else if (isStoresLowerCaseIdentifiers()) {
return catalogName.toLowerCase();
}
else {
@@ -149,7 +149,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
else if (isStoresUpperCaseIdentifiers()) {
return schemaName.toUpperCase();
}
else if(isStoresLowerCaseIdentifiers()) {
else if (isStoresLowerCaseIdentifiers()) {
return schemaName.toLowerCase();
}
else {
@@ -185,7 +185,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
else if (isStoresUpperCaseIdentifiers()) {
return parameterName.toUpperCase();
}
else if(isStoresLowerCaseIdentifiers()) {
else if (isStoresLowerCaseIdentifiers()) {
return parameterName.toLowerCase();
}
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -85,34 +85,23 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
}
/**
* Specify whether identifiers use upper case
*/
public void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers) {
this.storesUpperCaseIdentifiers = storesUpperCaseIdentifiers;
}
/**
* Get whether identifiers use upper case
*/
public boolean isStoresUpperCaseIdentifiers() {
return this.storesUpperCaseIdentifiers;
}
/**
* Specify whether identifiers use lower case.
*/
public void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers) {
this.storesLowerCaseIdentifiers = storesLowerCaseIdentifiers;
}
/**
* Get whether identifiers use lower case
*/
public boolean isStoresLowerCaseIdentifiers() {
return this.storesLowerCaseIdentifiers;
}
@Override
public boolean isTableColumnMetaDataUsed() {
return this.tableColumnMetaDataUsed;
@@ -138,16 +127,10 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
return null;
}
/**
* Specify whether a column name array is supported for generated keys
*/
public void setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported) {
this.getGeneratedKeysSupported = getGeneratedKeysSupported;
}
/**
* Specify whether a column name array is supported for generated keys
*/
public void setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported) {
this.generatedKeysColumnNameArraySupported = generatedKeysColumnNameArraySupported;
}
@@ -179,8 +162,8 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
setGetGeneratedKeysSupported(false);
}
}
catch (SQLException se) {
logger.warn("Error retrieving 'DatabaseMetaData.getGeneratedKeys' - " + se.getMessage());
catch (SQLException ex) {
logger.warn("Error retrieving 'DatabaseMetaData.getGeneratedKeys' - " + ex.getMessage());
}
try {
String databaseProductName = databaseMetaData.getDatabaseProductName();
@@ -198,26 +181,26 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
}
}
}
catch (SQLException se) {
logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductName' - " + se.getMessage());
catch (SQLException ex) {
logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductName' - " + ex.getMessage());
}
try {
this.databaseVersion = databaseMetaData.getDatabaseProductVersion();
}
catch (SQLException se) {
logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductVersion' - " + se.getMessage());
catch (SQLException ex) {
logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductVersion' - " + ex.getMessage());
}
try {
setStoresUpperCaseIdentifiers(databaseMetaData.storesUpperCaseIdentifiers());
}
catch (SQLException se) {
logger.warn("Error retrieving 'DatabaseMetaData.storesUpperCaseIdentifiers' - " + se.getMessage());
catch (SQLException ex) {
logger.warn("Error retrieving 'DatabaseMetaData.storesUpperCaseIdentifiers' - " + ex.getMessage());
}
try {
setStoresLowerCaseIdentifiers(databaseMetaData.storesLowerCaseIdentifiers());
}
catch (SQLException se) {
logger.warn("Error retrieving 'DatabaseMetaData.storesLowerCaseIdentifiers' - " + se.getMessage());
catch (SQLException ex) {
logger.warn("Error retrieving 'DatabaseMetaData.storesLowerCaseIdentifiers' - " + ex.getMessage());
}
}
@@ -238,7 +221,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
else if (isStoresUpperCaseIdentifiers()) {
return tableName.toUpperCase();
}
else if(isStoresLowerCaseIdentifiers()) {
else if (isStoresLowerCaseIdentifiers()) {
return tableName.toLowerCase();
}
else {
@@ -254,7 +237,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
else if (isStoresUpperCaseIdentifiers()) {
return catalogName.toUpperCase();
}
else if(isStoresLowerCaseIdentifiers()) {
else if (isStoresLowerCaseIdentifiers()) {
return catalogName.toLowerCase();
}
else {
@@ -270,7 +253,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
else if (isStoresUpperCaseIdentifiers()) {
return schemaName.toUpperCase();
}
else if(isStoresLowerCaseIdentifiers()) {
else if (isStoresLowerCaseIdentifiers()) {
return schemaName.toLowerCase();
}
else {
@@ -325,22 +308,23 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
tmd.setSchemaName(tables.getString("TABLE_SCHEM"));
tmd.setTableName(tables.getString("TABLE_NAME"));
if (tmd.getSchemaName() == null) {
tableMeta.put(userName != null ? userName.toUpperCase() : "", tmd);
tableMeta.put(this.userName != null ? this.userName.toUpperCase() : "", tmd);
}
else {
tableMeta.put(tmd.getSchemaName().toUpperCase(), tmd);
}
}
}
catch (SQLException se) {
logger.warn("Error while accessing table meta data results" + se.getMessage());
catch (SQLException ex) {
logger.warn("Error while accessing table meta data results" + ex.getMessage());
}
finally {
if (tables != null) {
try {
tables.close();
} catch (SQLException e) {
logger.warn("Error while closing table meta data results" + e.getMessage());
}
catch (SQLException ex) {
logger.warn("Error while closing table meta data results" + ex.getMessage());
}
}
}
@@ -431,16 +415,16 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
}
}
}
catch (SQLException se) {
logger.warn("Error while retrieving metadata for table columns: " + se.getMessage());
catch (SQLException ex) {
logger.warn("Error while retrieving metadata for table columns: " + ex.getMessage());
}
finally {
try {
if (tableColumns != null)
tableColumns.close();
}
catch (SQLException se) {
logger.warn("Problem closing ResultSet for table column metadata " + se.getMessage());
catch (SQLException ex) {
logger.warn("Problem closing ResultSet for table column metadata " + ex.getMessage());
}
}
@@ -458,7 +442,6 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
private String tableName;
public void setCatalogName(String catalogName) {
this.catalogName = catalogName;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -393,7 +393,7 @@ public class SingleConnectionFactory
/**
* Create a default Session for this ConnectionFactory,
* adaptign to JMS 1.0.2 style queue/topic mode if necessary.
* adapting to JMS 1.0.2 style queue/topic mode if necessary.
* @param con the JMS Connection to operate on
* @param mode the Session acknowledgement mode
* ({@code Session.TRANSACTED} or one of the common modes)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.beans.BeanWrapper;
/**
* Default implementation of the {@link JmsActivationSpecFactory} interface.
* Supports the standard JMS properties as defined by the JMS 1.5 specification,
* Supports the standard JMS properties as defined by the JCA 1.5 specification,
* as well as Spring's extended "maxConcurrency" and "prefetchSize" settings
* through autodetection of well-known vendor-specific provider properties.
*
@@ -158,7 +158,7 @@ public class DefaultJmsActivationSpecFactory extends StandardJmsActivationSpecFa
// JORAM
bw.setPropertyValue("maxMessages", Integer.toString(config.getPrefetchSize()));
}
else if(bw.isWritableProperty("maxBatchSize")){
else if (bw.isWritableProperty("maxBatchSize")){
// WebSphere
bw.setPropertyValue("maxBatchSize", Integer.toString(config.getPrefetchSize()));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -86,7 +86,7 @@ public abstract class JmsAccessor implements InitializingBean {
* <p>Setting this flag to "true" will use a short local JMS transaction
* when running outside of a managed transaction, and a synchronized local
* JMS transaction in case of a managed transaction (other than an XA
* transaction) being present. The latter has the effect of a local JMS
* transaction) being present. This has the effect of a local JMS
* transaction being managed alongside the main transaction (which might
* be a native JDBC transaction), with the JMS transaction committing
* right after the main transaction.
@@ -109,7 +109,7 @@ public abstract class JmsAccessor implements InitializingBean {
* Set the JMS acknowledgement mode by the name of the corresponding constant
* in the JMS {@link Session} interface, e.g. "CLIENT_ACKNOWLEDGE".
* <p>If you want to use vendor-specific extensions to the acknowledgment mode,
* use {@link #setSessionAcknowledgeModeName(String)} instead.
* use {@link #setSessionAcknowledgeMode(int)} instead.
* @param constantName the name of the {@link Session} acknowledge mode constant
* @see javax.jms.Session#AUTO_ACKNOWLEDGE
* @see javax.jms.Session#CLIENT_ACKNOWLEDGE
@@ -125,8 +125,8 @@ public abstract class JmsAccessor implements InitializingBean {
* {@link Session} to send a message.
* <p>Default is {@link Session#AUTO_ACKNOWLEDGE}.
* <p>Vendor-specific extensions to the acknowledgment mode can be set here as well.
* <p>Note that that inside an EJB the parameters to
* create(Queue/Topic)Session(boolean transacted, int acknowledgeMode) method
* <p>Note that that inside an EJB, the parameters to the
* {@code create(Queue/Topic)Session(boolean transacted, int acknowledgeMode)} method
* are not taken into account. Depending on the transaction context in the EJB,
* the container makes its own decisions on these values. See section 17.3.5
* of the EJB spec.

View File

@@ -94,7 +94,7 @@ public abstract class AbstractExceptionHandlerMethodResolver {
*/
private Method getMappedMethod(Class<? extends Exception> exceptionType) {
List<Class<? extends Throwable>> matches = new ArrayList<Class<? extends Throwable>>();
for(Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
for (Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
if (mappedException.isAssignableFrom(exceptionType)) {
matches.add(mappedException);
}

View File

@@ -39,7 +39,7 @@ import org.springframework.util.CollectionUtils;
* @since 4.0
*/
public abstract class AbstractBrokerMessageHandler
implements MessageHandler, SmartLifecycle, ApplicationEventPublisherAware {
implements MessageHandler, ApplicationEventPublisherAware, SmartLifecycle {
protected final Log logger = LogFactory.getLog(getClass());
@@ -51,10 +51,10 @@ public abstract class AbstractBrokerMessageHandler
private boolean autoStartup = true;
private Object lifecycleMonitor = new Object();
private volatile boolean running = false;
private final Object lifecycleMonitor = new Object();
public AbstractBrokerMessageHandler() {
this(Collections.<String>emptyList());
@@ -95,7 +95,6 @@ public abstract class AbstractBrokerMessageHandler
/**
* Check whether this message handler is currently running.
*
* <p>Note that even when this message handler is running the
* {@link #isBrokerAvailable()} flag may still independently alternate between
* being on and off depending on the concrete sub-class implementation.
@@ -107,23 +106,6 @@ public abstract class AbstractBrokerMessageHandler
}
}
/**
* Whether the message broker is currently available and able to process messages.
*
* <p>Note that this is in addition to the {@link #isRunning()} flag, which
* indicates whether this message handler is running. In other words the message
* handler must first be running and then the {@link #isBrokerAvailable()} flag
* may still independently alternate between being on and off depending on the
* concrete sub-class implementation.
*
* <p>Application components may implement
* {@link org.springframework.context.ApplicationListener<BrokerAvailabilityEvent>>}
* to receive notifications when broker becomes available and unavailable.
*/
public boolean isBrokerAvailable() {
return this.brokerAvailable.get();
}
@Override
public final void start() {
synchronized (this.lifecycleMonitor) {
@@ -166,6 +148,22 @@ public abstract class AbstractBrokerMessageHandler
}
}
/**
* Whether the message broker is currently available and able to process messages.
* <p>Note that this is in addition to the {@link #isRunning()} flag, which
* indicates whether this message handler is running. In other words the message
* handler must first be running and then the {@code #isBrokerAvailable()} flag
* may still independently alternate between being on and off depending on the
* concrete sub-class implementation.
* <p>Application components may implement
* {@code org.springframework.context.ApplicationListener&lt;BrokerAvailabilityEvent&gt;}
* to receive notifications when broker becomes available and unavailable.
*/
public boolean isBrokerAvailable() {
return this.brokerAvailable.get();
}
@Override
public final void handleMessage(Message<?> message) {
if (!this.running) {

View File

@@ -316,7 +316,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
public void addSubscription(String destination, String subscriptionId) {
Set<String> subs = this.subscriptions.get(destination);
if (subs == null) {
synchronized(this.monitor) {
synchronized (this.monitor) {
subs = this.subscriptions.get(destination);
if (subs == null) {
subs = new HashSet<String>(4);
@@ -331,7 +331,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
for (String destination : this.subscriptions.keySet()) {
Set<String> subscriptionIds = this.subscriptions.get(destination);
if (subscriptionIds.remove(subscriptionId)) {
synchronized(this.monitor) {
synchronized (this.monitor) {
if (subscriptionIds.isEmpty()) {
this.subscriptions.remove(destination);
}

View File

@@ -319,7 +319,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
protected Validator simpValidator() {
Validator validator = getValidator();
if (validator == null) {
if(this.applicationContext.containsBean(MVC_VALIDATOR_NAME)) {
if (this.applicationContext.containsBean(MVC_VALIDATOR_NAME)) {
validator = this.applicationContext.getBean(MVC_VALIDATOR_NAME, Validator.class);
}
else if (ClassUtils.isPresent("javax.validation.Validator", getClass().getClassLoader())) {

View File

@@ -192,7 +192,7 @@ public class StompBrokerRelayRegistration extends AbstractBrokerRegistration {
if (this.systemHeartbeatReceiveInterval != null) {
handler.setSystemHeartbeatReceiveInterval(this.systemHeartbeatReceiveInterval);
}
if(this.virtualHost != null) {
if (this.virtualHost != null) {
handler.setVirtualHost(this.virtualHost);
}

View File

@@ -535,7 +535,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
@Override
public void setStatus(int status) {
if(!this.isCommitted()) {
if (!this.isCommitted()) {
this.status = status;
}
}
@@ -543,7 +543,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
@Override
@Deprecated
public void setStatus(int status, String errorMessage) {
if(!this.isCommitted()) {
if (!this.isCommitted()) {
this.status = status;
this.errorMessage = errorMessage;
}

View File

@@ -78,6 +78,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
*/
protected abstract SmartContextLoader getAnnotationConfigLoader();
// --- SmartContextLoader --------------------------------------------------
private static String name(SmartContextLoader loader) {
@@ -94,6 +95,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
private static ApplicationContext delegateLoading(SmartContextLoader loader, MergedContextConfiguration mergedConfig)
throws Exception {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Delegating to %s to load context from %s.", name(loader), mergedConfig));
}
@@ -103,7 +105,8 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
private boolean supports(SmartContextLoader loader, MergedContextConfiguration mergedConfig) {
if (loader == getAnnotationConfigLoader()) {
return ObjectUtils.isEmpty(mergedConfig.getLocations()) && !ObjectUtils.isEmpty(mergedConfig.getClasses());
} else {
}
else {
return !ObjectUtils.isEmpty(mergedConfig.getLocations()) && ObjectUtils.isEmpty(mergedConfig.getClasses());
}
}
@@ -111,12 +114,10 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
/**
* Delegates to candidate {@code SmartContextLoaders} to process the supplied
* {@link ContextConfigurationAttributes}.
*
* <p>Delegation is based on explicit knowledge of the implementations of the
* default loaders for {@link #getXmlLoader() XML configuration files} and
* {@link #getAnnotationConfigLoader() annotated classes}. Specifically, the
* delegation algorithm is as follows:
*
* <ul>
* <li>If the resource locations or annotated classes in the supplied
* {@code ContextConfigurationAttributes} are not empty, the appropriate
@@ -131,7 +132,6 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
* If the annotation-based loader detects default configuration
* classes, an {@code info} message will be logged.</li>
* </ul>
*
* @param configAttributes the context configuration attributes to process
* @throws IllegalArgumentException if the supplied configuration attributes are
* {@code null}, or if the supplied configuration attributes include both
@@ -147,17 +147,19 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
Assert.notNull(configAttributes, "configAttributes must not be null");
Assert.isTrue(!(configAttributes.hasLocations() && configAttributes.hasClasses()), String.format(
"Cannot process locations AND classes for context "
+ "configuration %s; configure one or the other, but not both.", configAttributes));
"Cannot process locations AND classes for context configuration %s; configure one or the other, but not both.",
configAttributes));
// If the original locations or classes were not empty, there's no
// need to bother with default detection checks; just let the
// appropriate loader process the configuration.
if (configAttributes.hasLocations()) {
delegateProcessing(getXmlLoader(), configAttributes);
} else if (configAttributes.hasClasses()) {
}
else if (configAttributes.hasClasses()) {
delegateProcessing(getAnnotationConfigLoader(), configAttributes);
} else {
}
else {
// Else attempt to detect defaults...
// Let the XML loader process the configuration.
@@ -198,15 +200,15 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
// throw an exception.
if (!configAttributes.hasResources() && ObjectUtils.isEmpty(configAttributes.getInitializers())) {
throw new IllegalStateException(String.format(
"Neither %s nor %s was able to detect defaults, and no ApplicationContextInitializers "
+ "were declared for context configuration %s", name(getXmlLoader()),
"Neither %s nor %s was able to detect defaults, and no ApplicationContextInitializers " +
"were declared for context configuration %s", name(getXmlLoader()),
name(getAnnotationConfigLoader()), configAttributes));
}
if (configAttributes.hasLocations() && configAttributes.hasClasses()) {
String message = String.format(
"Configuration error: both default locations AND default configuration classes "
+ "were detected for context configuration %s; configure one or the other, but not both.",
"Configuration error: both default locations AND default configuration classes " +
"were detected for context configuration %s; configure one or the other, but not both.",
configAttributes);
logger.error(message);
throw new IllegalStateException(message);
@@ -217,12 +219,10 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
/**
* Delegates to an appropriate candidate {@code SmartContextLoader} to load
* an {@link ApplicationContext}.
*
* <p>Delegation is based on explicit knowledge of the implementations of the
* default loaders for {@link #getXmlLoader() XML configuration files} and
* {@link #getAnnotationConfigLoader() annotated classes}. Specifically, the
* delegation algorithm is as follows:
*
* <ul>
* <li>If the resource locations in the supplied {@code MergedContextConfiguration}
* are not empty and the annotated classes are empty,
@@ -231,7 +231,6 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
* are not empty and the resource locations are empty,
* the annotation-based loader will load the {@code ApplicationContext}.</li>
* </ul>
*
* @param mergedConfig the merged context configuration to use to load the application context
* @throws IllegalArgumentException if the supplied merged configuration is {@code null}
* @throws IllegalStateException if neither candidate loader is capable of loading an
@@ -240,7 +239,6 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
@Override
public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
Assert.notNull(mergedConfig, "mergedConfig must not be null");
List<SmartContextLoader> candidates = Arrays.asList(getXmlLoader(), getAnnotationConfigLoader());
for (SmartContextLoader loader : candidates) {
@@ -262,6 +260,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
name(getAnnotationConfigLoader()), mergedConfig));
}
// --- ContextLoader -------------------------------------------------------
/**
@@ -272,8 +271,8 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
*/
@Override
public final String[] processLocations(Class<?> clazz, String... locations) {
throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. "
+ "Call processContextConfiguration(ContextConfigurationAttributes) instead.");
throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. " +
"Call processContextConfiguration(ContextConfigurationAttributes) instead.");
}
/**
@@ -284,8 +283,8 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
*/
@Override
public final ApplicationContext loadContext(String... locations) throws Exception {
throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. "
+ "Call loadContext(MergedContextConfiguration) instead.");
throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. " +
"Call loadContext(MergedContextConfiguration) instead.");
}
}

View File

@@ -22,6 +22,7 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.SmartContextLoader;
import org.springframework.util.Assert;
@@ -38,45 +39,12 @@ public abstract class AnnotationConfigContextLoaderUtils {
private static final Log logger = LogFactory.getLog(AnnotationConfigContextLoaderUtils.class);
private AnnotationConfigContextLoaderUtils() {
/* no-op */
}
private static boolean isStaticNonPrivateAndNonFinal(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
int modifiers = clazz.getModifiers();
return (Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers) && !Modifier.isFinal(modifiers));
}
/**
* Determine if the supplied {@link Class} meets the criteria for being
* considered a <em>default configuration class</em> candidate.
*
* <p>Specifically, such candidates:
*
* <ul>
* <li>must not be {@code null}</li>
* <li>must not be {@code private}</li>
* <li>must not be {@code final}</li>
* <li>must be {@code static}</li>
* <li>must be annotated with {@code @Configuration}</li>
* </ul>
*
* @param clazz the class to check
* @return {@code true} if the supplied class meets the candidate criteria
*/
private static boolean isDefaultConfigurationClassCandidate(Class<?> clazz) {
return clazz != null && isStaticNonPrivateAndNonFinal(clazz) && clazz.isAnnotationPresent(Configuration.class);
}
/**
* Detect the default configuration classes for the supplied test class.
*
* <p>The returned class array will contain all static inner classes of
* the supplied class that meet the requirements for {@code @Configuration}
* class implementations as specified in the documentation for
* {@link Configuration @Configuration}.
*
* <p>The implementation of this method adheres to the contract defined in the
* {@link org.springframework.test.context.SmartContextLoader SmartContextLoader}
* SPI. Specifically, this method uses introspection to detect default
@@ -96,7 +64,8 @@ public abstract class AnnotationConfigContextLoaderUtils {
for (Class<?> candidate : declaringClass.getDeclaredClasses()) {
if (isDefaultConfigurationClassCandidate(candidate)) {
configClasses.add(candidate);
} else {
}
else {
if (logger.isDebugEnabled()) {
logger.debug(String.format(
"Ignoring class [%s]; it must be static, non-private, non-final, and annotated "
@@ -117,4 +86,28 @@ public abstract class AnnotationConfigContextLoaderUtils {
return configClasses.toArray(new Class<?>[configClasses.size()]);
}
/**
* Determine if the supplied {@link Class} meets the criteria for being
* considered a <em>default configuration class</em> candidate.
* <p>Specifically, such candidates:
* <ul>
* <li>must not be {@code null}</li>
* <li>must not be {@code private}</li>
* <li>must not be {@code final}</li>
* <li>must be {@code static}</li>
* <li>must be annotated with {@code @Configuration}</li>
* </ul>
* @param clazz the class to check
* @return {@code true} if the supplied class meets the candidate criteria
*/
private static boolean isDefaultConfigurationClassCandidate(Class<?> clazz) {
return (clazz != null && isStaticNonPrivateAndNonFinal(clazz) && clazz.isAnnotationPresent(Configuration.class));
}
private static boolean isStaticNonPrivateAndNonFinal(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
int modifiers = clazz.getModifiers();
return (Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers) && !Modifier.isFinal(modifiers));
}
}

View File

@@ -76,7 +76,7 @@ public abstract class AbstractMockMvcBuilder<B extends AbstractMockMvcBuilder<B>
public final <T extends B> T addFilters(Filter... filters) {
Assert.notNull(filters, "filters cannot be null");
for(Filter f : filters) {
for (Filter f : filters) {
Assert.notNull(f, "filters cannot contain null values");
this.filters.add(f);
}
@@ -110,7 +110,7 @@ public abstract class AbstractMockMvcBuilder<B extends AbstractMockMvcBuilder<B>
Assert.notNull(filter, "filter cannot be null");
Assert.notNull(urlPatterns, "urlPatterns cannot be null");
if(urlPatterns.length > 0) {
if (urlPatterns.length > 0) {
filter = new PatternMappingFilterProxy(filter, urlPatterns);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
@@ -10,12 +10,12 @@
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package org.springframework.test.web.servlet.setup;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -61,29 +61,32 @@ final class PatternMappingFilterProxy implements Filter {
public PatternMappingFilterProxy(Filter delegate, String... urlPatterns) {
Assert.notNull(delegate, "A delegate Filter is required");
this.delegate = delegate;
for(String urlPattern : urlPatterns) {
for (String urlPattern : urlPatterns) {
addUrlPattern(urlPattern);
}
}
private void addUrlPattern(String urlPattern) {
Assert.notNull(urlPattern, "Found null URL Pattern");
if(urlPattern.startsWith(EXTENSION_MAPPING_PATTERN)) {
if (urlPattern.startsWith(EXTENSION_MAPPING_PATTERN)) {
this.endsWithMatches.add(urlPattern.substring(1, urlPattern.length()));
} else if(urlPattern.equals(PATH_MAPPING_PATTERN)) {
}
else if (urlPattern.equals(PATH_MAPPING_PATTERN)) {
this.startsWithMatches.add("");
}
else if (urlPattern.endsWith(PATH_MAPPING_PATTERN)) {
this.startsWithMatches.add(urlPattern.substring(0, urlPattern.length() - 1));
this.exactMatches.add(urlPattern.substring(0, urlPattern.length() - 2));
} else {
if("".equals(urlPattern)) {
}
else {
if ("".equals(urlPattern)) {
urlPattern = "/";
}
this.exactMatches.add(urlPattern);
}
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
throws IOException, ServletException {
@@ -91,29 +94,30 @@ final class PatternMappingFilterProxy implements Filter {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String requestPath = urlPathHelper.getPathWithinApplication(httpRequest);
if(matches(requestPath)) {
if (matches(requestPath)) {
this.delegate.doFilter(request, response, filterChain);
} else {
}
else {
filterChain.doFilter(request, response);
}
}
private boolean matches(String requestPath) {
for(String pattern : this.exactMatches) {
if(pattern.equals(requestPath)) {
for (String pattern : this.exactMatches) {
if (pattern.equals(requestPath)) {
return true;
}
}
if(!requestPath.startsWith("/")) {
if (!requestPath.startsWith("/")) {
return false;
}
for(String pattern : this.endsWithMatches) {
if(requestPath.endsWith(pattern)) {
for (String pattern : this.endsWithMatches) {
if (requestPath.endsWith(pattern)) {
return true;
}
}
for(String pattern : this.startsWithMatches) {
if(requestPath.startsWith(pattern)) {
for (String pattern : this.startsWithMatches) {
if (requestPath.startsWith(pattern)) {
return true;
}
}

View File

@@ -72,7 +72,7 @@ final class SimpleStreamingClientHttpRequest extends AbstractClientHttpRequest {
@Override
protected OutputStream getBodyInternal(HttpHeaders headers) throws IOException {
if (this.body == null) {
if(this.outputStreaming) {
if (this.outputStreaming) {
int contentLength = (int) headers.getContentLength();
if (contentLength >= 0) {
this.connection.setFixedLengthStreamingMode(contentLength);

View File

@@ -62,12 +62,8 @@ public abstract class AbstractWireFeedHttpMessageConverter<T extends WireFeed> e
WireFeedInput feedInput = new WireFeedInput();
MediaType contentType = inputMessage.getHeaders().getContentType();
Charset charset;
if (contentType != null && contentType.getCharSet() != null) {
charset = contentType.getCharSet();
} else {
charset = DEFAULT_CHARSET;
}
Charset charset =
(contentType != null && contentType.getCharSet() != null? contentType.getCharSet() : DEFAULT_CHARSET);
try {
Reader reader = new InputStreamReader(inputMessage.getBody(), charset);
return (T) feedInput.build(reader);

View File

@@ -334,7 +334,7 @@ public class Jackson2ObjectMapperFactoryBean implements FactoryBean<ObjectMapper
/**
* Specify a {@link com.fasterxml.jackson.databind.PropertyNamingStrategy} to
* configure the {@link ObjectMapper} with.
* @@since 4.0.2
* @since 4.0.2
*/
public void setPropertyNamingStrategy(PropertyNamingStrategy propertyNamingStrategy) {
this.propertyNamingStrategy = propertyNamingStrategy;

View File

@@ -188,7 +188,8 @@ public class ContentNegotiationManagerFactoryBean
PathExtensionContentNegotiationStrategy strategy;
if (this.servletContext != null) {
strategy = new ServletPathExtensionContentNegotiationStrategy(this.servletContext, this.mediaTypes);
} else {
}
else {
strategy = new PathExtensionContentNegotiationStrategy(this.mediaTypes);
}
if (this.useJaf != null) {

View File

@@ -116,7 +116,7 @@ public class WebRequestDataBinder extends WebDataBinder {
public void bind(WebRequest request) {
MutablePropertyValues mpvs = new MutablePropertyValues(request.getParameterMap());
if(isMultipartRequest(request) && (request instanceof NativeWebRequest)) {
if (isMultipartRequest(request) && (request instanceof NativeWebRequest)) {
MultipartRequest multipartRequest = ((NativeWebRequest) request).getNativeRequest(MultipartRequest.class);
if (multipartRequest != null) {
bindMultipart(multipartRequest.getMultiFileMap(), mpvs);

View File

@@ -777,7 +777,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
public ResponseEntityResponseExtractor(Type responseType) {
if (responseType != null && !Void.class.equals(responseType)) {
this.delegate = new HttpMessageConverterExtractor<T>(responseType, getMessageConverters(), logger);
} else {
}
else {
this.delegate = null;
}
}

View File

@@ -82,7 +82,7 @@ public class ServletContextAwareProcessor implements BeanPostProcessor {
* has been registered.
*/
protected ServletContext getServletContext() {
if(this.servletContext == null && getServletConfig() != null) {
if (this.servletContext == null && getServletConfig() != null) {
return getServletConfig().getServletContext();
}
return this.servletContext;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@ package org.springframework.web.filter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -28,85 +27,91 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
/**
* A generic composite servlet {@link Filter} that just delegates its behaviour to a chain (list) of user supplied
* filters, achieving the functionality of a {@link FilterChain}, but conveniently using only {@link Filter} instances.
* This is useful for filters that require dependency injection, and can therefore be set up in a Spring application
* context. Typically this composite would be used in conjunction with {@link DelegatingFilterProxy}, so that it can be
* declared in Spring but applied to a servlet context.
* A generic composite servlet {@link Filter} that just delegates its behavior
* to a chain (list) of user-supplied filters, achieving the functionality of a
* {@link FilterChain}, but conveniently using only {@link Filter} instances.
*
* @since 3.1
* <p>This is useful for filters that require dependency injection, and can
* therefore be set up in a Spring application context. Typically, this
* composite would be used in conjunction with {@link DelegatingFilterProxy},
* so that it can be declared in Spring but applied to a servlet context.
*
* @author Dave Syer
*
* @since 3.1
*/
public class CompositeFilter implements Filter {
private List<? extends Filter> filters = new ArrayList<Filter>();
public void setFilters(List<? extends Filter> filters) {
this.filters = new ArrayList<Filter>(filters);
}
/**
* Clean up all the filters supplied, calling each one's destroy method in turn, but in reverse order.
*
* @see Filter#init(FilterConfig)
*/
@Override
public void destroy() {
for (int i = filters.size(); i-- > 0;) {
Filter filter = filters.get(i);
filter.destroy();
}
}
/**
* Initialize all the filters, calling each one's init method in turn in the order supplied.
*
* @see Filter#init(FilterConfig)
*/
@Override
public void init(FilterConfig config) throws ServletException {
for (Filter filter : filters) {
for (Filter filter : this.filters) {
filter.init(config);
}
}
/**
* Forms a temporary chain from the list of delegate filters supplied ({@link #setFilters(List)}) and executes them
* in order. Each filter delegates to the next one in the list, achieving the normal behaviour of a
* {@link FilterChain}, despite the fact that this is a {@link Filter}.
*
* Forms a temporary chain from the list of delegate filters supplied ({@link #setFilters})
* and executes them in order. Each filter delegates to the next one in the list, achieving
* the normal behavior of a {@link FilterChain}, despite the fact that this is a {@link Filter}.
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
new VirtualFilterChain(chain, filters).doFilter(request, response);
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
new VirtualFilterChain(chain, this.filters).doFilter(request, response);
}
/**
* Clean up all the filters supplied, calling each one's destroy method in turn, but in reverse order.
* @see Filter#init(FilterConfig)
*/
@Override
public void destroy() {
for (int i = this.filters.size(); i-- > 0;) {
Filter filter = this.filters.get(i);
filter.destroy();
}
}
private static class VirtualFilterChain implements FilterChain {
private final FilterChain originalChain;
private final List<? extends Filter> additionalFilters;
private int currentPosition = 0;
private VirtualFilterChain(FilterChain chain, List<? extends Filter> additionalFilters) {
public VirtualFilterChain(FilterChain chain, List<? extends Filter> additionalFilters) {
this.originalChain = chain;
this.additionalFilters = additionalFilters;
}
@Override
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException,
ServletException {
if (currentPosition == additionalFilters.size()) {
originalChain.doFilter(request, response);
} else {
currentPosition++;
Filter nextFilter = additionalFilters.get(currentPosition - 1);
public void doFilter(final ServletRequest request, final ServletResponse response)
throws IOException, ServletException {
if (this.currentPosition == this.additionalFilters.size()) {
this.originalChain.doFilter(request, response);
}
else {
this.currentPosition++;
Filter nextFilter = this.additionalFilters.get(this.currentPosition - 1);
nextFilter.doFilter(request, response, this);
}
}
}
}

View File

@@ -143,23 +143,23 @@ public class ControllerAdviceBean implements Ordered {
* @since 4.0
*/
public boolean isApplicableToBeanType(Class<?> beanType) {
if(!hasSelectors()) {
if (!hasSelectors()) {
return true;
}
else if (beanType != null) {
for (Class<?> clazz : this.assignableTypes) {
if(ClassUtils.isAssignable(clazz, beanType)) {
if (ClassUtils.isAssignable(clazz, beanType)) {
return true;
}
}
for (Class<? extends Annotation> annotationClass : this.annotations) {
if(AnnotationUtils.findAnnotation(beanType, annotationClass) != null) {
if (AnnotationUtils.findAnnotation(beanType, annotationClass) != null) {
return true;
}
}
String packageName = beanType.getPackage().getName();
for (Package basePackage : this.basePackages) {
if(packageName.startsWith(basePackage.getName())) {
if (packageName.startsWith(basePackage.getName())) {
return true;
}
}
@@ -227,7 +227,7 @@ public class ControllerAdviceBean implements Ordered {
for (String pkgName : basePackageNames) {
if (StringUtils.hasText(pkgName)) {
Package pkg = Package.getPackage(pkgName);
if(pkg != null) {
if (pkg != null) {
basePackages.add(pkg);
}
else {

View File

@@ -148,7 +148,7 @@ public class ExceptionHandlerMethodResolver {
*/
private Method getMappedMethod(Class<? extends Exception> exceptionType) {
List<Class<? extends Throwable>> matches = new ArrayList<Class<? extends Throwable>>();
for(Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
for (Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
if (mappedException.isAssignableFrom(exceptionType)) {
matches.add(mappedException);
}

View File

@@ -176,7 +176,7 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
Assert.notNull(multipartRequest, "Expected MultipartHttpServletRequest: is a MultipartResolver configured?");
arg = multipartRequest.getFiles(name);
}
else if(isMultipartFileArray(parameter)) {
else if (isMultipartFileArray(parameter)) {
assertIsMultipartRequest(servletRequest);
Assert.notNull(multipartRequest, "Expected MultipartHttpServletRequest: is a MultipartResolver configured?");
arg = multipartRequest.getFiles(name).toArray(new MultipartFile[0]);

View File

@@ -396,7 +396,7 @@ final class HierarchicalUriComponents extends UriComponents {
String path = getPath();
if (StringUtils.hasLength(path) && path.charAt(0) != PATH_DELIMITER) {
// Only prefix the path delimiter if something exists before it
if(getScheme() != null || getUserInfo() != null || getHost() != null || getPort() != -1) {
if (getScheme() != null || getUserInfo() != null || getHost() != null || getPort() != -1) {
path = PATH_DELIMITER + path;
}
}

View File

@@ -103,7 +103,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
for (String header : headers) {
HeaderExpression expr = new HeaderExpression(header);
if ("Accept".equalsIgnoreCase(expr.name)) {
for( MediaType mediaType : MediaType.parseMediaTypes(expr.value)) {
for ( MediaType mediaType : MediaType.parseMediaTypes(expr.value)) {
result.add(new ProduceMediaTypeExpression(mediaType, expr.isNegated));
}
}

View File

@@ -99,7 +99,7 @@ public final class RequestMethodsRequestCondition extends AbstractRequestConditi
return this;
}
RequestMethod incomingRequestMethod = getRequestMethod(request);
if(incomingRequestMethod != null) {
if (incomingRequestMethod != null) {
for (RequestMethod method : this.methods) {
if (method.equals(incomingRequestMethod)) {
return new RequestMethodsRequestCondition(method);

View File

@@ -381,7 +381,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
}
}
for (Entry<ControllerAdviceBean, ExceptionHandlerMethodResolver> entry : this.exceptionHandlerAdviceCache.entrySet()) {
if(entry.getKey().isApplicableToBeanType(handlerType)) {
if (entry.getKey().isApplicableToBeanType(handlerType)) {
ExceptionHandlerMethodResolver resolver = entry.getValue();
Method method = resolver.resolveMethod(exception);
if (method != null) {

View File

@@ -228,7 +228,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
if (this.code != null || this.text != null) {
// We have a code or default text that we need to resolve.
Object[] argumentsArray = resolveArguments(this.arguments);
if(!this.nestedArguments.isEmpty()) {
if (!this.nestedArguments.isEmpty()) {
argumentsArray = appendArguments(argumentsArray,
this.nestedArguments.toArray());
}
@@ -250,7 +250,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
}
private Object[] appendArguments(Object[] sourceArguments, Object[] additionalArguments) {
if(ObjectUtils.isEmpty(sourceArguments)) {
if (ObjectUtils.isEmpty(sourceArguments)) {
return additionalArguments;
}
Object[] arguments = new Object[sourceArguments.length + additionalArguments.length];

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -137,7 +137,8 @@ public class OptionsTag extends AbstractHtmlElementTag {
Object itemsObject = null;
if (items != null) {
itemsObject = (items instanceof String ? evaluate("items", items) : items);
} else {
}
else {
Class<?> selectTagBoundType = selectTag.getBindStatus().getValueType();
if (selectTagBoundType != null && selectTagBoundType.isEnum()) {
itemsObject = selectTagBoundType.getEnumConstants();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,19 +35,20 @@ public class PasswordInputTag extends InputTag {
/**
* Is the password value to be rendered?
* @return {@code true} if the password value to be rendered.
* @param showPassword {@code true} if the password value is to be rendered
*/
public void setShowPassword(boolean showPassword) {
this.showPassword = showPassword;
}
/**
* Is the password value to be rendered?
* @return {@code true} if the password value to be rendered
*/
public boolean isShowPassword() {
return this.showPassword;
}
/**
* Is the password value to be rendered?
* @param showPassword {@code true} if the password value is to be rendered.
*/
public void setShowPassword(boolean showPassword) {
this.showPassword = showPassword;
}
/**
* Flags "type" as an illegal dynamic attribute.
@@ -75,8 +76,10 @@ public class PasswordInputTag extends InputTag {
protected void writeValue(TagWriter tagWriter) throws JspException {
if (this.showPassword) {
super.writeValue(tagWriter);
} else {
}
else {
tagWriter.writeAttribute("value", processFieldValue(getName(), "", getType()));
}
}
}

View File

@@ -257,7 +257,7 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
}
/**
* Creates a new instance of {@link SpringTilesInitializer}.
* Creates a new instance of {@code SpringTilesInitializer}.
* <p>Override it to use a different initializer.
* @see org.apache.tiles.web.startup.AbstractTilesListener#createTilesInitializer()
*/

View File

@@ -82,7 +82,7 @@
* by user config.
*#
#macro( springBind $path )
#if("$!springHtmlEscape" != "")
#if ("$!springHtmlEscape" != "")
#set( $status = $springMacroRequestContext.getBindStatus($path, $springHtmlEscape) )
#else
#set( $status = $springMacroRequestContext.getBindStatus($path) )
@@ -171,7 +171,7 @@
* from a list of options.
*
* The null check for $status.value leverages Velocity's 'quiet' notation rather
* than the more common #if($status.value) since this method evaluates to the
* than the more common #if ($status.value) since this method evaluates to the
* boolean 'false' if the content of $status.value is the String "false" - not
* what we want.
*
@@ -185,7 +185,7 @@
<select id="${status.expression}" name="${status.expression}" ${attributes}>
#foreach($option in $options.keySet())
<option value="${option}"
#if("$!status.value" == "$option") selected="selected" #end>
#if ("$!status.value" == "$option") selected="selected" #end>
${options.get($option)}</option>
#end
</select>
@@ -208,7 +208,7 @@
#foreach($option in $options.keySet())
<option value="${option}"
#foreach($item in $status.actualValue)
#if($item == $option) selected="selected" #end
#if ($item == $option) selected="selected" #end
#end
>${options.get($option)}</option>
#end
@@ -231,7 +231,7 @@
#springBind($path)
#foreach($option in $options.keySet())
<input type="radio" name="${status.expression}" value="${option}"
#if("$!status.value" == "$option") checked="checked" #end
#if ("$!status.value" == "$option") checked="checked" #end
${attributes}
#springCloseTag()
${options.get($option)} ${separator}
@@ -255,7 +255,7 @@
#foreach($option in $options.keySet())
<input type="checkbox" name="${status.expression}" value="${option}"
#foreach($item in $status.actualValue)
#if($item == $option) checked="checked" #end
#if ($item == $option) checked="checked" #end
#end
${attributes} #springCloseTag()
${options.get($option)} ${separator}
@@ -275,7 +275,7 @@
#macro( springFormCheckbox $path $attributes )
#springBind($path)
<input type="hidden" name="_${status.expression}" value="on"/>
<input type="checkbox" id="${status.expression}" name="${status.expression}"#if("$!{status.value}"=="true") checked="checked"#end ${attributes}/>
<input type="checkbox" id="${status.expression}" name="${status.expression}"#if ("$!{status.value}"=="true") checked="checked"#end ${attributes}/>
#end
#**
@@ -293,10 +293,10 @@
*#
#macro( springShowErrors $separator $classOrStyle )
#foreach($error in $status.errorMessages)
#if($classOrStyle == "")
#if ($classOrStyle == "")
<b>${error}</b>
#else
#if($classOrStyle.indexOf(":") == -1)
#if ($classOrStyle.indexOf(":") == -1)
#set($attr="class")
#else
#set($attr="style")
@@ -314,7 +314,7 @@
* depending on the value of a 'springXhtmlCompliant' variable in the
* template context.
*#
#macro( springCloseTag )#if($springXhtmlCompliant)/>#else>#end #end
#macro( springCloseTag )#if ($springXhtmlCompliant)/>#else>#end #end

View File

@@ -107,7 +107,7 @@ public class WebSocketExtension {
}
else {
List<WebSocketExtension> result = new ArrayList<WebSocketExtension>();
for(String token : extensions.split(",")) {
for (String token : extensions.split(",")) {
result.add(parseExtension(token));
}
return result;

View File

@@ -122,7 +122,7 @@ public class WebSocketHttpHeaders extends HttpHeaders {
*/
public void setSecWebSocketExtensions(List<WebSocketExtension> extensions) {
List<String> result = new ArrayList<String>(extensions.size());
for(WebSocketExtension extension : extensions) {
for (WebSocketExtension extension : extensions) {
result.add(extension.toString());
}
set(SEC_WEBSOCKET_EXTENSIONS, toCommaDelimitedString(result));

View File

@@ -123,7 +123,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy {
private List<WebSocketExtension> getWebSocketExtensions() {
List<WebSocketExtension> result = new ArrayList<WebSocketExtension>();
for(String name : this.factory.getExtensionFactory().getExtensionNames()) {
for (String name : this.factory.getExtensionFactory().getExtensionNames()) {
result.add(new WebSocketExtension(name));
}
return result;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,7 +68,7 @@ public class HtmlFileTransportHandler extends AbstractHttpSendingTransportHandle
" </script>"
);
while(sb.length() < MINIMUM_PARTIAL_HTML_CONTENT_LENGTH) {
while (sb.length() < MINIMUM_PARTIAL_HTML_CONTENT_LENGTH) {
sb.append(" ");
}

View File

@@ -72,9 +72,9 @@ public class StreamingSockJsSession extends AbstractHttpSockJsSession {
this.byteCount = 0;
break;
}
} while (!getMessageCache().isEmpty());
}
while (!getMessageCache().isEmpty());
scheduleHeartbeat();
}
}