java.lang.Object
org.miaixz.bus.http.UnoUrl.Builder
- Enclosing class:
UnoUrl
A builder for creating
UnoUrl instances.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddEncodedPathSegment(String encodedPathSegment) Adds an encoded path segment.addEncodedPathSegments(String encodedPathSegments) Adds a list of encoded path segments.addEncodedQueryParameter(String encodedName, String encodedValue) Adds an encoded query parameter.addPathSegment(String pathSegment) Adds a path segment.addPathSegments(String pathSegments) Adds a list of path segments.addQueryParameter(String name, String value) Adds a query parameter.build()Builds a newUnoUrlinstance.encodedFragment(String encodedFragment) Sets the encoded fragment.encodedPassword(String encodedPassword) Sets the encoded password.encodedPath(String encodedPath) Sets the encoded path.encodedQuery(String encodedQuery) Sets the encoded query string.encodedUsername(String encodedUsername) Sets the encoded username.Sets the fragment.Sets the hostname.Sets the password.port(int port) Sets the port number.Sets the query string.removeAllEncodedQueryParameters(String encodedName) Removes all encoded query parameters with the given name.Removes all query parameters with the given name.removePathSegment(int index) Removes a path segment at a specific index.Sets the scheme of the URL.setEncodedPathSegment(int index, String encodedPathSegment) Sets an encoded path segment at a specific index.setEncodedQueryParameter(String encodedName, String encodedValue) Sets an encoded query parameter, replacing any existing parameters with the same name.setPathSegment(int index, String pathSegment) Sets a path segment at a specific index.setQueryParameter(String name, String value) Sets a query parameter, replacing any existing parameters with the same name.toString()Returns the string representation of the URL.Sets the username.
-
Constructor Details
-
Builder
public Builder()Default constructor.
-
-
Method Details
-
scheme
Sets the scheme of the URL.- Parameters:
scheme- The scheme (http or https).- Returns:
- this builder instance.
- Throws:
NullPointerException- if scheme is null.IllegalArgumentException- if the scheme is invalid.
-
username
Sets the username.- Parameters:
username- The username.- Returns:
- this builder instance.
- Throws:
NullPointerException- if username is null.
-
encodedUsername
Sets the encoded username.- Parameters:
encodedUsername- The encoded username.- Returns:
- this builder instance.
- Throws:
NullPointerException- if encodedUsername is null.
-
password
Sets the password.- Parameters:
password- The password.- Returns:
- this builder instance.
- Throws:
NullPointerException- if password is null.
-
encodedPassword
Sets the encoded password.- Parameters:
encodedPassword- The encoded password.- Returns:
- this builder instance.
- Throws:
NullPointerException- if encodedPassword is null.
-
host
Sets the hostname.- Parameters:
host- The hostname (regular hostname, IPv4, IPv6, or encoded IDN).- Returns:
- this builder instance.
- Throws:
NullPointerException- if host is null.IllegalArgumentException- if the host is invalid.
-
port
Sets the port number.- Parameters:
port- The port number.- Returns:
- this builder instance.
- Throws:
IllegalArgumentException- if the port number is invalid.
-
addPathSegment
Adds a path segment.- Parameters:
pathSegment- The path segment.- Returns:
- this builder instance.
- Throws:
NullPointerException- if pathSegment is null.
-
addPathSegments
Adds a list of path segments.- Parameters:
pathSegments- The path segments string.- Returns:
- this builder instance.
- Throws:
NullPointerException- if pathSegments is null.
-
addEncodedPathSegment
Adds an encoded path segment.- Parameters:
encodedPathSegment- The encoded path segment.- Returns:
- this builder instance.
- Throws:
NullPointerException- if encodedPathSegment is null.
-
addEncodedPathSegments
Adds a list of encoded path segments.- Parameters:
encodedPathSegments- The encoded path segments string.- Returns:
- this builder instance.
- Throws:
NullPointerException- if encodedPathSegments is null.
-
setPathSegment
Sets a path segment at a specific index.- Parameters:
index- The index.pathSegment- The path segment.- Returns:
- this builder instance.
- Throws:
NullPointerException- if pathSegment is null.IllegalArgumentException- if the path segment is invalid.
-
setEncodedPathSegment
Sets an encoded path segment at a specific index.- Parameters:
index- The index.encodedPathSegment- The encoded path segment.- Returns:
- this builder instance.
- Throws:
NullPointerException- if encodedPathSegment is null.IllegalArgumentException- if the path segment is invalid.
-
removePathSegment
Removes a path segment at a specific index.- Parameters:
index- The index.- Returns:
- this builder instance.
-
encodedPath
Sets the encoded path.- Parameters:
encodedPath- The encoded path.- Returns:
- this builder instance.
- Throws:
NullPointerException- if encodedPath is null.IllegalArgumentException- if the path is invalid.
-
query
Sets the query string.- Parameters:
query- The query string.- Returns:
- this builder instance.
-
encodedQuery
Sets the encoded query string.- Parameters:
encodedQuery- The encoded query string.- Returns:
- this builder instance.
-
addQueryParameter
Adds a query parameter.- Parameters:
name- The parameter name.value- The parameter value.- Returns:
- this builder instance.
- Throws:
NullPointerException- if name is null.
-
addEncodedQueryParameter
Adds an encoded query parameter.- Parameters:
encodedName- The encoded parameter name.encodedValue- The encoded parameter value.- Returns:
- this builder instance.
- Throws:
NullPointerException- if encodedName is null.
-
setQueryParameter
Sets a query parameter, replacing any existing parameters with the same name.- Parameters:
name- The parameter name.value- The parameter value.- Returns:
- this builder instance.
- Throws:
NullPointerException- if name is null.
-
setEncodedQueryParameter
Sets an encoded query parameter, replacing any existing parameters with the same name.- Parameters:
encodedName- The encoded parameter name.encodedValue- The encoded parameter value.- Returns:
- this builder instance.
- Throws:
NullPointerException- if encodedName is null.
-
removeAllQueryParameters
Removes all query parameters with the given name.- Parameters:
name- The parameter name.- Returns:
- this builder instance.
- Throws:
NullPointerException- if name is null.
-
removeAllEncodedQueryParameters
Removes all encoded query parameters with the given name.- Parameters:
encodedName- The encoded parameter name.- Returns:
- this builder instance.
- Throws:
NullPointerException- if encodedName is null.
-
fragment
Sets the fragment.- Parameters:
fragment- The fragment.- Returns:
- this builder instance.
-
encodedFragment
Sets the encoded fragment.- Parameters:
encodedFragment- The encoded fragment.- Returns:
- this builder instance.
-
build
Builds a newUnoUrlinstance.- Returns:
- a new
UnoUrlinstance. - Throws:
IllegalStateException- if the scheme or host is not set.
-
toString
Returns the string representation of the URL.
-