Package org.apache.http.impl.client
Class ClientParamsStack
java.lang.Object
org.apache.http.params.AbstractHttpParams
org.apache.http.impl.client.ClientParamsStack
- All Implemented Interfaces:
HttpParams
public class ClientParamsStack extends AbstractHttpParams
Represents a stack of parameter collections.
When retrieving a parameter, the stack is searched in a fixed order
and the first match returned. Setting parameters via the stack is
not supported. To minimize overhead, the stack has a fixed size and
does not maintain an internal array.
The supported stack entries, sorted by increasing priority, are:
- Application parameters: expected to be the same for all clients used by an application. These provide "global", that is application-wide, defaults.
- Client parameters:
specific to an instance of
HttpClient. These provide client specific defaults. - Request parameters: specific to a single request execution. For overriding client and global defaults.
- Override parameters:
specific to an instance of
HttpClient. These can be used to set parameters that cannot be overridden on a per-request basis.
null. That is preferable over
an empty params collection, since it avoids searching the empty collection
when looking up parameters.- Version:
- $Revision: 673450 $
- Author:
- Roland Weber
-
Field Summary
Fields Modifier and Type Field Description protected HttpParamsapplicationParamsThe application parameter collection, ornull.protected HttpParamsclientParamsThe client parameter collection, ornull.protected HttpParamsoverrideParamsThe override parameter collection, ornull.protected HttpParamsrequestParamsThe request parameter collection, ornull. -
Constructor Summary
Constructors Constructor Description ClientParamsStack(ClientParamsStack stack)Creates a copy of a parameter stack.ClientParamsStack(ClientParamsStack stack, HttpParams aparams, HttpParams cparams, HttpParams rparams, HttpParams oparams)Creates a modified copy of a parameter stack.ClientParamsStack(HttpParams aparams, HttpParams cparams, HttpParams rparams, HttpParams oparams)Creates a new parameter stack from elements. -
Method Summary
Modifier and Type Method Description HttpParamscopy()Does not copy parameters.HttpParamsgetApplicationParams()Obtains the application parameters of this stack.HttpParamsgetClientParams()Obtains the client parameters of this stack.HttpParamsgetOverrideParams()Obtains the override parameters of this stack.ObjectgetParameter(String name)Obtains a parameter from this stack.HttpParamsgetRequestParams()Obtains the request parameters of this stack.booleanremoveParameter(String name)Does not remove a parameter.HttpParamssetParameter(String name, Object value)Does not set a parameter.Methods inherited from class org.apache.http.params.AbstractHttpParams
getBooleanParameter, getDoubleParameter, getIntParameter, getLongParameter, isParameterFalse, isParameterTrue, setBooleanParameter, setDoubleParameter, setIntParameter, setLongParameter
-
Field Details
-
applicationParams
The application parameter collection, ornull. -
clientParams
The client parameter collection, ornull. -
requestParams
The request parameter collection, ornull. -
overrideParams
The override parameter collection, ornull.
-
-
Constructor Details
-
ClientParamsStack
public ClientParamsStack(HttpParams aparams, HttpParams cparams, HttpParams rparams, HttpParams oparams)Creates a new parameter stack from elements. The arguments will be stored as-is, there is no copying to prevent modification.- Parameters:
aparams- application parameters, ornullcparams- client parameters, ornullrparams- request parameters, ornulloparams- override parameters, ornull
-
ClientParamsStack
Creates a copy of a parameter stack. The new stack will have the exact same entries as the argument stack. There is no copying of parameters.- Parameters:
stack- the stack to copy
-
ClientParamsStack
public ClientParamsStack(ClientParamsStack stack, HttpParams aparams, HttpParams cparams, HttpParams rparams, HttpParams oparams)Creates a modified copy of a parameter stack. The new stack will contain the explicitly passed elements. For elements where the explicit argument isnull, the corresponding element from the argument stack is used. There is no copying of parameters.- Parameters:
stack- the stack to modifyaparams- application parameters, ornullcparams- client parameters, ornullrparams- request parameters, ornulloparams- override parameters, ornull
-
-
Method Details
-
getApplicationParams
Obtains the application parameters of this stack.- Returns:
- the application parameters, or
null
-
getClientParams
Obtains the client parameters of this stack.- Returns:
- the client parameters, or
null
-
getRequestParams
Obtains the request parameters of this stack.- Returns:
- the request parameters, or
null
-
getOverrideParams
Obtains the override parameters of this stack.- Returns:
- the override parameters, or
null
-
getParameter
Obtains a parameter from this stack. See class comment for search order.- Parameters:
name- the name of the parameter to obtain- Returns:
- the highest-priority value for that parameter, or
nullif it is not set anywhere in this stack - See Also:
HttpParams.setParameter(String, Object)
-
setParameter
Does not set a parameter. Parameter stacks are read-only. It is possible, though discouraged, to access and modify specific stack entries. Derived classes may change this behavior.- Parameters:
name- ignoredvalue- ignored- Returns:
- nothing
- Throws:
UnsupportedOperationException- always
-
removeParameter
Does not remove a parameter. Parameter stacks are read-only. It is possible, though discouraged, to access and modify specific stack entries. Derived classes may change this behavior.- Parameters:
name- ignored- Returns:
- nothing
- Throws:
UnsupportedOperationException- always
-
copy
Does not copy parameters. Parameter stacks are lightweight objects, expected to be instantiated as needed and to be used only in a very specific context. On top of that, they are read-only. The typical copy operation to prevent accidental modification of parameters passed by the application to a framework object is therefore pointless and disabled. Create a new stack if you really need a copy.
Derived classes may change this behavior.- Returns:
thisparameter stack
-