Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -33,7 +33,7 @@ public enum HttpMethod {
|
||||
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
|
||||
|
||||
|
||||
private static final Map<String, HttpMethod> mappings = new HashMap<String, HttpMethod>(8);
|
||||
private static final Map<String, HttpMethod> mappings = new HashMap<String, HttpMethod>(16);
|
||||
|
||||
static {
|
||||
for (HttpMethod httpMethod : values()) {
|
||||
|
||||
@@ -52,7 +52,7 @@ class HtmlCharacterEntityReferences {
|
||||
|
||||
private final String[] characterToEntityReferenceMap = new String[3000];
|
||||
|
||||
private final Map<String, Character> entityReferenceToCharacterMap = new HashMap<String, Character>(252);
|
||||
private final Map<String, Character> entityReferenceToCharacterMap = new HashMap<String, Character>(512);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -229,7 +229,7 @@ public abstract class AbstractDataBoundFormElementTag extends AbstractFormTag im
|
||||
protected final String processFieldValue(String name, String value, String type) {
|
||||
RequestDataValueProcessor processor = getRequestContext().getRequestDataValueProcessor();
|
||||
ServletRequest request = this.pageContext.getRequest();
|
||||
if (processor != null && (request instanceof HttpServletRequest)) {
|
||||
if (processor != null && request instanceof HttpServletRequest) {
|
||||
value = processor.processFormFieldValue((HttpServletRequest) request, name, value, type);
|
||||
}
|
||||
return value;
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class AbstractHtmlElementBodyTag extends AbstractHtmlElementTag
|
||||
* If {@link #shouldRender rendering}, flush any buffered
|
||||
* {@link BodyContent} or, if no {@link BodyContent} is supplied,
|
||||
* {@link #renderDefaultContent render the default content}.
|
||||
* @return Tag#EVAL_PAGE
|
||||
* @return a {@link javax.servlet.jsp.tagext.Tag#EVAL_PAGE} result
|
||||
*/
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
@@ -79,7 +79,7 @@ public abstract class AbstractHtmlElementBodyTag extends AbstractHtmlElementTag
|
||||
* override this to add additional content to the output.
|
||||
*/
|
||||
protected void renderFromBodyContent(BodyContent bodyContent, TagWriter tagWriter) throws JspException {
|
||||
flushBufferedBodyContent(this.bodyContent);
|
||||
flushBufferedBodyContent(bodyContent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -403,7 +403,7 @@ public abstract class AbstractHtmlElementTag extends AbstractDataBoundFormElemen
|
||||
throw new IllegalArgumentException(
|
||||
"Attribute " + localName + "=\"" + value + "\" is not allowed");
|
||||
}
|
||||
dynamicAttributes.put(localName, value);
|
||||
this.dynamicAttributes.put(localName, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -109,13 +109,13 @@ public class ButtonTag extends AbstractHtmlElementTag {
|
||||
* when the value is written.
|
||||
*/
|
||||
protected void writeValue(TagWriter tagWriter) throws JspException {
|
||||
String valueToUse = (getValue() != null) ? getValue() : getDefaultValue();
|
||||
String valueToUse = (getValue() != null ? getValue() : getDefaultValue());
|
||||
tagWriter.writeAttribute("value", processFieldValue(getName(), valueToUse, getType()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default value.
|
||||
* @return The default value if none supplied.
|
||||
* @return the default value if none supplied
|
||||
*/
|
||||
protected String getDefaultValue() {
|
||||
return "Submit";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -38,10 +38,11 @@ public class InputTag extends AbstractHtmlInputElementTag {
|
||||
|
||||
public static final String ONSELECT_ATTRIBUTE = "onselect";
|
||||
|
||||
public static final String READONLY_ATTRIBUTE = "readonly";
|
||||
|
||||
public static final String AUTOCOMPLETE_ATTRIBUTE = "autocomplete";
|
||||
|
||||
@Deprecated
|
||||
public static final String READONLY_ATTRIBUTE = "readonly";
|
||||
|
||||
|
||||
private String size;
|
||||
|
||||
@@ -156,10 +157,6 @@ public class InputTag extends AbstractHtmlInputElementTag {
|
||||
return SKIP_BODY;
|
||||
}
|
||||
|
||||
private boolean hasDynamicTypeAttribute() {
|
||||
return getDynamicAttributes() != null && getDynamicAttributes().containsKey("type");
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the '{@code value}' attribute to the supplied {@link TagWriter}.
|
||||
* Subclasses may choose to override this implementation to control exactly
|
||||
@@ -167,22 +164,21 @@ public class InputTag extends AbstractHtmlInputElementTag {
|
||||
*/
|
||||
protected void writeValue(TagWriter tagWriter) throws JspException {
|
||||
String value = getDisplayString(getBoundValue(), getPropertyEditor());
|
||||
String type = hasDynamicTypeAttribute() ? (String) getDynamicAttributes().get("type") : getType();
|
||||
String type = (hasDynamicTypeAttribute() ? (String) getDynamicAttributes().get("type") : getType());
|
||||
tagWriter.writeAttribute("value", processFieldValue(getName(), value, type));
|
||||
}
|
||||
|
||||
private boolean hasDynamicTypeAttribute() {
|
||||
return (getDynamicAttributes() != null && getDynamicAttributes().containsKey("type"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Flags {@code type="checkbox"} and {@code type="radio"} as illegal
|
||||
* dynamic attributes.
|
||||
*/
|
||||
@Override
|
||||
protected boolean isValidDynamicAttribute(String localName, Object value) {
|
||||
if ("type".equals(localName)) {
|
||||
if ("checkbox".equals(value) || "radio".equals(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return !("type".equals(localName) && ("checkbox".equals(value) || "radio".equals(value)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -215,8 +215,8 @@ public class OptionTag extends AbstractHtmlElementBodyTag implements BodyTag {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the label for this '{@code option}' element.
|
||||
* If the {@link #setLabel label} property is set then the resolved value
|
||||
* Return the value of the label for this '{@code option}' element.
|
||||
* <p>If the {@link #setLabel label} property is set then the resolved value
|
||||
* of that property is used, otherwise the value of the {@code resolvedValue}
|
||||
* argument is used.
|
||||
*/
|
||||
|
||||
@@ -100,7 +100,7 @@ class OptionWriter {
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new {@code OptionWriter} for the supplied {@code objectSource}.
|
||||
* Create a new {@code OptionWriter} for the supplied {@code objectSource}.
|
||||
* @param optionSource the source of the {@code options} (never {@code null})
|
||||
* @param bindStatus the {@link BindStatus} for the bound value (never {@code null})
|
||||
* @param valueProperty the name of the property used to render {@code option} values
|
||||
@@ -145,7 +145,7 @@ class OptionWriter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the inner '{@code option}' tags using the {@link #optionSource}.
|
||||
* Render the inner '{@code option}' tags using the {@link #optionSource}.
|
||||
* @see #doRenderFromCollection(java.util.Collection, TagWriter)
|
||||
*/
|
||||
private void renderFromArray(TagWriter tagWriter) throws JspException {
|
||||
@@ -153,7 +153,7 @@ class OptionWriter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the inner '{@code option}' tags using the supplied
|
||||
* Render the inner '{@code option}' tags using the supplied
|
||||
* {@link Map} as the source.
|
||||
* @see #renderOption(TagWriter, Object, Object, Object)
|
||||
*/
|
||||
@@ -173,7 +173,7 @@ class OptionWriter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the inner '{@code option}' tags using the {@link #optionSource}.
|
||||
* Render the inner '{@code option}' tags using the {@link #optionSource}.
|
||||
* @see #doRenderFromCollection(java.util.Collection, TagWriter)
|
||||
*/
|
||||
private void renderFromCollection(TagWriter tagWriter) throws JspException {
|
||||
@@ -181,7 +181,7 @@ class OptionWriter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the inner '{@code option}' tags using the {@link #optionSource}.
|
||||
* Render the inner '{@code option}' tags using the {@link #optionSource}.
|
||||
* @see #doRenderFromCollection(java.util.Collection, TagWriter)
|
||||
*/
|
||||
private void renderFromEnum(TagWriter tagWriter) throws JspException {
|
||||
@@ -189,7 +189,7 @@ class OptionWriter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the inner '{@code option}' tags using the supplied {@link Collection} of
|
||||
* Render the inner '{@code option}' tags using the supplied {@link Collection} of
|
||||
* objects as the source. The value of the {@link #valueProperty} field is used
|
||||
* when rendering the '{@code value}' of the '{@code option}' and the value of the
|
||||
* {@link #labelProperty} property is used when rendering the label.
|
||||
@@ -213,7 +213,7 @@ class OptionWriter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an HTML '{@code option}' with the supplied value and label. Marks the
|
||||
* Render an HTML '{@code option}' with the supplied value and label. Marks the
|
||||
* value as 'selected' if either the item itself or its value match the bound value.
|
||||
*/
|
||||
private void renderOption(TagWriter tagWriter, Object item, Object value, Object label) throws JspException {
|
||||
@@ -239,7 +239,7 @@ class OptionWriter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the display value of the supplied {@code Object},
|
||||
* Determine the display value of the supplied {@code Object},
|
||||
* HTML-escaped as required.
|
||||
*/
|
||||
private String getDisplayString(Object value) {
|
||||
@@ -249,7 +249,7 @@ class OptionWriter {
|
||||
|
||||
/**
|
||||
* Process the option value before it is written.
|
||||
* The default implementation simply returns the same value unchanged.
|
||||
* <p>The default implementation simply returns the same value unchanged.
|
||||
*/
|
||||
protected String processOptionValue(String resolvedValue) {
|
||||
return resolvedValue;
|
||||
@@ -257,7 +257,7 @@ class OptionWriter {
|
||||
|
||||
/**
|
||||
* Determine whether the supplied values matched the selected value.
|
||||
* Delegates to {@link SelectedValueComparator#isSelected}.
|
||||
* <p>Delegates to {@link SelectedValueComparator#isSelected}.
|
||||
*/
|
||||
private boolean isOptionSelected(Object resolvedValue) {
|
||||
return SelectedValueComparator.isSelected(this.bindStatus, resolvedValue);
|
||||
@@ -271,7 +271,7 @@ class OptionWriter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes default attributes configured to the supplied {@link TagWriter}.
|
||||
* Write default attributes configured to the supplied {@link TagWriter}.
|
||||
*/
|
||||
protected void writeCommonAttributes(TagWriter tagWriter) throws JspException {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -211,7 +211,6 @@ public class OptionsTag extends AbstractHtmlElementTag {
|
||||
protected String processOptionValue(String value) {
|
||||
return processFieldValue(this.selectName, value, "option");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -57,8 +57,8 @@ public class SelectTag extends AbstractHtmlInputElementTag {
|
||||
|
||||
|
||||
/**
|
||||
* The {@link Collection}, {@link Map} or array of objects used to generate the inner
|
||||
* '{@code option}' tags.
|
||||
* The {@link Collection}, {@link Map} or array of objects used to generate
|
||||
* the inner '{@code option}' tags.
|
||||
*/
|
||||
private Object items;
|
||||
|
||||
@@ -291,7 +291,7 @@ public class SelectTag extends AbstractHtmlInputElementTag {
|
||||
public int doEndTag() throws JspException {
|
||||
if (this.tagWriter != null) {
|
||||
this.tagWriter.endTag();
|
||||
writeHiddenTagIfNecessary(tagWriter);
|
||||
writeHiddenTagIfNecessary(this.tagWriter);
|
||||
}
|
||||
return EVAL_PAGE;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -189,7 +189,7 @@ public class TagWriter {
|
||||
}
|
||||
|
||||
private boolean inTag() {
|
||||
return this.tagState.size() > 0;
|
||||
return !this.tagState.isEmpty();
|
||||
}
|
||||
|
||||
private TagStateEntry currentState() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -34,6 +34,7 @@ public class TextareaTag extends AbstractHtmlInputElementTag {
|
||||
|
||||
public static final String ONSELECT_ATTRIBUTE = "onselect";
|
||||
|
||||
@Deprecated
|
||||
public static final String READONLY_ATTRIBUTE = "readonly";
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user