javax.ws.rs.client
Interface WebTarget


public interface WebTarget

A resource target identified by the resource URI.

Since:
2.0
Author:
Marek Potociar

Method Summary
 Configuration configuration()
          Get access to the underlying configuration.
 java.net.URI getUri()
          Get the URI identifying the resource.
 UriBuilder getUriBuilder()
          Get the URI builder initialized with the URI of the current resource target.
 WebTarget matrixParam(java.lang.String name, java.lang.Object... values)
          Create a new WebTarget instance by appending a matrix parameter to the existing set of matrix parameters of the current final segment of the URI of the current target instance.
 WebTarget path(java.lang.String path)
          Create a new WebTarget instance by appending path to the URI of the current target instance.
 WebTarget pathParam(java.lang.String name, java.lang.Object value)
          Create a new WebTarget instance by replacing existing path parameter in the URI of the current target instance with a supplied value.
 WebTarget pathParams(java.util.Map<java.lang.String,java.lang.Object> parameters)
          Create a new WebTarget instance by replacing one or more existing path parameters in the URI of the current target instance with supplied values.
 WebTarget queryParam(java.lang.String name, java.lang.Object... values)
          Create a new WebTarget instance by adding a query parameter to the URI of the current target instance.
 WebTarget queryParams(MultivaluedMap<java.lang.String,java.lang.Object> parameters)
          Create a new WebTarget instance by adding one or more query parameters and respective values to the URI of the current target instance.
 Invocation.Builder request()
          Start building a request to the targeted web resource.
 Invocation.Builder request(MediaType... acceptedResponseTypes)
          Start building a request to the targeted web resource and define the accepted response media types.
 Invocation.Builder request(java.lang.String... acceptedResponseTypes)
          Start building a request to the targeted web resource and define the accepted response media types.
 

Method Detail

getUri

java.net.URI getUri()
Get the URI identifying the resource.

Returns:
the resource URI.

getUriBuilder

UriBuilder getUriBuilder()
Get the URI builder initialized with the URI of the current resource target. The returned URI builder is detached from the target, i.e. any updates in the URI builder MUST NOT have any effects on the URI of the originating target.

Returns:
the initialized URI builder.

configuration

Configuration configuration()
Get access to the underlying configuration.

Returns:
a mutable configuration bound to the instance.

path

WebTarget path(java.lang.String path)
               throws java.lang.NullPointerException
Create a new WebTarget instance by appending path to the URI of the current target instance.

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.

A snapshot of the present configuration of the current (parent) target instance is taken and is inherited by the newly constructed (child) target instance.

Parameters:
path - the path, may contain URI template parameters.
Returns:
a new target instance.
Throws:
java.lang.NullPointerException - if path is null.

pathParam

WebTarget pathParam(java.lang.String name,
                    java.lang.Object value)
                    throws java.lang.IllegalArgumentException,
                           java.lang.NullPointerException
Create a new WebTarget instance by replacing existing path parameter in the URI of the current target instance with a supplied value.

A snapshot of the present configuration of the current (parent) target instance is taken and is inherited by the newly constructed (child) target instance.

Parameters:
name - path parameter template name.
value - value to be used to replace the template.
Returns:
a new target instance.
Throws:
java.lang.IllegalArgumentException - if there is no such path parameter.
java.lang.NullPointerException - if name or value is null.

pathParams

WebTarget pathParams(java.util.Map<java.lang.String,java.lang.Object> parameters)
                     throws java.lang.IllegalArgumentException,
                            java.lang.NullPointerException
Create a new WebTarget instance by replacing one or more existing path parameters in the URI of the current target instance with supplied values.

A snapshot of the present configuration of the current (parent) target instance is taken and is inherited by the newly constructed (child) target instance.

Parameters:
parameters - a map of URI template parameter names and values.
Returns:
a new target instance.
Throws:
java.lang.IllegalArgumentException - if the supplied map is empty.
java.lang.NullPointerException - if the parameter map or any of the names or values is null.

matrixParam

WebTarget matrixParam(java.lang.String name,
                      java.lang.Object... values)
                      throws java.lang.NullPointerException
Create a new WebTarget instance by appending a matrix parameter to the existing set of matrix parameters of the current final segment of the URI of the current target instance. 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; appending a value to an existing matrix parameter name will not affect the position of the matrix parameter in the URI path.

A snapshot of the present configuration of the current (parent) target instance is taken and is inherited by the newly constructed (child) target instance.

Parameters:
name - the matrix parameter name, may contain URI template parameters.
values - 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:
a new target instance.
Throws:
java.lang.NullPointerException - if the name or any of the values is null.
See Also:
Matrix URIs

queryParam

WebTarget queryParam(java.lang.String name,
                     java.lang.Object... values)
                     throws java.lang.NullPointerException
Create a new WebTarget instance by adding a query parameter to the URI of the current target instance. If multiple values are supplied the parameter will be added once per value.

A snapshot of the present configuration of the current (parent) target instance is taken and is inherited by the newly constructed (child) target instance.

Parameters:
name - the query parameter name, may contain URI template parameters
values - 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:
a new target instance.
Throws:
java.lang.NullPointerException - if name or any of the values is null.

queryParams

WebTarget queryParams(MultivaluedMap<java.lang.String,java.lang.Object> parameters)
                      throws java.lang.IllegalArgumentException,
                             java.lang.NullPointerException
Create a new WebTarget instance by adding one or more query parameters and respective values to the URI of the current target instance.

A snapshot of the present configuration of the current (parent) target instance is taken and is inherited by the newly constructed (child) target instance.

Parameters:
parameters - a map of query parameter names and values.
Returns:
a new target instance.
Throws:
java.lang.IllegalArgumentException - if the supplied map is empty.
java.lang.NullPointerException - if the parameter map or any of the names or values is null.

request

Invocation.Builder request()
Start building a request to the targeted web resource.

Returns:
builder for a request targeted at the URI referenced by this target instance.

request

Invocation.Builder request(java.lang.String... acceptedResponseTypes)
Start building a request to the targeted web resource and define the accepted response media types.

Parameters:
acceptedResponseTypes - accepted response media types.
Returns:
builder for a request targeted at the URI referenced by this target instance.

request

Invocation.Builder request(MediaType... acceptedResponseTypes)
Start building a request to the targeted web resource and define the accepted response media types.

Parameters:
acceptedResponseTypes - accepted response media types.
Returns:
builder for a request targeted at the URI referenced by this target instance.


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.