|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectself.philbrown.droidQuery.AjaxOptions
public class AjaxOptions
Build an Ajax Request
Constructor Summary | |
---|---|
AjaxOptions()
Default Constructor |
|
AjaxOptions(JSONObject json)
Construct a new AjaxOptions Object with the given JSONObject of Ajax Options values. |
|
AjaxOptions(Map<String,Object> settings)
Constructs a new AjaxOptions Object with the given Key-Value Mapping of Ajax Options values. |
|
AjaxOptions(String json)
Construct with JSON string. |
|
AjaxOptions(String url,
Map<String,Object> settings)
Constructs a new AjaxOptions Object with the given URL and the Key-Value Mapping of Ajax Options values. |
Method Summary | |
---|---|
String |
accepts()
Get the content type sent in the request header that tells the server what kind of response it will accept in return. |
AjaxOptions |
accepts(String accepts)
Set the content type sent in the request header that tells the server what kind of response it will accept in return. |
static void |
ajaxSetup(AjaxOptions options)
Set options to be included in all ajax requests. |
boolean |
async()
Get the asynchronous nature of the Task. |
AjaxOptions |
async(boolean async)
Set the asynchronous nature of the Task. |
Function |
beforeSend()
Gets the function that is registered to call before the Ajax Task begins |
AjaxOptions |
beforeSend(Function beforeSend)
Sets the function that is registered to call before the Ajax Task begins |
boolean |
cache()
Get whether or not the most recent responses will be cached. |
AjaxOptions |
cache(boolean cache)
Set whether or not the most recent responses will be cached. |
long |
cacheTimeout()
Get the amount of time required, in milliseconds, between the current response and a cached response, in order to update the response data and cache the new response. |
AjaxOptions |
cacheTimeout(long cacheTimeout)
Set the amount of time required, in milliseconds, between the current response and a cached response, in order to update the response data and cache the new response. |
Function |
complete()
Gets the function that is registered to call when the task has completed |
AjaxOptions |
complete(Function complete)
Sets the function that is registered to when the task has completed. |
String |
contentType()
Get the content type of the data sent to the server. |
AjaxOptions |
contentType(String contentType)
Set the content type of the data sent to the server. |
Context |
context()
Get the context |
AjaxOptions |
context(Context context)
Set the context. |
Map<String,String> |
cookies()
Get the Key-Value mapping of cookies to send in the Ajax request. |
void |
cookies(JSONObject cookies)
Set the Key-Value mapping of cookies to send in the Ajax request. |
void |
cookies(Map<String,String> cookies)
Set the Key-Value mapping of cookies to send in the Ajax request. |
CustomHttpUriRequest |
customRequest()
Get a new instance of the subclass of CustomHttpUriRequest that is used when the
type option is set to "CUSTOM". |
AjaxOptions |
customRequest(String customRequestClass)
Set the class name of the subclass of CustomHttpUriRequest that is used when the
type option is set to "CUSTOM". |
SAXParser |
customXMLParser()
Get the custom parser for handling XML with a SAX parser instead of converting it to a Document. |
AjaxOptions |
customXMLParser(SAXParser customXMLParser)
Set the custom parser for handling XML with a SAX parser, instead of converting it to a Document Object. |
Object |
data()
Get the data to be sent to the server |
AjaxOptions |
data(Object data)
Set the data to be sent to the server. |
Function |
dataFilter()
Get the function to be used to handle the raw response data. |
AjaxOptions |
dataFilter(Function dataFilter)
Set the function to be used to handle the raw response data. |
String |
dataType()
Gets the type of the data that the request expects from the server |
AjaxOptions |
dataType(String dataType)
Sets the type of the data that the request expects from the server. |
boolean |
debug()
Get whether or not Ajax debug output will be pushed to the logcat |
AjaxOptions |
debug(boolean debug)
Sets whether or not Ajax debug output will be pushed to the logcat |
Function |
error()
Get the function to be called if the request fails. |
AjaxOptions |
error(Function error)
Set the function to be called if the request fails. |
byte[] |
getEncodedCredentials()
As a security feature, this class will not allow queries of authentication passwords. |
boolean |
global()
Get whether to trigger global Ajax event handlers for this request. |
AjaxOptions |
global(boolean global)
Set whether to trigger global Ajax event handlers for this request. |
Headers |
headers()
Get the HTTP Headers for the request |
AjaxOptions |
headers(Headers headers)
Set the HTTP Headers for the request |
boolean |
ifModified()
Get whether or not the response is only considered successful if it has been changed since the last request. |
AjaxOptions |
ifModified(boolean ifModified)
Set whether or not the response is only considered successful if it has been changed since the last request. |
int |
imageHeight()
Get the output bitmap height for requests that set the type attribute to "IMAGE". |
AjaxOptions |
imageHeight(int height)
Set the output bitmap height for requests that set the type attribute to "IMAGE". |
int |
imageWidth()
Get the output bitmap width for requests that set the type attribute to "IMAGE". |
AjaxOptions |
imageWidth(int width)
Set the output bitmap width for requests that set the type attribute to "IMAGE". |
AjaxOptions |
password(String password)
Set the password to use if prompted with an HTTP access authentication request. |
String |
processData()
Get the name of a class that extends DataProcessor that is meant to handle
raw data to send in the HTTP request, in order to prevent it from being converted to a String. |
AjaxOptions |
processData(String processDataClass)
Set the name of a class that extends DataProcessor in order to handle
raw data to send in the HTTP request, in order to prevent it from being converted to a String. |
DefaultHandler |
SAXContentHandler()
Get the SAX parser Content Handler |
AjaxOptions |
SAXContentHandler(DefaultHandler SAXContentHandler)
Set the Content Handler that should be used to handle SAX parsing. |
Map<Integer,Function> |
statusCode()
Get a mapping of numeric HTTP codes to functions to be called when the response has the corresponding code. |
AjaxOptions |
statusCode(Integer code,
Function function)
Adds a Key-Value entry to the status code mapping of numeric HTTP codes to functions to be called when the response has the corresponding code. |
AjaxOptions |
statusCode(Map<Integer,Function> statusCode)
Sets a mapping of numeric HTTP codes to functions to be called when the response has the corresponding code. |
Function |
success()
Gets the function that will be called if the request succeeds. |
AjaxOptions |
success(Function success)
Sets the function that will be called if the request succeeds. |
int |
timeout()
Get the request (and socket) timeout (in milliseconds) for the request. |
AjaxOptions |
timeout(int timeout)
Set the timeout (in milliseconds) for the request. |
String |
type()
Get the type of request to make. |
AjaxOptions |
type(String type)
Set the type of request to make. |
String |
url()
Get the request URL |
AjaxOptions |
url(String url)
Set the request URL |
String |
username()
Get the username to use if prompted with an HTTP access authentication request. |
AjaxOptions |
username(String username)
Set the username to use if prompted with an HTTP access authentication request |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AjaxOptions()
public AjaxOptions(String json) throws JSONException
json
- JSON options
JSONException
public AjaxOptions(String url, Map<String,Object> settings)
url
- the request URLsettings
- mapping of Ajax Options values. Can include all types - Strings, Functions, etc.public AjaxOptions(Map<String,Object> settings)
settings
- mapping of Ajax Options values. Can include all types - Strings, Functions, etc.public AjaxOptions(JSONObject json) throws JSONException
json
- the JSONObject
JSONException
- if the json
is malformedMethod Detail |
---|
public String accepts()
public AjaxOptions accepts(String accepts)
public boolean async()
true
if the task should be asynchronous (default). false
Otherwise.public AjaxOptions async(boolean async)
async
- true
if the task should be asynchronous (default). false
Otherwise.
public Function beforeSend()
public AjaxOptions beforeSend(Function beforeSend)
beforeSend
- the Function to call. This will receive a null
Object for the
droidQuery parameter unless context
is non-null. If that is
the case, beforeSend
will receive a droidQuery instance with that context.
The varargs parameter will include these options, so that they can be manipulated.
public Function complete()
public AjaxOptions complete(Function complete)
null
Object for the
droidQuery parameter unless context
is non-null. If that is
the case, complete
will receive a droidQuery instance with that context.
complete
- the Function to call
public String contentType()
public AjaxOptions contentType(String contentType)
contentType
-
public Context context()
public AjaxOptions context(Context context)
null
value will allow the callback Functions
(such as success
, error
, beforeSend
,
and complete
) to pass a non-null
droidQuery instance.
context
-
public Object data()
public AjaxOptions data(Object data)
processData
is set to false.
data
-
public boolean debug()
true
if the debug information will be printed. Otherwise false
public AjaxOptions debug(boolean debug)
debug
- true
if the debug information will be printed. Otherwise false
.
Default is false
.
public Function dataFilter()
public AjaxOptions dataFilter(Function dataFilter)
null
Object for the
droidQuery parameter unless context
is non-null. If that is
the case, dataFilter
will receive a droidQuery instance with that context.
dataFilter
-
public String dataType()
public AjaxOptions dataType(String dataType)
customXMLParser()
or SAXContentHandler()
have been set, no Document will be returned. Instead, it will
pass a descriptive String.
"html": Returns HTML as plain text.
"script": Evaluates the response as bourne (NOT bash) script and returns it as plain text.
"json": Evaluates the response as JSON and returns a JSONObject object. The JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. (See json.org for more information on proper JSON formatting.)
"text": A plain text string.
"image" : returns a bitmap object
dataType
-
public AjaxOptions SAXContentHandler(DefaultHandler SAXContentHandler)
success()
to NOT pass a XML Document variable as a parameter. Instead, it will pass a
descriptive String.
SAXContentHandler
-
public DefaultHandler SAXContentHandler()
public AjaxOptions customXMLParser(SAXParser customXMLParser)
success()
to NOT pass a XML Document variable as a
parameter.Instead, it will pass a descriptive String.
customXMLParser
-
public SAXParser customXMLParser()
public Function error()
public AjaxOptions error(Function error)
AjaxTask.AjaxError
error, the integer Status, and the String Error for varargs.
It will also receive a null
Object for the
droidQuery parameter unless context
is non-null. If that is
the case, error
will receive a droidQuery instance with that context.
public boolean global()
public AjaxOptions global(boolean global)
true
.
Set to false
to prevent the global handlers like ajaxStart
or
ajaxStop
from being triggered. This can be used to control various
Ajax Events.
public Headers headers()
public AjaxOptions headers(Headers headers)
headers
- the HTTP Headers for the requestpublic boolean cache()
true
if the most recent responses will be cached. Otherwise, false
.public AjaxOptions cache(boolean cache)
cache
- If set to true
, the most recent responses will be cached.
The length of time that a cached response is considered valid can be set using the
cacheTimeout
option. Default is false
.
public long cacheTimeout()
cache
option is set to true
.
public AjaxOptions cacheTimeout(long cacheTimeout)
cache
option is set to true
.
cacheTimeout
- the time, in milliseconds
public Map<String,String> cookies()
public void cookies(Map<String,String> cookies)
cookies
- public void cookies(JSONObject cookies) throws JSONException
cookies
-
JSONException
- if the JSON is malformedpublic boolean ifModified()
true
to enable the check. Otherwise false
.public AjaxOptions ifModified(boolean ifModified)
false
, ignoring the header.
{@code
- true} to enable the check. Otherwise false
.
public AjaxOptions password(String password)
password()
method in order to protect the password.
password
- the password to use for authentication
username()
,
getEncodedCredentials()
public String processData()
DataProcessor
that is meant to handle
raw data to send in the HTTP request, in order to prevent it from being converted to a String.
If null
is returned, then no such class has been configured.
DataProcessor
public AjaxOptions processData(String processDataClass)
DataProcessor
in order to handle
raw data to send in the HTTP request, in order to prevent it from being converted to a String.
This name should include the package name (for example: "com.example.android.MyDataProcessor").
processDataClass
- the name of a class that extends DataProcessor
public Map<Integer,Function> statusCode()
public AjaxOptions statusCode(Map<Integer,Function> statusCode)
null
Object for the
droidQuery parameter unless context
is non-null. If that is
the case, statusCode
will receive a droidQuery instance with that context.
statusCode
- the mapping
statusCode(Integer, Function)
public AjaxOptions statusCode(Integer code, Function function)
$.ajax(new AjaxOptions(this).statusCode(404, new Function(){ public void invoke(Object... params) { $.with(this).alert("Page not found"); } }));
code
- the code key for the given functionfunction
- the function to call when the response returns the given code
public Function success()
public AjaxOptions success(Function success)
null
Object for the
droidQuery parameter unless context
is non-null. If that is
the case, success
will receive a droidQuery instance with that context.
success
- the function
public int timeout()
public AjaxOptions timeout(int timeout)
timeout
- the timeout, in milliseconds
public String type()
customRequestClass
public AjaxOptions type(String type)
type
- the response type
customRequestClass
public int imageWidth()
public AjaxOptions imageWidth(int width)
width
- the scaled width, or -1 if the image width should not be scaled
public int imageHeight()
public AjaxOptions imageHeight(int height)
height
- the scaled height, or -1 if the image height should not be scaled
public String url()
public AjaxOptions url(String url)
url
- the request URL
public String username()
password(String)
,
getEncodedCredentials()
public AjaxOptions username(String username)
username
- the String username
public CustomHttpUriRequest customRequest() throws Exception
CustomHttpUriRequest
that is used when the
type
option is set to "CUSTOM".
Exception
- if the class name is null
or is not a valid class namepublic AjaxOptions customRequest(String customRequestClass)
CustomHttpUriRequest
that is used when the
type
option is set to "CUSTOM". Once instantiated, the Object is used to pass
a custom HTTP Request type to the HTTP Client.
customRequestClass
- the name of the class. Should include the full package name.
For example: "com.example.android.MyCustomHttpUriRequest".
public static void ajaxSetup(AjaxOptions options)
options
- options to be included in all ajax requestspublic byte[] getEncodedCredentials()
username()
,
password(String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |