Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -30,9 +30,9 @@ import org.springframework.core.convert.converter.Converter;
|
|||||||
*/
|
*/
|
||||||
final class StringToBooleanConverter implements Converter<String, Boolean> {
|
final class StringToBooleanConverter implements Converter<String, Boolean> {
|
||||||
|
|
||||||
private static final Set<String> trueValues = new HashSet<>(4);
|
private static final Set<String> trueValues = new HashSet<>(8);
|
||||||
|
|
||||||
private static final Set<String> falseValues = new HashSet<>(4);
|
private static final Set<String> falseValues = new HashSet<>(8);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
trueValues.add("true");
|
trueValues.add("true");
|
||||||
@@ -46,6 +46,7 @@ final class StringToBooleanConverter implements Converter<String, Boolean> {
|
|||||||
falseValues.add("0");
|
falseValues.add("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean convert(String source) {
|
public Boolean convert(String source) {
|
||||||
String value = source.trim();
|
String value = source.trim();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -19,6 +19,7 @@ package org.springframework.core.convert.support;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,6 +32,7 @@ import org.springframework.util.StringUtils;
|
|||||||
final class StringToUUIDConverter implements Converter<String, UUID> {
|
final class StringToUUIDConverter implements Converter<String, UUID> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nullable
|
||||||
public UUID convert(String source) {
|
public UUID convert(String source) {
|
||||||
return (StringUtils.hasLength(source) ? UUID.fromString(source.trim()) : null);
|
return (StringUtils.hasLength(source) ? UUID.fromString(source.trim()) : null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,10 +369,10 @@ public final class ContentDisposition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode the given header field param as describe in RFC 5987.
|
* Decode the given header field param as described in RFC 5987.
|
||||||
* <p>Only the US-ASCII, UTF-8 and ISO-8859-1 charsets are supported.
|
* <p>Only the US-ASCII, UTF-8 and ISO-8859-1 charsets are supported.
|
||||||
* @param filename the header field param
|
* @param filename the filename
|
||||||
* @param charset the charset to use
|
* @param charset the charset for the filename
|
||||||
* @return the encoded header field param
|
* @return the encoded header field param
|
||||||
* @see <a href="https://tools.ietf.org/html/rfc5987">RFC 5987</a>
|
* @see <a href="https://tools.ietf.org/html/rfc5987">RFC 5987</a>
|
||||||
*/
|
*/
|
||||||
@@ -380,18 +380,18 @@ public final class ContentDisposition {
|
|||||||
Assert.notNull(filename, "'input' String` should not be null");
|
Assert.notNull(filename, "'input' String` should not be null");
|
||||||
Assert.notNull(charset, "'charset' should not be null");
|
Assert.notNull(charset, "'charset' should not be null");
|
||||||
byte[] value = filename.getBytes(charset);
|
byte[] value = filename.getBytes(charset);
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (index < value.length) {
|
while (index < value.length) {
|
||||||
byte b = value[index];
|
byte b = value[index];
|
||||||
if (isRFC5987AttrChar(b)) {
|
if (isRFC5987AttrChar(b)) {
|
||||||
bos.write((char) b);
|
baos.write((char) b);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
else if (b == '%' && index < value.length - 2) {
|
else if (b == '%' && index < value.length - 2) {
|
||||||
char[] array = new char[]{(char) value[index + 1], (char) value[index + 2]};
|
char[] array = new char[]{(char) value[index + 1], (char) value[index + 2]};
|
||||||
try {
|
try {
|
||||||
bos.write(Integer.parseInt(String.valueOf(array), 16));
|
baos.write(Integer.parseInt(String.valueOf(array), 16));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex) {
|
catch (NumberFormatException ex) {
|
||||||
throw new IllegalArgumentException(INVALID_HEADER_FIELD_PARAMETER_FORMAT, ex);
|
throw new IllegalArgumentException(INVALID_HEADER_FIELD_PARAMETER_FORMAT, ex);
|
||||||
@@ -402,7 +402,7 @@ public final class ContentDisposition {
|
|||||||
throw new IllegalArgumentException(INVALID_HEADER_FIELD_PARAMETER_FORMAT);
|
throw new IllegalArgumentException(INVALID_HEADER_FIELD_PARAMETER_FORMAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new String(bos.toByteArray(), charset);
|
return new String(baos.toByteArray(), charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isRFC5987AttrChar(byte c) {
|
private static boolean isRFC5987AttrChar(byte c) {
|
||||||
@@ -522,7 +522,7 @@ public final class ContentDisposition {
|
|||||||
|
|
||||||
private static class BuilderImpl implements Builder {
|
private static class BuilderImpl implements Builder {
|
||||||
|
|
||||||
private String type;
|
private final String type;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
@@ -143,9 +143,9 @@ frameworks besides Spring make this possible.
|
|||||||
`org.springframework.aop.support.JdkRegexpMethodPointcut` is a generic regular
|
`org.springframework.aop.support.JdkRegexpMethodPointcut` is a generic regular
|
||||||
expression pointcut that uses the regular expression support in the JDK.
|
expression pointcut that uses the regular expression support in the JDK.
|
||||||
|
|
||||||
With the `JdkRegexpMethodPointcut` class, you can provide a list of pattern strings. If
|
With the `JdkRegexpMethodPointcut` class, you can provide a list of pattern strings.
|
||||||
any of these is a match, the pointcut evaluates to `true`. (So, the result is
|
If any of these is a match, the pointcut evaluates to `true`. (As a consequence,
|
||||||
effectively the union of these pointcuts.)
|
the resulting pointcut is effectively the union of the specified patterns.)
|
||||||
|
|
||||||
The following example shows how to use `JdkRegexpMethodPointcut`:
|
The following example shows how to use `JdkRegexpMethodPointcut`:
|
||||||
|
|
||||||
|
|||||||
@@ -1413,7 +1413,7 @@ join point, unless you specify otherwise, the order of execution is undefined. Y
|
|||||||
control the order of execution by specifying precedence. This is done in the normal
|
control the order of execution by specifying precedence. This is done in the normal
|
||||||
Spring way by either implementing the `org.springframework.core.Ordered` interface in
|
Spring way by either implementing the `org.springframework.core.Ordered` interface in
|
||||||
the aspect class or annotating it with the `@Order` annotation. Given two aspects, the
|
the aspect class or annotating it with the `@Order` annotation. Given two aspects, the
|
||||||
aspect returning the lower value from `Ordered.getValue()` (or the annotation value) has
|
aspect returning the lower value from `Ordered.getOrder()` (or the annotation value) has
|
||||||
the higher precedence.
|
the higher precedence.
|
||||||
|
|
||||||
When two pieces of advice defined in the same aspect both need to run at the same
|
When two pieces of advice defined in the same aspect both need to run at the same
|
||||||
@@ -2531,7 +2531,7 @@ an aspect weaving phase to your build script.
|
|||||||
If you have chosen to use Spring AOP, you have a choice of @AspectJ or XML style.
|
If you have chosen to use Spring AOP, you have a choice of @AspectJ or XML style.
|
||||||
There are various tradeoffs to consider.
|
There are various tradeoffs to consider.
|
||||||
|
|
||||||
The XML style may most familiar to existing Spring users, and it is backed by genuine
|
The XML style may be most familiar to existing Spring users, and it is backed by genuine
|
||||||
POJOs. When using AOP as a tool to configure enterprise services, XML can be a good
|
POJOs. When using AOP as a tool to configure enterprise services, XML can be a good
|
||||||
choice (a good test is whether you consider the pointcut expression to be a part of your
|
choice (a good test is whether you consider the pointcut expression to be a part of your
|
||||||
configuration that you might want to change independently). With the XML style, it is
|
configuration that you might want to change independently). With the XML style, it is
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ information on using the `BeanFactory` instead of the `ApplicationContext,` see
|
|||||||
|
|
||||||
In Spring, the objects that form the backbone of your application and that are managed
|
In Spring, the objects that form the backbone of your application and that are managed
|
||||||
by the Spring IoC container are called beans. A bean is an object that is
|
by the Spring IoC container are called beans. A bean is an object that is
|
||||||
instantiated, assembled, and otherwise managed by a Spring IoC container. Otherwise, a
|
instantiated, assembled, and managed by a Spring IoC container. Otherwise, a
|
||||||
bean is simply one of many objects in your application. Beans, and the dependencies
|
bean is simply one of many objects in your application. Beans, and the dependencies
|
||||||
among them, are reflected in the configuration metadata used by a container.
|
among them, are reflected in the configuration metadata used by a container.
|
||||||
|
|
||||||
@@ -2089,7 +2089,7 @@ startup, because it must satisfy the singleton's dependencies. The lazy-initiali
|
|||||||
is injected into a singleton bean elsewhere that is not lazy-initialized.
|
is injected into a singleton bean elsewhere that is not lazy-initialized.
|
||||||
|
|
||||||
You can also control lazy-initialization at the container level by using the
|
You can also control lazy-initialization at the container level by using the
|
||||||
`default-lazy-init` attribute on the `<beans/>` element, a the following example shows:
|
`default-lazy-init` attribute on the `<beans/>` element, as the following example shows:
|
||||||
|
|
||||||
====
|
====
|
||||||
[source,xml,indent=0]
|
[source,xml,indent=0]
|
||||||
@@ -4190,7 +4190,8 @@ which these `BeanFactoryPostProcessor` instances run by setting the `order` prop
|
|||||||
However, you can only set this property if the `BeanFactoryPostProcessor` implements the
|
However, you can only set this property if the `BeanFactoryPostProcessor` implements the
|
||||||
`Ordered` interface. If you write your own `BeanFactoryPostProcessor`, you should
|
`Ordered` interface. If you write your own `BeanFactoryPostProcessor`, you should
|
||||||
consider implementing the `Ordered` interface, too. See the javadoc of the
|
consider implementing the `Ordered` interface, too. See the javadoc of the
|
||||||
{api-spring-framework}/beans/factory/config/BeanFactoryPostProcessor.html[`BeanFactoryPostProcessor`] and {api-spring-framework}/core/Ordered.html[`Ordered`] interfaces for more details.
|
{api-spring-framework}/beans/factory/config/BeanFactoryPostProcessor.html[`BeanFactoryPostProcessor`]
|
||||||
|
and {api-spring-framework}/core/Ordered.html[`Ordered`] interfaces for more details.
|
||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
====
|
====
|
||||||
|
|||||||
Reference in New Issue
Block a user