Package com.contentstack.sdk
Class Entry
java.lang.Object
com.contentstack.sdk.Entry
The Get a single
Entry request
fetches a particular entry of a content type.
- Since:
- 01-11-2017
- Version:
- 1.0.0
- Author:
- Shailesh Mishra
-
Method Summary
Modifier and TypeMethodDescriptionThis method adds key and value to an Entry.configure
(org.json.JSONObject jsonObject) Specifies list of field ids that would be 'excluded' from the response.exceptWithReferenceUid
(List<String> fieldUid, String referenceFieldUid) Specifies an array of 'except' keys that would be 'excluded' in the response.void
fetch
(EntryResultCallBack callback) Fetches the latest version of the entries from Contentstack.com content stackGet object value for key.getAllEntries
(String refKey, String refContentType) Get value for the given reference key.Get an asset from the entryGet an assets from the entry.getBoolean
(String key) Get boolean value for key.Get contentType name.GetCalendar
value of creation time of entry.Get uid who created this entry.GetCalendar
value for keyGetCalendar
value of deletion time of entry.Get uid who deleted this entry.double
Get double value for keyfloat
Get integer value for keyGet a list of group from entry.int
Get integer value for keyorg.json.JSONArray
getJSONArray
(String key) GetJSONArray
value for keyorg.json.JSONObject
getJSONObject
(String key) GetJSONObject
value for keylong
Get long value for keyGetJSONObject
value for keyshort
Get short value for keyGet string value for key.String[]
getTags()
Get tags.getTitle()
Get title stringgetUid()
Get uid.GetCalendar
value of updating time of entry.Get uid who updated this entry.getURL()
Get url stringIncludes Branch in the entry responseInclude Content Type of all returned objects along with objects themselves.includeEmbeddedItems instance of Entry Include Embedded Objects (Entries and Assets) along with entry/entries details.Retrieve the published content of the fallback locale if an entry is not localized in specified localeIncludes Metadata the entry responseincludeReference
(String referenceField) Add a constraint that requires a particular reference key details.includeReference
(String[] referenceFields) Add a constraint that requires a particular reference key details.This method also includes the content type UIDs of the referenced entries returned in the responseSpecifies an array of 'only' keys in BASE object that would be 'included' in the response.onlyWithReferenceUid
(List<String> fieldUid, String referenceFieldUid) Specifies an array of 'only' keys that would be 'included' in the response.void
removeHeader
(String key) Remove header key.void
Set headers.org.json.JSONObject
toJSON()
Get entry representation in json
-
Method Details
-
configure
-
setHeader
Set headers.- Parameters:
key
- custom_header_keyvalue
- custom_header_value
Example :
-
removeHeader
Remove header key.- Parameters:
key
- custom_header_key
Example :
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); Entry entry = stack.contentType("form_name").entry("entry_uid"); entry.removeHeader("custom_header_key");
-
getTitle
Get title string- Returns:
- String @title
Example :
String title = entry.getTitle();
-
getURL
Get url string- Returns:
- String @url
Example :
String url = entry.getURL();
-
getTags
Get tags.- Returns:
- String @tags
Example :
String[] tags = entry.getURL();
-
getContentType
Get contentType name.- Returns:
- String @contentTypeName
Example :
String contentType = entry.getFileType();
-
getUid
Get uid.- Returns:
- String @uid
Example :
String uid = entry.getUid();
-
getLocale
-
setLocale
- Parameters:
locale
-String
- Returns:
- Entry
Example :
Entry entry = entry.setLanguage();
-
toJSON
public org.json.JSONObject toJSON()Get entry representation in json- Returns:
- resultJson
Example :
JSONObject json = entry.toJSON();
-
get
Get object value for key.- Parameters:
key
- field_uid as key.
Example :
Object obj = entry.get("key");
- Returns:
- Object @resultJson
-
getString
Get string value for key.- Parameters:
key
- field_uid as key.
Example :
String value = entry.getString("key");
- Returns:
- String @getString
-
getBoolean
Get boolean value for key.- Parameters:
key
- field_uid as key.
Example :
Boolean value = entry.getBoolean("key");
- Returns:
- boolean @getBoolean
-
getJSONArray
GetJSONArray
value for key- Parameters:
key
- field_uid as key.
Example :
JSONArray value = entry.getJSONArray("key");
- Returns:
- JSONArray @getJSONArray
-
getJSONObject
GetJSONObject
value for key- Parameters:
key
- field_uid as key.
Example :
JSONObject value = entry.getJSONObject("key");
- Returns:
- JSONObject @getJSONObject
-
getNumber
GetJSONObject
value for key- Parameters:
key
- field_uid as key.
Example :
JSONObject value = entry.getJSONObject("key");
- Returns:
- Number @getNumber
-
getInt
Get integer value for key- Parameters:
key
- field_uid as key.
Example :
int value = entry.getInt("key");
- Returns:
- int @getInt
-
getFloat
Get integer value for key- Parameters:
key
- field_uid as key.- Returns:
- float @getFloat
Example :
float value = entry.getFloat("key");
-
getDouble
Get double value for key- Parameters:
key
- field_uid as key.- Returns:
- double @getDouble
Example :
double value = entry.getDouble("key");
-
getLong
Get long value for key- Parameters:
key
- field_uid as key.
Example :
long value = entry.getLong("key");
- Returns:
- long @getLong
-
getShort
Get short value for key- Parameters:
key
- field_uid as key.
Example :
short value = entry.getShort("key");
- Returns:
- short @getShort
-
getDate
GetCalendar
value for key- Parameters:
key
- field_uid as key.
Example :
Calendar value = entry.getDate("key");
- Returns:
- Calendar @getDate
-
getCreateAt
GetCalendar
value of creation time of entry.- Returns:
- Calendar @getCreateAt
Example :
Calendar createdAt = entry.getCreateAt("key");
-
getCreatedBy
Get uid who created this entry.- Returns:
- String @getCreatedBy
Example :
String createdBy_uid = entry.getCreatedBy();
-
getUpdateAt
GetCalendar
value of updating time of entry.- Returns:
- Calendar @getUpdateAt
Example :
Calendar updatedAt = entry.getUpdateAt("key");
-
getUpdatedBy
Get uid who updated this entry.- Returns:
- String @getString
Example :
String updatedBy_uid = entry.getUpdatedBy();
-
getDeleteAt
GetCalendar
value of deletion time of entry.- Returns:
- Calendar
Example :
Calendar updatedAt = entry.getUpdateAt("key");
-
getDeletedBy
Get uid who deleted this entry.- Returns:
- String
Example :
String deletedBy_uid = entry.getDeletedBy();
-
getAsset
Get an asset from the entry- Parameters:
key
- field_uid as key.- Returns:
- Asset
Example :
Asset asset = entry.getAsset("key");
-
getAssets
Get an assets from the entry. This works with multiple true fields
Example :
{ @code List asset = entry.getAssets("key"); }
- Parameters:
key
- This is the String key- Returns:
- ArrayList This returns list of Assets.
-
getGroup
- Parameters:
key
- field_uid as key.
Example :
Group innerGroup = entry.getGroup("key"); return null
- Returns:
Group
-
getGroups
Get a list of group from entry.Note :- This will work when group is multiple true.
- Parameters:
key
- field_uid as key.- Returns:
- list of group from entry
Example :
Group innerGroup = entry.getGroups("key");
-
getAllEntries
Get value for the given reference key.- Parameters:
refKey
- key of a reference field.refContentType
- class uid.- Returns:
ArrayList
ofEntry
instances. Also specified contentType value will be set as class uid for allEntry
instance.
Example :
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); Query csQuery = stack.contentType("contentType_name").query(); csQuery.includeReference("for_bug"); csQuery.find(new QueryResultsCallBack() {<br> @Override public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {<br> if(error == null){ List<Entry> list = queryResult.getResultObjects(); for (int i = 0; i < list.queueSize(); i++) { Entry entry = list.get(i); Entry taskEntry = entry.getAllEntries("for_task", "task"); } } } });
-
except
Specifies list of field ids that would be 'excluded' from the response.- Parameters:
fieldUid
- field uid which get 'excluded' from the response.
-
includeReference
Add a constraint that requires a particular reference key details.- Parameters:
referenceField
- key that to be constrained.
-
includeReference
Add a constraint that requires a particular reference key details.- Parameters:
referenceFields
- array key that to be constrained.
-
only
Specifies an array of 'only' keys in BASE object that would be 'included' in the response.- Parameters:
fieldUid
- Array of the 'only' reference keys to be included in response.- Returns:
Entry
object, so you can chain this call.
Example :
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); Entry entry = stack.contentType("form_name").entry("entry_uid");
entry.only(new String[]{"name", "description"});
-
onlyWithReferenceUid
public Entry onlyWithReferenceUid(@NotNull List<String> fieldUid, @NotNull String referenceFieldUid) Specifies an array of 'only' keys that would be 'included' in the response.- Parameters:
fieldUid
- Array of the 'only' reference keys to be included in response.referenceFieldUid
- Key who has reference to some other class object.
-
exceptWithReferenceUid
public Entry exceptWithReferenceUid(@NotNull List<String> fieldUid, @NotNull String referenceFieldUid) Specifies an array of 'except' keys that would be 'excluded' in the response.- Parameters:
fieldUid
- Array of the 'except' reference keys to be excluded in response.referenceFieldUid
- Key who has reference to some other class object.
-
fetch
Fetches the latest version of the entries from Contentstack.com content stack- Parameters:
callback
-EntryResultCallBack
object to notify the application when the request has completed.
Example :
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); Entry entry = stack.contentType("form_name").entry("entry_uid");<br> entry.fetch(new EntryResultCallBack() {<br> @Override public void onCompletion(ResponseType responseType, Error error) { }<br> });<br>
-
addParam
This method adds key and value to an Entry.- Parameters:
key
- The key as string which needs to be added to an Entryvalue
- The value as string which needs to be added to an Entry- Returns:
Entry
Example :
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); final Entry entry = stack.contentType("user").entry("entryUid"); <br> entry.addParam("include_dimensions", "true"); <br> entry.fetch(new ResultCallBack() { <br>@ Override public void onCompletion(ResponseType responseType, Error error) { }<br> });<br>
-
includeReferenceContentTypeUID
This method also includes the content type UIDs of the referenced entries returned in the response -
includeContentType
Include Content Type of all returned objects along with objects themselves. -
includeFallback
Retrieve the published content of the fallback locale if an entry is not localized in specified locale- Returns:
Entry
object, so you can chain this call.
Example :
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); final Entry entry = stack.contentType("user").entry("entryUid"); entry.includeFallback();
-
includeEmbeddedItems
includeEmbeddedItems instance of Entry Include Embedded Objects (Entries and Assets) along with entry/entries details. -
includeBranch
Includes Branch in the entry response- Returns:
Entry
object, so you can chain this call.
Example :
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); final Entry entry = stack.contentType("user").entry("entryUid"); entry.includeBranch();
-
includeMetadata
Includes Metadata the entry response- Returns:
Entry
object, so you can chain this call.
Example :
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); final Entry entry = stack.contentType("user").entry("entryUid"); entry.includeMetadata();
-