1
1
/*
2
- * Copyright 2002-2013 the original author or authors.
2
+ * Copyright 2002-2014 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
30
30
import org .springframework .util .MultiValueMap ;
31
31
32
32
/**
33
- * Represents an immutable collection of URI components, mapping component type to string
34
- * values. Contains convenience getters for all components. Effectively similar to {@link
35
- * java.net.URI}, but with more powerful encoding options and support for URI template
36
- * variables.
33
+ * Represents an immutable collection of URI components, mapping component type to
34
+ * String values. Contains convenience getters for all components. Effectively similar
35
+ * to {@link java.net.URI}, but with more powerful encoding options and support for
36
+ * URI template variables.
37
37
*
38
38
* @author Arjen Poutsma
39
39
* @since 3.1
40
40
* @see UriComponentsBuilder
41
41
*/
42
+ @ SuppressWarnings ("serial" )
42
43
public abstract class UriComponents implements Serializable {
43
44
44
45
private static final String DEFAULT_ENCODING = "UTF-8" ;
@@ -118,54 +119,55 @@ public final String getFragment() {
118
119
/**
119
120
* Encode all URI components using their specific encoding rules, and returns the
120
121
* result as a new {@code UriComponents} instance. This method uses UTF-8 to encode.
121
- * @return the encoded uri components
122
+ * @return the encoded URI components
122
123
*/
123
124
public final UriComponents encode () {
124
125
try {
125
126
return encode (DEFAULT_ENCODING );
126
127
}
127
- catch (UnsupportedEncodingException e ) {
128
- throw new InternalError ("\" " + DEFAULT_ENCODING + "\" not supported" );
128
+ catch (UnsupportedEncodingException ex ) {
129
+ // should not occur
130
+ throw new IllegalStateException (ex );
129
131
}
130
132
}
131
133
132
134
/**
133
135
* Encode all URI components using their specific encoding rules, and
134
136
* returns the result as a new {@code UriComponents} instance.
135
137
* @param encoding the encoding of the values contained in this map
136
- * @return the encoded uri components
138
+ * @return the encoded URI components
137
139
* @throws UnsupportedEncodingException if the given encoding is not supported
138
140
*/
139
141
public abstract UriComponents encode (String encoding ) throws UnsupportedEncodingException ;
140
142
141
143
/**
142
- * Replaces all URI template variables with the values from a given map. The map keys
143
- * represent variable names; the values variable values. The order of variables is not
144
- * significant.
144
+ * Replace all URI template variables with the values from a given map.
145
+ * <p>The given map keys represent variable names; the corresponding values
146
+ * represent variable values. The order of variables is not significant.
145
147
* @param uriVariables the map of URI variables
146
- * @return the expanded uri components
148
+ * @return the expanded URI components
147
149
*/
148
150
public final UriComponents expand (Map <String , ?> uriVariables ) {
149
151
Assert .notNull (uriVariables , "'uriVariables' must not be null" );
150
152
return expandInternal (new MapTemplateVariables (uriVariables ));
151
153
}
152
154
153
155
/**
154
- * Replaces all URI template variables with the values from a given array. The array
155
- * represent variable values. The order of variables is significant.
156
- * @param uriVariableValues URI variable values
157
- * @return the expanded uri components
156
+ * Replace all URI template variables with the values from a given array.
157
+ * <p>The given array represents variable values. The order of variables is significant.
158
+ * @param uriVariableValues the URI variable values
159
+ * @return the expanded URI components
158
160
*/
159
161
public final UriComponents expand (Object ... uriVariableValues ) {
160
162
Assert .notNull (uriVariableValues , "'uriVariableValues' must not be null" );
161
163
return expandInternal (new VarArgsTemplateVariables (uriVariableValues ));
162
164
}
163
165
164
166
/**
165
- * Replaces all URI template variables with the values from the given {@link
166
- * UriTemplateVariables}
167
- * @param uriVariables URI template values
168
- * @return the expanded uri components
167
+ * Replace all URI template variables with the values from the given
168
+ * {@link UriTemplateVariables}.
169
+ * @param uriVariables the URI template values
170
+ * @return the expanded URI components
169
171
*/
170
172
abstract UriComponents expandInternal (UriTemplateVariables uriVariables );
171
173
@@ -176,12 +178,12 @@ public final UriComponents expand(Object... uriVariableValues) {
176
178
public abstract UriComponents normalize ();
177
179
178
180
/**
179
- * Returns a URI string from this {@code UriComponents} instance.
181
+ * Return a URI string from this {@code UriComponents} instance.
180
182
*/
181
183
public abstract String toUriString ();
182
184
183
185
/**
184
- * Returns a {@code URI} from this {@code UriComponents} instance.
186
+ * Return a {@code URI} from this {@code UriComponents} instance.
185
187
*/
186
188
public abstract URI toUri ();
187
189
0 commit comments