public class

ContentQuery

extends Query
java.lang.Object
   ↳ com.neomades.content.Query
     ↳ com.neomades.content.ContentQuery
Known Direct Subclasses

Class Overview

ContentQuery is a webservice query.

ContentQuery can be sent to network using Screen.postQuery(Query) or postQuery(Query).

An instance of ContentQuery can be used only once.

DefaultRetryPolicy is the RetryPolicy set by default for a new ContentQuery.

Limitations

To download big data, do not use ContentQuery. Prefer using HttpRequest and getDataStream().

Summary

Public Constructors
ContentQuery(int method, String url)
Creates a new query with the given method (one of the values from Method), and URL.
Protected Constructors
ContentQuery()
Public Methods
void cancel()
Cancels this query.
CacheEntry getCacheEntry()
Returns the annotated cache entry, or null if there isn't one.
String getCacheKey()
Returns the cache key for this request.
String getContentResponseType()
Returns the ContentResponse type.
final int getMethod()
Returns the method for this request.
int getPriority()
Returns the Priority of this query; NORMAL by default.
RetryPolicy getRetryPolicy()
Returns the retry policy that should be used for this request.
final Object getTag()
final int getTimeoutMs()
Returns the socket timeout in milliseconds per retry attempt.
String getUrl()
Returns the URL of this request.
boolean hasHadResponseDelivered()
Returns true if this request has had a response delivered for it.
final boolean isCanceled()
void setCache(Cache cache)
Sets the Cache to use with this query (if the query shouldCache())
void setCacheEntry(CacheEntry entry)
Annotates this request with an entry retrieved for it from cache.
void setCacheType(String cacheType)
Sets the type of Cache to use from ContentManager.
void setContentManager(ContentManager manager)
void setContentResponseType(String responseType)
Sets the ContentResponse type when the query has had response delivered.
void setHeaders(Map<StringString> headers)
Sets a list of extra HTTP headers to go along with this query.
void setNetwork(Network network)
Sets the Network to use with this query.
void setNetworkType(String networkType)
Sets the type of Network to use from ContentManager.
void setParameter(Object parameter)
Sets a model Object to serialize through a Parser.
void setParameterParser(Parser parser)
Set the Parser instance to use for serializing parameter.
void setParameterParserType(String parameterParserType)
Set the type of Parser to use for serializing parameter.
void setPriority(int priority)
Returns this query priority.
void setResponseParser(Parser responseParserType)
Sets the parser for reading network data.
void setResponseParserType(String responseParserType)
Sets the response data Parser type.
void setRetryPolicy(RetryPolicy policy)
Sets the RetryPolicy to use with this query.
void setRetryPolicyType(String retryPolicy)
Sets the type of RetryPolicy to use from ContentManager.
final void setShouldCache(boolean shouldCache)
Set whether or not responses to this request should be cached.
void setTag(Object tag)
void setUrlParams(Map<StringString> urlParams)
Sets a list of URL parameters (key-value table).
final boolean shouldCache()
Returns true if responses to this request should be cached.
Protected Methods
final void onExecute()
Internal method.
[Expand]
Inherited Methods
From class com.neomades.content.Query
From class java.lang.Object

Public Constructors

public ContentQuery (int method, String url)

Creates a new query with the given method (one of the values from Method), and URL.

Parameters
method one of the values from Method
url an URL

Protected Constructors

protected ContentQuery ()

Public Methods

public void cancel ()

Cancels this query. If the query was waiting in the queue, it will be removed from the waiting queue.

To cancel a Query through the EventBus, a special query exists: CancelQuery.

public CacheEntry getCacheEntry ()

Returns the annotated cache entry, or null if there isn't one.

If the query has delivered a response from cache, this methods will return the associated cache entry.

Returns
  • the associated cache entry if there is one, otherwise null.
See Also

public String getCacheKey ()

Returns the cache key for this request. By default, this is the URL.

Returns
  • the cache key

public String getContentResponseType ()

Returns the ContentResponse type.

Returns

public final int getMethod ()

Returns the method for this request. Can be one of the values in Method.

Returns

public int getPriority ()

Returns the Priority of this query; NORMAL by default.

Returns
  • the query priority

public RetryPolicy getRetryPolicy ()

Returns the retry policy that should be used for this request.

Returns
  • the retry policy for this query
See Also

public final Object getTag ()

Returns
  • the tag object

public final int getTimeoutMs ()

Returns the socket timeout in milliseconds per retry attempt. (This value can be changed per retry attempt if a backoff is specified via backoffTimeout()). If there are no retry attempts remaining, this will cause delivery of a Error timeout error.

public String getUrl ()

Returns the URL of this request.

Returns
  • the base URL

public boolean hasHadResponseDelivered ()

Returns true if this request has had a response delivered for it.

Returns
  • true if this request has had a response delivered for it.

public final boolean isCanceled ()

Returns
  • if this query is cancelled.

public void setCache (Cache cache)

Sets the Cache to use with this query (if the query shouldCache())

Parameters
cache a cache instance

public void setCacheEntry (CacheEntry entry)

Annotates this request with an entry retrieved for it from cache. Used for cache coherency support.

This method is used by Cache.

Parameters
entry a cache entry

public void setCacheType (String cacheType)

Sets the type of Cache to use from ContentManager.

Parameters
cacheType type of Cache from ContentManager

public void setContentManager (ContentManager manager)

Parameters
manager a ContentManager instance.

public void setContentResponseType (String responseType)

Sets the ContentResponse type when the query has had response delivered.

Useful to differentiate many content responses.

Parameters
responseType type of response
See Also

public void setHeaders (Map<StringString> headers)

Sets a list of extra HTTP headers to go along with this query.

Parameters
headers HTTP headers

public void setNetwork (Network network)

Sets the Network to use with this query.

Parameters
network a Network instance

public void setNetworkType (String networkType)

Sets the type of Network to use from ContentManager.

Parameters
networkType type of Network from ContentManager

public void setParameter (Object parameter)

Sets a model Object to serialize through a Parser.

Parameters
parameter the object to serialize before executing query.

public void setParameterParser (Parser parser)

Set the Parser instance to use for serializing parameter.

Parameters
parser the parser to use

public void setParameterParserType (String parameterParserType)

Set the type of Parser to use for serializing parameter.

Different types of Parser are registered by ContentManager.

Parameters
parameterParserType type of Parser

public void setPriority (int priority)

Returns this query priority.

Queries are waiting inside a waiting queue. By default, queries have a NORMAL priority.

Parameters
priority one of Priority values.
See Also

public void setResponseParser (Parser responseParserType)

Sets the parser for reading network data.

Parameters
responseParserType the parser to use for reading network data
See Also

public void setResponseParserType (String responseParserType)

Sets the response data Parser type.

Different types of Parser are registered by ContentManager.

Parameters
responseParserType the parser to use for reading network data

public void setRetryPolicy (RetryPolicy policy)

Sets the RetryPolicy to use with this query.

Parameters
policy a retry policy instance

public void setRetryPolicyType (String retryPolicy)

Sets the type of RetryPolicy to use from ContentManager.

Parameters
retryPolicy type of RetryPolicy from ContentManager

public final void setShouldCache (boolean shouldCache)

Set whether or not responses to this request should be cached.

Parameters
shouldCache true if the query should be cached.

public void setTag (Object tag)

public void setUrlParams (Map<StringString> urlParams)

Sets a list of URL parameters (key-value table). Theses URL params will be appended to the URL like ¶mName=paramValue.

Parameters
urlParams URL parameters.

public final boolean shouldCache ()

Returns true if responses to this request should be cached.

Returns
  • if the query should be cached

Protected Methods

protected final void onExecute ()

Internal method.