ClientParamsStackpublic 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
{@link org.apache.http.client.HttpClient 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
{@link org.apache.http.client.HttpClient HttpClient}.
These can be used to set parameters that cannot be overridden
on a per-request basis.
Each stack entry may be null . That is preferable over
an empty params collection, since it avoids searching the empty collection
when looking up parameters. |
Fields Summary |
---|
private final Log | log | protected final HttpParams | applicationParamsThe application parameter collection, or null . | protected final HttpParams | clientParamsThe client parameter collection, or null . | protected final HttpParams | requestParamsThe request parameter collection, or null . | protected final HttpParams | overrideParamsThe override parameter collection, or null . |
Constructors Summary |
---|
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.
applicationParams = aparams;
clientParams = cparams;
requestParams = rparams;
overrideParams = oparams;
| public ClientParamsStack(ClientParamsStack stack)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.
this(stack.getApplicationParams(),
stack.getClientParams(),
stack.getRequestParams(),
stack.getOverrideParams());
| 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 is null ,
the corresponding element from the argument stack is used.
There is no copying of parameters.
this((aparams != null) ? aparams : stack.getApplicationParams(),
(cparams != null) ? cparams : stack.getClientParams(),
(rparams != null) ? rparams : stack.getRequestParams(),
(oparams != null) ? oparams : stack.getOverrideParams());
|
Methods Summary |
---|
public org.apache.http.params.HttpParams | 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.
return this;
| public final org.apache.http.params.HttpParams | getApplicationParams()Obtains the application parameters of this stack.
return applicationParams;
| public final org.apache.http.params.HttpParams | getClientParams()Obtains the client parameters of this stack.
return clientParams;
| public final org.apache.http.params.HttpParams | getOverrideParams()Obtains the override parameters of this stack.
return overrideParams;
| public java.lang.Object | getParameter(java.lang.String name)Obtains a parameter from this stack.
See class comment for search order.
if (name == null) {
throw new IllegalArgumentException
("Parameter name must not be null.");
}
Object result = null;
if (overrideParams != null) {
result = overrideParams.getParameter(name);
}
if ((result == null) && (requestParams != null)) {
result = requestParams.getParameter(name);
}
if ((result == null) && (clientParams != null)) {
result = clientParams.getParameter(name);
}
if ((result == null) && (applicationParams != null)) {
result = applicationParams.getParameter(name);
}
if (this.log.isDebugEnabled()) {
this.log.debug("'" + name + "': " + result);
}
return result;
| public final org.apache.http.params.HttpParams | getRequestParams()Obtains the request parameters of this stack.
return requestParams;
| public boolean | removeParameter(java.lang.String name)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.
throw new UnsupportedOperationException
("Removing parameters in a stack is not supported.");
| public org.apache.http.params.HttpParams | setParameter(java.lang.String name, java.lang.Object value)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.
throw new UnsupportedOperationException
("Setting parameters in a stack is not supported.");
|
|