org.jboss.resteasy.client.jaxrs.internal
Class ClientWebTarget

java.lang.Object
  extended by org.jboss.resteasy.client.jaxrs.internal.ClientWebTarget
All Implemented Interfaces:
WebTarget, ResteasyWebTarget

public class ClientWebTarget
extends Object
implements ResteasyWebTarget

Version:
$Revision: 1 $
Author:
Bill Burke

Field Summary
protected  ResteasyClient client
           
protected  ClientConfiguration configuration
           
protected  UriBuilder uriBuilder
           
 
Constructor Summary
protected ClientWebTarget(ResteasyClient client, ClientConfiguration configuration)
           
  ClientWebTarget(ResteasyClient client, String uri, ClientConfiguration configuration)
           
  ClientWebTarget(ResteasyClient client, UriBuilder uriBuilder, ClientConfiguration configuration)
           
  ClientWebTarget(ResteasyClient client, URI uri, ClientConfiguration configuration)
           
 
Method Summary
 ResteasyWebTarget clone()
           
 Configuration configuration()
          Get access to the underlying configuration.
 ResteasyClient getResteasyClient()
           
 URI getUri()
          Get the URI identifying the resource.
 UriBuilder getUriBuilder()
          Get the URI builder initialized with the URI of the current resource target.
 ResteasyWebTarget matrixParam(String name, 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.
 ResteasyWebTarget path(Class<?> resource)
           
 ResteasyWebTarget path(Method method)
           
 ResteasyWebTarget path(String path)
          Create a new WebTarget instance by appending path to the URI of the current target instance.
<T> T
proxy(Class<T> proxyInterface)
           
<T> ProxyBuilder<T>
proxyBuilder(Class<T> proxyInterface)
           
 ResteasyWebTarget queryParam(String name, Object... values)
          Create a new WebTarget instance by configuring a query parameter on the URI of the current target instance.
 ResteasyWebTarget queryParamNoTemplate(String name, Object... values)
          Will encode any '{}' characters and not treat them as template parameters
 ResteasyWebTarget queryParams(MultivaluedMap<String,Object> parameters)
           
 ResteasyWebTarget queryParamsNoTemplate(MultivaluedMap<String,Object> parameters)
          Will encode any '{}' characters and not treat them as template parameters
 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(String... acceptedResponseTypes)
          Start building a request to the targeted web resource and define the accepted response media types.
 ResteasyWebTarget resolveTemplate(String name, Object value)
          Create a new WebTarget instance by resolving a URI template with a given name in the URI of the current target instance using a supplied value.
 ResteasyWebTarget resolveTemplate(String name, Object value, boolean encodeSlashInPath)
          Create a new WebTarget instance by resolving a URI template with a given name in the URI of the current target instance using a supplied value.
 ResteasyWebTarget resolveTemplateFromEncoded(String name, Object value)
          Create a new WebTarget instance by resolving a URI template with a given name in the URI of the current target instance using a supplied encoded value.
 ResteasyWebTarget resolveTemplates(Map<String,Object> templateValues)
          Create a new WebTarget instance by resolving one or more URI templates in the URI of the current target instance using supplied name-value pairs.
 ResteasyWebTarget resolveTemplates(Map<String,Object> templateValues, boolean encodeSlashInPath)
          Create a new WebTarget instance by resolving one or more URI templates in the URI of the current target instance using supplied name-value pairs.
 ResteasyWebTarget resolveTemplatesFromEncoded(Map<String,Object> templateValues)
          Create a new WebTarget instance by resolving one or more URI templates in the URI of the current target instance using supplied name-encoded value pairs.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

client

protected ResteasyClient client

uriBuilder

protected UriBuilder uriBuilder

configuration

protected ClientConfiguration configuration
Constructor Detail

ClientWebTarget

protected ClientWebTarget(ResteasyClient client,
                          ClientConfiguration configuration)

ClientWebTarget

public ClientWebTarget(ResteasyClient client,
                       String uri,
                       ClientConfiguration configuration)
                throws IllegalArgumentException,
                       NullPointerException
Throws:
IllegalArgumentException
NullPointerException

ClientWebTarget

public ClientWebTarget(ResteasyClient client,
                       URI uri,
                       ClientConfiguration configuration)
                throws NullPointerException
Throws:
NullPointerException

ClientWebTarget

public ClientWebTarget(ResteasyClient client,
                       UriBuilder uriBuilder,
                       ClientConfiguration configuration)
                throws NullPointerException
Throws:
NullPointerException
Method Detail

clone

public ResteasyWebTarget clone()
Specified by:
clone in interface ResteasyWebTarget
Overrides:
clone in class Object

getResteasyClient

public ResteasyClient getResteasyClient()
Specified by:
getResteasyClient in interface ResteasyWebTarget

proxy

public <T> T proxy(Class<T> proxyInterface)
Specified by:
proxy in interface ResteasyWebTarget

proxyBuilder

public <T> ProxyBuilder<T> proxyBuilder(Class<T> proxyInterface)
Specified by:
proxyBuilder in interface ResteasyWebTarget

getUri

public URI getUri()
Description copied from interface: WebTarget
Get the URI identifying the resource.

Specified by:
getUri in interface WebTarget
Returns:
the resource URI.

getUriBuilder

public UriBuilder getUriBuilder()
Description copied from interface: WebTarget
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.

Specified by:
getUriBuilder in interface WebTarget
Returns:
the initialized URI builder.

configuration

public Configuration configuration()
Description copied from interface: WebTarget
Get access to the underlying configuration.

Specified by:
configuration in interface WebTarget
Returns:
a mutable configuration bound to the instance.

path

public ResteasyWebTarget path(String path)
                       throws NullPointerException
Description copied from interface: WebTarget
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.

Specified by:
path in interface WebTarget
Specified by:
path in interface ResteasyWebTarget
Parameters:
path - the path, may contain URI template parameters.
Returns:
a new target instance.
Throws:
NullPointerException - if path is null.

path

public ResteasyWebTarget path(Class<?> resource)
                       throws IllegalArgumentException
Specified by:
path in interface ResteasyWebTarget
Throws:
IllegalArgumentException

path

public ResteasyWebTarget path(Method method)
                       throws IllegalArgumentException
Specified by:
path in interface ResteasyWebTarget
Throws:
IllegalArgumentException

resolveTemplate

public ResteasyWebTarget resolveTemplate(String name,
                                         Object value)
                                  throws NullPointerException
Description copied from interface: WebTarget
Create a new WebTarget instance by resolving a URI template with a given name in the URI of the current target instance using a supplied value. In case a null template name or value is entered a NullPointerException is thrown.

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

Specified by:
resolveTemplate in interface WebTarget
Specified by:
resolveTemplate in interface ResteasyWebTarget
Parameters:
name - name of the URI template.
value - value to be used to resolve the template.
Returns:
a new target instance.
Throws:
NullPointerException - if the resolved template name or value is null.

resolveTemplates

public ResteasyWebTarget resolveTemplates(Map<String,Object> templateValues)
                                   throws NullPointerException
Description copied from interface: WebTarget
Create a new WebTarget instance by resolving one or more URI templates in the URI of the current target instance using supplied name-value pairs. A call to the method with an empty parameter map is ignored, i.e. same WebTarget instance is returned.

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

Specified by:
resolveTemplates in interface WebTarget
Specified by:
resolveTemplates in interface ResteasyWebTarget
Parameters:
templateValues - a map of URI template names and their values.
Returns:
a new target instance or the same target instance in case the input name-value map is empty.
Throws:
NullPointerException - if the name-value map or any of the names or values in the map is null.

resolveTemplate

public ResteasyWebTarget resolveTemplate(String name,
                                         Object value,
                                         boolean encodeSlashInPath)
                                  throws NullPointerException
Description copied from interface: WebTarget
Create a new WebTarget instance by resolving a URI template with a given name in the URI of the current target instance using a supplied value. In case a null template name or value is entered a NullPointerException is thrown.

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

Specified by:
resolveTemplate in interface WebTarget
Specified by:
resolveTemplate in interface ResteasyWebTarget
Parameters:
name - name of the URI template.
value - value to be used to resolve the template.
encodeSlashInPath - 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:
a new target instance.
Throws:
NullPointerException - if the resolved template name or value is null.

resolveTemplateFromEncoded

public ResteasyWebTarget resolveTemplateFromEncoded(String name,
                                                    Object value)
                                             throws NullPointerException
Description copied from interface: WebTarget
Create a new WebTarget instance by resolving a URI template with a given name in the URI of the current target 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 value is entered a NullPointerException is thrown.

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

Specified by:
resolveTemplateFromEncoded in interface WebTarget
Specified by:
resolveTemplateFromEncoded in interface ResteasyWebTarget
Parameters:
name - name of the URI template.
value - encoded value to be used to resolve the template.
Returns:
a new target instance.
Throws:
NullPointerException - if the resolved template name or value is null.

resolveTemplatesFromEncoded

public ResteasyWebTarget resolveTemplatesFromEncoded(Map<String,Object> templateValues)
                                              throws NullPointerException
Description copied from interface: WebTarget
Create a new WebTarget instance by resolving one or more URI templates in the URI of the current target instance using supplied name-encoded 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, i.e. same WebTarget instance is returned.

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

Specified by:
resolveTemplatesFromEncoded in interface WebTarget
Specified by:
resolveTemplatesFromEncoded in interface ResteasyWebTarget
Parameters:
templateValues - a map of URI template names and their encoded values.
Returns:
a new target instance or the same target instance in case the input name-value map is empty.
Throws:
NullPointerException - if the name-value map or any of the names or encoded values in the map is null.

resolveTemplates

public ResteasyWebTarget resolveTemplates(Map<String,Object> templateValues,
                                          boolean encodeSlashInPath)
                                   throws NullPointerException
Description copied from interface: WebTarget
Create a new WebTarget instance by resolving one or more URI templates in the URI of the current target instance using supplied name-value pairs. A call to the method with an empty parameter map is ignored, i.e. same WebTarget instance is returned.

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

Specified by:
resolveTemplates in interface WebTarget
Specified by:
resolveTemplates in interface ResteasyWebTarget
Parameters:
templateValues - a map of URI template names and their values.
encodeSlashInPath - 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:
a new target instance or the same target instance in case the input name-value map is empty.
Throws:
NullPointerException - if the name-value map or any of the names or values in the map is null.

matrixParam

public ResteasyWebTarget matrixParam(String name,
                                     Object... values)
                              throws NullPointerException
Description copied from interface: WebTarget
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. In case a single null value is entered, all parameters with that name in the current final path segment are removed (if present) from the collection of last segment matrix parameters inherited from the current target.

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.

Specified by:
matrixParam in interface WebTarget
Specified by:
matrixParam in interface ResteasyWebTarget
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:
NullPointerException - if the parameter name is null or if there are multiple values present and any of those values is null.
See Also:
Matrix URIs

queryParam

public ResteasyWebTarget queryParam(String name,
                                    Object... values)
                             throws NullPointerException
Description copied from interface: WebTarget
Create a new WebTarget instance by configuring a query parameter on the URI of the current target instance. If multiple values are supplied the parameter will be added once per value. In case a single null value is entered, all parameters with that name are removed (if present) from the collection of query parameters inherited from the current target.

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

Specified by:
queryParam in interface WebTarget
Specified by:
queryParam in interface ResteasyWebTarget
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:
NullPointerException - if the parameter name is null or if there are multiple values present and any of those values is null.

queryParams

public ResteasyWebTarget queryParams(MultivaluedMap<String,Object> parameters)
                              throws IllegalArgumentException,
                                     NullPointerException
Specified by:
queryParams in interface ResteasyWebTarget
Throws:
IllegalArgumentException
NullPointerException

queryParamNoTemplate

public ResteasyWebTarget queryParamNoTemplate(String name,
                                              Object... values)
                                       throws NullPointerException
Description copied from interface: ResteasyWebTarget
Will encode any '{}' characters and not treat them as template parameters

Specified by:
queryParamNoTemplate in interface ResteasyWebTarget
Throws:
NullPointerException

queryParamsNoTemplate

public ResteasyWebTarget queryParamsNoTemplate(MultivaluedMap<String,Object> parameters)
                                        throws IllegalArgumentException,
                                               NullPointerException
Description copied from interface: ResteasyWebTarget
Will encode any '{}' characters and not treat them as template parameters

Specified by:
queryParamsNoTemplate in interface ResteasyWebTarget
Throws:
IllegalArgumentException
NullPointerException

request

public Invocation.Builder request()
Description copied from interface: WebTarget
Start building a request to the targeted web resource.

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

request

public Invocation.Builder request(String... acceptedResponseTypes)
Description copied from interface: WebTarget
Start building a request to the targeted web resource and define the accepted response media types.

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

request

public Invocation.Builder request(MediaType... acceptedResponseTypes)
Description copied from interface: WebTarget
Start building a request to the targeted web resource and define the accepted response media types.

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


Copyright © 2012. All Rights Reserved.