@@ -81,10 +81,10 @@ public class GenericUrl extends GenericData {
8181 private String fragment ;
8282
8383 /**
84- * If true, the URL string originally given is used as is (without encoding, decoding and
85- * escaping) whenever referenced; otherwise, part of the URL string may be encoded or decoded as
86- * deemed appropriate or necessary.
87- */
84+ * If true, the URL string originally given is used as is (without encoding, decoding and
85+ * escaping) whenever referenced; otherwise, part of the URL string may be encoded or decoded as
86+ * deemed appropriate or necessary.
87+ */
8888 private boolean verbatim ;
8989
9090 public GenericUrl () {}
@@ -112,20 +112,20 @@ public GenericUrl(String encodedUrl) {
112112 /**
113113 * Constructs from an encoded URL.
114114 *
115- * <p>Any known query parameters with pre-defined fields as data keys are parsed based on
116- * their data type. Any unrecognized query parameter are always parsed as a string.
115+ * <p>Any known query parameters with pre-defined fields as data keys are parsed based on their
116+ * data type. Any unrecognized query parameter are always parsed as a string.
117117 *
118118 * <p>Any {@link MalformedURLException} is wrapped in an {@link IllegalArgumentException}.
119119 *
120120 * @param encodedUrl encoded URL, including any existing query parameters that should be parsed
121- * @param verbatim flag, to specify if URL should be used as is (without encoding, decoding and escaping)
121+ * @param verbatim flag, to specify if URL should be used as is (without encoding, decoding and
122+ * escaping)
122123 * @throws IllegalArgumentException if URL has a syntax error
123124 */
124125 public GenericUrl (String encodedUrl , boolean verbatim ) {
125126 this (parseURL (encodedUrl ), verbatim );
126127 }
127128
128-
129129 /**
130130 * Constructs from a URI.
131131 *
@@ -140,7 +140,8 @@ public GenericUrl(URI uri) {
140140 * Constructs from a URI.
141141 *
142142 * @param uri URI
143- * @param verbatim flag, to specify if URL should be used as is (without encoding, decoding and escaping)
143+ * @param verbatim flag, to specify if URL should be used as is (without encoding, decoding and
144+ * escaping)
144145 */
145146 public GenericUrl (URI uri , boolean verbatim ) {
146147 this (
@@ -168,7 +169,8 @@ public GenericUrl(URL url) {
168169 * Constructs from a URL.
169170 *
170171 * @param url URL
171- * @param verbatim flag, to specify if URL should be used as is (without encoding, decoding and escaping)
172+ * @param verbatim flag, to specify if URL should be used as is (without encoding, decoding and
173+ * escaping)
172174 * @since 1.14
173175 */
174176 public GenericUrl (URL url , boolean verbatim ) {
@@ -209,7 +211,7 @@ private GenericUrl(
209211 UrlEncodedParser .parse (query , this );
210212 }
211213 this .userInfo = userInfo != null ? CharEscapers .decodeUri (userInfo ) : null ;
212- }
214+ }
213215 }
214216
215217 @ Override
@@ -567,10 +569,11 @@ public static List<String> toPathParts(String encodedPath) {
567569 *
568570 * @param encodedPath slash-prefixed encoded path, for example {@code
569571 * "/m8/feeds/contacts/default/full"}
570- * @param verbatim flag, to specify if URL should be used as is (without encoding, decoding and escaping)
571- * @return path parts (decoded if not {@code verbatim}), with each part assumed to be preceded by a {@code '/'}, for example
572- * {@code "", "m8", "feeds", "contacts", "default", "full"}, or {@code null} for {@code null}
573- * or {@code ""} input
572+ * @param verbatim flag, to specify if URL should be used as is (without encoding, decoding and
573+ * escaping)
574+ * @return path parts (decoded if not {@code verbatim}), with each part assumed to be preceded by
575+ * a {@code '/'}, for example {@code "", "m8", "feeds", "contacts", "default", "full"}, or
576+ * {@code null} for {@code null} or {@code ""} input
574577 */
575578 public static List <String > toPathParts (String encodedPath , boolean verbatim ) {
576579 if (encodedPath == null || encodedPath .length () == 0 ) {
@@ -588,7 +591,7 @@ public static List<String> toPathParts(String encodedPath, boolean verbatim) {
588591 } else {
589592 sub = encodedPath .substring (cur );
590593 }
591- result .add (verbatim ? sub : CharEscapers .decodeUri (sub ));
594+ result .add (verbatim ? sub : CharEscapers .decodeUriPath (sub ));
592595 cur = slash + 1 ;
593596 }
594597 return result ;
@@ -608,13 +611,17 @@ private void appendRawPathFromParts(StringBuilder buf) {
608611 }
609612
610613 /** Adds query parameters from the provided entrySet into the buffer. */
611- static void addQueryParams (Set <Entry <String , Object >> entrySet , StringBuilder buf , boolean verbatim ) {
614+ static void addQueryParams (
615+ Set <Entry <String , Object >> entrySet , StringBuilder buf , boolean verbatim ) {
612616 // (similar to UrlEncodedContent)
613617 boolean first = true ;
614618 for (Map .Entry <String , Object > nameValueEntry : entrySet ) {
615619 Object value = nameValueEntry .getValue ();
616620 if (value != null ) {
617- String name = verbatim ? nameValueEntry .getKey () : CharEscapers .escapeUriQuery (nameValueEntry .getKey ());
621+ String name =
622+ verbatim
623+ ? nameValueEntry .getKey ()
624+ : CharEscapers .escapeUriQuery (nameValueEntry .getKey ());
618625 if (value instanceof Collection <?>) {
619626 Collection <?> collectionValue = (Collection <?>) value ;
620627 for (Object repeatedValue : collectionValue ) {
@@ -627,15 +634,17 @@ static void addQueryParams(Set<Entry<String, Object>> entrySet, StringBuilder bu
627634 }
628635 }
629636
630- private static boolean appendParam (boolean first , StringBuilder buf , String name , Object value , boolean verbatim ) {
637+ private static boolean appendParam (
638+ boolean first , StringBuilder buf , String name , Object value , boolean verbatim ) {
631639 if (first ) {
632640 first = false ;
633641 buf .append ('?' );
634642 } else {
635643 buf .append ('&' );
636644 }
637645 buf .append (name );
638- String stringValue = verbatim ? value .toString () : CharEscapers .escapeUriQuery (value .toString ());
646+ String stringValue =
647+ verbatim ? value .toString () : CharEscapers .escapeUriQuery (value .toString ());
639648 if (stringValue .length () != 0 ) {
640649 buf .append ('=' ).append (stringValue );
641650 }
0 commit comments