Package com.contentstack.sdk
Class ContentType
- java.lang.Object
-
- com.contentstack.sdk.ContentType
-
public class ContentType extends Object
A Content Type is the structure or blueprint of a page or a section that your web or mobile property will display. It lets you define the overall schema of this blueprint by adding fields and setting its properties.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
contentTypeName
protected Stack
stackInstance
-
Constructor Summary
Constructors Modifier Constructor Description protected
ContentType(String contentTypeName)
-
Method Summary
Modifier and Type Method Description protected Entry
entry()
Entry
entry(String entryUid)
Represents aEntry
.void
fetch(org.json.JSONObject params, ContentTypesCallback callback)
This call returns information of a specific content type.Query
query()
Represents aQuery
.void
removeHeader(String key)
Remove header key.void
setHeader(String key, String value)
To set headers for Built.io Contentstack rest calls.protected void
setStackInstance(Stack stack)
-
-
-
Constructor Detail
-
ContentType
protected ContentType(String contentTypeName)
-
-
Method Detail
-
setStackInstance
protected void setStackInstance(Stack stack)
-
setHeader
public void setHeader(String key, String value)
To set headers for Built.io Contentstack rest calls.
Scope is limited to this object and followed classes.- Parameters:
key
- header name.value
- header value against given header name.
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); ContentType contentType = stack.contentType("form_name");
contentType.setHeader("custom_key", "custom_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); ContentType contentType = stack.contentType("form_name");
contentType.removeHeader("custom_header_key");
-
entry
public Entry entry(String entryUid)
- Parameters:
entryUid
- Set entry uid.- Returns:
Entry
instance.
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); ContentType contentType = stack.contentType("form_name");
// setUid will identify the object, and calling save will update it ENTRY entry = contentType.entry("bltf4fbbc94e8c851db");
-
entry
protected Entry entry()
-
query
public Query query()
- Returns:
Query
instance.
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); ContentType contentType = stack.contentType("form_name");
Query csQuery = contentType.query();
-
fetch
public void fetch(org.json.JSONObject params, ContentTypesCallback callback)
This call returns information of a specific content type. It returns the content type schema, but does not include its entries.- Parameters:
params
- query parameterscallback
-ContentTypesCallback
Example :
ContentType contentType = stack.contentType("content_type_uid"); JSONObject params = new JSONObject(); params.put("include_snippet_schema", true); params.put("limit", 3); contentType.fetch(params, new ContentTypesCallback() { public void onCompletion(ContentTypesModel contentTypesModel, Error error) { if (error==null){ }else { } } });
-
-