Browse Source

Polishing

pull/763/merge
Juergen Hoeller 10 years ago
parent
commit
0711d6d0df
  1. 2
      spring-core/src/main/java/org/springframework/core/convert/support/StreamConverter.java
  2. 5
      spring-core/src/main/java/org/springframework/core/convert/support/StringToLocaleConverter.java
  3. 10
      spring-core/src/main/java/org/springframework/core/convert/support/StringToUUIDConverter.java
  4. 9
      spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilter.java

2
spring-core/src/main/java/org/springframework/core/convert/support/StreamConverter.java

@ -44,10 +44,12 @@ public class StreamConverter implements ConditionalGenericConverter { @@ -44,10 +44,12 @@ public class StreamConverter implements ConditionalGenericConverter {
private final ConversionService conversionService;
public StreamConverter(ConversionService conversionService) {
this.conversionService = conversionService;
}
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return CONVERTIBLE_TYPES;

5
spring-core/src/main/java/org/springframework/core/convert/support/StringToLocaleConverter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 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.
@ -22,10 +22,11 @@ import org.springframework.core.convert.converter.Converter; @@ -22,10 +22,11 @@ import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;
/**
* Converts a String to a Locale.
* Converts from a String to a {@link java.util.Locale}.
*
* @author Keith Donald
* @since 3.0
* @see StringUtils#parseLocaleString
*/
final class StringToLocaleConverter implements Converter<String, Locale> {

10
spring-core/src/main/java/org/springframework/core/convert/support/StringToUUIDConverter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 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.
@ -22,19 +22,17 @@ import org.springframework.core.convert.converter.Converter; @@ -22,19 +22,17 @@ import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;
/**
* Converts from a String to a java.util.UUID by calling {@link UUID#fromString(String)}.
* Converts from a String to a {@link java.util.UUID}.
*
* @author Phillip Webb
* @since 3.2
* @see UUID#fromString
*/
final class StringToUUIDConverter implements Converter<String, UUID> {
@Override
public UUID convert(String source) {
if (StringUtils.hasLength(source)) {
return UUID.fromString(source.trim());
}
return null;
return (StringUtils.hasLength(source) ? UUID.fromString(source.trim()) : null);
}
}

9
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@ -59,8 +59,7 @@ public class ResourceUrlEncodingFilter extends OncePerRequestFilter { @@ -59,8 +59,7 @@ public class ResourceUrlEncodingFilter extends OncePerRequestFilter {
/* Cache the index of the path within the DispatcherServlet mapping. */
private Integer indexLookupPath;
private ResourceUrlEncodingResponseWrapper(HttpServletRequest request, HttpServletResponse wrapped) {
public ResourceUrlEncodingResponseWrapper(HttpServletRequest request, HttpServletResponse wrapped) {
super(wrapped);
this.request = request;
}
@ -69,11 +68,11 @@ public class ResourceUrlEncodingFilter extends OncePerRequestFilter { @@ -69,11 +68,11 @@ public class ResourceUrlEncodingFilter extends OncePerRequestFilter {
public String encodeURL(String url) {
ResourceUrlProvider resourceUrlProvider = getResourceUrlProvider();
if (resourceUrlProvider == null) {
logger.debug("Request attribute exposing ResourceUrlProvider not found.");
logger.debug("Request attribute exposing ResourceUrlProvider not found");
return super.encodeURL(url);
}
initIndexLookupPath(resourceUrlProvider);
if(url.length() >= this.indexLookupPath) {
if (url.length() >= this.indexLookupPath) {
String prefix = url.substring(0, this.indexLookupPath);
String lookupPath = url.substring(this.indexLookupPath);
lookupPath = resourceUrlProvider.getForLookupPath(lookupPath);

Loading…
Cancel
Save