Skip to content

Commit a5b30fd

Browse files
committed
polishing
1 parent 35971f9 commit a5b30fd

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/SelectedValueComparator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2010 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -112,7 +112,7 @@ private static boolean collectionCompare(Collection boundCollection, Object cand
112112
}
113113
}
114114
catch (ClassCastException ex) {
115-
// Probably from a - ignore.
115+
// Probably from a TreeSet - ignore.
116116
}
117117
return exhaustiveCollectionCompare(boundCollection, candidateValue, bindStatus);
118118
}
@@ -181,7 +181,7 @@ else if (ObjectUtils.getDisplayString(boundValue).equals(candidateDisplayString)
181181
else if (editor != null && candidate instanceof String) {
182182
// Try PE-based comparison (PE should *not* be allowed to escape creating thread)
183183
String candidateAsString = (String) candidate;
184-
Object candidateAsValue = null;
184+
Object candidateAsValue;
185185
if (convertedValueCache != null && convertedValueCache.containsKey(editor)) {
186186
candidateAsValue = convertedValueCache.get(editor);
187187
}

org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
135135

136136
private List<ViewResolver> viewResolvers;
137137

138+
138139
public void setOrder(int order) {
139140
this.order = order;
140141
}
@@ -312,7 +313,8 @@ protected List<MediaType> getMediaTypes(HttpServletRequest request) {
312313
}
313314
if (this.defaultContentType != null) {
314315
if (logger.isDebugEnabled()) {
315-
logger.debug("Requested media types is " + defaultContentType + " (based on defaultContentType property)");
316+
logger.debug("Requested media types is " + this.defaultContentType +
317+
" (based on defaultContentType property)");
316318
}
317319
return Collections.singletonList(this.defaultContentType);
318320
}
@@ -323,9 +325,9 @@ protected List<MediaType> getMediaTypes(HttpServletRequest request) {
323325

324326
/**
325327
* Determines the {@link MediaType} for the given filename.
326-
* <p>The default implementation will check the {@linkplain #setMediaTypes(Map) media types} property first for a
327-
* defined mapping. If not present, and if the Java Activation Framework can be found on the class path, it will call
328-
* {@link FileTypeMap#getContentType(String)}
328+
* <p>The default implementation will check the {@linkplain #setMediaTypes(Map) media types}
329+
* property first for a defined mapping. If not present, and if the Java Activation Framework
330+
* can be found on the classpath, it will call {@link FileTypeMap#getContentType(String)}
329331
* <p>This method can be overriden to provide a different algorithm.
330332
* @param filename the current request file name (i.e. {@code hotels.html})
331333
* @return the media type, if any
@@ -337,7 +339,7 @@ protected MediaType getMediaTypeFromFilename(String filename) {
337339
}
338340
extension = extension.toLowerCase(Locale.ENGLISH);
339341
MediaType mediaType = this.mediaTypes.get(extension);
340-
if (mediaType == null && useJaf && jafPresent) {
342+
if (mediaType == null && this.useJaf && jafPresent) {
341343
mediaType = ActivationMediaTypeFactory.getMediaType(filename);
342344
if (mediaType != null) {
343345
this.mediaTypes.putIfAbsent(extension, mediaType);
@@ -361,18 +363,14 @@ protected MediaType getMediaTypeFromParameter(String parameterValue) {
361363
public View resolveViewName(String viewName, Locale locale) throws Exception {
362364
RequestAttributes attrs = RequestContextHolder.getRequestAttributes();
363365
Assert.isInstanceOf(ServletRequestAttributes.class, attrs);
364-
365366
List<MediaType> requestedMediaTypes = getMediaTypes(((ServletRequestAttributes) attrs).getRequest());
366-
367367
List<View> candidateViews = getCandidateViews(viewName, locale, requestedMediaTypes);
368-
369368
View bestView = getBestView(candidateViews, requestedMediaTypes);
370-
371369
if (bestView != null) {
372370
return bestView;
373371
}
374372
else {
375-
if (useNotAcceptableStatusCode) {
373+
if (this.useNotAcceptableStatusCode) {
376374
if (logger.isDebugEnabled()) {
377375
logger.debug("No acceptable view found; returning 406 (Not Acceptable) status code");
378376
}
@@ -389,8 +387,8 @@ public View resolveViewName(String viewName, Locale locale) throws Exception {
389387

390388
private List<View> getCandidateViews(String viewName, Locale locale, List<MediaType> requestedMediaTypes)
391389
throws Exception {
392-
List<View> candidateViews = new ArrayList<View>();
393390

391+
List<View> candidateViews = new ArrayList<View>();
394392
for (ViewResolver viewResolver : this.viewResolvers) {
395393
View view = viewResolver.resolveViewName(viewName, locale);
396394
if (view != null) {
@@ -408,7 +406,6 @@ private List<View> getCandidateViews(String viewName, Locale locale, List<MediaT
408406

409407
}
410408
}
411-
412409
if (!CollectionUtils.isEmpty(this.defaultViews)) {
413410
candidateViews.addAll(this.defaultViews);
414411
}
@@ -452,6 +449,7 @@ private View getBestView(List<View> candidateViews, List<MediaType> requestedMed
452449

453450
}
454451

452+
455453
/**
456454
* Inner class to avoid hard-coded JAF dependency.
457455
*/
@@ -501,6 +499,7 @@ public static MediaType getMediaType(String fileName) {
501499
}
502500
}
503501

502+
504503
private static final View NOT_ACCEPTABLE_VIEW = new View() {
505504

506505
public String getContentType() {
@@ -512,4 +511,5 @@ public void render(Map<String, ?> model, HttpServletRequest request, HttpServlet
512511
response.setStatus(HttpServletResponse.SC_NOT_ACCEPTABLE);
513512
}
514513
};
514+
515515
}

org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/RedirectView.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ protected void appendQueryProperties(StringBuilder targetUrl, Map<String, Object
261261
boolean first = (getUrl().indexOf('?') < 0);
262262
for (Map.Entry<String, Object> entry : queryProperties(model).entrySet()) {
263263
Object rawValue = entry.getValue();
264-
Iterator valueIter = null;
264+
Iterator valueIter;
265265
if (rawValue != null && rawValue.getClass().isArray()) {
266266
valueIter = Arrays.asList(ObjectUtils.toObjectArray(rawValue)).iterator();
267267
}
@@ -398,14 +398,18 @@ protected void sendRedirect(
398398
/**
399399
* Determines the status code to use for HTTP 1.1 compatible requests.
400400
* <p>The default implemenetation returns the {@link #setStatusCode(HttpStatus) statusCode}
401-
* property if set, or the value of the {@link #RESPONSE_STATUS_ATTRIBUTE} attribute. If neither are
402-
* set, it defaults to {@link HttpStatus#SEE_OTHER} (303).
401+
* property if set, or the value of the {@link #RESPONSE_STATUS_ATTRIBUTE} attribute.
402+
* If neither are set, it defaults to {@link HttpStatus#SEE_OTHER} (303).
403403
* @param request the request to inspect
404-
* @return the response
404+
* @param response the servlet response
405+
* @param targetUrl the target URL
406+
* @return the response status
405407
*/
406-
protected HttpStatus getHttp11StatusCode(HttpServletRequest request, HttpServletResponse response, String targetUrl) {
407-
if (statusCode != null) {
408-
return statusCode;
408+
protected HttpStatus getHttp11StatusCode(
409+
HttpServletRequest request, HttpServletResponse response, String targetUrl) {
410+
411+
if (this.statusCode != null) {
412+
return this.statusCode;
409413
}
410414
HttpStatus attributeStatusCode = (HttpStatus) request.getAttribute(View.RESPONSE_STATUS_ATTRIBUTE);
411415
if (attributeStatusCode != null) {

0 commit comments

Comments
 (0)