Polishing
This commit is contained in:
@@ -39,6 +39,7 @@ import org.springframework.util.StringUtils;
|
|||||||
* Extension of {@link UriComponents} for hierarchical URIs.
|
* Extension of {@link UriComponents} for hierarchical URIs.
|
||||||
*
|
*
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
|
* @author Juergen Hoeller
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 3.1.3
|
* @since 3.1.3
|
||||||
@@ -95,7 +96,7 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// component getters
|
// Component getters
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSchemeSpecificPart() {
|
public String getSchemeSpecificPart() {
|
||||||
@@ -169,7 +170,7 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the map of query parameters. Empty if no query has been set.
|
* Return the map of query parameters. Empty if no query has been set.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MultiValueMap<String, String> getQueryParams() {
|
public MultiValueMap<String, String> getQueryParams() {
|
||||||
@@ -177,13 +178,13 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// encoding
|
// Encoding
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode all URI components using their specific encoding rules and return
|
* Encode all URI components using their specific encoding rules and return
|
||||||
* the result as a new {@code UriComponents} instance.
|
* the result as a new {@code UriComponents} instance.
|
||||||
* @param charset the encoding of the values contained in this map
|
* @param charset the encoding of the values
|
||||||
* @return the encoded uri components
|
* @return the encoded URI components
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public HierarchicalUriComponents encode(Charset charset) {
|
public HierarchicalUriComponents encode(Charset charset) {
|
||||||
@@ -217,11 +218,11 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||||||
/**
|
/**
|
||||||
* Encode the given source into an encoded String using the rules specified
|
* Encode the given source into an encoded String using the rules specified
|
||||||
* by the given component and with the given options.
|
* by the given component and with the given options.
|
||||||
* @param source the source string
|
* @param source the source String
|
||||||
* @param encoding the encoding of the source string
|
* @param encoding the encoding of the source String
|
||||||
* @param type the URI component for the source
|
* @param type the URI component for the source
|
||||||
* @return the encoded URI
|
* @return the encoded URI
|
||||||
* @throws IllegalArgumentException when the given uri parameter is not a valid URI
|
* @throws IllegalArgumentException when the given value is not a valid URI component
|
||||||
*/
|
*/
|
||||||
static String encodeUriComponent(String source, String encoding, Type type) {
|
static String encodeUriComponent(String source, String encoding, Type type) {
|
||||||
return encodeUriComponent(source, Charset.forName(encoding), type);
|
return encodeUriComponent(source, Charset.forName(encoding), type);
|
||||||
@@ -230,8 +231,8 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||||||
/**
|
/**
|
||||||
* Encode the given source into an encoded String using the rules specified
|
* Encode the given source into an encoded String using the rules specified
|
||||||
* by the given component and with the given options.
|
* by the given component and with the given options.
|
||||||
* @param source the source string
|
* @param source the source String
|
||||||
* @param charset the encoding of the source string
|
* @param charset the encoding of the source String
|
||||||
* @param type the URI component for the source
|
* @param type the URI component for the source
|
||||||
* @return the encoded URI
|
* @return the encoded URI
|
||||||
* @throws IllegalArgumentException when the given value is not a valid URI component
|
* @throws IllegalArgumentException when the given value is not a valid URI component
|
||||||
@@ -270,7 +271,7 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// verifying
|
// Verifying
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies all URI components to determine whether they contain any illegal
|
* Verifies all URI components to determine whether they contain any illegal
|
||||||
@@ -326,7 +327,7 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// expanding
|
// Expanding
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HierarchicalUriComponents expandInternal(UriTemplateVariables uriVariables) {
|
protected HierarchicalUriComponents expandInternal(UriTemplateVariables uriVariables) {
|
||||||
@@ -372,10 +373,10 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// other functionality
|
// Other functionality
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a URI string from this {@code UriComponents} instance.
|
* Returns a URI String from this {@code UriComponents} instance.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toUriString() {
|
public String toUriString() {
|
||||||
@@ -487,7 +488,7 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// inner types
|
// Nested types
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enumeration used to identify the allowed characters per URI component.
|
* Enumeration used to identify the allowed characters per URI component.
|
||||||
@@ -659,7 +660,7 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a path backed by a string.
|
* Represents a path backed by a String.
|
||||||
*/
|
*/
|
||||||
static final class FullPathComponent implements PathComponent {
|
static final class FullPathComponent implements PathComponent {
|
||||||
|
|
||||||
@@ -716,14 +717,14 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a path backed by a string list (i.e. path segments).
|
* Represents a path backed by a String list (i.e. path segments).
|
||||||
*/
|
*/
|
||||||
static final class PathSegmentComponent implements PathComponent {
|
static final class PathSegmentComponent implements PathComponent {
|
||||||
|
|
||||||
private final List<String> pathSegments;
|
private final List<String> pathSegments;
|
||||||
|
|
||||||
public PathSegmentComponent(List<String> pathSegments) {
|
public PathSegmentComponent(List<String> pathSegments) {
|
||||||
Assert.notNull(pathSegments);
|
Assert.notNull(pathSegments, "List must not be null");
|
||||||
this.pathSegments = Collections.unmodifiableList(new ArrayList<>(pathSegments));
|
this.pathSegments = Collections.unmodifiableList(new ArrayList<>(pathSegments));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -889,7 +890,7 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return 42;
|
return getClass().hashCode();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -37,15 +37,14 @@ import org.springframework.util.MultiValueMap;
|
|||||||
* URI template variables.
|
* URI template variables.
|
||||||
*
|
*
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
|
* @author Juergen Hoeller
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
* @see UriComponentsBuilder
|
* @see UriComponentsBuilder
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public abstract class UriComponents implements Serializable {
|
public abstract class UriComponents implements Serializable {
|
||||||
|
|
||||||
/**
|
/** Captures URI template variable names */
|
||||||
* Captures URI template variable names.
|
|
||||||
*/
|
|
||||||
private static final Pattern NAMES_PATTERN = Pattern.compile("\\{([^/]+?)\\}");
|
private static final Pattern NAMES_PATTERN = Pattern.compile("\\{([^/]+?)\\}");
|
||||||
|
|
||||||
|
|
||||||
@@ -172,7 +171,7 @@ public abstract class UriComponents implements Serializable {
|
|||||||
* Replace all URI template variables with the values from the given {@link
|
* Replace all URI template variables with the values from the given {@link
|
||||||
* UriTemplateVariables}
|
* UriTemplateVariables}
|
||||||
* @param uriVariables URI template values
|
* @param uriVariables URI template values
|
||||||
* @return the expanded uri components
|
* @return the expanded URI components
|
||||||
*/
|
*/
|
||||||
abstract UriComponents expandInternal(UriTemplateVariables uriVariables);
|
abstract UriComponents expandInternal(UriTemplateVariables uriVariables);
|
||||||
|
|
||||||
@@ -183,7 +182,7 @@ public abstract class UriComponents implements Serializable {
|
|||||||
public abstract UriComponents normalize();
|
public abstract UriComponents normalize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a URI string from this {@code UriComponents} instance.
|
* Return a URI String from this {@code UriComponents} instance.
|
||||||
*/
|
*/
|
||||||
public abstract String toUriString();
|
public abstract String toUriString();
|
||||||
|
|
||||||
@@ -204,7 +203,7 @@ public abstract class UriComponents implements Serializable {
|
|||||||
protected abstract void copyToUriComponentsBuilder(UriComponentsBuilder builder);
|
protected abstract void copyToUriComponentsBuilder(UriComponentsBuilder builder);
|
||||||
|
|
||||||
|
|
||||||
// static expansion helpers
|
// Static expansion helpers
|
||||||
|
|
||||||
static String expandUriComponent(String source, UriTemplateVariables uriVariables) {
|
static String expandUriComponent(String source, UriTemplateVariables uriVariables) {
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
@@ -155,9 +155,9 @@ public abstract class UriUtils {
|
|||||||
* <a href="https://tools.ietf.org/html/rfc3986#section-2">RFC 3986 Section 2</a>.
|
* <a href="https://tools.ietf.org/html/rfc3986#section-2">RFC 3986 Section 2</a>.
|
||||||
* <p>This can be used to ensure the given String will not contain any
|
* <p>This can be used to ensure the given String will not contain any
|
||||||
* characters with reserved URI meaning regardless of URI component.
|
* characters with reserved URI meaning regardless of URI component.
|
||||||
* @param source the string to be encoded
|
* @param source the String to be encoded
|
||||||
* @param encoding the character encoding to encode to
|
* @param encoding the character encoding to encode to
|
||||||
* @return the encoded string
|
* @return the encoded String
|
||||||
* @throws UnsupportedEncodingException when the given encoding parameter is not supported
|
* @throws UnsupportedEncodingException when the given encoding parameter is not supported
|
||||||
*/
|
*/
|
||||||
public static String encode(String source, String encoding) throws UnsupportedEncodingException {
|
public static String encode(String source, String encoding) throws UnsupportedEncodingException {
|
||||||
|
|||||||
Reference in New Issue
Block a user