Package com.contentstack.sdk
Class Entry
- java.lang.Object
-
- com.contentstack.sdk.Entry
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EntryaddParam(@NotNull String key, @NotNull String value)This method adds key and value to an Entry.Entryconfigure(org.json.JSONObject jsonObject)Entryexcept(@NotNull String[] fieldUid)Specifies list of field ids that would be 'excluded' from the response.EntryexceptWithReferenceUid(@NotNull List<String> fieldUid, @NotNull String referenceFieldUid)Specifies an array of 'except' keys that would be 'excluded' in the response.voidfetch(EntryResultCallBack callback)Fetches the latest version of the entries from Contentstack.com content stackObjectget(@NotNull String key)Get object value for key.List<Entry>getAllEntries(String refKey, String refContentType)Get value for the given reference key.AssetgetAsset(String key)Get an asset from the entryList<Asset>getAssets(String key)Get an assets from the entry.BooleangetBoolean(@NotNull String key)Get boolean value for key.StringgetContentType()Get contentType name.CalendargetCreateAt()GetCalendarvalue of creation time of entry.StringgetCreatedBy()Get uid who created this entry.CalendargetDate(@NotNull String key)GetCalendarvalue for keyCalendargetDeleteAt()GetCalendarvalue of deletion time of entry.StringgetDeletedBy()Get uid who deleted this entry.doublegetDouble(@NotNull String key)Get double value for keyfloatgetFloat(@NotNull String key)Get integer value for keyGroupgetGroup(String key)List<Group>getGroups(String key)Get a list of group from entry.LinkedHashMap<String,Object>getHeaders()intgetInt(@NotNull String key)Get integer value for keyorg.json.JSONArraygetJSONArray(@NotNull String key)GetJSONArrayvalue for keyorg.json.JSONObjectgetJSONObject(@NotNull String key)GetJSONObjectvalue for keyStringgetLocale()longgetLong(@NotNull String key)Get long value for keyNumbergetNumber(@NotNull String key)GetJSONObjectvalue for keyshortgetShort(@NotNull String key)Get short value for keyStringgetString(@NotNull String key)Get string value for key.String[]getTags()Get tags.StringgetTitle()Get title stringStringgetUid()Get uid.CalendargetUpdateAt()GetCalendarvalue of updating time of entry.StringgetUpdatedBy()Get uid who updated this entry.StringgetURL()Get url stringEntryincludeBranch()Includes Branch in the entry responseEntryincludeContentType()Include Content Type of all returned objects along with objects themselves.EntryincludeEmbeddedItems()includeEmbeddedItems instance of Entry Include Embedded Objects (Entries and Assets) along with entry/entries details.EntryincludeFallback()Retrieve the published content of the fallback locale if an entry is not localized in specified localeEntryincludeMetadata()Includes Metadata the entry responseEntryincludeReference(@NotNull String referenceField)Add a constraint that requires a particular reference key details.EntryincludeReference(@NotNull String[] referenceFields)Add a constraint that requires a particular reference key details.EntryincludeReferenceContentTypeUID()This method also includes the content type UIDs of the referenced entries returned in the responseEntryonly(String[] fieldUid)Specifies an array of 'only' keys in BASE object that would be 'included' in the response.EntryonlyWithReferenceUid(@NotNull List<String> fieldUid, @NotNull String referenceFieldUid)Specifies an array of 'only' keys that would be 'included' in the response.voidremoveHeader(String key)Remove header key.voidsetHeader(String key, String value)Set headers.EntrysetLocale(@NotNull String locale)org.json.JSONObjecttoJSON()Get entry representation in jsonEntryvariants(@NotNull String variants)The variant header will be added to clientEntryvariants(@NotNull String[] variants)
-
-
-
Method Detail
-
configure
public Entry configure(org.json.JSONObject jsonObject)
-
setHeader
public void setHeader(String key, String value)
Set headers.- Parameters:
key- custom_header_keyvalue- custom_header_value
Example :
-
removeHeader
public void removeHeader(String key)
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
public String getTitle()
Get title string- Returns:
- String @title
Example :
String title = entry.getTitle();
-
getURL
public String getURL()
Get url string- Returns:
- String @url
Example :
String url = entry.getURL();
-
getTags
public String[] getTags()
Get tags.- Returns:
- String @tags
Example :
String[] tags = entry.getURL();
-
getContentType
public String getContentType()
Get contentType name.- Returns:
- String @contentTypeName
Example :
String contentType = entry.getFileType();
-
getUid
public String getUid()
Get uid.- Returns:
- String @uid
Example :
String uid = entry.getUid();
-
getLocale
public String getLocale()
-
setLocale
public Entry setLocale(@NotNull @NotNull String locale)
- 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
public Object get(@NotNull @NotNull String key)
Get object value for key.- Parameters:
key- field_uid as key.
Example :
Object obj = entry.get("key");- Returns:
- Object @resultJson
-
getString
public String getString(@NotNull @NotNull String key)
Get string value for key.- Parameters:
key- field_uid as key.
Example :
String value = entry.getString("key");- Returns:
- String @getString
-
getBoolean
public Boolean getBoolean(@NotNull @NotNull String key)
Get boolean value for key.- Parameters:
key- field_uid as key.
Example :
Boolean value = entry.getBoolean("key");- Returns:
- boolean @getBoolean
-
getJSONArray
public org.json.JSONArray getJSONArray(@NotNull @NotNull String key)GetJSONArrayvalue for key- Parameters:
key- field_uid as key.
Example :
JSONArray value = entry.getJSONArray("key");- Returns:
- JSONArray @getJSONArray
-
getJSONObject
public org.json.JSONObject getJSONObject(@NotNull @NotNull String key)GetJSONObjectvalue for key- Parameters:
key- field_uid as key.
Example :
JSONObject value = entry.getJSONObject("key");- Returns:
- JSONObject @getJSONObject
-
getNumber
public Number getNumber(@NotNull @NotNull String key)
GetJSONObjectvalue for key- Parameters:
key- field_uid as key.
Example :
JSONObject value = entry.getJSONObject("key");- Returns:
- Number @getNumber
-
getInt
public int getInt(@NotNull @NotNull String key)Get integer value for key- Parameters:
key- field_uid as key.
Example :
int value = entry.getInt("key");- Returns:
- int @getInt
-
getFloat
public float getFloat(@NotNull @NotNull String key)Get integer value for key- Parameters:
key- field_uid as key.- Returns:
- float @getFloat
Example :
float value = entry.getFloat("key");
-
getDouble
public double getDouble(@NotNull @NotNull String key)Get double value for key- Parameters:
key- field_uid as key.- Returns:
- double @getDouble
Example :
double value = entry.getDouble("key");
-
getLong
public long getLong(@NotNull @NotNull String key)Get long value for key- Parameters:
key- field_uid as key.
Example :
long value = entry.getLong("key");- Returns:
- long @getLong
-
getShort
public short getShort(@NotNull @NotNull String key)Get short value for key- Parameters:
key- field_uid as key.
Example :
short value = entry.getShort("key");- Returns:
- short @getShort
-
getDate
public Calendar getDate(@NotNull @NotNull String key)
GetCalendarvalue for key- Parameters:
key- field_uid as key.
Example :
Calendar value = entry.getDate("key");- Returns:
- Calendar @getDate
-
getCreateAt
public Calendar getCreateAt()
GetCalendarvalue of creation time of entry.- Returns:
- Calendar @getCreateAt
Example :
Calendar createdAt = entry.getCreateAt("key");
-
getCreatedBy
public String getCreatedBy()
Get uid who created this entry.- Returns:
- String @getCreatedBy
Example :
String createdBy_uid = entry.getCreatedBy();
-
getUpdateAt
public Calendar getUpdateAt()
GetCalendarvalue of updating time of entry.- Returns:
- Calendar @getUpdateAt
Example :
Calendar updatedAt = entry.getUpdateAt("key");
-
getUpdatedBy
public String getUpdatedBy()
Get uid who updated this entry.- Returns:
- String @getString
Example :
String updatedBy_uid = entry.getUpdatedBy();
-
getDeleteAt
public Calendar getDeleteAt()
GetCalendarvalue of deletion time of entry.- Returns:
- Calendar
Example :
Calendar updatedAt = entry.getUpdateAt("key");
-
getDeletedBy
public String getDeletedBy()
Get uid who deleted this entry.- Returns:
- String
Example :
String deletedBy_uid = entry.getDeletedBy();
-
getAsset
public Asset getAsset(String key)
Get an asset from the entry- Parameters:
key- field_uid as key.- Returns:
- Asset
Example :
Asset asset = entry.getAsset("key");
-
getAssets
public List<Asset> getAssets(String key)
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
public Group getGroup(String key)
- Parameters:
key- field_uid as key.
Example :
Group innerGroup = entry.getGroup("key"); return null- Returns:
Group
-
getGroups
public List<Group> getGroups(String key)
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
public List<Entry> getAllEntries(String refKey, String refContentType)
Get value for the given reference key.- Parameters:
refKey- key of a reference field.refContentType- class uid.- Returns:
ArrayListofEntryinstances. Also specified contentType value will be set as class uid for allEntryinstance.
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
public Entry except(@NotNull @NotNull String[] fieldUid)
Specifies list of field ids that would be 'excluded' from the response.- Parameters:
fieldUid- field uid which get 'excluded' from the response.
-
includeReference
public Entry includeReference(@NotNull @NotNull String referenceField)
Add a constraint that requires a particular reference key details.- Parameters:
referenceField- key that to be constrained.
-
includeReference
public Entry includeReference(@NotNull @NotNull String[] referenceFields)
Add a constraint that requires a particular reference key details.- Parameters:
referenceFields- array key that to be constrained.
-
only
public Entry only(String[] fieldUid)
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:
Entryobject, 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 @NotNull List<String> fieldUid, @NotNull @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 @NotNull List<String> fieldUid, @NotNull @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
public void fetch(EntryResultCallBack callback)
Fetches the latest version of the entries from Contentstack.com content stack- Parameters:
callback-EntryResultCallBackobject 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
public Entry addParam(@NotNull @NotNull String key, @NotNull @NotNull String value)
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
public Entry includeReferenceContentTypeUID()
This method also includes the content type UIDs of the referenced entries returned in the response
-
includeContentType
public Entry includeContentType()
Include Content Type of all returned objects along with objects themselves.
-
includeFallback
public Entry includeFallback()
Retrieve the published content of the fallback locale if an entry is not localized in specified locale- Returns:
Entryobject, 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
public Entry includeEmbeddedItems()
includeEmbeddedItems instance of Entry Include Embedded Objects (Entries and Assets) along with entry/entries details.
-
includeBranch
public Entry includeBranch()
Includes Branch in the entry response- Returns:
Entryobject, 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
public Entry includeMetadata()
Includes Metadata the entry response- Returns:
Entryobject, so you can chain this call.
Example :
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); final Entry entry = stack.contentType("user").entry("entryUid"); entry.includeMetadata();
-
variants
public Entry variants(@NotNull @NotNull String variants)
The variant header will be added to client- Returns:
- {Entry} import contentstack from '@contentstack/delivery-sdk' Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); Entry entry = stack.contentType("user").entry("entry_uid").variant("variant_uid").fetch();
-
getHeaders
public LinkedHashMap<String,Object> getHeaders()
-
-