public static final class Uri.Builder extends Object
The standard URI format is as follows:
[scheme:]scheme-specific-part[#fragment]
An opaque URI must be an absolute URI, and its scheme-specific-part
field cannot start with a slash (/).
An opaque URI does not need to be parsed.
A hierarchical URI can be an absolute URI, but its scheme-specific-part
field must start with a slash (/).
It can also be a relative URI.
The standard format of a hierarchical URI is as follows:
[scheme:][//authority][path][?query][#fragment]
If the URI is of the server type, its authority field can be parsed in the following format:
[user-info@]host[:port]
| 构造器 | 说明 |
|---|---|
Builder() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
Uri.Builder |
appendDecodedPath(String path) |
Appends the decoded
path to the existing path in the current hierarchical URI. |
Uri.Builder |
appendDecodedQueryParam(String key,
String value) |
Appends the decoded
query to the current hierarchical URI. |
Uri.Builder |
appendEncodedPath(String path) |
Appends the encoded
path to the existing path in the current hierarchical URI. |
Uri |
build() |
|
Uri.Builder |
clearQuery() |
Clears the
query field of the current hierarchical URI. |
Uri.Builder |
decodedAuthority(String authority) |
Sets all characters of the
authority field in the current hierarchical URI to be encoded,
including the at signs (@) and colons (:). |
Uri.Builder |
decodedFragment(String fragment) |
Sets all characters of the
fragment field in the current URI to be encoded. |
Uri.Builder |
decodedOpaqueSsp(String opaqueSsp) |
Sets the
scheme-specific-part field in the current opaque URI to be encoded
but not to be parsed. |
Uri.Builder |
decodedPath(String path) |
Sets the characters other than slashes (/) of the
path field in the current
hierarchical URI to be encoded. |
Uri.Builder |
decodedQuery(String query) |
Sets all characters of the
query field in the current hierarchical URI to be encoded,
including the question marks (?) and equal signs (=). |
Uri.Builder |
encodedAuthority(String authority) |
Sets the
authority field of the current hierarchical URI. |
Uri.Builder |
encodedFragment(String fragment) |
Sets the
fragment field of the current URI. |
Uri.Builder |
encodedOpaqueSsp(String opaqueSsp) |
Sets the
scheme-specific-part field in the current opaque URI not to be parsed. |
Uri.Builder |
encodedPath(String path) |
Sets the
path field of the current hierarchical URI. |
Uri.Builder |
encodedQuery(String query) |
Sets the
query field of the current hierarchical URI. |
Uri.Builder |
scheme(String scheme) |
Sets the
scheme field of the current URI. |
String |
toString() |
Obtains the string representation of
Uri that is created via Builder. |
public Uri.Builder scheme(String scheme)
scheme field of the current URI.scheme - Indicates the scheme field to set.Builder object.public Uri.Builder decodedOpaqueSsp(String opaqueSsp)
scheme-specific-part field in the current opaque URI to be encoded
but not to be parsed.opaqueSsp - Indicates the decoded scheme-specific-part field to set for the opaque URI.Builder object.public Uri.Builder encodedOpaqueSsp(String opaqueSsp)
scheme-specific-part field in the current opaque URI not to be parsed.opaqueSsp - Indicates the encoded scheme-specific-part field to set for the opaque URI.Builder object.public Uri.Builder decodedAuthority(String authority)
authority field in the current hierarchical URI to be encoded,
including the at signs (@) and colons (:).authority - Indicates the decoded authority field to set for the hierarchical URI.Builder object.public Uri.Builder encodedAuthority(String authority)
authority field of the current hierarchical URI.authority - Indicates the encoded authority field to set for the hierarchical URI.Builder object.public Uri.Builder decodedPath(String path)
path field in the current
hierarchical URI to be encoded.path - Indicates the decoded path field to set for the hierarchical URI.Builder object.public Uri.Builder encodedPath(String path)
path field of the current hierarchical URI.path - Indicates the encoded path field to set for the hierarchical URI.Builder object.public Uri.Builder appendDecodedPath(String path)
path to the existing path in the current hierarchical URI.
If the path field in the URI has not been set, this added path will be processed as an
absolute path.
path - Indicates the decoded path to append to the hierarchical URI. The path must
not start with a slash (/).Builder object.public Uri.Builder appendEncodedPath(String path)
path to the existing path in the current hierarchical URI.
If the path field in the URI has not been set, this added path will be processed as an
absolute path.
path - Indicates the encoded path to append to the hierarchical URI. The path must not
start with a slash (/).Builder object.public Uri.Builder decodedQuery(String query)
query field in the current hierarchical URI to be encoded,
including the question marks (?) and equal signs (=).query - Indicates the decoded query field to set for the hierarchical URI.Builder object.public Uri.Builder encodedQuery(String query)
query field of the current hierarchical URI.query - Indicates the encoded query field to set for the hierarchical URI.Builder object.public Uri.Builder appendDecodedQueryParam(String key, String value)
query to the current hierarchical URI.key - Indicates the key of the decoded query.value - Indicates the value of the decoded query.Builder object.public Uri.Builder clearQuery()
query field of the current hierarchical URI.Builder object.public Uri.Builder decodedFragment(String fragment)
fragment field in the current URI to be encoded.fragment - Indicates the decoded fragment field to set for the URI.Builder object.public Uri.Builder encodedFragment(String fragment)
fragment field of the current URI.fragment - Indicates the encoded fragment field to set for the URI.Builder object.public Uri build()
opaque URI if the opaqueSsp parameter has been set;
returns a hierarchical URI otherwise.UnsupportedOperationException - Throws this exception if the opaqueSsp is
not null but scheme is null.