public class UriBuilderImpl extends UriBuilder
UriBuilder
.Constructor and Description |
---|
UriBuilderImpl() |
Modifier and Type | Method and Description |
---|---|
java.net.URI |
build(java.lang.Object... values)
Build a URI, using the supplied values in order to replace any URI
template parameters.
|
java.net.URI |
buildFromEncoded(java.lang.Object... values)
Build a URI.
|
java.net.URI |
buildFromEncodedMap(java.util.Map<java.lang.String,? extends java.lang.Object> values)
Build a URI, any URI template parameters will be replaced by the value in
the supplied map.
|
java.net.URI |
buildFromMap(java.util.Map<java.lang.String,? extends java.lang.Object> values)
Build a URI, any URI template parameters will be replaced by the value in
the supplied map.
|
UriBuilder |
clone()
Create a copy of the UriBuilder preserving its state.
|
UriBuilder |
fragment(java.lang.String fragment)
Set the URI fragment.
|
UriBuilder |
host(java.lang.String host)
Set the URI host.
|
UriBuilder |
matrixParam(java.lang.String name,
java.lang.Object... values)
Append a matrix parameter to the existing set of matrix parameters of
the current final segment of the URI path.
|
UriBuilder |
path(java.lang.Class resource)
Append the path from a Path-annotated class to the
existing path.
|
UriBuilder |
path(java.lang.Class resource,
java.lang.String methodName)
Append the path from a Path-annotated method to the
existing path.
|
UriBuilder |
path(java.lang.reflect.Method method)
Append the path from a
Path -annotated method to the
existing path. |
UriBuilder |
path(java.lang.String path)
Append path to the existing path.
|
UriBuilder |
port(int port)
Set the URI port.
|
UriBuilder |
queryParam(java.lang.String name,
java.lang.Object... values)
Append a query parameter to the existing set of query parameters.
|
UriBuilder |
replaceMatrix(java.lang.String matrix)
Set the matrix parameters of the current final segment of the current URI path.
|
UriBuilder |
replaceMatrixParam(java.lang.String name,
java.lang.Object... values)
Replace the existing value(s) of a matrix parameter on
the current final segment of the URI path.
|
UriBuilder |
replacePath(java.lang.String path)
Set the URI path.
|
UriBuilder |
replaceQuery(java.lang.String query)
Set the URI query string.
|
UriBuilder |
replaceQueryParam(java.lang.String name,
java.lang.Object... values)
Replace the existing value(s) of a query parameter.
|
UriBuilder |
scheme(java.lang.String scheme)
Set the URI scheme.
|
UriBuilder |
schemeSpecificPart(java.lang.String ssp)
Set the URI scheme-specific-part (see
URI ). |
UriBuilder |
segment(java.lang.String... segments)
Append path segments to the existing path.
|
UriBuilder |
uri(java.net.URI uri)
Copies the non-null components of the supplied URI to the UriBuilder replacing
any existing values for those components.
|
UriBuilder |
userInfo(java.lang.String ui)
Set the URI user-info.
|
fromPath, fromResource, fromUri, fromUri, newInstance
public UriBuilder clone()
UriBuilder
UriBuilder.build(java.lang.Object...)
method.clone
in class UriBuilder
public UriBuilder uri(java.net.URI uri)
UriBuilder
uri
in class UriBuilder
uri
- the URI to copy components frompublic UriBuilder scheme(java.lang.String scheme)
UriBuilder
scheme
in class UriBuilder
scheme
- the URI scheme, may contain URI template parameters.
A null value will unset the URI scheme.public UriBuilder schemeSpecificPart(java.lang.String ssp)
UriBuilder
URI
). This
method will overwrite any existing
values for authority, user-info, host, port and path.schemeSpecificPart
in class UriBuilder
ssp
- the URI scheme-specific-part, may contain URI template parameterspublic UriBuilder userInfo(java.lang.String ui)
UriBuilder
userInfo
in class UriBuilder
ui
- the URI user-info, may contain URI template parameters.
A null value will unset userInfo component of the URI.public UriBuilder host(java.lang.String host)
UriBuilder
host
in class UriBuilder
host
- the URI host, may contain URI template parameters.
A null value will unset the host component of the URI.public UriBuilder port(int port)
UriBuilder
port
in class UriBuilder
port
- the URI port, a value of -1 will unset an explicit port.public UriBuilder replacePath(java.lang.String path)
UriBuilder
replacePath
in class UriBuilder
path
- the path, may contain URI template parameters.
A null value will unset the path component of the URI.public UriBuilder path(java.lang.String path)
UriBuilder
path
in class UriBuilder
path
- the path, may contain URI template parameterspublic UriBuilder path(java.lang.Class resource)
UriBuilder
path
in class UriBuilder
resource
- a resource whose Path
value will be
used to obtain the path to append.public UriBuilder path(java.lang.Class resource, java.lang.String methodName)
UriBuilder
path(Method)
, it
can only be used in cases where there is a single method with the
specified name that is annotated with Path
.path
in class UriBuilder
resource
- the resource containing the methodmethodName
- the name of the method whose Path
value will be
used to obtain the path to appendpublic UriBuilder path(java.lang.reflect.Method method)
UriBuilder
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.path
in class UriBuilder
method
- a method whose Path
value will be
used to obtain the path to append to the existing pathpublic UriBuilder segment(java.lang.String... segments) throws java.lang.IllegalArgumentException
UriBuilder
segment
in class UriBuilder
segments
- the path segment values, each may contain URI template
parametersjava.lang.IllegalArgumentException
- if segments or any element of segments
is nullpublic UriBuilder replaceMatrix(java.lang.String matrix)
UriBuilder
replaceMatrix
in class UriBuilder
matrix
- 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.public UriBuilder matrixParam(java.lang.String name, java.lang.Object... values)
UriBuilder
matrixParam
in class UriBuilder
name
- the matrix parameter name, may contain URI template parametersvalues
- the matrix parameter value(s), each object will be converted
to a String
using its toString()
method. Stringified
values may contain URI template parameters.public UriBuilder replaceMatrixParam(java.lang.String name, java.lang.Object... values)
UriBuilder
replaceMatrixParam
in class UriBuilder
name
- the matrix parameter name, may contain URI template parametersvalues
- 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.public UriBuilder replaceQuery(java.lang.String query)
UriBuilder
replaceQuery
in class UriBuilder
query
- the URI query string, may contain URI template parameters.
A null value will remove all query parameters.public UriBuilder queryParam(java.lang.String name, java.lang.Object... values)
UriBuilder
queryParam
in class UriBuilder
name
- the query parameter name, may contain URI template parametersvalues
- the query parameter value(s), each object will be converted
to a String
using its toString()
method. Stringified
values may contain URI template parameters.public UriBuilder replaceQueryParam(java.lang.String name, java.lang.Object... values)
UriBuilder
replaceQueryParam
in class UriBuilder
name
- the query parameter name, may contain URI template parametersvalues
- 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.public UriBuilder fragment(java.lang.String fragment)
UriBuilder
fragment
in class UriBuilder
fragment
- the URI fragment, may contain URI template parameters.
A null value will remove any existing fragment.public java.net.URI buildFromMap(java.util.Map<java.lang.String,? extends java.lang.Object> values)
UriBuilder
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.buildFromMap
in class UriBuilder
values
- a map of URI template parameter names and valuespublic java.net.URI buildFromEncodedMap(java.util.Map<java.lang.String,? extends java.lang.Object> values) throws java.lang.IllegalArgumentException, UriBuilderException
UriBuilder
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.buildFromEncodedMap
in class UriBuilder
values
- a map of URI template parameter names and valuesjava.lang.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.public java.net.URI build(java.lang.Object... values)
UriBuilder
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".
build
in class UriBuilder
values
- a list of URI template parameter valuespublic java.net.URI buildFromEncoded(java.lang.Object... values)
UriBuilder
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".
buildFromEncoded
in class UriBuilder
values
- a list of URI template parameter valuesCopyright © 2016 Oracle Corporation. All Rights Reserved.