|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.nativex.common.Request
public abstract class Request
A basic request object to be used with ServerRequestManager.
Nested Class Summary | |
---|---|
static class |
Request.HTTP_ACTION
Enumerates the possible HTTP methods. |
Field Summary | |
---|---|
private Integer |
actionType
|
static HttpClient |
defaultClient
The field defaultClient should be used for testing purposes only. |
private boolean |
enableLogging
|
private Request.HTTP_ACTION |
httpAction
|
private HttpClient |
httpClient
|
private OnRequestCompletedListener |
listener
|
private String |
request
|
private String |
requestType
|
private String |
url
|
Constructor Summary | |
---|---|
Request()
Basic constructor. |
|
Request(String url,
String request,
String requestType,
Request.HTTP_ACTION action)
Constructor that receives the request parameters. |
Method Summary | |
---|---|
void |
executeListener(boolean succeded,
Response response)
Executes the listener set with setListener(). |
abstract void |
generateRequest()
Generates the request body. |
abstract Response |
generateResponse()
Generates the proper type of response according to the request response. |
Integer |
getActionType()
|
Map<String,String> |
getHeaders()
Returns a list of extra HTTP headers to go along with this request. |
Request.HTTP_ACTION |
getHttpAction()
Returns the request HTTP method. |
HttpClient |
getHttpClient()
|
String |
getPrettyRequest()
Prettifies the request body for debugging output. |
String |
getRequest()
Returns the request body. |
String |
getRequestType()
Returns the request type. |
String |
getUrl()
Returns the request URL. |
boolean |
isLoggingEnabled()
|
void |
postExecute()
|
protected void |
postExecuteImmediatelyAfter()
|
void |
preExecute()
|
protected void |
preExecuteJustBefore()
|
void |
setActionType(Integer type)
|
protected void |
setHttpAction(Request.HTTP_ACTION httpAction)
Sets the HTTP method. |
void |
setHttpClient(HttpClient httpClient)
|
void |
setListener(OnRequestCompletedListener listener)
Sets a listener that fires when the request is completed. |
protected void |
setLoggingEnabled(boolean isEnabled)
|
protected void |
setRequest(String request)
Sets the request body. |
protected void |
setRequestType(String requestType)
Sets the request type. |
protected void |
setUrl(String url)
Sets the request URL. |
abstract boolean |
shouldExecute()
Checks if the request should be executed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static HttpClient defaultClient
private String url
private String request
private String requestType
private Request.HTTP_ACTION httpAction
private OnRequestCompletedListener listener
private HttpClient httpClient
private Integer actionType
private boolean enableLogging
Constructor Detail |
---|
public Request()
public Request(String url, String request, String requestType, Request.HTTP_ACTION action)
url
- String
. The URL the request is made to.request
- String
. The request body.requestType
- String
. The request type.action
- Request.HTTP_ACTION
. The HTTP method of the request.Method Detail |
---|
public HttpClient getHttpClient()
public void setHttpClient(HttpClient httpClient)
public String getRequest()
String
. The request body.public String getPrettyRequest()
String
The request body, only prettier.protected void setRequest(String request)
request
- String
. The request body.public String getUrl()
String
. The request URL.protected void setUrl(String url)
url
- String
. The request URL.public String getRequestType()
String
. The request type.protected void setRequestType(String requestType)
requestType
- String
. The request type.public Request.HTTP_ACTION getHttpAction()
Request.HTTP_ACTION
. The HTTP method.public Map<String,String> getHeaders()
protected void setHttpAction(Request.HTTP_ACTION httpAction)
httpAction
- Request.HTTP_ACTION
. The HTTP method.public abstract Response generateResponse()
Response
The type of the response expected from that request.public abstract void generateRequest()
public abstract boolean shouldExecute()
Boolean
. Returns true if the request should be executed or false when skipped.public void setListener(OnRequestCompletedListener listener)
listener
- OnRequestCompletedListener
. Listener that fires when the request is completed.public void executeListener(boolean succeded, Response response)
succeded
- Boolean
. Notifies if the request is successful.response
- Response
. The response from the server.public void preExecute()
public void postExecute()
public void setActionType(Integer type)
public Integer getActionType()
protected void preExecuteJustBefore()
protected void postExecuteImmediatelyAfter()
public boolean isLoggingEnabled()
protected void setLoggingEnabled(boolean isEnabled)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |