- All Superinterfaces:
Cloneable
A URI builder is used for creating URIs as defined by RFC 3986.
The URI components provided to the builder can be parameterized with parameters of the form {<name>[:<pattern>]}
when the
component allows it. It allows to create URI templates used to generate contextual URIs or create URI patterns to match particular URIs.
The following is a complete example of parameterized URI:
{scheme}://{userinfo}@{host}:{port}/a/{segment}?parameter={parameter}#{fragment}
- Since:
- 1.0
- Author:
- Jeremy Kuhn
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault URI
Builds the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping slash in the path segment components.default URI
Builds the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping slash in the path segment components.Builds the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping or not slash in the path segment components.default URI
Builds the URI from the builder's URI components after replacing the parameters with the string representation of the specified values.Builds the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping or not slash in the path segment components.default String
Builds the path component string from the builder's URI path segment components after replacing the parameters with the string representation of the specified values escaping slash in path segment components.default String
Builds the path component string from the builder's URI path segment components after replacing the parameters with the string representation of the specified values escaping slash in path segment components.Builds the path component string from the builder's URI path segment components after replacing the parameters with the string representation of the specified values escaping or not slash in the path segment components.Builds the path component string from the builder's URI path segment components after replacing the parameters with the string representation of the specified values escaping slash in path segment components.Builds the path component string from the builder's URI path segment components after replacing the parameters with the string representation of the specified values escaping or not slash in the path segment components.default URIPattern
Builds a URI pattern to exactly match builder's URI path component.buildPathPattern
(boolean matchTrailingSlash) Builds a URI pattern to match builder's URI path component including trailing slash or not.default URIPattern
Builds a URI pattern to exactly match builder's URI.buildPattern
(boolean matchTrailingSlash) Builds a URI pattern to match builder's URI including trailing slash or not.default String
buildQuery
(Object... values) Builds the query component string from the builder's URI query parameter components after replacing the parameters with the string representation of the specified values.buildQuery
(List<Object> values) Builds the query component string from the builder's URI query parameter components after replacing the parameters with the string representation of the specified values.buildQuery
(Map<String, ?> values) Builds the query component string from the builder's URI query parameter components after replacing the parameters with the string representation of the specified values.Builds the path component raw string from the builder's path segment components.Builds the query component raw string from the builder's query parameter components.Builds the raw string representation of the URI from the builder's URI components.default String
buildString
(Object... values) Builds the string representation of the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping slash in path segment components.default String
buildString
(List<Object> values) Builds the string representation of the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping slash in path segment components.buildString
(List<Object> values, boolean escapeSlash) Builds the string representation of the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping or not slash in the path segment components.default String
buildString
(Map<String, ?> values) Builds the string representation of the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping slash in path segment components.buildString
(Map<String, ?> values, boolean escapeSlash) Builds the string representation of the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping or not slash in the path segment components.Clears the path component.Clears the query component.clone()
Clones the URI builder.Sets the fragment component as defined by RFC 3986 Section 3.5.Returns the list of parameters specified in all builder's URI components.Returns the list of parameters specified in the builder's path component.getQueryParameters
(Object... values) Returns a map containing the query parameters after replacing the parameters with the string representation of the specified values.getQueryParameters
(List<Object> values) Returns a map containing the query parameters after replacing the parameters with the string representation of the specified values.getQueryParameters
(Map<String, ?> values) Returns a map containing the query parameters after replacing the parameters with the string representation of the specified values.Returns a map containing the raw query parameters.Sets the host component as defined by RFC 3986 Section 3.2.2.default URIBuilder
Appends the specified path as defined by RFC 3986 Section 3.3 ignoring the trailing slashAppends the specified path as defined by RFC 3986 Section 3.3 ignoring or not the trailing slash.Sets the port component as defined by RFC 3986 Section 3.2.3.Sets the port component as defined by RFC 3986 Section 3.2.3.Sets the query component as defined by RFC 3986 Section 3.4.queryParameter
(String name, String value) Appends a query parameter component with specified name and value as defined by RFC 3986 Section 3.4.Sets the scheme component as defined by RFC 3986 Section 3.1.Appends the specified path segment as defined by RFC 3986 Section 3.3Sets the user information component as defined by RFC 3986 Section 3.2.1.
-
Method Details
-
scheme
Sets the scheme component as defined by RFC 3986 Section 3.1.
- Parameters:
scheme
- the scheme to set- Returns:
- the URI builder
-
userInfo
Sets the user information component as defined by RFC 3986 Section 3.2.1.
- Parameters:
userInfo
- the user information to set- Returns:
- the URI builder
-
host
Sets the host component as defined by RFC 3986 Section 3.2.2.
- Parameters:
host
- the host to set- Returns:
- the URI builder
-
port
Sets the port component as defined by RFC 3986 Section 3.2.3.
- Parameters:
port
- the port to set- Returns:
- the URI builder
-
port
Sets the port component as defined by RFC 3986 Section 3.2.3.
- Parameters:
port
- the port to set- Returns:
- the URI builder
-
path
Appends the specified path as defined by RFC 3986 Section 3.3 ignoring the trailing slash
- Parameters:
path
- the path to append- Returns:
- the URI builder
-
path
Appends the specified path as defined by RFC 3986 Section 3.3 ignoring or not the trailing slash.
- Parameters:
path
- the path to appendignoreTrailingSlash
- true to ignore the trailing slash- Returns:
- the URI builder
-
segment
Appends the specified path segment as defined by RFC 3986 Section 3.3
- Parameters:
segment
- the path segment to append- Returns:
- the URI builder
-
clearPath
URIBuilder clearPath()Clears the path component.
- Returns:
- the URI builder
-
query
Sets the query component as defined by RFC 3986 Section 3.4.
This method basically replaces previous query component value with the specified value removing query parameters if any. Implementation does not extract query parameters from the specified value which remains opaque. If you wish to provide query parameters you should use
queryParameter(String, String)
instead.- Parameters:
value
- the query value- Returns:
- the URI builder
-
queryParameter
Appends a query parameter component with specified name and value as defined by RFC 3986 Section 3.4.
- Parameters:
name
- the query parameter namevalue
- the query parameter value- Returns:
- the URI builder
-
clearQuery
URIBuilder clearQuery()Clears the query component.
- Returns:
- the URI builder
-
fragment
Sets the fragment component as defined by RFC 3986 Section 3.5.
- Parameters:
fragment
- the fragment to set- Returns:
- the URI builder
-
getParameterNames
Returns the list of parameters specified in all builder's URI components.
- Returns:
- a list of parameter names
-
getPathParameterNames
Returns the list of parameters specified in the builder's path component.
- Returns:
- a list of parameter names
-
getQueryParameters
Returns a map containing the query parameters after replacing the parameters with the string representation of the specified values.
- Parameters:
values
- an array of values to replace the components parameters- Returns:
- a map of query parameters grouped by name
- Throws:
URIBuilderException
- if there was an error building the query parameters
-
getQueryParameters
Returns a map containing the query parameters after replacing the parameters with the string representation of the specified values.
- Parameters:
values
- a list of values to replace the components parameters- Returns:
- a map of query parameters grouped by name
- Throws:
URIBuilderException
- if there was an error building the query parameters
-
getQueryParameters
Returns a map containing the query parameters after replacing the parameters with the string representation of the specified values.
- Parameters:
values
- a map of values to replace the components parameters- Returns:
- a map of query parameters grouped by name
- Throws:
URIBuilderException
- if there was an error building the query parameters
-
getRawQueryParameters
Returns a map containing the raw query parameters.
- Returns:
- a map of query parameters grouped by name
- Throws:
URIBuilderException
- if there was an error building the query parameters
-
build
Builds the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping slash in the path segment components.
- Parameters:
values
- an array of values to replace the components parameters- Returns:
- a URI
- Throws:
URIBuilderException
- if there was an error building the URI
-
build
Builds the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping slash in the path segment components.
- Parameters:
values
- a list of values to replace the components parameters- Returns:
- a URI
- Throws:
URIBuilderException
- if there was an error building the URI
-
build
Builds the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping or not slash in the path segment components.
- Parameters:
values
- a list of values to replace the components parametersescapeSlash
- true to escape slash in the path segment components- Returns:
- a URI
- Throws:
URIBuilderException
- if there was an error building the URI
-
build
Builds the URI from the builder's URI components after replacing the parameters with the string representation of the specified values.
- Parameters:
values
- a map of values to replace the components parameters- Returns:
- a URI
- Throws:
URIBuilderException
- if there was an error building the URI
-
build
Builds the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping or not slash in the path segment components.
- Parameters:
values
- a map of values to replace the components parametersescapeSlash
- true to escape slash in the path segment components- Returns:
- a URI
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildString
Builds the string representation of the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping slash in path segment components.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- an array of values to replace the components parameters- Returns:
- a string representation of a URI
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildString
Builds the string representation of the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping slash in path segment components.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- a list of values to replace the components parameters- Returns:
- a string representation of a URI
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildString
Builds the string representation of the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping or not slash in the path segment components.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- a list of values to replace the components parametersescapeSlash
- true to escape slash in the path segment components- Returns:
- a string representation of a URI
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildString
Builds the string representation of the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping slash in path segment components.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- a map of values to replace the components parameters- Returns:
- a string representation of a URI
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildString
Builds the string representation of the URI from the builder's URI components after replacing the parameters with the string representation of the specified values escaping or not slash in the path segment components.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- a map of values to replace the components parametersescapeSlash
- true to escape slash in the path segment components- Returns:
- a string representation of a URI
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildRawString
Builds the raw string representation of the URI from the builder's URI components.
- Returns:
- a raw string representation of a URI
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildPath
Builds the path component string from the builder's URI path segment components after replacing the parameters with the string representation of the specified values escaping slash in path segment components.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- an array of values to replace the path components parameters- Returns:
- a path string
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildPath
Builds the path component string from the builder's URI path segment components after replacing the parameters with the string representation of the specified values escaping slash in path segment components.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- a list of values to replace the path components parameters- Returns:
- a path string
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildPath
Builds the path component string from the builder's URI path segment components after replacing the parameters with the string representation of the specified values escaping or not slash in the path segment components.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- an array of values to replace the path components parametersescapeSlash
- true to escape slash in the path segment components- Returns:
- a path string
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildPath
Builds the path component string from the builder's URI path segment components after replacing the parameters with the string representation of the specified values escaping slash in path segment components.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- a map of values to replace the components parameters- Returns:
- a path string
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildPath
Builds the path component string from the builder's URI path segment components after replacing the parameters with the string representation of the specified values escaping or not slash in the path segment components.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- a map of values to replace the components parametersescapeSlash
- true to escape slashes, false otherwise- Returns:
- a path string
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildRawPath
Builds the path component raw string from the builder's path segment components.
- Returns:
- a raw path string
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildQuery
Builds the query component string from the builder's URI query parameter components after replacing the parameters with the string representation of the specified values.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- an array of values to replace the path components parameters- Returns:
- a query string
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildQuery
Builds the query component string from the builder's URI query parameter components after replacing the parameters with the string representation of the specified values.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- a list of values to replace the path components parameters- Returns:
- a query string
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildQuery
Builds the query component string from the builder's URI query parameter components after replacing the parameters with the string representation of the specified values.
Note that the resulting value is percent encoded as defined by RFC 3986 Section 2.1.
- Parameters:
values
- a map of values to replace the components parameters- Returns:
- a query string
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildRawQuery
Builds the query component raw string from the builder's query parameter components.
- Returns:
- a raw query string
- Throws:
URIBuilderException
- if there was an error building the URI
-
buildPattern
Builds a URI pattern to exactly match builder's URI.
- Returns:
- a URI pattern
-
buildPattern
Builds a URI pattern to match builder's URI including trailing slash or not.
- Parameters:
matchTrailingSlash
- true to match trailing slash- Returns:
- a URI pattern
-
buildPathPattern
Builds a URI pattern to exactly match builder's URI path component.
- Returns:
- a URI pattern
-
buildPathPattern
Builds a URI pattern to match builder's URI path component including trailing slash or not.
- Parameters:
matchTrailingSlash
- true to match trailing slash- Returns:
- a URI pattern
-
clone
URIBuilder clone()Clones the URI builder.
- Returns:
- A copy of the URI builder
-