Top Description Constructors Methods
javax.ws.rs.core

public abstract Class UriBuilder

extends Object
Class Inheritance
Imports
java.lang.reflect.Method, java.net.URI, java.util.Map, javax.ws.rs.ext.RuntimeDelegate

URI template-aware utility class for building URIs from their components. See 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.
Authors
Paul Sandoz, Marc Hadley
Since
1.0
See Also
java.net.URI, javax.ws.rs.Path

Constructor Summary

AccessConstructor and Description
protected
UriBuilder()

Protected constructor, use one of the static fromXxx(...) methods to obtain an instance.

Method Summary

Modifier and TypeMethod and Description
public abstract URI

Returns:

the URI built from the UriBuilder.
build
(Object...
a list of URI template parameter values.
values
)

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.
build
(Object[]
a list of URI template parameter values.
values
,
boolean
if 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.
encodeSlashInPath
)

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.
buildFromEncoded
(Object...
a list of URI template parameter values.
values
)

Build a URI.

public abstract URI

Returns:

the URI built from the UriBuilder.
buildFromEncodedMap
(Map<String, ?>
a map of URI template parameter names and values.
values
)

Build a URI.

public abstract URI

Returns:

the URI built from the UriBuilder.
buildFromMap
(Map<String, ?>
a map of URI template parameter names and values.
values
)

Build a URI.

public abstract URI

Returns:

the URI built from the UriBuilder.
buildFromMap
(Map<String, ?>
a map of URI template parameter names and values.
values
,
boolean
if 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.
encodeSlashInPath
)

Build a URI.

public abstract UriBuilder

Returns:

a copy of the UriBuilder.
clone
()

Overrides java.lang.Object.clone.

Create a copy of the UriBuilder preserving its state.
public abstract UriBuilder

Returns:

the updated UriBuilder.
fragment
(String
the URI fragment, may contain URI template parameters. A null value will remove any existing fragment.
fragment
)

Set the URI fragment.

public static UriBuilder

Returns:

the updated UriBuilder.
fromMethod
(Class<?>
the resource containing the method.
resource
,
String
the name of the method whose javax.ws.rs.Path value will be used to obtain the path to append.
method
)

Create a new instance representing a relative URI initialized from a javax.ws.rs.Path-annotated method.

public static UriBuilder

Returns:

a new UriBuilder.
fromPath
(String
a URI path that will be used to initialize the UriBuilder, may contain URI template parameters.
path
)

Create a new instance representing a relative URI initialized from a URI path.

public static UriBuilder

Returns:

a new UriBuilder.
fromResource
(Class<?>
a root resource whose javax.ws.rs.Path value will be used to initialize the UriBuilder.
resource
)

Create a new instance representing a relative URI initialized from a root resource class.

public static UriBuilder

Returns:

a new UriBuilder.
fromUri
(URI
a URI that will be used to initialize the UriBuilder.
uri
)

Create a new instance initialized from an existing URI.

public static UriBuilder

Returns:

a new UriBuilder.
fromUri
(String
a URI template that will be used to initialize the UriBuilder, may contain URI parameters.
uriTemplate
)

Create a new instance initialized from an existing URI.

public abstract UriBuilder

Returns:

the updated UriBuilder.
host
(String
the URI host, may contain URI template parameters. A null value will unset the host component of the URI, but will not unset other authority component parts (user info or port).
host
)

Set the URI host.

public abstract UriBuilder

Returns:

the updated UriBuilder.
matrixParam
(String
the matrix parameter name, may contain URI template parameters.
name
,
Object...
the matrix parameter value(s), each object will be converted. to a String using its toString() method. Stringified values may contain URI template parameters.
values
)

Append a matrix parameter to the existing set of matrix parameters of the current final segment of the URI path.

protected static UriBuilder

Returns:

a new instance of UriBuilder.
newInstance
()

Creates a new instance of UriBuilder.

public abstract UriBuilder

Returns:

the updated UriBuilder.
path
(String
the path, may contain URI template parameters.
path
)

Append path to the existing path.

public abstract UriBuilder

Returns:

the updated UriBuilder.
path
(Class<T>
a resource whose javax.ws.rs.Path value will be used to obtain the path to append.
resource
)

Append the path from a Path-annotated class to the existing path.

public abstract UriBuilder

Returns:

the updated UriBuilder.
path
(Class<T>
the resource containing the method.
resource
,
String
the name of the method whose javax.ws.rs.Path value will be used to obtain the path to append.
method
)

Append the path from a Path-annotated method to the existing path.

public abstract UriBuilder

Returns:

the updated UriBuilder.
path
(Method
a method whose javax.ws.rs.Path value will be used to obtain the path to append to the existing path.
method
)

Append the path from a javax.ws.rs.Path-annotated method to the existing path.

public abstract UriBuilder

Returns:

the updated UriBuilder.
port
(int
the URI port, a value of -1 will unset an explicit port.
port
)

Set the URI port.

public abstract UriBuilder

Returns:

the updated UriBuilder.
queryParam
(String
the query parameter name, may contain URI template parameters.
name
,
Object...
the query parameter value(s), each object will be converted to a String using its toString() method. Stringified values may contain URI template parameters.
values
)

Append a query parameter to the existing set of query parameters.

public abstract UriBuilder

Returns:

the updated UriBuilder.
replaceMatrix
(String
the matrix parameters, may contain URI template parameters. A null value will remove all matrix parameters of the current final segment of the current URI path.
matrix
)

Set the matrix parameters of the current final segment of the current URI path.

public abstract UriBuilder

Returns:

the updated UriBuilder.
replaceMatrixParam
(String
the matrix parameter name, may contain URI template parameters.
name
,
Object...
the matrix parameter value(s), each object will be converted. to a 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.
values
)

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.
replacePath
(String
the path, may contain URI template parameters. A null value will unset the path component of the URI.
path
)

Set the URI path.

public abstract UriBuilder

Returns:

the updated UriBuilder.
replaceQuery
(String
the URI query string, may contain URI template parameters. A null value will remove all query parameters.
query
)

Set the URI query string.

public abstract UriBuilder

Returns:

the updated UriBuilder.
replaceQueryParam
(String
the query parameter name, may contain URI template parameters.
name
,
Object...
the query parameter value(s), each object will be converted to a 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.
values
)

Replace the existing value(s) of a query parameter.

public abstract UriBuilder

Returns:

the updated UriBuilder.
resolveTemplate
(String
name of the URI template.
name
,
Object
value to be used to resolve the template.
value
)

Resolve a URI template with a given name in this UriBuilder instance using a supplied value.

public abstract UriBuilder

Returns:

the updated UriBuilder.
resolveTemplate
(String
name of the URI template.
name
,
Object
value to be used to resolve the template.
value
,
boolean
if 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.
encodeSlashInPath
)

Resolve a URI template with a given name in this UriBuilder instance using a supplied value.

public abstract UriBuilder

Returns:

the updated UriBuilder.
resolveTemplateFromEncoded
(String
name of the URI template.
name
,
Object
encoded value to be used to resolve the template.
value
)

Resolve a URI template with a given name in this UriBuilder instance using a supplied encoded value.

public abstract UriBuilder

Returns:

the updated UriBuilder.
resolveTemplates
(Map<String, Object>
a map of URI template names and their values.
templateValues
)

Resolve one or more URI templates in this UriBuilder instance using supplied name-value pairs.

public abstract UriBuilder

Returns:

the updated UriBuilder.
resolveTemplates
(Map<String, Object>
a map of URI template names and their values.
templateValues
,
boolean
if 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.
encodeSlashInPath
)

Resolve one or more URI templates in this UriBuilder instance using supplied name-value pairs.

public abstract UriBuilder

Returns:

the updated UriBuilder.
resolveTemplatesFromEncoded
(Map<String, Object>
a map of URI template names and their values.
templateValues
)

Resolve one or more URI templates in this UriBuilder instance using supplied name-value pairs.

public abstract UriBuilder

Returns:

the updated UriBuilder.
scheme
(String
the URI scheme, may contain URI template parameters. A null value will unset the URI scheme, but will not unset the any scheme-specific-part components.
scheme
)

Set the URI scheme.

public abstract UriBuilder

Returns:

the updated UriBuilder.
schemeSpecificPart
(String
the URI scheme-specific-part, may contain URI template parameters.
ssp
)

Set the URI scheme-specific-part (see java.net.URI).

public abstract UriBuilder

Returns:

the updated UriBuilder.
segment
(String...
the path segment values, each may contain URI template parameters.
segments
)

Append path segments to the existing path.

public abstract String

Returns:

the URI template string for this URI builder.
toTemplate
()

Get the URI template string represented by this URI builder.

public abstract UriBuilder

Returns:

the updated UriBuilder.
uri
(URI
the URI to copy components from.
uri
)

Copies the non-null components of the supplied URI to the UriBuilder replacing any existing values for those components.

public abstract UriBuilder

Returns:

the updated UriBuilder.
uri
(String
a URI template that will be used to initialize the UriBuilder, may contain URI parameters.
uriTemplate
)

Parses the uriTemplate string and copies the parsed components of the supplied URI to the UriBuilder replacing any existing values for those components.

public abstract UriBuilder

Returns:

the updated UriBuilder.
userInfo
(String
the URI user-info, may contain URI template parameters. A null value will unset userInfo component of the URI.
ui
)

Set the URI user-info.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

UriBuilderback to summary
protected UriBuilder()

Protected constructor, use one of the static fromXxx(...) methods to obtain an instance.

Method Detail

buildback 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 String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All '%' characters in the stringified values will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.

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 '/' characters in the stringified values will be encoded in path templates, i.e. the result is identical to invoking build(Object[], boolean) build(values, true)}. To override this behavior use build(values, false) instead.

Parameters
values:Object[]

a list of URI template parameter values.

Returns:URI

the URI built from the UriBuilder.

Exceptions
IllegalArgumentException:
if there are any URI template parameters without a supplied value, or if a value is null.
UriBuilderException:
if a URI cannot be constructed based on the current state of the builder.
See Also
build(Object[], boolean), buildFromEncoded(Object...)
buildback 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 String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All '%' characters in the stringified values will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.

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 encodeSlashInPath parameter may be used to override the default encoding of '/' characters in the stringified template values in cases when the template is part of the URI path component when using the build(Object[]) method. If the encodeSlashInPath parameter is set to true (default), the slash ('/') characters in parameter values will be encoded if the template is placed in the URI path component. If set to false the default encoding behavior is overridden an slash characters in template values will not be encoded when used to substitute path templates.

Parameters
values:Object[]

a list of URI template parameter values.

encodeSlashInPath:boolean

if 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.

Returns:URI

the URI built from the UriBuilder.

Exceptions
IllegalArgumentException:
if there are any URI template parameters without a supplied value, or if a value is null.
UriBuilderException:
if a URI cannot be constructed based on the current state of the builder.
Since
2.0
See Also
build(Object[]), buildFromEncoded(Object...)
buildFromEncodedback 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 String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All % characters in the stringified values that are not followed by two hexadecimal numbers will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.

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".

Parameters
values:Object[]

a list of URI template parameter values.

Returns:URI

the URI built from the UriBuilder.

Exceptions
IllegalArgumentException:
if there are any URI template parameters without a supplied value, or if a value is null.
UriBuilderException:
if a URI cannot be constructed based on the current state of the builder.
See Also
build(Object[]), build(Object[], boolean)
buildFromEncodedMapback 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 String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All % characters in the stringified values that are not followed by two hexadecimal numbers will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.

Parameters
values:Map<String, ?>

a map of URI template parameter names and values.

Returns:URI

the URI built from the UriBuilder.

Exceptions
IllegalArgumentException:
if there are any URI template parameters without a supplied value, or if a template parameter value is null.
UriBuilderException:
if a URI cannot be constructed based on the current state of the builder.
Since
2.0
See Also
buildFromMap(java.util.Map), buildFromMap(java.util.Map, boolean)
buildFromMapback 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 String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All '%' characters in the stringified values will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.

Note

By default all '/' characters in the stringified values will be encoded in path templates, i.e. the result is identical to invoking buildFromMap(valueMap, true). To override this behavior use buildFromMap(valueMap, false) instead.

Parameters
values:Map<String, ?>

a map of URI template parameter names and values.

Returns:URI

the URI built from the UriBuilder.

Exceptions
IllegalArgumentException:
if there are any URI template parameters without a supplied value, or if a template parameter value is null.
UriBuilderException:
if a URI cannot be constructed based on the current state of the builder.
See Also
buildFromMap(java.util.Map, boolean), buildFromEncodedMap(java.util.Map)
buildFromMapback 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 String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All '%' characters in the stringified values will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.

The encodeSlashInPath parameter may be used to override the default encoding of '/' characters in the stringified template values in cases when the template is part of the URI path component when using the buildFromMap(java.util.Map) method. If the encodeSlashInPath parameter is set to true (default), the slash ('/') characters in parameter values will be encoded if the template is placed in the URI path component. If set to false the default encoding behavior is overridden an slash characters in template values will not be encoded when used to substitute path templates.

Parameters
values:Map<String, ?>

a map of URI template parameter names and values.

encodeSlashInPath:boolean

if 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.

Returns:URI

the URI built from the UriBuilder.

Exceptions
IllegalArgumentException:
if there are any URI template parameters without a supplied value, or if a template parameter value is null.
UriBuilderException:
if a URI cannot be constructed based on the current state of the builder.
See Also
buildFromMap(java.util.Map), buildFromEncodedMap(java.util.Map)
cloneback to summary
public abstract UriBuilder clone()

Overrides java.lang.Object.clone.

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 build(Object...) method.

Returns:UriBuilder

a copy of the UriBuilder.

Annotations
@SuppressWarnings:CloneDoesntDeclareCloneNotSupportedException
@Override
fragmentback to summary
public abstract UriBuilder fragment(String fragment)

Set the URI fragment.

Parameters
fragment:String

the URI fragment, may contain URI template parameters. A null value will remove any existing fragment.

Returns:UriBuilder

the updated UriBuilder.

fromMethodback to summary
public static UriBuilder fromMethod(Class<?> resource, String method)

Create a new instance representing a relative URI initialized from a javax.ws.rs.Path-annotated method. This method can only be used in cases where there is a single method with the specified name that is annotated with javax.ws.rs.Path.

Parameters
resource:Class<?>

the resource containing the method.

method:String

the name of the method whose javax.ws.rs.Path value will be used to obtain the path to append.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if resource or method is null, or there is more than or less than one variant of the method annotated with javax.ws.rs.Path.
Since
2.0
fromPathback to summary
public static UriBuilder fromPath(String path) throws IllegalArgumentException

Create a new instance representing a relative URI initialized from a URI path.

Parameters
path:String

a URI path that will be used to initialize the UriBuilder, may contain URI template parameters.

Returns:UriBuilder

a new UriBuilder.

Exceptions
IllegalArgumentException:
if path is null.
fromResourceback to summary
public static UriBuilder fromResource(Class<?> resource)

Create a new instance representing a relative URI initialized from a root resource class.

Parameters
resource:Class<?>

a root resource whose javax.ws.rs.Path value will be used to initialize the UriBuilder.

Returns:UriBuilder

a new UriBuilder.

Exceptions
IllegalArgumentException:
if resource is not annotated with javax.ws.rs.Path or resource is null.
fromUriback to summary
public static UriBuilder fromUri(URI uri)

Create a new instance initialized from an existing URI.

Parameters
uri:URI

a URI that will be used to initialize the UriBuilder.

Returns:UriBuilder

a new UriBuilder.

Exceptions
IllegalArgumentException:
if uri is null.
fromUriback to summary
public static UriBuilder fromUri(String uriTemplate)

Create a new instance initialized from an existing URI.

Parameters
uriTemplate:String

a URI template that will be used to initialize the UriBuilder, may contain URI parameters.

Returns:UriBuilder

a new UriBuilder.

Exceptions
IllegalArgumentException:
if uriTemplate is not a valid URI template or is null.
hostback to summary
public abstract UriBuilder host(String host)

Set the URI host.

Parameters
host:String

the URI host, may contain URI template parameters. A null value will unset the host component of the URI, but will not unset other authority component parts (user info or port).

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if host is invalid.
matrixParamback 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.

Parameters
name:String

the matrix parameter name, may contain URI template parameters.

values:Object[]

the matrix parameter value(s), each object will be converted. to a String using its toString() method. Stringified values may contain URI template parameters.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if name or values is null.
See Also
Matrix URIs
newInstanceback to summary
protected static UriBuilder newInstance()

Creates a new instance of UriBuilder.

Returns:UriBuilder

a new instance of UriBuilder.

pathback 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.

Parameters
path:String

the path, may contain URI template parameters.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if path is null.
pathback 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.

Parameters
resource:Class<T>

a resource whose javax.ws.rs.Path value will be used to obtain the path to append.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if resource is null, or if resource is not annotated with javax.ws.rs.Path.
pathback 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(Method), it can only be used in cases where there is a single method with the specified name that is annotated with javax.ws.rs.Path.

Parameters
resource:Class<T>

the resource containing the method.

method:String

the name of the method whose javax.ws.rs.Path value will be used to obtain the path to append.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if resource or method is null, or there is more than or less than one variant of the method annotated with javax.ws.rs.Path.
pathback to summary
public abstract UriBuilder path(Method method)

Append the path from a javax.ws.rs.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.

Parameters
method:Method

a method whose javax.ws.rs.Path value will be used to obtain the path to append to the existing path.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if method is null or is not annotated with a javax.ws.rs.Path.
portback to summary
public abstract UriBuilder port(int port)

Set the URI port.

Parameters
port:int

the URI port, a value of -1 will unset an explicit port.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if port is invalid.
queryParamback 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.

Parameters
name:String

the query parameter name, may contain URI template parameters.

values:Object[]

the query parameter value(s), each object will be converted to a String using its toString() method. Stringified values may contain URI template parameters.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if name or values is null.
replaceMatrixback 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.

Parameters
matrix:String

the matrix parameters, may contain URI template parameters. A null value will remove all matrix parameters of the current final segment of the current URI path.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if matrix cannot be parsed.
See Also
Matrix URIs
replaceMatrixParamback 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.

Parameters
name:String

the matrix parameter name, may contain URI template parameters.

values:Object[]

the matrix parameter value(s), each object will be converted. to a 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.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if name is null.
See Also
Matrix URIs
replacePathback 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.

Parameters
path:String

the path, may contain URI template parameters. A null value will unset the path component of the URI.

Returns:UriBuilder

the updated UriBuilder.

replaceQueryback to summary
public abstract UriBuilder replaceQuery(String query)

Set the URI query string. This method will overwrite any existing query parameters.

Parameters
query:String

the URI query string, may contain URI template parameters. A null value will remove all query parameters.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if query cannot be parsed.
replaceQueryParamback 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.

Parameters
name:String

the query parameter name, may contain URI template parameters.

values:Object[]

the query parameter value(s), each object will be converted to a 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.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if name is null.
resolveTemplateback to summary
public abstract UriBuilder resolveTemplate(String name, Object value)

Resolve a URI template with a given name in this UriBuilder instance using a supplied value. In case a null template name or value is entered a IllegalArgumentException is thrown.

Parameters
name:String

name of the URI template.

value:Object

value to be used to resolve the template.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if the resolved template name or value is null.
Since
2.0
resolveTemplateback to summary
public abstract UriBuilder resolveTemplate(String name, Object value, boolean encodeSlashInPath)

Resolve a URI template with a given name in this UriBuilder instance using a supplied value. In case a null template name or value is entered a IllegalArgumentException is thrown.

Parameters
name:String

name of the URI template.

value:Object

value to be used to resolve the template.

encodeSlashInPath:boolean

if 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.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if the resolved template name or value is null.
Since
2.0
resolveTemplateFromEncodedback to summary
public abstract UriBuilder resolveTemplateFromEncoded(String name, Object value)

Resolve a URI template with a given name in this UriBuilder instance using a supplied encoded value. A template with a matching name will be replaced by the supplied value. Value is converted to String using its toString() method and is then encoded to match the rules of the URI component to which they pertain. All % characters in the stringified values that are not followed by two hexadecimal numbers will be encoded. In case a null template name or encoded value is entered a IllegalArgumentException is thrown.

Parameters
name:String

name of the URI template.

value:Object

encoded value to be used to resolve the template.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if the resolved template name or encoded value is null.
Since
2.0
resolveTemplatesback to summary
public abstract UriBuilder resolveTemplates(Map<String, Object> templateValues)

Resolve one or more URI templates in this UriBuilder instance using supplied name-value pairs. A call to the method with an empty parameter map is ignored.

Parameters
templateValues:Map<String, Object>

a map of URI template names and their values.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if the name-value map or any of the names or values in the map is null.
Since
2.0
resolveTemplatesback to summary
public abstract UriBuilder resolveTemplates(Map<String, Object> templateValues, boolean encodeSlashInPath) throws IllegalArgumentException

Resolve one or more URI templates in this UriBuilder instance using supplied name-value pairs. A call to the method with an empty parameter map is ignored.

Parameters
templateValues:Map<String, Object>

a map of URI template names and their values.

encodeSlashInPath:boolean

if 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.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if the name-value map or any of the names or values in the map is null.
Since
2.0
resolveTemplatesFromEncodedback to summary
public abstract UriBuilder resolveTemplatesFromEncoded(Map<String, Object> templateValues)

Resolve one or more URI templates in this UriBuilder instance using supplied name-value pairs. All templates with their name matching one of the keys in the supplied map will be replaced by the value in the supplied map. Values are converted to String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All % characters in the stringified values that are not followed by two hexadecimal numbers will be encoded. A call to the method with an empty parameter map is ignored.

Parameters
templateValues:Map<String, Object>

a map of URI template names and their values.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if the name-value map or any of the names or values in the map is null.
Since
2.0
schemeback to summary
public abstract UriBuilder scheme(String scheme)

Set the URI scheme.

Parameters
scheme:String

the URI scheme, may contain URI template parameters. A null value will unset the URI scheme, but will not unset the any scheme-specific-part components.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if scheme is invalid.
schemeSpecificPartback to summary
public abstract UriBuilder schemeSpecificPart(String ssp)

Set the URI scheme-specific-part (see java.net.URI). This method will overwrite any existing values for authority, user-info, host, port and path.

Parameters
ssp:String

the URI scheme-specific-part, may contain URI template parameters.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if ssp cannot be parsed or is null.
segmentback 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.

Parameters
segments:String[]

the path segment values, each may contain URI template parameters.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if segments or any element of segments is null.
toTemplateback to summary
public abstract String toTemplate()

Get the URI template string represented by this URI builder.

Returns:String

the URI template string for this URI builder.

Since
2.0
uriback 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.

Parameters
uri:URI

the URI to copy components from.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if the uri parameter is null.
uriback to summary
public abstract UriBuilder uri(String uriTemplate)

Parses the uriTemplate string and copies the parsed components of the supplied URI to the UriBuilder replacing any existing values for those components.

Parameters
uriTemplate:String

a URI template that will be used to initialize the UriBuilder, may contain URI parameters.

Returns:UriBuilder

the updated UriBuilder.

Exceptions
IllegalArgumentException:
if uriTemplate is not a valid URI template or is null.
Since
2.0
userInfoback to summary
public abstract UriBuilder userInfo(String ui)

Set the URI user-info.

Parameters
ui:String

the URI user-info, may contain URI template parameters. A null value will unset userInfo component of the URI.

Returns:UriBuilder

the updated UriBuilder.