Package com.contentstack.sdk
Class Entry
- java.lang.Object
-
- com.contentstack.sdk.Entry
-
public class Entry extends Object
MIT License Copyright (c) 2012 - 2019 Contentstack Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
Field Summary
Fields Modifier and Type Field Description protected HashMap<String,Object>
_metadata
protected LinkedHashMap<String,Object>
formHeader
protected String
language
protected HashMap<String,Object>
owner
protected String
ownerEmailId
protected String
ownerUid
protected org.json.JSONObject
resultJson
protected String
title
protected String
uid
protected String
url
-
Method Summary
Modifier and Type Method Description Entry
addParam(String key, String value)
This method adds key and value to an Entry.Entry
configure(org.json.JSONObject jsonObject)
Entry
except(String[] fieldUid)
Specifies list of field uids that would be 'excluded' from the response.Entry
exceptWithReferenceUid(ArrayList<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 stackObject
get(String key)
Get object value for key.ArrayList<Entry>
getAllEntries(String refKey, String refContentType)
Get value for the given reference key.Asset
getAsset(String key)
Get an asset from the entryList<Asset>
getAssets(String key)
Get an assets from the entry.Boolean
getBoolean(String key)
Get boolean value for key.String
getContentType()
Get contentType name.Calendar
getCreateAt()
GetCalendar
value of creation time of entry.String
getCreatedBy()
Get uid who created this entry.Calendar
getDate(String key)
GetCalendar
value for keyCalendar
getDeleteAt()
GetCalendar
value of deletion time of entry.String
getDeletedBy()
Get uid who deleted this entry.double
getDouble(String key)
Get double value for keyfloat
getFloat(String key)
Get integer value for keyGroup
getGroup(String key)
Get a group from entry.List<Group>
getGroups(String key)
Get a list of group from entry.int
getInt(String key)
Get integer value for keyorg.json.JSONArray
getJSONArray(String key)
GetJSONArray
value for keyorg.json.JSONObject
getJSONObject(String key)
GetJSONObject
value for keyLanguage
getLanguage()
Deprecated.String
getLocale()
long
getLong(String key)
Get long value for keyNumber
getNumber(String key)
GetJSONObject
value for keyHashMap<String,Object>
getOwner()
short
getShort(String key)
Get short value for keyString
getString(String key)
Get string value for key.String[]
getTags()
Get tags.String
getTitle()
Get title stringString
getUid()
Get uid.Calendar
getUpdateAt()
GetCalendar
value of updating time of entry.String
getUpdatedBy()
Get uid who updated this entry.String
getURL()
Get url stringEntry
includeReference(String referenceField)
Add a constraint that requires a particular reference key details.Entry
includeReference(String[] referenceFields)
Add a constraint that requires a particular reference key details.Entry
includeReferenceContentTypeUID()
This method also includes the content type UIDs of the referenced entries returned in the responseEntry
only(String[] fieldUid)
Specifies an array of 'only' keys in BASE object that would be 'included' in the response.Entry
onlyWithReferenceUid(ArrayList<String> fieldUid, String referenceFieldUid)
Specifies an array of 'only' keys that would be 'included' in the response.void
removeHeader(String key)
Remove header key.protected void
setContentTypeInstance(ContentType contentTypeInstance)
void
setHeader(String key, String value)
Set headers.Entry
setLocale(String locale)
protected void
setTags(String[] tags)
protected void
setUid(String uid)
org.json.JSONObject
toJSON()
Get entry representation in json
-
-
-
Field Detail
-
formHeader
protected LinkedHashMap<String,Object> formHeader
-
uid
protected String uid
-
resultJson
protected org.json.JSONObject resultJson
-
ownerEmailId
protected String ownerEmailId
-
ownerUid
protected String ownerUid
-
title
protected String title
-
url
protected String url
-
language
protected String language
-
-
Constructor Detail
-
Entry
protected Entry(String contentTypeName)
-
-
Method Detail
-
setContentTypeInstance
protected void setContentTypeInstance(ContentType contentTypeInstance)
-
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 :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); Entry entry = stack.contentType("form_name").entry("entry_uid"); entry.setHeader("custom_header_key", "custom_header_value");
-
removeHeader
public void removeHeader(String key)
Remove header key.- Parameters:
key
- custom_header_key
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); 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();
-
getLanguage
@Deprecated public Language getLanguage()
Deprecated.GetLanguage
instance- Returns:
- Language @getLanguage
Example :
Language local = entry.getLanguage();
-
setLocale
public Entry setLocale(String locale)
- Parameters:
locale
-String
- Returns:
- Entry
Example :
Entry entry = entry.setLanguage();
-
getLocale
public String getLocale()
-
toJSON
public org.json.JSONObject toJSON()
Get entry representation in json- Returns:
- JSONObject @resultJson
Example :
JSONObject json = entry.toJSON();
-
get
public Object get(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(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(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(String key)
GetJSONArray
value for key- Parameters:
key
- field_uid as key.
Example :
JSONArray value = entry.getJSONArray("key");
- Returns:
- JSONArray @getJSONArray
-
getJSONObject
public org.json.JSONObject getJSONObject(String key)
GetJSONObject
value for key- Parameters:
key
- field_uid as key.
Example :
JSONObject value = entry.getJSONObject("key");
- Returns:
- JSONObject @getJSONObject
-
getNumber
public Number getNumber(String key)
GetJSONObject
value for key- Parameters:
key
- field_uid as key.
Example :
JSONObject value = entry.getJSONObject("key");
- Returns:
- Number @getNumber
-
getInt
public int getInt(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(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(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(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(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(String key)
GetCalendar
value for key- Parameters:
key
- field_uid as key.
Example :
Calendar value = entry.getDate("key");
- Returns:
- Calendar @getDate
-
getCreateAt
public Calendar getCreateAt()
GetCalendar
value 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()
GetCalendar
value 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()
GetCalendar
value 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 :
List<Asset> asset = entry.getAssets("key");
- Parameters:
key
- This is the String key- Returns:
- ArrayList This returns list of Assets.
-
getGroup
public Group getGroup(String key)
Get a group from entry.- Parameters:
key
- field_uid as key.
Example :
Group innerGroup = entry.getGroup("key");
- Returns:
- null
-
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 ArrayList<Entry> getAllEntries(String refKey, String refContentType)
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 :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token.
Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); 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 = builtqueryresult.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(String[] fieldUid)
Specifies list of field uids that would be 'excluded' from the response.- Parameters:
fieldUid
- field uid which get 'excluded' from the response.- Returns:
Entry
object, so you can chain this call.
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); Entry entry = stack.contentType("form_name").entry("entry_uid");
entry.except(new String[]{"name", "description"});
-
includeReference
public Entry includeReference(String referenceField)
Add a constraint that requires a particular reference key details.- Parameters:
referenceField
- key that to be constrained.- Returns:
Entry
object, so you can chain this call.
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); Entry entry = stack.contentType("form_name").entry("entry_uid");
entry.includeReference("referenceUid");
-
includeReference
public Entry includeReference(String[] referenceFields)
Add a constraint that requires a particular reference key details.- Parameters:
referenceFields
- array key that to be constrained.- Returns:
Entry
object, so you can chain this call.
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); Entry entry = stack.contentType("form_name").entry("entry_uid");
entry.includeReference(new String[]{"referenceUid_A", "referenceUid_B"});
-
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:
Entry
object, so you can chain this call.
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); Entry entry = stack.contentType("form_name").entry("entry_uid");
entry.only(new String[]{"name", "description"});
-
onlyWithReferenceUid
public Entry onlyWithReferenceUid(ArrayList<String> fieldUid, 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..- Returns:
Entry
object, so you can chain this call.
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); Entry entry = stack.contentType("form_name").entry("entry_uid");
ArrayList<String> array = new ArrayList<String>(); array.add("description"); array.add("name"); entry.onlyWithReferenceUid(array, "referenceUid");
-
exceptWithReferenceUid
public Entry exceptWithReferenceUid(ArrayList<String> fieldUid, 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.- Returns:
Entry
object, so you can chain this call.
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); Entry entry = stack.contentType("form_name").entry("entry_uid");
ArrayList<String> array = new ArrayList<String>(); array.add("description"); array.add("name");
entry.onlyWithReferenceUid(array, "referenceUid");
-
setTags
protected void setTags(String[] tags)
-
setUid
protected void setUid(String uid)
-
fetch
public void fetch(EntryResultCallBack callBack)
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 :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token.
Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); Entry entry = stack.contentType("form_name").entry("entry_uid");<br> entry.fetch(new BuiltResultCallBack() {<br> @Override public void onCompletion(ResponseType responseType, BuiltError builtError) { }<br> });<br>
-
addParam
public Entry addParam(String key, 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 :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token.
Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); final Entry entry = stack.contentType("user").entry("blt3b0aaebf6f1c3762"); <br> entry.addParam("include_dimensions", "true"); <br> entry.fetch(new BuiltResultCallBack() { <br>@ Override public void onCompletion(ResponseType responseType, BuiltError builtError) { }<br> });<br>
-
includeReferenceContentTypeUID
public Entry includeReferenceContentTypeUID()
This method also includes the content type UIDs of the referenced entries returned in the response- Returns:
Entry
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token.
Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); final Entry entry = stack.contentType("user").entry("blt3b0aaebf6f1c3762"); <br> entry.includeReferenceContentTypeUID; <br> entry.fetch(new BuiltResultCallBack() { <br>@ Override public void onCompletion(ResponseType responseType, BuiltError builtError) { }<br> });<br>
-
-