@@ -81,10 +81,10 @@ public class GenericUrl extends GenericData {
81
81
private String fragment ;
82
82
83
83
/**
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
+ */
88
88
private boolean verbatim ;
89
89
90
90
public GenericUrl () {}
@@ -112,20 +112,20 @@ public GenericUrl(String encodedUrl) {
112
112
/**
113
113
* Constructs from an encoded URL.
114
114
*
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.
117
117
*
118
118
* <p>Any {@link MalformedURLException} is wrapped in an {@link IllegalArgumentException}.
119
119
*
120
120
* @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)
122
123
* @throws IllegalArgumentException if URL has a syntax error
123
124
*/
124
125
public GenericUrl (String encodedUrl , boolean verbatim ) {
125
126
this (parseURL (encodedUrl ), verbatim );
126
127
}
127
128
128
-
129
129
/**
130
130
* Constructs from a URI.
131
131
*
@@ -140,7 +140,8 @@ public GenericUrl(URI uri) {
140
140
* Constructs from a URI.
141
141
*
142
142
* @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)
144
145
*/
145
146
public GenericUrl (URI uri , boolean verbatim ) {
146
147
this (
@@ -168,7 +169,8 @@ public GenericUrl(URL url) {
168
169
* Constructs from a URL.
169
170
*
170
171
* @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)
172
174
* @since 1.14
173
175
*/
174
176
public GenericUrl (URL url , boolean verbatim ) {
@@ -209,7 +211,7 @@ private GenericUrl(
209
211
UrlEncodedParser .parse (query , this );
210
212
}
211
213
this .userInfo = userInfo != null ? CharEscapers .decodeUri (userInfo ) : null ;
212
- }
214
+ }
213
215
}
214
216
215
217
@ Override
@@ -567,10 +569,11 @@ public static List<String> toPathParts(String encodedPath) {
567
569
*
568
570
* @param encodedPath slash-prefixed encoded path, for example {@code
569
571
* "/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
574
577
*/
575
578
public static List <String > toPathParts (String encodedPath , boolean verbatim ) {
576
579
if (encodedPath == null || encodedPath .length () == 0 ) {
@@ -588,7 +591,7 @@ public static List<String> toPathParts(String encodedPath, boolean verbatim) {
588
591
} else {
589
592
sub = encodedPath .substring (cur );
590
593
}
591
- result .add (verbatim ? sub : CharEscapers .decodeUri (sub ));
594
+ result .add (verbatim ? sub : CharEscapers .decodeUriPath (sub ));
592
595
cur = slash + 1 ;
593
596
}
594
597
return result ;
@@ -608,13 +611,17 @@ private void appendRawPathFromParts(StringBuilder buf) {
608
611
}
609
612
610
613
/** 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 ) {
612
616
// (similar to UrlEncodedContent)
613
617
boolean first = true ;
614
618
for (Map .Entry <String , Object > nameValueEntry : entrySet ) {
615
619
Object value = nameValueEntry .getValue ();
616
620
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 ());
618
625
if (value instanceof Collection <?>) {
619
626
Collection <?> collectionValue = (Collection <?>) value ;
620
627
for (Object repeatedValue : collectionValue ) {
@@ -627,15 +634,17 @@ static void addQueryParams(Set<Entry<String, Object>> entrySet, StringBuilder bu
627
634
}
628
635
}
629
636
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 ) {
631
639
if (first ) {
632
640
first = false ;
633
641
buf .append ('?' );
634
642
} else {
635
643
buf .append ('&' );
636
644
}
637
645
buf .append (name );
638
- String stringValue = verbatim ? value .toString () : CharEscapers .escapeUriQuery (value .toString ());
646
+ String stringValue =
647
+ verbatim ? value .toString () : CharEscapers .escapeUriQuery (value .toString ());
639
648
if (stringValue .length () != 0 ) {
640
649
buf .append ('=' ).append (stringValue );
641
650
}
0 commit comments