|
42 | 42 | import org.springframework.web.util.UriComponents.UriTemplateVariables;
|
43 | 43 |
|
44 | 44 | /**
|
45 |
| - * Builder for {@link UriComponents}. |
46 |
| - * |
47 |
| - * <p>Typical usage involves: |
| 45 | + * Builder for {@link UriComponents}. Use as follows: |
48 | 46 | * <ol>
|
49 |
| - * <li>Create a {@code UriComponentsBuilder} with one of the static factory methods |
50 |
| - * (such as {@link #fromPath(String)} or {@link #fromUri(URI)})</li> |
51 |
| - * <li>Set the various URI components through the respective methods ({@link #scheme(String)}, |
52 |
| - * {@link #userInfo(String)}, {@link #host(String)}, {@link #port(int)}, {@link #path(String)}, |
53 |
| - * {@link #pathSegment(String...)}, {@link #queryParam(String, Object...)}, and |
54 |
| - * {@link #fragment(String)}.</li> |
55 |
| - * <li>Build the {@link UriComponents} instance with the {@link #build()} method.</li> |
| 47 | + * <li>Create a builder through a factory method, e.g. {@link #fromUriString(String)}. |
| 48 | + * <li>Set URI components (e.g. scheme, host, path, etc) through instance methods. |
| 49 | + * <li>Build the {@link UriComponents}.</li> |
| 50 | + * <li>Expand URI variables from a map or array or variable values. |
| 51 | + * <li>Encode via {@link UriComponents#encode()}.</li> |
| 52 | + * <li>Use {@link UriComponents#toUri()} or {@link UriComponents#toUriString()}. |
56 | 53 | * </ol>
|
57 | 54 | *
|
| 55 | + * <p>By default, URI parsing is based on the {@link ParserType#RFC RFC parser type}, |
| 56 | + * which expects input strings to conform to RFC 3986 syntax. The alternative |
| 57 | + * {@link ParserType#WHAT_WG WhatWG parser type}, based on the algorithm from |
| 58 | + * the WhatWG <a href="https://url.spec.whatwg.org">URL Living Standard</a> |
| 59 | + * provides more lenient handling of a wide range of cases that occur in user |
| 60 | + * types URL's. |
| 61 | + * |
58 | 62 | * @author Arjen Poutsma
|
59 | 63 | * @author Rossen Stoyanchev
|
60 | 64 | * @author Phillip Webb
|
@@ -785,43 +789,39 @@ public UriComponentsBuilder cloneBuilder() {
|
785 | 789 | }
|
786 | 790 |
|
787 | 791 |
|
788 |
| - private interface PathComponentBuilder { |
789 |
| - |
790 |
| - @Nullable |
791 |
| - PathComponent build(); |
792 |
| - |
793 |
| - PathComponentBuilder cloneBuilder(); |
794 |
| - } |
795 |
| - |
796 |
| - |
797 | 792 | /**
|
798 |
| - * Enum to represent different URI parsing mechanisms. |
| 793 | + * Enum to provide a choice of URI parsers to use in {@link #fromUriString(String, ParserType)}. |
| 794 | + * @since 6.2 |
799 | 795 | */
|
800 | 796 | public enum ParserType {
|
801 | 797 |
|
802 | 798 | /**
|
803 |
| - * Parser that expects URI's conforming to RFC 3986 syntax. |
| 799 | + * This parser type expects URI's to conform to RFC 3986 syntax. |
804 | 800 | */
|
805 | 801 | RFC,
|
806 | 802 |
|
807 | 803 | /**
|
808 |
| - * Parser based on algorithm defined in the WhatWG URL Living standard. |
809 |
| - * Browsers use this algorithm to align on lenient parsing of user typed |
810 |
| - * URL's that may deviate from RFC syntax. |
811 |
| - * <p>For more details, see: |
812 |
| - * <ul> |
813 |
| - * <li><a href="https://url.spec.whatwg.org">URL Living Standard</a> |
814 |
| - * <li><a href="https://url.spec.whatwg.org/#url-parsing">Section 4.4: URL parsing</a> |
815 |
| - * <li><a href="https://github.com/web-platform-tests/wpt/tree/master/url">web-platform-tests</a> |
816 |
| - * </ul> |
817 |
| - * <p>Use this if you need to leniently handle URL's that don't conform |
818 |
| - * to RFC syntax, or for alignment with browser parsing. |
| 804 | + * This parser follows the |
| 805 | + * <a href="https://url.spec.whatwg.org/#url-parsing">URL parsing algorithm</a> |
| 806 | + * in the WhatWG URL Living standard that browsers implement to align on |
| 807 | + * lenient handling of user typed URL's that may not conform to RFC syntax. |
| 808 | + * @see <a href="https://url.spec.whatwg.org">URL Living Standard</a> |
| 809 | + * @see <a href="https://github.com/web-platform-tests/wpt/tree/master/url">URL tests</a> |
819 | 810 | */
|
820 | 811 | WHAT_WG
|
821 | 812 |
|
822 | 813 | }
|
823 | 814 |
|
824 | 815 |
|
| 816 | + private interface PathComponentBuilder { |
| 817 | + |
| 818 | + @Nullable |
| 819 | + PathComponent build(); |
| 820 | + |
| 821 | + PathComponentBuilder cloneBuilder(); |
| 822 | + } |
| 823 | + |
| 824 | + |
825 | 825 | private static class CompositePathComponentBuilder implements PathComponentBuilder {
|
826 | 826 |
|
827 | 827 | private final Deque<PathComponentBuilder> builders = new ArrayDeque<>();
|
|
0 commit comments