public class Query extends Object implements INotifyClass
| Modifier and Type | Field and Description |
|---|---|
protected ContentType |
contentTypeInstance |
protected LinkedHashMap<String,Object> |
formHeader |
protected org.json.JSONObject |
urlQueries |
| Modifier | Constructor and Description |
|---|---|
protected |
Query(String formName) |
| Modifier and Type | Method and Description |
|---|---|
Query |
addParam(String key,
String value)
This method adds key and value to an Entry.
|
Query |
addQuery(String key,
String value)
Add a custom query against specified key.
|
Query |
and(ArrayList<Query> queryObjects)
Combines all the queries together using AND operator
|
Query |
ascending(String key)
Sort the results in ascending order with the given key.
|
Query |
containedIn(String key,
Object[] values)
Add a constraint to the query that requires a particular key's entry to be contained
in the provided array.
|
Query |
count()
Retrieve only count of entries in result.
|
Query |
descending(String key)
Sort the results in descending order with the given key.
|
Query |
except(ArrayList<String> fieldUid)
Specifies list of field uids that would be 'excluded' from the response.
|
Query |
except(String[] fieldUids)
Specifies list of field uids that would be 'excluded' from the response.
|
Query |
exceptWithReferenceUid(ArrayList<String> fieldUid,
String referenceFieldUid)
Specifies an array of 'except' keys that would be 'excluded' in the response.
|
protected void |
execQuery(SingleQueryResultCallback callBack,
QueryResultsCallBack callback,
boolean isFromLocal) |
Query |
exists(String key)
Add a constraint that requires, a specified key exists in response.
|
Query |
find(QueryResultsCallBack callback)
Execute a Query and Caches its result (Optional)
|
Query |
findOne(SingleQueryResultCallback callBack)
Execute a Query and Caches its result (Optional)
|
String |
getContentType() |
void |
getResult(Object object,
String controller) |
void |
getResultObject(List<Object> objects,
org.json.JSONObject jsonObject,
boolean isSingleEntry) |
Query |
greaterThan(String key,
Object value)
Add a constraint to the query that requires a particular key entry to be greater than the provided value.
|
Query |
greaterThanOrEqualTo(String key,
Object value)
Add a constraint to the query that requires a particular key entry to be greater than or equal to the provided value.
|
Query |
includeContentType()
Include Content Type of all returned objects along with objects themselves.
|
Query |
includeCount()
Retrieve count and data of objects in result
|
Query |
includeEmbeddedItems()
includeEmbeddedItems instance of Query
Include Embedded Objects (Entries and Assets) along with entry/entries details.
Stack stack = Contentstack.stack( "ApiKey", "deliveryToken", "environment"); final Query query = stack.contentType("user").query(); query = query.includeEmbeddedObjects() |
Query |
includeFallback()
Retrieve the published content of the fallback locale if an entry is not localized in specified locale
|
Query |
includeOwner()
Include object owner's profile in the objects data.
|
Query |
includeReference(String key)
Add a constraint that requires a particular reference key details.
|
Query |
includeReferenceContentTypUid()
This method also includes the content type UIDs of the referenced entries returned in the response
|
Query |
language(Language language)
Deprecated.
|
Query |
lessThan(String key,
Object value)
Add a constraint to the query that requires a particular key entry to be less than the provided value.
|
Query |
lessThanOrEqualTo(String key,
Object value)
Add a constraint to the query that requires a particular key entry to be less than or equal to the provided value.
|
Query |
limit(int number)
A limit on the number of objects to return.
|
Query |
locale(String locale)
Set
Language instance. |
Query |
notContainedIn(String key,
Object[] values)
Add a constraint to the query that requires a particular key entry's
value not be contained in the provided array.
|
Query |
notEqualTo(String key,
Object value)
Add a constraint to the query that requires a particular key's
entry to be not equal to the provided value.
|
Query |
notExists(String key)
Add a constraint that requires, a specified key does not exists in response.
|
Query |
only(String[] fieldUid)
Specifies an array of 'only' keys in BASE object that would be 'included' in the response.
|
Query |
onlyWithReferenceUid(ArrayList<String> fieldUid,
String referenceFieldUid)
Specifies an array of 'only' keys that would be 'included' in the response.
|
Query |
or(ArrayList<Query> queryObjects)
Add a constraint to fetch all entries which satisfy any queries.
|
Query |
regex(String key,
String regex)
Add a regular expression constraint for finding string values that match the provided regular expression.
|
Query |
regex(String key,
String regex,
String modifiers)
Add a regular expression constraint for finding string values that match the provided regular expression.
|
void |
removeHeader(String key)
Remove header key @param key custom_header_key
|
Query |
removeQuery(String key)
Remove provided query key from custom query if exist.
|
Query |
search(String value)
This method provides only the entries matching the specified value.
|
protected void |
setContentTypeInstance(ContentType contentTypeInstance) |
void |
setHeader(String key,
String value)
To set headers for Built.io Contentstack rest calls.
|
protected void |
setQueryJson(QueryResultsCallBack callback) |
Query |
skip(int number)
The number of objects to skip before returning any.
|
Query |
tags(String[] tags)
Include tags with which to search entries.
|
Query |
where(String key,
Object value)
Add a constraint to fetch all entries that contains given value against specified key
|
Query |
whereIn(String key,
Query queryObject)
Get entries having values based on referenced fields.
|
Query |
whereNotIn(String key,
Query queryObject)
Get entries having values based on referenced fields.
|
protected ContentType contentTypeInstance
protected LinkedHashMap<String,Object> formHeader
protected org.json.JSONObject urlQueries
protected Query(String formName)
protected void setContentTypeInstance(ContentType contentTypeInstance)
public void setHeader(String key, String value)
key - header name.value - header value against given header name.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.setHeader("custom_key", "custom_value");
public void removeHeader(String key)
key - String
Stack stack = Contentstack..stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.removeHeader("custom_key");
public String getContentType()
public Query where(String key, Object value)
key - field uid.value - field value which get 'included' from the response.Query object, so you can chain this call.
Note : for group field provide key in a "key.groupFieldUid" format.
Example :
Stack stack = Contentstack..stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.where("uid", "bltf4fbsample851db");
public Query addQuery(String key, String value)
key - key.value - value.Query object, so you can chain this call.
Stack stack = Contentstack..stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.addQuery("query_param_key", "query_param_value");
public Query removeQuery(String key)
key - Query name to remove.
projectQuery.removeQuery("Query_Key");
public Query and(ArrayList<Query> queryObjects)
queryObjects - list of Query instances on which AND query executes.Query object, so you can chain this call.
Stack stack = Contentstack..stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
Query query = projectClass.query();
query.where('username','something');
Query subQuery = projectClass.query();
subQuery.where('email_address','something@email.com');
ArrayList<Query> array = new ArrayList<Query>();
array.add(query);
array.add(subQuery);
projectQuery.and(array);
public Query or(ArrayList<Query> queryObjects)
queryObjects - list of Query instances on which OR query executes.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
Query query = projectClass.query();
query.where('username','something');
Query subQuery = projectClass.query();
subQuery.where('email_address','something@email.com');
ArrayList<Query> array = new ArrayList<Query>();
array.add(query);
array.add(subQuery);
csQuery.or(array);
public Query lessThan(String key, Object value)
key - the key to be constrained.value - the value that provides an upper bound.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.lessThan("due_date", "2013-06-25T00:00:00+05:30");
public Query lessThanOrEqualTo(String key, Object value)
key - The key to be constrainedvalue - The value that must be equalled.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.lessThanOrEqualTo("due_date", "2013-06-25T00:00:00+05:30");
public Query greaterThan(String key, Object value)
key - The key to be constrained.value - The value that provides an lower bound.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.greaterThan("due_date", "2013-06-25T00:00:00+05:30");
public Query greaterThanOrEqualTo(String key, Object value)
key - The key to be constrained.value - The value that provides an lower bound.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.greaterThanOrEqualTo("due_date", "2013-06-25T00:00:00+05:30");
public Query notEqualTo(String key, Object value)
key - The key to be constrained.value - The object that must not be equaled.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.notEqualTo("due_date", "2013-06-25T00:00:00+05:30");
public Query containedIn(String key, Object[] values)
key - The key to be constrained.values - The possible values for the key's object.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.containedIn("severity", new Object[]{"Show Stopper", "Critical"});
public Query notContainedIn(String key, Object[] values)
key - The key to be constrained.values - The list of values the key object should not be.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.notContainedIn("severity", new Object[]{"Show Stopper", "Critical"});
public Query exists(String key)
key - The key to be constrained.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.exists("status");
public Query notExists(String key)
key - The key to be constrained.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.notExists("status");
public Query includeReference(String key)
key - key that to be constrained.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.includeReference("for_bug");
public Query tags(String[] tags)
tags - Comma separated array of tags with which to search entries.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.tags(new String[]{"tag1","tag2"});
public Query ascending(String key)
key - The key to order by.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.ascending("name");
public Query descending(String key)
key - The key to order by.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.descending("name");
public Query except(ArrayList<String> fieldUid)
fieldUid - field uid which get 'excluded' from the response.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
ArrayList<String> array = new ArrayList<String>();
array.add("name");
array.add("description");
csQuery.except(array);
public Query except(String[] fieldUids)
fieldUids - field uid which get 'excluded' from the response.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.except(new String[]{"name", "description"});
public Query only(String[] fieldUid)
fieldUid - Array of the 'only' reference keys to be included in response.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.only(new String[]{"name"});
public Query onlyWithReferenceUid(ArrayList<String> fieldUid, String referenceFieldUid)
fieldUid - Array of the 'only' reference keys to be included in response.referenceFieldUid - Key who has reference to some other class object.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
ArrayList<String> array = new ArrayList<String>();
array.add("description");
array.add("name");
csQuery.onlyWithReferenceUid(array, "for_bug");
public Query exceptWithReferenceUid(ArrayList<String> fieldUid, String referenceFieldUid)
fieldUid - Array of the 'except' reference keys to be excluded in response.referenceFieldUid - Key who has reference to some other class object.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
ArrayList<String> array = new ArrayList<String>();
array.add("description");
array.add("name");
csQuery.exceptWithReferenceUid(array, "for_bug");
public Query count()
Query object, so you can chain this call.
Note :-
Call QueryResult.getCount() method in the success to get count of objects.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.count();
public Query includeCount()
Query object, so you can chain this call.
Note :-
Call QueryResult.getCount() method in the success to get count of objects.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.includeCount();
public Query includeContentType()
Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.includeContentType();
public Query includeOwner()
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.includeOwner();
public Query skip(int number)
number - No of objects to skip from returned objectsQuery object, so you can chain this call.
Note:
The skip parameter can be used for pagination, "skip" specifies the number of objects to skip in the response.
Example :
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.skip(2);
public Query limit(int number)
number - No of objects to limit.Query object, so you can chain this call.
Note: The limit parameter can be used for pagination, "
limit" specifies the number of objects to limit to in the response.
Example :
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.limit(2);
public Query regex(String key, String regex)
key - The key to be constrained.regex - The regular expression pattern to match.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.regex("name", "^browser");
public Query regex(String key, String regex, String modifiers)
key - The key to be constrained.regex - The regular expression pattern to matchmodifiers - Any of the following supported Regular expression modifiers.
use i for case-insensitive matching.
use m for making dot match newlines.
use x for ignoring whitespace in regex
Query object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.regex("name", "^browser", "i");
@Deprecated public Query language(Language language)
Language instance.public Query search(String value)
value - value used to match or compareQuery object, so you can chain this call.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.search("header");
public Query find(QueryResultsCallBack callback)
callback - QueryResultsCallBack object to notify the application when the request has completed.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.find(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {
}
});
public Query findOne(SingleQueryResultCallback callBack)
callBack - QueryResultsCallBack object to notify the application when the request has completed.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.findOne(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, ENTRY entry, Error error) {
}
});
protected void setQueryJson(QueryResultsCallBack callback)
protected void execQuery(SingleQueryResultCallback callBack, QueryResultsCallBack callback, boolean isFromLocal)
public void getResult(Object object, String controller)
getResult in interface INotifyClasspublic void getResultObject(List<Object> objects, org.json.JSONObject jsonObject, boolean isSingleEntry)
getResultObject in interface INotifyClasspublic Query addParam(String key, String value)
key: - The key as string which needs to be added to the Queryvalue: - The value as string which needs to be added to the Query
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.addParam("key", "some_value");
csQuery.findOne(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, ENTRY entry, Error error) {
}
});
public Query includeReferenceContentTypUid()
Query
//'blt5d4sample2633b' is a dummy Stack API key
//'blt6d0240b5sample254090d' is dummy access token.
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.includeReferenceContentTypUid();
csQuery.findOne(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, ENTRY entry, Error error) {
}
});
public Query whereIn(String key, Query queryObject)
key - The key to be constrainedqueryObject - Query object, so you can chain this callQuery object, so you can chain this call
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.whereIn("due_date", csQuery);
public Query whereNotIn(String key, Query queryObject)
key - The key to be constrainedqueryObject - Query object, so you can chain this callQuery object, so you can chain this call
Stack stack = Contentstack.stack( "APIKey", "deliveryToken", "environment_name");
Query csQuery = stack.contentType("contentType_name").query();
csQuery.whereNotIn("due_date", csQuery);
public Query includeFallback()
Query object, so you can chain this call.
Stack stack = Contentstack.stack( "ApiKey", "deliveryToken", environment_name);
Query csQuery = stack.contentType("contentType_name").query();
csQuery.includeFallback();
public Query includeEmbeddedItems()
QueryCopyright © 2021 Contentstack.. All rights reserved.