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 Details

  • Constructor Details

  • Method Details

    • 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("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( "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false);
        ContentType contentType = stack.contentType("form_name");
      contentType.removeHeader("custom_header_key");
    • entry

      public Entry entry​(String entryUid)
      Represents a Entry. Create Entry instance
      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( "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()
      Represents a Query. Create Query instance.
      Returns:
      Query instance.

      Example :
        //'blt5d4sample2633b' is a dummy Stack API key
        //'blt6d0240b5sample254090d' is dummy access token.
        Stack stack = Contentstack.stack("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 parameters
      callback - 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 {
      
       }
       }
       });