com.sun.jersey.api.client
Class ClientRequest

java.lang.Object
  extended by com.sun.jersey.api.client.ClientRequest

public abstract class ClientRequest
extends java.lang.Object

A client (out-bound) HTTP request.

Instances may be created by using the static method create() and methods on ClientRequest.Builder.

Author:
Paul.Sandoz@Sun.Com

Nested Class Summary
static class ClientRequest.Builder
          The builder for building a ClientRequest instance.
 
Constructor Summary
ClientRequest()
           
 
Method Summary
abstract  ClientRequest clone()
          Clone the request.
static ClientRequest.Builder create()
          Create a builder for building a new ClientRequest instance.
abstract  ClientRequestAdapter getAdapter()
          Get the client request adapter.
abstract  java.lang.Object getEntity()
          Get the entity of the request.
abstract  MultivaluedMap<java.lang.String,java.lang.Object> getHeaders()
          Get the HTTP headers of the request.
static java.lang.String getHeaderValue(java.lang.Object headerValue)
          Convert a header value, represented as a general object, to the string value.
abstract  MultivaluedMap<java.lang.String,java.lang.Object> getMetadata()
          Deprecated. 
abstract  java.lang.String getMethod()
          Get the HTTP method of the request.
abstract  java.util.Map<java.lang.String,java.lang.Object> getProperties()
          Get the mutable property bag.
 boolean getPropertyAsFeature(java.lang.String name)
          Get a feature that is boolean property of the property bag.
 boolean getPropertyAsFeature(java.lang.String name, boolean defaultValue)
          Get a feature that is boolean property of the property bag.
abstract  java.net.URI getURI()
          Get the URI of the request.
abstract  void setAdapter(ClientRequestAdapter adapter)
          Set the client request adapter.
abstract  void setEntity(java.lang.Object entity)
          Set the entity of the request.
abstract  void setMethod(java.lang.String method)
          Set the HTTP method of the request.
abstract  void setProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
          Sets properties (replaces everything previously set).
abstract  void setURI(java.net.URI uri)
          Set the URI of the request.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientRequest

public ClientRequest()
Method Detail

getProperties

public abstract java.util.Map<java.lang.String,java.lang.Object> getProperties()
Get the mutable property bag.

Returns:
the property bag.

setProperties

public abstract void setProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
Sets properties (replaces everything previously set).


getPropertyAsFeature

public boolean getPropertyAsFeature(java.lang.String name)
Get a feature that is boolean property of the property bag.

Parameters:
name - the name of the feature;
Returns:
true if the feature value is present and is an instance of Boolean and that value is true, otherwise false.

getPropertyAsFeature

public boolean getPropertyAsFeature(java.lang.String name,
                                    boolean defaultValue)
Get a feature that is boolean property of the property bag.

Parameters:
name - the name of the feature;
defaultValue - the default boolean value if the property is absent.
Returns:
true if the feature value is present and is an instance of Boolean and that value is true, otherwise the defaultValue.

getURI

public abstract java.net.URI getURI()
Get the URI of the request. The URI shall contain sufficient components to correctly dispatch a request

Returns:
the URI of the request.

setURI

public abstract void setURI(java.net.URI uri)
Set the URI of the request. The URI shall contain sufficient components to correctly dispatch a request

Parameters:
uri - the URI of the request.

getMethod

public abstract java.lang.String getMethod()
Get the HTTP method of the request.

Returns:
the HTTP method.

setMethod

public abstract void setMethod(java.lang.String method)
Set the HTTP method of the request.

Parameters:
method - the HTTP method.

getEntity

public abstract java.lang.Object getEntity()
Get the entity of the request.

Returns:
the entity of the request.

setEntity

public abstract void setEntity(java.lang.Object entity)
Set the entity of the request.

Any Java type instance for a request entity, that is supported by the client configuration of the client, can be passed. If generic information is required then an instance of GenericEntity may be used.

Parameters:
entity - the entity of the request.

getMetadata

@Deprecated
public abstract MultivaluedMap<java.lang.String,java.lang.Object> getMetadata()
Deprecated. 

Get the HTTP headers of the request.

Returns:
the HTTP headers of the request.

getHeaders

public abstract MultivaluedMap<java.lang.String,java.lang.Object> getHeaders()
Get the HTTP headers of the request.

Returns:
the HTTP headers of the request.

getAdapter

public abstract ClientRequestAdapter getAdapter()
Get the client request adapter.

Returns:
the client request adapter.

setAdapter

public abstract void setAdapter(ClientRequestAdapter adapter)
Set the client request adapter.

If an existing adapter is set then usually this adapter wrapped in the new adapter to be set such that the current adaption behavior is retained and augmented with the new adaptation behavior.

Parameters:
adapter - the client request adapter.

clone

public abstract ClientRequest clone()
Clone the request.

Overrides:
clone in class java.lang.Object
Returns:
the cloned request.

create

public static final ClientRequest.Builder create()
Create a builder for building a new ClientRequest instance.

Returns:
the builder.

getHeaderValue

public static java.lang.String getHeaderValue(java.lang.Object headerValue)
Convert a header value, represented as a general object, to the string value.

This method defers to RuntimeDelegate.createHeaderDelegate(java.lang.Class) to obtain a RuntimeDelegate.HeaderDelegate to convert the value to a string. If a RuntimeDelegate.HeaderDelegate is not found then the toString is utilized.

Parameters:
headerValue - the header value as an object
Returns:
the string value


Copyright © 2013 Oracle Corporation. All Rights Reserved.