Build 1.0_r1(from source)

org.apache.http.protocol
Class BasicHttpProcessor

java.lang.Object
  extended by org.apache.http.protocol.BasicHttpProcessor
All Implemented Interfaces:
Cloneable, HttpRequestInterceptor, HttpResponseInterceptor, HttpProcessor, HttpRequestInterceptorList, HttpResponseInterceptorList

public final class BasicHttpProcessor
extends Object
implements HttpProcessor, HttpRequestInterceptorList, HttpResponseInterceptorList, Cloneable

Keeps lists of interceptors for processing requests and responses.

Since:
4.0

Field Summary
protected  List requestInterceptors
           
protected  List responseInterceptors
           
 
Constructor Summary
BasicHttpProcessor()
           
 
Method Summary
 void addInterceptor(HttpRequestInterceptor interceptor)
          Same as addRequestInterceptor.
 void addInterceptor(HttpRequestInterceptor interceptor, int index)
           
 void addInterceptor(HttpResponseInterceptor interceptor)
          Same as addResponseInterceptor.
 void addInterceptor(HttpResponseInterceptor interceptor, int index)
           
 void addRequestInterceptor(HttpRequestInterceptor itcp)
          Appends a request interceptor to this list.
 void addRequestInterceptor(HttpRequestInterceptor itcp, int index)
          Inserts a request interceptor at the specified index.
 void addResponseInterceptor(HttpResponseInterceptor itcp)
          Appends a response interceptor to this list.
 void addResponseInterceptor(HttpResponseInterceptor itcp, int index)
          Inserts a response interceptor at the specified index.
 void clearInterceptors()
          Clears both interceptor lists maintained by this processor.
 void clearRequestInterceptors()
          Removes all request interceptors from this list.
 void clearResponseInterceptors()
          Removes all response interceptors from this list.
 Object clone()
          Returns a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.
 BasicHttpProcessor copy()
          Creates a copy of this instance
protected  void copyInterceptors(BasicHttpProcessor target)
           
 HttpRequestInterceptor getRequestInterceptor(int index)
          Obtains a request interceptor from this list.
 int getRequestInterceptorCount()
          Obtains the current size of this list.
 HttpResponseInterceptor getResponseInterceptor(int index)
          Obtains a response interceptor from this list.
 int getResponseInterceptorCount()
          Obtains the current size of this list.
 void process(HttpRequest request, HttpContext context)
          Processes a request.
 void process(HttpResponse response, HttpContext context)
          Processes a response.
 void removeRequestInterceptorByClass(Class clazz)
          Removes all request interceptor of the specified class
 void removeResponseInterceptorByClass(Class clazz)
          Removes all response interceptor of the specified class
 void setInterceptors(List list)
          Sets the interceptor lists.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestInterceptors

protected List requestInterceptors

responseInterceptors

protected List responseInterceptors
Constructor Detail

BasicHttpProcessor

public BasicHttpProcessor()
Method Detail

addRequestInterceptor

public void addRequestInterceptor(HttpRequestInterceptor itcp)
Description copied from interface: HttpRequestInterceptorList
Appends a request interceptor to this list.

Specified by:
addRequestInterceptor in interface HttpRequestInterceptorList
Parameters:
itcp - the request interceptor to add

addRequestInterceptor

public void addRequestInterceptor(HttpRequestInterceptor itcp,
                                  int index)
Description copied from interface: HttpRequestInterceptorList
Inserts a request interceptor at the specified index.

Specified by:
addRequestInterceptor in interface HttpRequestInterceptorList
Parameters:
itcp - the request interceptor to add
index - the index to insert the interceptor at

addResponseInterceptor

public void addResponseInterceptor(HttpResponseInterceptor itcp,
                                   int index)
Description copied from interface: HttpResponseInterceptorList
Inserts a response interceptor at the specified index.

Specified by:
addResponseInterceptor in interface HttpResponseInterceptorList
Parameters:
itcp - the response interceptor to add
index - the index to insert the interceptor at

removeRequestInterceptorByClass

public void removeRequestInterceptorByClass(Class clazz)
Description copied from interface: HttpRequestInterceptorList
Removes all request interceptor of the specified class

Specified by:
removeRequestInterceptorByClass in interface HttpRequestInterceptorList
Parameters:
clazz - the class of the instances to be removed.

removeResponseInterceptorByClass

public void removeResponseInterceptorByClass(Class clazz)
Description copied from interface: HttpResponseInterceptorList
Removes all response interceptor of the specified class

Specified by:
removeResponseInterceptorByClass in interface HttpResponseInterceptorList
Parameters:
clazz - the class of the instances to be removed.

addInterceptor

public final void addInterceptor(HttpRequestInterceptor interceptor)
Same as addRequestInterceptor.

Parameters:
interceptor - the interceptor to add

addInterceptor

public final void addInterceptor(HttpRequestInterceptor interceptor,
                                 int index)

getRequestInterceptorCount

public int getRequestInterceptorCount()
Description copied from interface: HttpRequestInterceptorList
Obtains the current size of this list.

Specified by:
getRequestInterceptorCount in interface HttpRequestInterceptorList
Returns:
the number of request interceptors in this list

getRequestInterceptor

public HttpRequestInterceptor getRequestInterceptor(int index)
Description copied from interface: HttpRequestInterceptorList
Obtains a request interceptor from this list.

Specified by:
getRequestInterceptor in interface HttpRequestInterceptorList
Parameters:
index - the index of the interceptor to obtain, 0 for first
Returns:
the interceptor at the given index, or null if the index is out of range

clearRequestInterceptors

public void clearRequestInterceptors()
Description copied from interface: HttpRequestInterceptorList
Removes all request interceptors from this list.

Specified by:
clearRequestInterceptors in interface HttpRequestInterceptorList

addResponseInterceptor

public void addResponseInterceptor(HttpResponseInterceptor itcp)
Description copied from interface: HttpResponseInterceptorList
Appends a response interceptor to this list.

Specified by:
addResponseInterceptor in interface HttpResponseInterceptorList
Parameters:
itcp - the response interceptor to add

addInterceptor

public final void addInterceptor(HttpResponseInterceptor interceptor)
Same as addResponseInterceptor.

Parameters:
interceptor - the interceptor to add

addInterceptor

public final void addInterceptor(HttpResponseInterceptor interceptor,
                                 int index)

getResponseInterceptorCount

public int getResponseInterceptorCount()
Description copied from interface: HttpResponseInterceptorList
Obtains the current size of this list.

Specified by:
getResponseInterceptorCount in interface HttpResponseInterceptorList
Returns:
the number of response interceptors in this list

getResponseInterceptor

public HttpResponseInterceptor getResponseInterceptor(int index)
Description copied from interface: HttpResponseInterceptorList
Obtains a response interceptor from this list.

Specified by:
getResponseInterceptor in interface HttpResponseInterceptorList
Parameters:
index - the index of the interceptor to obtain, 0 for first
Returns:
the interceptor at the given index, or null if the index is out of range

clearResponseInterceptors

public void clearResponseInterceptors()
Description copied from interface: HttpResponseInterceptorList
Removes all response interceptors from this list.

Specified by:
clearResponseInterceptors in interface HttpResponseInterceptorList

setInterceptors

public void setInterceptors(List list)
Sets the interceptor lists. First, both interceptor lists maintained by this processor will be cleared. Subsequently, elements of the argument list that are request interceptors will be added to the request interceptor list. Elements that are response interceptors will be added to the response interceptor list. Elements that are both request and response interceptor will be added to both lists. Elements that are neither request nor response interceptor will be ignored.

Specified by:
setInterceptors in interface HttpRequestInterceptorList
Specified by:
setInterceptors in interface HttpResponseInterceptorList
Parameters:
list - the list of request and response interceptors from which to initialize

clearInterceptors

public void clearInterceptors()
Clears both interceptor lists maintained by this processor.


process

public void process(HttpRequest request,
                    HttpContext context)
             throws IOException,
                    HttpException
Description copied from interface: HttpRequestInterceptor
Processes a request. On the client side, this step is performed before the request is sent to the server. On the server side, this step is performed on incoming messages before the message body is evaluated.

Specified by:
process in interface HttpRequestInterceptor
Parameters:
request - the request to preprocess
context - the context for the request
Throws:
IOException - in case of an IO problem
HttpException - in case of a protocol or other problem

process

public void process(HttpResponse response,
                    HttpContext context)
             throws IOException,
                    HttpException
Description copied from interface: HttpResponseInterceptor
Processes a response. On the server side, this step is performed before the response is sent to the client. On the client side, this step is performed on incoming messages before the message body is evaluated.

Specified by:
process in interface HttpResponseInterceptor
Parameters:
response - the response to postprocess
context - the context for the request
Throws:
IOException - in case of an IO problem
HttpException - in case of a protocol or other problem

copyInterceptors

protected void copyInterceptors(BasicHttpProcessor target)

copy

public BasicHttpProcessor copy()
Creates a copy of this instance

Returns:
new instance of the BasicHttpProcessor

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from class: Object
Returns a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.

Classes which wish to support cloning must specify that they implement the Cloneable interface, since the implementation checks for this.

Overrides:
clone in class Object
Returns:
Object a shallow copy of this object.
Throws:
CloneNotSupportedException - if the receiver's class does not implement the interface Cloneable.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature