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

@@ -366,7 +366,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
private void configurePathMatchingProperties(RootBeanDefinition handlerMappingDef,
Element element, ParserContext parserContext) {
Element pathMatchingElement = DomUtils.getChildElementByTagName(element, "path-matching");
if(pathMatchingElement != null) {
if (pathMatchingElement != null) {
Object source = parserContext.extractSource(element);
if (pathMatchingElement.hasAttribute("suffix-pattern")) {
Boolean useSuffixPatternMatch = Boolean.valueOf(pathMatchingElement.getAttribute("suffix-pattern"));
@@ -568,7 +568,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
if (StringUtils.hasText("bean")) {
reference = new RuntimeBeanReference(refElement.getAttribute("bean"),false);
list.add(reference);
}else if(StringUtils.hasText("parent")){
}else if (StringUtils.hasText("parent")){
reference = new RuntimeBeanReference(refElement.getAttribute("parent"),true);
list.add(reference);
}else{

View File

@@ -63,8 +63,8 @@ abstract class MvcNamespaceUtils {
* @return a RuntimeBeanReference to this {@link UrlPathHelper} instance
*/
public static RuntimeBeanReference registerUrlPathHelper(RuntimeBeanReference urlPathHelperRef, ParserContext parserContext, Object source) {
if(urlPathHelperRef != null) {
if(parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)) {
if (urlPathHelperRef != null) {
if (parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)) {
parserContext.getRegistry().removeAlias(URL_PATH_HELPER_BEAN_NAME);
}
parserContext.getRegistry().registerAlias(urlPathHelperRef.getBeanName(), URL_PATH_HELPER_BEAN_NAME);
@@ -86,8 +86,8 @@ abstract class MvcNamespaceUtils {
* @return a RuntimeBeanReference to this {@link PathMatcher} instance
*/
public static RuntimeBeanReference registerPathMatcher(RuntimeBeanReference pathMatcherRef, ParserContext parserContext, Object source) {
if(pathMatcherRef != null) {
if(parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) {
if (pathMatcherRef != null) {
if (parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) {
parserContext.getRegistry().removeAlias(PATH_MATCHER_BEAN_NAME);
}
parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME);

View File

@@ -110,12 +110,12 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
}
ManagedList<? super Object> resourceResolvers = parseResourceResolvers(parserContext, element, source);
if(!resourceResolvers.isEmpty()) {
if (!resourceResolvers.isEmpty()) {
resourceHandlerDef.getPropertyValues().add("resourceResolvers", resourceResolvers);
}
ManagedList<? super Object> resourceTransformers = parseResourceTransformers(parserContext, element, source);
if(!resourceTransformers.isEmpty()) {
if (!resourceTransformers.isEmpty()) {
resourceHandlerDef.getPropertyValues().add("resourceTransformers", resourceTransformers);
}

View File

@@ -175,7 +175,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser {
List<Element> elements = DomUtils.getChildElementsByTagName(resolverElement, new String[] {"default-views"});
if (!elements.isEmpty()) {
ManagedList<Object> list = new ManagedList<Object>();
for(Element element : DomUtils.getChildElementsByTagName(elements.get(0), "bean", "ref")) {
for (Element element : DomUtils.getChildElementsByTagName(elements.get(0), "bean", "ref")) {
list.add(context.getDelegate().parsePropertySubElement(element, null));
}
values.add("defaultViews", list);

View File

@@ -218,19 +218,19 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
handlerMapping.setContentNegotiationManager(mvcContentNegotiationManager());
PathMatchConfigurer configurer = getPathMatchConfigurer();
if(configurer.isUseSuffixPatternMatch() != null) {
if (configurer.isUseSuffixPatternMatch() != null) {
handlerMapping.setUseSuffixPatternMatch(configurer.isUseSuffixPatternMatch());
}
if(configurer.isUseRegisteredSuffixPatternMatch() != null) {
if (configurer.isUseRegisteredSuffixPatternMatch() != null) {
handlerMapping.setUseRegisteredSuffixPatternMatch(configurer.isUseRegisteredSuffixPatternMatch());
}
if(configurer.isUseTrailingSlashMatch() != null) {
if (configurer.isUseTrailingSlashMatch() != null) {
handlerMapping.setUseTrailingSlashMatch(configurer.isUseTrailingSlashMatch());
}
if(configurer.getPathMatcher() != null) {
if (configurer.getPathMatcher() != null) {
handlerMapping.setPathMatcher(configurer.getPathMatcher());
}
if(configurer.getUrlPathHelper() != null) {
if (configurer.getUrlPathHelper() != null) {
handlerMapping.setUrlPathHelper(configurer.getUrlPathHelper());
}
return handlerMapping;
@@ -534,7 +534,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
*/
@Bean
public PathMatcher mvcPathMatcher() {
if(getPathMatchConfigurer().getPathMatcher() != null) {
if (getPathMatchConfigurer().getPathMatcher() != null) {
return getPathMatchConfigurer().getPathMatcher();
}
else {
@@ -551,7 +551,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
*/
@Bean
public UrlPathHelper mvcUrlPathHelper() {
if(getPathMatchConfigurer().getUrlPathHelper() != null) {
if (getPathMatchConfigurer().getUrlPathHelper() != null) {
return getPathMatchConfigurer().getUrlPathHelper();
}
else {

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

@@ -406,7 +406,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

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.servlet.resource;
import java.io.ByteArrayOutputStream;
@@ -69,6 +70,7 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
private final String fileExtension;
/**
* Create an AppCacheResourceTransformer that transforms files with extension ".manifest"
*/
@@ -90,6 +92,7 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
this.sectionTransformers.put("CACHE:", new CacheSection());
}
@Override
public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) throws IOException {
resource = transformerChain.transform(request, resource);
@@ -102,7 +105,7 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream());
String content = new String(bytes, DEFAULT_CHARSET);
if(!content.startsWith(MANIFEST_HEADER)) {
if (!content.startsWith(MANIFEST_HEADER)) {
if (logger.isTraceEnabled()) {
logger.trace("AppCache manifest does not start with 'CACHE MANIFEST', skipping: " + resource);
}
@@ -118,17 +121,14 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
Scanner scanner = new Scanner(content);
SectionTransformer currentTransformer = this.sectionTransformers.get(MANIFEST_HEADER);
while(scanner.hasNextLine()) {
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if(this.sectionTransformers.containsKey(line.trim())) {
if (this.sectionTransformers.containsKey(line.trim())) {
currentTransformer = this.sectionTransformers.get(line.trim());
contentWriter.write(line + "\n");
hashBuilder.appendString(line);
}
else {
contentWriter.write(currentTransformer.transform(line, hashBuilder, resource, transformerChain) + "\n");
}
}
@@ -147,23 +147,25 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
/**
* Transforms a line in a section of the manifest
*
* The actual transformation depends on the chose transformation strategy
* <p>The actual transformation depends on the chose transformation strategy
* for the current manifest section (CACHE, NETWORK, FALLBACK, etc).
*/
String transform(String line, HashBuilder builder, Resource resource,
ResourceTransformerChain transformerChain) throws IOException;
}
private static class NoOpSection implements SectionTransformer {
public String transform(String line, HashBuilder builder,
Resource resource, ResourceTransformerChain transformerChain) throws IOException {
public String transform(String line, HashBuilder builder, Resource resource, ResourceTransformerChain transformerChain)
throws IOException {
builder.appendString(line);
return line;
}
}
private static class CacheSection implements SectionTransformer {
private final String COMMENT_DIRECTIVE = "#";
@@ -172,30 +174,26 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
public String transform(String line, HashBuilder builder,
Resource resource, ResourceTransformerChain transformerChain) throws IOException {
if(isLink(line) && !hasScheme(line)) {
if (isLink(line) && !hasScheme(line)) {
Resource appCacheResource = transformerChain.getResolverChain().resolveResource(null, line, Arrays.asList(resource));
String path = transformerChain.getResolverChain().resolveUrlPath(line, Arrays.asList(resource));
builder.appendResource(appCacheResource);
if (logger.isTraceEnabled()) {
logger.trace("Link modified: " + path + " (original: " + line + ")");
}
return path;
}
builder.appendString(line);
return line;
}
private boolean hasScheme(String link) {
int schemeIndex = link.indexOf(":");
return link.startsWith("//") || (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/"));
return (link.startsWith("//") || (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/")));
}
private boolean isLink(String line) {
return StringUtils.hasText(line) && !line.startsWith(COMMENT_DIRECTIVE);
return (StringUtils.hasText(line) && !line.startsWith(COMMENT_DIRECTIVE));
}
}
@@ -204,7 +202,7 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
private final ByteArrayOutputStream baos;
private HashBuilder(int initialSize) {
public HashBuilder(int initialSize) {
this.baos = new ByteArrayOutputStream(initialSize);
}

View File

@@ -102,7 +102,7 @@ public class CssLinkResourceTransformer implements ResourceTransformer {
writer.write(content.substring(index, info.getStart()));
String link = content.substring(info.getStart(), info.getEnd());
String newLink = null;
if(!hasScheme(link)) {
if (!hasScheme(link)) {
newLink = transformerChain.getResolverChain().resolveUrlPath(link, Arrays.asList(resource));
}
if (logger.isTraceEnabled()) {
@@ -159,7 +159,8 @@ public class CssLinkResourceTransformer implements ResourceTransformer {
index = extractLink(index, content, linkInfos);
}
} while (true);
}
while (true);
}
private int skipWhitespace(String content, int index) {

View File

@@ -73,7 +73,7 @@ public class VersionResourceResolver extends AbstractResourceResolver {
}
VersionStrategy versionStrategy = findStrategy(requestPath);
if(versionStrategy == null) {
if (versionStrategy == null) {
return null;
}
@@ -114,7 +114,7 @@ public class VersionResourceResolver extends AbstractResourceResolver {
String baseUrl = chain.resolveUrlPath(resourceUrlPath, locations);
if (StringUtils.hasText(baseUrl)) {
VersionStrategy versionStrategy = findStrategy(resourceUrlPath);
if(versionStrategy == null) {
if (versionStrategy == null) {
return null;
}
return versionStrategy.addVersionToUrl(baseUrl, locations, chain);
@@ -129,12 +129,12 @@ public class VersionResourceResolver extends AbstractResourceResolver {
protected VersionStrategy findStrategy(String requestPath) {
String path = "/".concat(requestPath);
List<String> matchingPatterns = new ArrayList<String>();
for(String pattern : this.versionStrategyMap.keySet()) {
if(this.pathMatcher.match(pattern, path)) {
for (String pattern : this.versionStrategyMap.keySet()) {
if (this.pathMatcher.match(pattern, path)) {
matchingPatterns.add(pattern);
}
}
if(!matchingPatterns.isEmpty()) {
if (!matchingPatterns.isEmpty()) {
Comparator<String> comparator = this.pathMatcher.getPatternComparator(path);
Collections.sort(matchingPatterns, comparator);
return this.versionStrategyMap.get(matchingPatterns.get(0));

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

@@ -283,7 +283,7 @@ public class MappingJackson2JsonView extends AbstractView {
Class<?> serializationView = (Class<?>) model.get(JsonView.class.getName());
String jsonpParameterValue = getJsonpParameterValue(request);
Object value = filterModel(model);
if(serializationView != null || jsonpParameterValue != null) {
if (serializationView != null || jsonpParameterValue != null) {
MappingJacksonValue container = new MappingJacksonValue(value);
container.setSerializationView(serializationView);
container.setJsonpFunction(jsonpParameterValue);

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