javax.ws.rs.Path#value for an explanation of URI templates.
Builder methods perform contextual encoding of characters not permitted in
the corresponding URI component following the rules of the
application/x-www-form-urlencoded
media type for query parameters and
RFC 3986 for all other
components. Note that only characters not permitted in a particular component
are subject to encoding so, e.g., a path supplied to one of the path
methods may contain matrix parameters or multiple path segments since the
separators are legal characters and will not be encoded. Percent encoded
values are also recognized where allowed and will not be double encoded.
URI templates are allowed in most components of a URI but their value is restricted to a particular component. E.g.
UriBuilder.fromPath("{arg1}").build("foo#bar");
would result in encoding of the '#' such that the resulting URI is
"foo%23bar". To create a URI "foo#bar" use
UriBuilder.fromPath("{arg1}").fragment("{arg2}").build("foo", "bar")
instead. URI template names and delimiters are never encoded but their
values are encoded when a URI is built.
Template parameter regular expressions are ignored when building a URI, i.e.
no validation is performed.
java.net.URI, javax.ws.rs.Path
| Access | Constructor and Description |
|---|---|
| protected | UriBuilder()
Protected constructor, use one of the static |
| Modifier and Type | Method and Description |
|---|---|
| public abstract URI | |
| public abstract URI | Returns: the URI built from the UriBuilder.a list of URI template parameter values. values, boolean if encodeSlashInPath)true, the slash ('/') characters
in parameter values will be encoded if the template
is placed in the URI path component, otherwise the slash
characters will not be encoded in path templates.Build a URI, using the supplied values in order to replace any URI template parameters. |
| public abstract URI | Returns: the URI built from the UriBuilder.a list of URI template parameter values. values)Build a URI. |
| public abstract URI | Returns: the URI built from the UriBuilder.a map of URI template parameter names and values. values)Build a URI. |
| public abstract URI | Returns: the URI built from the UriBuilder.a map of URI template parameter names and values. values)Build a URI. |
| public abstract URI | Returns: the URI built from the UriBuilder.a map of URI template parameter names and values. values, boolean if encodeSlashInPath)true, the slash ('/') characters
in parameter values will be encoded if the template
is placed in the URI path component, otherwise the slash
characters will not be encoded in path templates.Build a URI. |
| public abstract UriBuilder | Returns: a copy of the UriBuilder.Overrides java. |
| public abstract UriBuilder | |
| public static UriBuilder | |
| public static UriBuilder | Returns: the updated UriBuilder.the resource containing the method. resource, String the name of the method whose method)javax.ws.rs.Path value will be
used to obtain the path to append.Create a new instance representing a relative URI initialized from a
|
| public static UriBuilder | |
| public static UriBuilder | Returns: a new UriBuilder.a root resource whose resource)javax.ws.rs.Path value will
be used to initialize the UriBuilder.Create a new instance representing a relative URI initialized from a root resource class. |
| public static UriBuilder | |
| public static UriBuilder | |
| public abstract UriBuilder | |
| public abstract UriBuilder | Returns: the updated UriBuilder.the matrix parameter name, may contain URI template parameters. name, Object... the matrix parameter value(s), each object will be converted.
to a values)String using its toString() method. Stringified
values may contain URI template parameters.Append a matrix parameter to the existing set of matrix parameters of the current final segment of the URI path. |
| protected static UriBuilder | |
| public abstract UriBuilder | |
| public abstract UriBuilder | Returns: the updated UriBuilder.a resource whose resource)javax.ws.rs.Path value will be
used to obtain the path to append.Append the path from a Path-annotated class to the existing path. |
| public abstract UriBuilder | Returns: the updated UriBuilder.the resource containing the method. resource, String the name of the method whose method)javax.ws.rs.Path value will be
used to obtain the path to append.Append the path from a Path-annotated method to the existing path. |
| public abstract UriBuilder | Returns: the updated UriBuilder.a method whose method)javax.ws.rs.Path value will be
used to obtain the path to append to the existing path.Append the path from a |
| public abstract UriBuilder | Returns: the updated UriBuilder.the URI port, a value of -1 will unset an explicit port. port)Set the URI port. |
| public abstract UriBuilder | Returns: the updated UriBuilder.the query parameter name, may contain URI template parameters. name, Object... the query parameter value(s), each object will be converted
to a values)String using its toString() method. Stringified
values may contain URI template parameters.Append a query parameter to the existing set of query parameters. |
| public abstract UriBuilder | Returns: the updated UriBuilder.the matrix parameters, may contain URI template parameters.
A matrix)null value will remove all matrix parameters of the current final segment
of the current URI path.Set the matrix parameters of the current final segment of the current URI path. |
| public abstract UriBuilder | Returns: the updated UriBuilder.the matrix parameter name, may contain URI template parameters. name, Object... the matrix parameter value(s), each object will be converted.
to a values)String using its toString() method. Stringified
values may contain URI template parameters. If values is empty
or null then all current values of the parameter are removed.Replace the existing value(s) of a matrix parameter on the current final segment of the URI path. |
| public abstract UriBuilder | Returns: the updated UriBuilder.the path, may contain URI template parameters.
A path)null value will unset the path component of the URI.Set the URI path. |
| public abstract UriBuilder | Returns: the updated UriBuilder.the URI query string, may contain URI template parameters.
A query)null value will remove all query parameters.Set the URI query string. |
| public abstract UriBuilder | Returns: the updated UriBuilder.the query parameter name, may contain URI template parameters. name, Object... the query parameter value(s), each object will be converted
to a values)String using its toString() method. Stringified
values may contain URI template parameters. If values is empty
or null then all current values of the parameter are removed.Replace the existing value(s) of a query parameter. |
| public abstract UriBuilder | Returns: the updated UriBuilder.name of the URI template. name, Object value to be used to resolve the template. value)Resolve a URI template with a given |
| public abstract UriBuilder | Returns: the updated UriBuilder.name of the URI template. name, Object value to be used to resolve the template. value, boolean if encodeSlashInPath)true, the slash ('/') characters
in template values will be encoded if the template
is placed in the URI path component, otherwise the slash
characters will not be encoded in path templates.Resolve a URI template with a given |
| public abstract UriBuilder | Returns: the updated UriBuilder.name of the URI template. name, Object encoded value to be used to resolve the template. value)Resolve a URI template with a given |
| public abstract UriBuilder | Returns: the updated UriBuilder.a map of URI template names and their values. templateValues)Resolve one or more URI templates in this |
| public abstract UriBuilder | Returns: the updated UriBuilder.a map of URI template names and their values. templateValues, boolean if encodeSlashInPath)true, the slash ('/') characters
in template values will be encoded if the template
is placed in the URI path component, otherwise the slash
characters will not be encoded in path templates.Resolve one or more URI templates in this |
| public abstract UriBuilder | Returns: the updated UriBuilder.a map of URI template names and their values. templateValues)Resolve one or more URI templates in this |
| public abstract UriBuilder | |
| public abstract UriBuilder | Returns: the updated UriBuilder.the URI scheme-specific-part, may contain URI template parameters. ssp)Set the URI scheme-specific-part (see |
| public abstract UriBuilder | |
| public abstract String | Returns: the URI template string for this URI builder.Get the URI template string represented by this URI builder. |
| public abstract UriBuilder | |
| public abstract UriBuilder | |
| public abstract UriBuilder |
| UriBuilder | back to summary |
|---|---|
| protected UriBuilder() Protected constructor, use one of the static | |
| build | back to summary |
|---|---|
| public abstract URI build(Object... values) throws IllegalArgumentException, UriBuilderException Build a URI, using the supplied values in order to replace any URI
template parameters. Values are converted to All instances of the same template parameter will be replaced by the same value that corresponds to the position of the first instance of the template parameter. e.g. the template "{a}/{b}/{a}" with values {"x", "y", "z"} will result in the the URI "x/y/x", not "x/y/z". Note By default all
| |
| build | back to summary |
|---|---|
| public abstract URI build(Object[] values, boolean encodeSlashInPath) throws IllegalArgumentException, UriBuilderException Build a URI, using the supplied values in order to replace any URI
template parameters. Values are converted to All instances of the same template parameter will be replaced by the same value that corresponds to the position of the first instance of the template parameter. e.g. the template "{a}/{b}/{a}" with values {"x", "y", "z"} will result in the the URI "x/y/x", not "x/y/z".
The
| |
| buildFromEncoded | back to summary |
|---|---|
| public abstract URI buildFromEncoded(Object... values) throws IllegalArgumentException, UriBuilderException Build a URI.
Any URI templates parameters will be replaced with the supplied values in
order. Values are converted to All instances of the same template parameter will be replaced by the same value that corresponds to the position of the first instance of the template parameter. e.g. the template "{a}/{b}/{a}" with values {"x", "y", "z"} will result in the the URI "x/y/x", not "x/y/z".
| |
| buildFromEncodedMap | back to summary |
|---|---|
| public abstract URI buildFromEncodedMap(Map<String, ?> values) throws IllegalArgumentException, UriBuilderException Build a URI.
Any URI template parameters will be replaced by the value in
the supplied map. Values are converted to
| |
| buildFromMap | back to summary |
|---|---|
| public abstract URI buildFromMap(Map<String, ?> values) Build a URI.
Any URI template parameters will be replaced by the value in
the supplied map. Values are converted to Note By default all
| |
| buildFromMap | back to summary |
|---|---|
| public abstract URI buildFromMap(Map<String, ?> values, boolean encodeSlashInPath) throws IllegalArgumentException, UriBuilderException Build a URI.
Any URI template parameters will be replaced by the value in
the supplied map. Values are converted to
The
| |
| clone | back to summary |
|---|---|
| public abstract UriBuilder clone() Overrides java. Create a copy of the UriBuilder preserving its state. This is a more
efficient means of creating a copy than constructing a new UriBuilder
from a URI returned by the
| |
| fragment | back to summary |
|---|---|
| public abstract UriBuilder fragment(String fragment) Set the URI fragment.
| |
| fromLink | back to summary |
|---|---|
| public static UriBuilder fromLink(Link link) Create a new instance initialized from a Link.
| |
| fromMethod | back to summary |
|---|---|
| public static UriBuilder fromMethod(Class<?> resource, String method) Create a new instance representing a relative URI initialized from a
| |
| fromPath | back to summary |
|---|---|
| public static UriBuilder fromPath(String path) throws IllegalArgumentException Create a new instance representing a relative URI initialized from a URI path.
| |
| fromResource | back to summary |
|---|---|
| public static UriBuilder fromResource(Class<?> resource) Create a new instance representing a relative URI initialized from a root resource class.
| |
| fromUri | back to summary |
|---|---|
| public static UriBuilder fromUri(URI uri) Create a new instance initialized from an existing URI.
| |
| fromUri | back to summary |
|---|---|
| public static UriBuilder fromUri(String uriTemplate) Create a new instance initialized from an existing URI.
| |
| host | back to summary |
|---|---|
| public abstract UriBuilder host(String host) Set the URI host.
| |
| matrixParam | back to summary |
|---|---|
| public abstract UriBuilder matrixParam(String name, Object... values) Append a matrix parameter to the existing set of matrix parameters of the current final segment of the URI path. If multiple values are supplied the parameter will be added once per value. Note that the matrix parameters are tied to a particular path segment; subsequent addition of path segments will not affect their position in the URI path.
| |
| newInstance | back to summary |
|---|---|
| protected static UriBuilder newInstance() Creates a new instance of UriBuilder.
| |
| path | back to summary |
|---|---|
| public abstract UriBuilder path(String path) Append path to the existing path. When constructing the final path, a '/' separator will be inserted between the existing path and the supplied path if necessary. Existing '/' characters are preserved thus a single value can represent multiple URI path segments.
| |
| path | back to summary |
|---|---|
| public abstract UriBuilder path(Class<T> resource) Append the path from a Path-annotated class to the existing path. When constructing the final path, a '/' separator will be inserted between the existing path and the supplied path if necessary.
| |
| path | back to summary |
|---|---|
| public abstract UriBuilder path(Class<T> resource, String method) Append the path from a Path-annotated method to the
existing path.
When constructing the final path, a '/' separator will be inserted
between the existing path and the supplied path if necessary.
This method is a convenience shortcut to
| |
| path | back to summary |
|---|---|
| public abstract UriBuilder path(Method method) Append the path from a
| |
| port | back to summary |
|---|---|
| public abstract UriBuilder port(int port) Set the URI port.
| |
| queryParam | back to summary |
|---|---|
| public abstract UriBuilder queryParam(String name, Object... values) Append a query parameter to the existing set of query parameters. If multiple values are supplied the parameter will be added once per value.
| |
| replaceMatrix | back to summary |
|---|---|
| public abstract UriBuilder replaceMatrix(String matrix) Set the matrix parameters of the current final segment of the current URI path. This method will overwrite any existing matrix parameters on the current final segment of the current URI path. Note that the matrix parameters are tied to a particular path segment; subsequent addition of path segments will not affect their position in the URI path.
| |
| replaceMatrixParam | back to summary |
|---|---|
| public abstract UriBuilder replaceMatrixParam(String name, Object... values) Replace the existing value(s) of a matrix parameter on the current final segment of the URI path. If multiple values are supplied the parameter will be added once per value. Note that the matrix parameters are tied to a particular path segment; subsequent addition of path segments will not affect their position in the URI path.
| |
| replacePath | back to summary |
|---|---|
| public abstract UriBuilder replacePath(String path) Set the URI path. This method will overwrite any existing path and associated matrix parameters. Existing '/' characters are preserved thus a single value can represent multiple URI path segments.
| |
| replaceQuery | back to summary |
|---|---|
| public abstract UriBuilder replaceQuery(String query) Set the URI query string. This method will overwrite any existing query parameters.
| |
| replaceQueryParam | back to summary |
|---|---|
| public abstract UriBuilder replaceQueryParam(String name, Object... values) Replace the existing value(s) of a query parameter. If multiple values are supplied the parameter will be added once per value.
| |
| resolveTemplate | back to summary |
|---|---|
| public abstract UriBuilder resolveTemplate(String name, Object value) Resolve a URI template with a given
| |
| resolveTemplate | back to summary |
|---|---|
| public abstract UriBuilder resolveTemplate(String name, Object value, boolean encodeSlashInPath) Resolve a URI template with a given
| |
| resolveTemplateFromEncoded | back to summary |
|---|---|
| public abstract UriBuilder resolveTemplateFromEncoded(String name, Object value) Resolve a URI template with a given
| |
| resolveTemplates | back to summary |
|---|---|
| public abstract UriBuilder resolveTemplates(Map<String, Object> templateValues) Resolve one or more URI templates in this
| |
| resolveTemplates | back to summary |
|---|---|
| public abstract UriBuilder resolveTemplates(Map<String, Object> templateValues, boolean encodeSlashInPath) throws IllegalArgumentException Resolve one or more URI templates in this
| |
| resolveTemplatesFromEncoded | back to summary |
|---|---|
| public abstract UriBuilder resolveTemplatesFromEncoded(Map<String, Object> templateValues) Resolve one or more URI templates in this
| |
| scheme | back to summary |
|---|---|
| public abstract UriBuilder scheme(String scheme) Set the URI scheme.
| |
| schemeSpecificPart | back to summary |
|---|---|
| public abstract UriBuilder schemeSpecificPart(String ssp) Set the URI scheme-specific-part (see
| |
| segment | back to summary |
|---|---|
| public abstract UriBuilder segment(String... segments) Append path segments to the existing path. When constructing the final path, a '/' separator will be inserted between the existing path and the first path segment if necessary and each supplied segment will also be separated by '/'. Existing '/' characters are encoded thus a single value can only represent a single URI path segment.
| |
| toTemplate | back to summary |
|---|---|
| public abstract String toTemplate() Get the URI template string represented by this URI builder.
| |
| uri | back to summary |
|---|---|
| public abstract UriBuilder uri(URI uri) Copies the non-null components of the supplied URI to the UriBuilder replacing any existing values for those components.
| |
| uri | back to summary |
|---|---|
| public abstract UriBuilder uri(String uriTemplate) Parses the
| |
| userInfo | back to summary |
|---|---|
| public abstract UriBuilder userInfo(String ui) Set the URI user-info.
| |