Class Group


  • public class Group
    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.
    • Constructor Detail

      • Group

        protected Group​(Stack stack,
                        org.json.JSONObject jsonObject)
    • Method Detail

      • toJSON

        public org.json.JSONObject toJSON()
        Get group representation in json
        Returns:
        JSONObject

        Example :
         JSONObject json = group.toJSON();
         
      • get

        public Object get​(String key)
        Get object value for key.
        Parameters:
        key - field_uid as key.
        Returns:
        JSONObject

        Example :
         Object obj = group.get("key");
         
      • getString

        public String getString​(String key)
        Get string value for key.
        Parameters:
        key - field_uid as key.
        Returns:
        String

        Example :
         String value = group.getString("key");
         
      • getBoolean

        public Boolean getBoolean​(String key)
        Get boolean value for key.
        Parameters:
        key - field_uid as key.
        Returns:
        boolean true or false

        Example :
         Boolean value = group.getBoolean("key");
         
      • getJSONArray

        public org.json.JSONArray getJSONArray​(String key)
        Get JSONArray value for key
        Parameters:
        key - field_uid as key.
        Returns:
        JSONArray

        Example :
         JSONArray value = group.getJSONArray("key");
         
      • getJSONObject

        public org.json.JSONObject getJSONObject​(String key)
        Get JSONObject value for key
        Parameters:
        key - field_uid as key.
        Returns:
        JSONObject

        Example :
         JSONObject value = group.getJSONObject("key");
         
      • getNumber

        public Number getNumber​(String key)
        Get JSONObject value for key
        Parameters:
        key - field_uid as key.
        Returns:
        Number

        Example :
         JSONObject value = group.getJSONObject("key");
         
      • getInt

        public int getInt​(String key)
        Get integer value for key
        Parameters:
        key - field_uid as key.
        Returns:
        int

        Example :
         int value = group.getInt("key");
         
      • getFloat

        public float getFloat​(String key)
        Get integer value for key
        Parameters:
        key - field_uid as key.
        Returns:
        float

        Example :
         float value = group.getFloat("key");
         
      • getDouble

        public double getDouble​(String key)
        Get double value for key
        Parameters:
        key - field_uid as key.
        Returns:
        double

        Example :
         double value = group.getDouble("key");
         
      • getLong

        public long getLong​(String key)
        Get long value for key
        Parameters:
        key - field_uid as key.
        Returns:
        long

        Example :
         long value = group.getLong("key");
         
      • getShort

        public short getShort​(String key)
        Get short value for key
        Parameters:
        key - field_uid as key.
        Returns:
        short

        Example :
         short value = group.getShort("key");
         
      • getDate

        public Calendar getDate​(String key)
        Get Calendar value for key
        Parameters:
        key - field_uid as key.
        Returns:
        Date

        Example :
         Calendar value = group.getDate("key");
         
      • getAsset

        public Asset getAsset​(String key)
        Get an asset from the group
        Parameters:
        key - field_uid as key.
        Returns:
        Asset object

        Example :
         Asset asset = group.getAsset("key");
         
      • getAssets

        public List<Asset> getAssets​(String key)
        Get an assets from the group. This works with multiple true fields
        Parameters:
        key - field_uid as key.

        Example :
         List<Asset> asset = group.getAssets("key"); 
        Returns:
        ArrayList of Asset
      • getGroup

        public Group getGroup​(String key)
        Get a group from the group.
        Parameters:
        key - field_uid as key.

        Example :
         Group innerGroup = group.getGroup("key");
        Returns:
        Group object
      • getGroups

        public List<Group> getGroups​(String key)
        Get a list of group from the group.

        Note :- This will work when group is multiple true.

        Parameters:
        key - field_uid as key.

        Example :
         Group innerGroup = group.getGroups("key");
        Returns:
        List of Group
      • 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 of Entry instances. Also specified contentType value will be set as class uid for all Entry 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>
                  &#64;
             Override
          public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {<br>
             if(error == null){
             List&#60;Entry&#62; list = builtqueryresult.getResultObjects();
              for (int i = 0; i < list.queueSize(); i++) {
                   Entry   entry   = list.get(i);
                   Group   group   = entry.getGroup("fieldUid");
                   Entry taskEntry = entry.getAllEntries("for_task", "task");
                   }
                 }
               }
              });<br>