Skip to content

Commit e24ac55

Browse files
committed
Polishing
1 parent b17a6f9 commit e24ac55

File tree

13 files changed

+45
-49
lines changed

13 files changed

+45
-49
lines changed

spring-web/src/main/java/org/springframework/http/HttpMethod.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -33,7 +33,7 @@ public enum HttpMethod {
3333
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
3434

3535

36-
private static final Map<String, HttpMethod> mappings = new HashMap<String, HttpMethod>(8);
36+
private static final Map<String, HttpMethod> mappings = new HashMap<String, HttpMethod>(16);
3737

3838
static {
3939
for (HttpMethod httpMethod : values()) {

spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityReferences.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class HtmlCharacterEntityReferences {
5252

5353
private final String[] characterToEntityReferenceMap = new String[3000];
5454

55-
private final Map<String, Character> entityReferenceToCharacterMap = new HashMap<String, Character>(252);
55+
private final Map<String, Character> entityReferenceToCharacterMap = new HashMap<String, Character>(512);
5656

5757

5858
/**

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/AbstractDataBoundFormElementTag.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -229,7 +229,7 @@ protected String convertToDisplayString(Object value) throws JspException {
229229
protected final String processFieldValue(String name, String value, String type) {
230230
RequestDataValueProcessor processor = getRequestContext().getRequestDataValueProcessor();
231231
ServletRequest request = this.pageContext.getRequest();
232-
if (processor != null && (request instanceof HttpServletRequest)) {
232+
if (processor != null && request instanceof HttpServletRequest) {
233233
value = processor.processFormFieldValue((HttpServletRequest) request, name, value, type);
234234
}
235235
return value;

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementBodyTag.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected int writeTagContent(TagWriter tagWriter) throws JspException {
5757
* If {@link #shouldRender rendering}, flush any buffered
5858
* {@link BodyContent} or, if no {@link BodyContent} is supplied,
5959
* {@link #renderDefaultContent render the default content}.
60-
* @return Tag#EVAL_PAGE
60+
* @return a {@link javax.servlet.jsp.tagext.Tag#EVAL_PAGE} result
6161
*/
6262
@Override
6363
public int doEndTag() throws JspException {
@@ -79,7 +79,7 @@ public int doEndTag() throws JspException {
7979
* override this to add additional content to the output.
8080
*/
8181
protected void renderFromBodyContent(BodyContent bodyContent, TagWriter tagWriter) throws JspException {
82-
flushBufferedBodyContent(this.bodyContent);
82+
flushBufferedBodyContent(bodyContent);
8383
}
8484

8585
/**

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTag.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -403,7 +403,7 @@ public void setDynamicAttribute(String uri, String localName, Object value ) thr
403403
throw new IllegalArgumentException(
404404
"Attribute " + localName + "=\"" + value + "\" is not allowed");
405405
}
406-
dynamicAttributes.put(localName, value);
406+
this.dynamicAttributes.put(localName, value);
407407
}
408408

409409
/**

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/ButtonTag.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -109,13 +109,13 @@ protected int writeTagContent(TagWriter tagWriter) throws JspException {
109109
* when the value is written.
110110
*/
111111
protected void writeValue(TagWriter tagWriter) throws JspException {
112-
String valueToUse = (getValue() != null) ? getValue() : getDefaultValue();
112+
String valueToUse = (getValue() != null ? getValue() : getDefaultValue());
113113
tagWriter.writeAttribute("value", processFieldValue(getName(), valueToUse, getType()));
114114
}
115115

116116
/**
117117
* Return the default value.
118-
* @return The default value if none supplied.
118+
* @return the default value if none supplied
119119
*/
120120
protected String getDefaultValue() {
121121
return "Submit";

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/InputTag.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -38,10 +38,11 @@ public class InputTag extends AbstractHtmlInputElementTag {
3838

3939
public static final String ONSELECT_ATTRIBUTE = "onselect";
4040

41-
public static final String READONLY_ATTRIBUTE = "readonly";
42-
4341
public static final String AUTOCOMPLETE_ATTRIBUTE = "autocomplete";
4442

43+
@Deprecated
44+
public static final String READONLY_ATTRIBUTE = "readonly";
45+
4546

4647
private String size;
4748

@@ -156,33 +157,28 @@ protected int writeTagContent(TagWriter tagWriter) throws JspException {
156157
return SKIP_BODY;
157158
}
158159

159-
private boolean hasDynamicTypeAttribute() {
160-
return getDynamicAttributes() != null && getDynamicAttributes().containsKey("type");
161-
}
162-
163160
/**
164161
* Writes the '{@code value}' attribute to the supplied {@link TagWriter}.
165162
* Subclasses may choose to override this implementation to control exactly
166163
* when the value is written.
167164
*/
168165
protected void writeValue(TagWriter tagWriter) throws JspException {
169166
String value = getDisplayString(getBoundValue(), getPropertyEditor());
170-
String type = hasDynamicTypeAttribute() ? (String) getDynamicAttributes().get("type") : getType();
167+
String type = (hasDynamicTypeAttribute() ? (String) getDynamicAttributes().get("type") : getType());
171168
tagWriter.writeAttribute("value", processFieldValue(getName(), value, type));
172169
}
173170

171+
private boolean hasDynamicTypeAttribute() {
172+
return (getDynamicAttributes() != null && getDynamicAttributes().containsKey("type"));
173+
}
174+
174175
/**
175176
* Flags {@code type="checkbox"} and {@code type="radio"} as illegal
176177
* dynamic attributes.
177178
*/
178179
@Override
179180
protected boolean isValidDynamicAttribute(String localName, Object value) {
180-
if ("type".equals(localName)) {
181-
if ("checkbox".equals(value) || "radio".equals(value)) {
182-
return false;
183-
}
184-
}
185-
return true;
181+
return !("type".equals(localName) && ("checkbox".equals(value) || "radio".equals(value)));
186182
}
187183

188184
/**

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/OptionTag.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -215,8 +215,8 @@ protected String autogenerateId() throws JspException {
215215
}
216216

217217
/**
218-
* Returns the value of the label for this '{@code option}' element.
219-
* If the {@link #setLabel label} property is set then the resolved value
218+
* Return the value of the label for this '{@code option}' element.
219+
* <p>If the {@link #setLabel label} property is set then the resolved value
220220
* of that property is used, otherwise the value of the {@code resolvedValue}
221221
* argument is used.
222222
*/

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/OptionWriter.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class OptionWriter {
100100

101101

102102
/**
103-
* Creates a new {@code OptionWriter} for the supplied {@code objectSource}.
103+
* Create a new {@code OptionWriter} for the supplied {@code objectSource}.
104104
* @param optionSource the source of the {@code options} (never {@code null})
105105
* @param bindStatus the {@link BindStatus} for the bound value (never {@code null})
106106
* @param valueProperty the name of the property used to render {@code option} values
@@ -145,15 +145,15 @@ else if (this.optionSource instanceof Class && ((Class<?>) this.optionSource).is
145145
}
146146

147147
/**
148-
* Renders the inner '{@code option}' tags using the {@link #optionSource}.
148+
* Render the inner '{@code option}' tags using the {@link #optionSource}.
149149
* @see #doRenderFromCollection(java.util.Collection, TagWriter)
150150
*/
151151
private void renderFromArray(TagWriter tagWriter) throws JspException {
152152
doRenderFromCollection(CollectionUtils.arrayToList(this.optionSource), tagWriter);
153153
}
154154

155155
/**
156-
* Renders the inner '{@code option}' tags using the supplied
156+
* Render the inner '{@code option}' tags using the supplied
157157
* {@link Map} as the source.
158158
* @see #renderOption(TagWriter, Object, Object, Object)
159159
*/
@@ -173,23 +173,23 @@ private void renderFromMap(TagWriter tagWriter) throws JspException {
173173
}
174174

175175
/**
176-
* Renders the inner '{@code option}' tags using the {@link #optionSource}.
176+
* Render the inner '{@code option}' tags using the {@link #optionSource}.
177177
* @see #doRenderFromCollection(java.util.Collection, TagWriter)
178178
*/
179179
private void renderFromCollection(TagWriter tagWriter) throws JspException {
180180
doRenderFromCollection((Collection<?>) this.optionSource, tagWriter);
181181
}
182182

183183
/**
184-
* Renders the inner '{@code option}' tags using the {@link #optionSource}.
184+
* Render the inner '{@code option}' tags using the {@link #optionSource}.
185185
* @see #doRenderFromCollection(java.util.Collection, TagWriter)
186186
*/
187187
private void renderFromEnum(TagWriter tagWriter) throws JspException {
188188
doRenderFromCollection(CollectionUtils.arrayToList(((Class<?>) this.optionSource).getEnumConstants()), tagWriter);
189189
}
190190

191191
/**
192-
* Renders the inner '{@code option}' tags using the supplied {@link Collection} of
192+
* Render the inner '{@code option}' tags using the supplied {@link Collection} of
193193
* objects as the source. The value of the {@link #valueProperty} field is used
194194
* when rendering the '{@code value}' of the '{@code option}' and the value of the
195195
* {@link #labelProperty} property is used when rendering the label.
@@ -213,7 +213,7 @@ else if (item instanceof Enum) {
213213
}
214214

215215
/**
216-
* Renders an HTML '{@code option}' with the supplied value and label. Marks the
216+
* Render an HTML '{@code option}' with the supplied value and label. Marks the
217217
* value as 'selected' if either the item itself or its value match the bound value.
218218
*/
219219
private void renderOption(TagWriter tagWriter, Object item, Object value, Object label) throws JspException {
@@ -239,7 +239,7 @@ private void renderOption(TagWriter tagWriter, Object item, Object value, Object
239239
}
240240

241241
/**
242-
* Determines the display value of the supplied {@code Object},
242+
* Determine the display value of the supplied {@code Object},
243243
* HTML-escaped as required.
244244
*/
245245
private String getDisplayString(Object value) {
@@ -249,15 +249,15 @@ private String getDisplayString(Object value) {
249249

250250
/**
251251
* Process the option value before it is written.
252-
* The default implementation simply returns the same value unchanged.
252+
* <p>The default implementation simply returns the same value unchanged.
253253
*/
254254
protected String processOptionValue(String resolvedValue) {
255255
return resolvedValue;
256256
}
257257

258258
/**
259259
* Determine whether the supplied values matched the selected value.
260-
* Delegates to {@link SelectedValueComparator#isSelected}.
260+
* <p>Delegates to {@link SelectedValueComparator#isSelected}.
261261
*/
262262
private boolean isOptionSelected(Object resolvedValue) {
263263
return SelectedValueComparator.isSelected(this.bindStatus, resolvedValue);
@@ -271,7 +271,7 @@ protected boolean isOptionDisabled() throws JspException {
271271
}
272272

273273
/**
274-
* Writes default attributes configured to the supplied {@link TagWriter}.
274+
* Write default attributes configured to the supplied {@link TagWriter}.
275275
*/
276276
protected void writeCommonAttributes(TagWriter tagWriter) throws JspException {
277277
}

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/OptionsTag.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -211,7 +211,6 @@ protected void writeCommonAttributes(TagWriter tagWriter) throws JspException {
211211
protected String processOptionValue(String value) {
212212
return processFieldValue(this.selectName, value, "option");
213213
}
214-
215214
}
216215

217216
}

0 commit comments

Comments
 (0)