|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.ws.rs.core.UriBuilder
org.jboss.resteasy.specimpl.UriBuilderImpl
public class UriBuilderImpl
Constructor Summary | |
---|---|
UriBuilderImpl()
|
Method Summary | |
---|---|
URI |
build(Object... values)
Build a URI, using the supplied values in order to replace any URI template parameters. |
URI |
buildFromEncoded(Object... values)
Build a URI. |
URI |
buildFromEncodedMap(Map<String,? extends Object> values)
Build a URI, any URI template parameters will be replaced by the value in the supplied map. |
URI |
buildFromMap(Map<String,? extends Object> values)
Build a URI, any URI template parameters will be replaced by the value in the supplied map. |
URI |
buildFromMap(Map<String,? extends Object> paramMap,
boolean fromEncodedMap)
|
protected URI |
buildFromValues(boolean encoded,
Object... values)
|
UriBuilder |
clientQueryParam(String name,
Object value)
Called by ClientRequest.getUri() to add a query parameter for @QueryParam parameters. |
UriBuilder |
clone()
Create a copy of the UriBuilder preserving its state. |
static Matcher |
createUriParamMatcher(String string)
|
UriBuilder |
fragment(String fragment)
Set the URI fragment. |
static UriBuilder |
fromTemplate(String uriTemplate)
You may put path parameters anywhere within the uriTemplate except port |
String |
getFragment()
|
String |
getHost()
|
String |
getPath()
|
List<String> |
getPathParamNamesInDeclarationOrder()
Return a unique order list of path params |
int |
getPort()
|
String |
getQuery()
|
String |
getScheme()
|
String |
getUserInfo()
|
UriBuilder |
host(String host)
Set the URI host. |
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. |
UriBuilder |
path(Class resource)
Append the path from a Path-annotated class to the existing path. |
UriBuilder |
path(Class resource,
String method)
Append the path from a Path-annotated method to the existing path. |
UriBuilder |
path(Method method)
Append the path from a Path -annotated method to the
existing path. |
UriBuilder |
path(String segment)
Append path to the existing path. |
protected static String |
paths(boolean encode,
String basePath,
String... segments)
|
UriBuilder |
port(int port)
Set the URI port. |
UriBuilder |
queryParam(String name,
Object... values)
Append a query parameter to the existing set of query parameters. |
UriBuilder |
replaceMatrix(String matrix)
Set the matrix parameters of the current final segment of the current URI path. |
UriBuilder |
replaceMatrixParam(String name,
Object... values)
Replace the existing value(s) of a matrix parameter on the current final segment of the URI path. |
protected StringBuffer |
replaceParameter(Map<String,? extends Object> paramMap,
boolean fromEncodedMap,
String string,
StringBuffer buffer)
|
UriBuilder |
replacePath(String path)
Set the URI path. |
protected StringBuffer |
replacePathParameter(String name,
String value,
boolean isEncoded,
String string,
StringBuffer buffer)
|
UriBuilder |
replaceQuery(String query)
Set the URI query string. |
UriBuilder |
replaceQueryParam(String name,
Object... values)
Replace the existing value(s) of a query parameter. |
protected StringBuffer |
replaceQueryStringParameter(Map<String,? extends Object> paramMap,
boolean fromEncodedMap,
String string,
StringBuffer buffer)
|
UriBuilder |
scheme(String scheme)
Set the URI scheme. |
UriBuilder |
schemeSpecificPart(String ssp)
Set the URI scheme-specific-part (see URI ). |
UriBuilder |
segment(String... segments)
Append path segments to the existing path. |
UriBuilder |
substitutePathParam(String name,
Object value,
boolean isEncoded)
Only replace path params in path of URI. |
UriBuilder |
uri(URI uri)
Copies the non-null components of the supplied URI to the UriBuilder replacing any existing values for those components. |
UriBuilder |
uriTemplate(String uriTemplate)
You may put path parameters anywhere within the uriTemplate except port |
UriBuilder |
userInfo(String ui)
Set the URI user-info. |
Methods inherited from class javax.ws.rs.core.UriBuilder |
---|
fromPath, fromResource, fromUri, fromUri, newInstance |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UriBuilderImpl()
Method Detail |
---|
public UriBuilder clone()
UriBuilder
UriBuilder.build(java.lang.Object...)
method.
clone
in class UriBuilder
public static UriBuilder fromTemplate(String uriTemplate)
uriTemplate
-
public UriBuilder uriTemplate(String uriTemplate)
uriTemplate
-
public UriBuilder uri(URI uri) throws IllegalArgumentException
UriBuilder
uri
in class UriBuilder
uri
- the URI to copy components from
IllegalArgumentException
- if uri is nullpublic UriBuilder scheme(String scheme) throws IllegalArgumentException
UriBuilder
scheme
in class UriBuilder
scheme
- the URI scheme, may contain URI template parameters.
A null value will unset the URI scheme.
IllegalArgumentException
- if scheme is invalidpublic UriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException
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 parameters
IllegalArgumentException
- if ssp cannot be parsed or is nullpublic UriBuilder userInfo(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(String host) throws IllegalArgumentException
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.
IllegalArgumentException
- if host is invalid.public UriBuilder port(int port) throws IllegalArgumentException
UriBuilder
port
in class UriBuilder
port
- the URI port, a value of -1 will unset an explicit port.
IllegalArgumentException
- if port is invalidprotected static String paths(boolean encode, String basePath, String... segments)
public UriBuilder path(String segment) throws IllegalArgumentException
UriBuilder
path
in class UriBuilder
segment
- the path, may contain URI template parameters
IllegalArgumentException
- if path is nullpublic UriBuilder path(Class resource) throws IllegalArgumentException
UriBuilder
path
in class UriBuilder
resource
- a resource whose Path
value will be
used to obtain the path to append.
IllegalArgumentException
- if resource is null, or
if resource is not annotated with Path
public UriBuilder path(Class resource, String method) throws IllegalArgumentException
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 methodmethod
- the name of the method whose Path
value will be
used to obtain the path to append
IllegalArgumentException
- if resource or method is null,
or there is more than or less than one variant of the method annotated with
Path
public UriBuilder path(Method method) throws IllegalArgumentException
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 path
IllegalArgumentException
- if method is null or is
not annotated with a Path
public UriBuilder replaceMatrix(String matrix) throws IllegalArgumentException
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.
IllegalArgumentException
- if matrix cannot be parsedpublic UriBuilder replaceQuery(String query) throws IllegalArgumentException
UriBuilder
replaceQuery
in class UriBuilder
query
- the URI query string, may contain URI template parameters.
A null value will remove all query parameters.
IllegalArgumentException
- if query cannot be parsedpublic UriBuilder fragment(String fragment) throws IllegalArgumentException
UriBuilder
fragment
in class UriBuilder
fragment
- the URI fragment, may contain URI template parameters.
A null value will remove any existing fragment.
IllegalArgumentException
public UriBuilder substitutePathParam(String name, Object value, boolean isEncoded)
name
- value
- isEncoded
-
public URI buildFromMap(Map<String,? extends Object> values) throws 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 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 values
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 URI buildFromEncodedMap(Map<String,? extends Object> values) throws 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 values
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 URI buildFromMap(Map<String,? extends Object> paramMap, boolean fromEncodedMap) throws IllegalArgumentException, UriBuilderException
IllegalArgumentException
UriBuilderException
protected StringBuffer replacePathParameter(String name, String value, boolean isEncoded, String string, StringBuffer buffer)
public static Matcher createUriParamMatcher(String string)
protected StringBuffer replaceParameter(Map<String,? extends Object> paramMap, boolean fromEncodedMap, String string, StringBuffer buffer)
protected StringBuffer replaceQueryStringParameter(Map<String,? extends Object> paramMap, boolean fromEncodedMap, String string, StringBuffer buffer)
public List<String> getPathParamNamesInDeclarationOrder()
public URI build(Object... values) throws 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 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 values
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.protected URI buildFromValues(boolean encoded, Object... values)
public UriBuilder matrixParam(String name, Object... values) throws IllegalArgumentException
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.
IllegalArgumentException
- if name or values is nullpublic UriBuilder replaceMatrixParam(String name, Object... values) throws IllegalArgumentException
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.
IllegalArgumentException
- if name is null.public UriBuilder clientQueryParam(String name, Object value) throws IllegalArgumentException
@QueryParam
parameters. We do not use UriBuilder.queryParam()
because
@QueryParam
parameters).
%
characters that are followed by two hex characters).
The JavaDoc for @QueryParam.value()
explicitly states that
the value is specified in decoded format and that "any percent
encoded literals within the value will not be decoded and will
instead be treated as literal text". This means that it is an
explicit bug to perform contextual URI encoding of this method's
name parameter; hence, we must always encode said parameter. This
method also foregoes contextual URI encoding on this method's value
parameter because it represents arbitrary data passed to a
QueryParam
parameter of a client proxy (since the client
proxy is nothing more than a transport layer, it should not be
"interpreting" such data; instead, it should faithfully transmit
this data over the wire).
name
- the name of the query parameter.value
- the value of the query parameter.
IllegalArgumentException
public UriBuilder queryParam(String name, Object... values) throws IllegalArgumentException
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.
IllegalArgumentException
- if name or values is nullpublic UriBuilder replaceQueryParam(String name, Object... values) throws IllegalArgumentException
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.
IllegalArgumentException
- if name is nullpublic String getHost()
public String getScheme()
public int getPort()
public String getUserInfo()
public String getPath()
public String getQuery()
public String getFragment()
public UriBuilder segment(String... segments) throws IllegalArgumentException
UriBuilder
segment
in class UriBuilder
segments
- the path segment values, each may contain URI template
parameters
IllegalArgumentException
- if segments or any element of segments
is nullpublic URI buildFromEncoded(Object... values) throws 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.
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 values
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.public UriBuilder replacePath(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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |