public class Query extends Object implements INotifyClass
| Modifier and Type | Field and Description |
|---|---|
protected ContentType |
contentTypeInstance |
protected String |
contentTypeUid |
protected LinkedHashMap<String,Object> |
headers |
protected org.json.JSONObject |
mainJSON |
protected org.json.JSONArray |
objectUidForExcept |
protected org.json.JSONArray |
objectUidForInclude |
protected org.json.JSONArray |
objectUidForOnly |
protected QueryResultsCallBack |
queryResultCallback |
protected org.json.JSONObject |
queryValue |
protected org.json.JSONObject |
queryValueJSON |
protected SingleQueryResultCallback |
singleQueryResultCallback |
protected org.json.JSONObject |
urlQueries |
| Modifier | Constructor and Description |
|---|---|
protected |
Query(String formName) |
| Modifier and Type | Method and Description |
|---|---|
Query |
addParam(String paramKey,
String paramValue)
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[] fieldIds)
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) |
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 |
includeBranch()
Includes Branch in the entry response
|
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() |
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 |
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 using locale code.
|
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() |
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> headers
protected org.json.JSONObject urlQueries
protected org.json.JSONObject mainJSON
protected String contentTypeUid
protected QueryResultsCallBack queryResultCallback
protected SingleQueryResultCallback singleQueryResultCallback
protected org.json.JSONObject queryValueJSON
protected org.json.JSONObject queryValue
protected org.json.JSONArray objectUidForInclude
protected org.json.JSONArray objectUidForExcept
protected org.json.JSONArray objectUidForOnly
protected Query(String formName)
protected void setContentTypeInstance(ContentType contentTypeInstance)
public void setHeader(@NotNull
String key,
@NotNull
String value)
key - header name.value - header value against given header name.
Stack stack = Contentstack.stack( "apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.setHeader("custom_key", "custom_value");
public void removeHeader(@NotNull
String key)
key - String
Stack stack = Contentstack..stack( "apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.removeHeader("custom_key");
public String getContentType()
public Query where(@NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.where("uid", "entry_uid");
public Query addQuery(@NotNull String key, String value)
key - key.value - value.Query object, so you can chain this call.
Stack stack = Contentstack..stack( "apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.addQuery("query_param_key", "query_param_value");
public Query removeQuery(@NotNull String key)
key - Query name to remove.
projectQuery.removeQuery("Query_Key");
public Query and(@NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").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");
Query csQuery = stack.contentType("contentTypeUid").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(@NotNull String key, @NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.lessThan("due_date", "2013-06-25T00:00:00+05:30");
public Query lessThanOrEqualTo(@NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.lessThanOrEqualTo("due_date", "2013-06-25T00:00:00+05:30");
public Query greaterThan(@NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.greaterThanOrEqualTo("due_date", "2013-06-25T00:00:00+05:30");
public Query notEqualTo(@NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.notEqualTo("due_date", "2013-06-25T00:00:00+05:30");
public Query containedIn(@NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.containedIn("severity", new Object[] { "Show Stopper", "Critical" });
public Query notContainedIn(@NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.notContainedIn("severity", new Object[] { "Show Stopper", "Critical" });
public Query exists(@NotNull String key)
key - The key to be constrained.Query object, so you can chain this call.
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.exists("status");
public Query notExists(@NotNull String key)
key - The key to be constrained.Query object, so you can chain this call.
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.includeReference("for_bug");
public Query tags(@NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.tags(new String[] { "tag1", "tag2" });
public Query ascending(@NotNull String key)
key - The key to order by.Query object, so you can chain this call.
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.ascending("name");
public Query descending(@NotNull String key)
key - The key to order by.Query object, so you can chain this call.
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.descending("name");
public Query except(@NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
ArrayList<String> array = new ArrayList<String>();
array.add("name");
array.add("description");
csQuery.except(array);
public Query except(@NotNull String[] fieldIds)
fieldIds - field uid which get 'excluded' from the response.Query object, so you can chain this call.
Stack stack = Contentstack.stack( "apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.except(new String[]{"name", "description"});
public Query only(@NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.only(new String[]{"name"});
public Query onlyWithReferenceUid(@NotNull ArrayList<String> fieldUid, @NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
ArrayList<String> array = new ArrayList<String>();
array.add("description");
array.add("name");
csQuery.onlyWithReferenceUid(array, "for_bug");
public Query exceptWithReferenceUid(@NotNull ArrayList<String> fieldUid, @NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").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");
Query csQuery = stack.contentType("contentTypeUid").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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.includeCount();
public Query includeContentType()
Query object, so you can chain this call.
Stack stack = Contentstack.stack( "apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.includeContentType();
public Query includeOwner()
Stack stack = Contentstack.stack( "apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").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");
Query csQuery = stack.contentType("contentTypeUid").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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.limit(2);
public Query regex(@NotNull String key, @NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.regex("name", "^browser");
public Query regex(@NotNull String key, @NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.regex("name", "^browser", "i");
public Query search(@NotNull String value)
value - value used to match or compareQuery object, so you can chain this call.
Stack stack = Contentstack.stack( "apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").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");
Query csQuery = stack.contentType("contentTypeUid").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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.findOne(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, ENTRY entry, Error error) {
}
});
protected void setQueryJson()
protected void execQuery(SingleQueryResultCallback callBack, QueryResultsCallBack callback)
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(@NotNull String paramKey, @NotNull String paramValue)
paramKey: - The key as string which needs to be added to the QueryparamValue: - The value as string which needs to be added to the Query
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.addParam("key", "some_value");
csQuery.findOne(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, ENTRY entry, Error error) {
}
});
public Query includeReferenceContentTypUid()
Query
Stack stack = Contentstack.stack( "apiKey", "deliveryToken", "environment");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.includeReferenceContentTypUid();
csQuery.findOne(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, ENTRY entry, Error error) {
}
});
public Query whereIn(@NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.whereIn("due_date", csQuery);
public Query whereNotIn(@NotNull 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");
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.whereNotIn("due_date", csQuery);
public Query includeFallback()
Query object, so you can chain this call.
Stack stack = Contentstack.stack("apiKey", "deliveryToken", environment);
Query csQuery = stack.contentType("contentTypeUid").query();
csQuery.includeFallback();
public Query includeEmbeddedItems()
Query object, so you can chain this call. Copyright © 2021 Contentstack.. All rights reserved.