org.apache.wink.client
Interface Resource


public interface Resource

Represents a web resource, enabling the invocation of different http methods


Method Summary
 Resource accept(javax.ws.rs.core.MediaType... values)
          Add values to the Accept header.
 Resource accept(java.lang.String... values)
          Add values to the Accept header.
 Resource acceptLanguage(java.util.Locale... values)
          Add values to the Accept-Language header.
 Resource acceptLanguage(java.lang.String... values)
          Add values to the Accept-Language header.
 java.lang.Object attribute(java.lang.String key)
          Get an attribute
 Resource attribute(java.lang.String key, java.lang.Object value)
          Set an attribute on the resource.
 Resource contentType(javax.ws.rs.core.MediaType mediaType)
          Set the Content-Type header, overriding any previous value.
 Resource contentType(java.lang.String mediaType)
          Set the Content-Type header, overriding any previous value.
 Resource cookie(javax.ws.rs.core.Cookie value)
          Add a Cookie value.
 Resource cookie(java.lang.String value)
          Add a Cookie value.
 ClientResponse delete()
          Invoke the DELETE method
<T> T
delete(java.lang.Class<T> responseEntity)
          Invoke the DELETE method
<T> T
delete(EntityType<T> responseEntity)
          Invoke the DELETE method
 ClientResponse get()
          Invoke the GET method
<T> T
get(java.lang.Class<T> responseEntity)
          Invoke the GET method
<T> T
get(EntityType<T> responseEntity)
          Invoke the GET method
 javax.ws.rs.core.UriBuilder getUriBuilder()
          Get the UriBuilder associated with this resource.
 ClientResponse head()
          Invoke the HEAD method
 Resource header(java.lang.String name, java.lang.String... values)
          Add a request header to be used in every invocation
<T> T
invoke(java.lang.String method, java.lang.Class<T> responseEntity, java.lang.Object requestEntity)
          Invoke a request to the uri associated with the resource, and with any headers and attributes set on the resource.
<T> T
invoke(java.lang.String method, EntityType<T> responseEntity, java.lang.Object requestEntity)
          Invoke a request to the uri associated with the resource, and with any headers and attributes set on the resource.
 ClientResponse options()
          Invoke the OPTIONS method
<T> T
post(java.lang.Class<T> responseEntity, java.lang.Object requestEntity)
          Invoke the POST method
<T> T
post(EntityType<T> responseEntity, java.lang.Object requestEntity)
          Invoke the POST method
 ClientResponse post(java.lang.Object requestEntity)
          Invoke the POST method
<T> T
put(java.lang.Class<T> responseEntity, java.lang.Object requestEntity)
          Invoke the PUT method
<T> T
put(EntityType<T> responseEntity, java.lang.Object requestEntity)
          Invoke the PUT method
 ClientResponse put(java.lang.Object requestEntity)
          Invoke the PUT method
 Resource queryParam(java.lang.String key, java.lang.Object... values)
          Add a query parameter to the uri
 Resource queryParams(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> params)
          Add all the query parameters from the provided multivalued map.
 Resource uri(java.lang.String uri)
          Set the uri of this resource and create a new UriBuilder
 Resource uri(java.net.URI uri)
          Set the uri of this resource and create a new UriBuilder
 

Method Detail

header

Resource header(java.lang.String name,
                java.lang.String... values)
Add a request header to be used in every invocation

Parameters:
name - name of the header to add. the name of the header is case insensitive.
values - the values of the header. All of the values will be added to the same header, separated by a commas (,).
Returns:
this resource instance

accept

Resource accept(java.lang.String... values)
Add values to the Accept header.

Parameters:
values - accept header values to add
Returns:
this resource instance

accept

Resource accept(javax.ws.rs.core.MediaType... values)
Add values to the Accept header.

Parameters:
values - accept header values to add
Returns:
this resource instance

acceptLanguage

Resource acceptLanguage(java.lang.String... values)
Add values to the Accept-Language header.

Parameters:
values - accept-langage header values to add
Returns:
this resource instance

acceptLanguage

Resource acceptLanguage(java.util.Locale... values)
Add values to the Accept-Language header.

Parameters:
values - accept-langage header values to add
Returns:
this resource instance

cookie

Resource cookie(java.lang.String value)
Add a Cookie value. Every call to this method will create a new Cookie header.

Parameters:
value - the cookie value to add
Returns:
this resource instance

cookie

Resource cookie(javax.ws.rs.core.Cookie value)
Add a Cookie value. Every call to this method will create a new Cookie header.

Parameters:
value - the cookie value to add
Returns:
this resource instance

contentType

Resource contentType(java.lang.String mediaType)
Set the Content-Type header, overriding any previous value.

Parameters:
mediaType - the content type to set
Returns:
this resource instance

contentType

Resource contentType(javax.ws.rs.core.MediaType mediaType)
Set the Content-Type header, overriding any previous value.

Parameters:
mediaType - the content type to set
Returns:
this resource instance

queryParam

Resource queryParam(java.lang.String key,
                    java.lang.Object... values)
Add a query parameter to the uri

Parameters:
key - the name of the query parameter
values - values of the query parameters. A query parameter will be added for every value
Returns:
this resource instance

queryParams

Resource queryParams(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> params)
Add all the query parameters from the provided multivalued map.

Parameters:
params - multivalued map of parameters.
Returns:
this resource instance

attribute

Resource attribute(java.lang.String key,
                   java.lang.Object value)
Set an attribute on the resource. All the attributes are available to handlers during a request via the BaseRequestResponse.getAttributes() and BaseRequestResponse.getAttributes() methods.

Parameters:
key - attribute key
value - attribute value
Returns:
this resource instance

attribute

java.lang.Object attribute(java.lang.String key)
Get an attribute

Parameters:
key - attribute key
Returns:
attribute value, or null if the attribute is not set

getUriBuilder

javax.ws.rs.core.UriBuilder getUriBuilder()
Get the UriBuilder associated with this resource. All modifications to the builder affect the uri of the resource

Returns:
the UriBuilder associated with this resource

uri

Resource uri(java.net.URI uri)
Set the uri of this resource and create a new UriBuilder

Parameters:
uri - the new uri for this resource
Returns:
this resource instance

uri

Resource uri(java.lang.String uri)
Set the uri of this resource and create a new UriBuilder

Parameters:
uri - the new uri for this resource
Returns:
this resource instance

invoke

<T> T invoke(java.lang.String method,
             java.lang.Class<T> responseEntity,
             java.lang.Object requestEntity)
Invoke a request to the uri associated with the resource, and with any headers and attributes set on the resource. If the response code represents an error code, then a ClientWebException is thrown.

Type Parameters:
T - the type of response entity to return
Parameters:
method - the http request method
responseEntity - the class of the response entity to return
requestEntity - the request entity for methods that can send an entity (PUT, POST)
Returns:
an instance of the response entity as specified by the response entity type
Throws:
ClientWebException - if the response code represents an error code
ClientRuntimeException - if there are other exceptions that the Wink client encounters

invoke

<T> T invoke(java.lang.String method,
             EntityType<T> responseEntity,
             java.lang.Object requestEntity)
Invoke a request to the uri associated with the resource, and with any headers and attributes set on the resource. If the response code represents an error code, then a ClientWebException is thrown.

Type Parameters:
T - the type of response entity to return
Parameters:
method - the http request method
responseEntity - an instance of EntityType specifying the response entity to return
requestEntity - the request entity for methods that can send an entity (PUT, POST)
Returns:
an instance of the response entity as specified by the response entity type
Throws:
ClientWebException - if the response code represents an error code
ClientRuntimeException - if there are other exceptions that the Wink client encounters

head

ClientResponse head()
Invoke the HEAD method

Returns:
the ClientResponse for the invocation

options

ClientResponse options()
Invoke the OPTIONS method

Returns:
the ClientResponse for the invocation

get

<T> T get(java.lang.Class<T> responseEntity)
Invoke the GET method

Type Parameters:
T - type of response entity
Parameters:
responseEntity - response entity class
Returns:
an instance of the response entity as specified by the response entity type
Throws:
ClientWebException - if the response code represents an error code
ClientRuntimeException - if there are other exceptions that the Wink client encounters

get

<T> T get(EntityType<T> responseEntity)
Invoke the GET method

Type Parameters:
T - type of response entity
Parameters:
responseEntity - an instance of EntityType specifying the response entity to return
Returns:
an instance of the response entity as specified by the response entity type
Throws:
ClientWebException - if the response code represents an error code
ClientRuntimeException - if there are other exceptions that the Wink client encounters

get

ClientResponse get()
Invoke the GET method

Returns:
the ClientResponse for the invocation

post

<T> T post(java.lang.Class<T> responseEntity,
           java.lang.Object requestEntity)
Invoke the POST method

Type Parameters:
T - type of response entity
Parameters:
responseEntity - response entity class
requestEntity - request entity to send
Returns:
an instance of the response entity as specified by the response entity type
Throws:
ClientWebException - if the response code represents an error code
ClientRuntimeException - if there are other exceptions that the Wink client encounters

post

<T> T post(EntityType<T> responseEntity,
           java.lang.Object requestEntity)
Invoke the POST method

Type Parameters:
T - type of response entity
Parameters:
responseEntity - an instance of EntityType specifying the response entity to return
requestEntity - request entity to send
Returns:
an instance of the response entity as specified by the response entity type
Throws:
ClientWebException - if the response code represents an error code
ClientRuntimeException - if there are other exceptions that the Wink client encounters

post

ClientResponse post(java.lang.Object requestEntity)
Invoke the POST method

Returns:
the ClientResponse for the invocation

put

<T> T put(java.lang.Class<T> responseEntity,
          java.lang.Object requestEntity)
Invoke the PUT method

Type Parameters:
T - type of response entity
Parameters:
responseEntity - response entity class
requestEntity - request entity to send
Returns:
an instance of the response entity as specified by the response entity type
Throws:
ClientWebException - if the response code represents an error code
ClientRuntimeException - if there are other exceptions that the Wink client encounters

put

<T> T put(EntityType<T> responseEntity,
          java.lang.Object requestEntity)
Invoke the PUT method

Type Parameters:
T - type of response entity
Parameters:
responseEntity - an instance of EntityType specifying the response entity to return
requestEntity - request entity to send
Returns:
an instance of the response entity as specified by the response entity type
Throws:
ClientWebException - if the response code represents an error code
ClientRuntimeException - if there are other exceptions that the Wink client encounters

put

ClientResponse put(java.lang.Object requestEntity)
Invoke the PUT method

Returns:
the ClientResponse for the invocation

delete

<T> T delete(java.lang.Class<T> responseEntity)
Invoke the DELETE method

Type Parameters:
T - type of response entity
Parameters:
responseEntity - response entity class
Returns:
an instance of the response entity as specified by the response entity type
Throws:
ClientWebException - if the response code represents an error code
ClientRuntimeException - if there are other exceptions that the Wink client encounters

delete

<T> T delete(EntityType<T> responseEntity)
Invoke the DELETE method

Type Parameters:
T - type of response entity
Parameters:
responseEntity - an instance of EntityType specifying the response entity to return
Returns:
an instance of the response entity as specified by the response entity type
Throws:
ClientWebException - if the response code represents an error code
ClientRuntimeException - if there are other exceptions that the Wink client encounters

delete

ClientResponse delete()
Invoke the DELETE method

Returns:
the ClientResponse for the invocation


Copyright © 2009-2013 The Apache Software Foundation. All Rights Reserved.