Consistent bracket alignment

This commit is contained in:
Juergen Hoeller
2014-07-18 17:21:55 +02:00
parent 188e58c46a
commit 9d6c38bd54
96 changed files with 526 additions and 515 deletions

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

@@ -138,7 +138,7 @@ public class ResourceHttpMessageConverter extends AbstractHttpMessageConverter<R
}
public static MediaType getMediaType(Resource resource) {
if(resource.getFilename() == null) {
if (resource.getFilename() == null) {
return null;
}
String mediaType = fileTypeMap.getContentType(resource.getFilename());

View File

@@ -65,12 +65,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

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

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

@@ -799,7 +799,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;
}
}
@@ -226,7 +226,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;
}
}