Class KiiBaseObject

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.json.JSONObject mJSON  
      protected org.json.JSONObject mJSONPatch  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Boolean getBoolean​(java.lang.String key)
      Get boolean in the Entity associated with the key.
      java.lang.Boolean getBoolean​(java.lang.String key, java.lang.Boolean default_value)
      Get boolean in the KiiBaseObject associated with the key.
      byte[] getByteArray​(java.lang.String key)
      Get byte array associated with the key if exists, otherwise returns null.
      double getDouble​(java.lang.String key)
      Get double in the Entity associated with the key.
      double getDouble​(java.lang.String key, double default_value)
      Get double in the KiiBaseObject associated with the key.
      int getInt​(java.lang.String key)
      Get int in the KiiBaseObject associated with the key.
      int getInt​(java.lang.String key, int default_value)
      Get int in the KiiBaseObject associated with the key.
      org.json.JSONArray getJsonArray​(java.lang.String key)
      Get JSONArray in the Entity associated with the key.
      org.json.JSONArray getJSONArray​(java.lang.String key, org.json.JSONArray default_value)
      Get JSONArray in the KiiBaseObject associated with the key.
      org.json.JSONObject getJSONObject​(java.lang.String key)
      Get JSONObject in the KiiBaseObject associated with the key.
      protected org.json.JSONObject getJSONOfArbitraryFields()
      Return json that contains key/value of keyset.
      long getLong​(java.lang.String key)
      Get long in the KiiBaseObject associated with the key.
      long getLong​(java.lang.String key, long default_value)
      Get long in the KiiBaseObject associated with the key.
      java.lang.Object getObject​(java.lang.String key)
      Obtain value as Object.
      java.lang.Object getObject​(java.lang.String key, java.lang.Object fallback)
      Get Object in the KiiBaseObject associated with the key.
      java.lang.String getString​(java.lang.String key)
      Get String in the KiiBaseObject associated with the key.
      java.lang.String getString​(java.lang.String key, java.lang.String value)
      Get String in the KiiBaseObject associated with the key.
      android.net.Uri getUri​(java.lang.String key)
      Get Uri in the Entity associated with the key.
      boolean has​(java.lang.String key)
      Determine if the KiiBaseObject contains a specific key.
      java.util.HashSet<java.lang.String> keySet()
      Get the key set of the object.
      void remove​(java.lang.String key)
      Remove a pair of key/value from KiiBaseObject
      protected void removeReserveProperty​(java.lang.String key)  
      void set​(java.lang.String key, byte[] value)
      Create/Update the key/value byte array in the KiiBaseObject
      void set​(java.lang.String key, double value)
      Create/Update association of the specified key with the specified double value in the KiiObject.
      void set​(java.lang.String key, int value)
      Create/Update the key/value int in the KiiBaseObject
      void set​(java.lang.String key, long value)
      Create/Update the key/value long in the KiiBaseObject
      void set​(java.lang.String key, android.net.Uri value)
      Create/Update the key/value Uri in the KiiBaseObject
      void set​(java.lang.String key, java.lang.Boolean value)
      Create/Update the key/value boolean in the KiiBaseObject
      void set​(java.lang.String key, java.lang.String value)
      Create/Update the key/value string in the KiiBaseObject
      void set​(java.lang.String key, org.json.JSONArray value)
      Create/Update association of the specified key with the specified JSONArray value in the KiiObject.
      void set​(java.lang.String key, org.json.JSONObject value)
      Create/Update the key/value JSONObject in the KiiBaseObject
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • mJSON

        protected org.json.JSONObject mJSON
      • mJSONPatch

        protected org.json.JSONObject mJSONPatch
    • Method Detail

      • keySet

        @NonNull
        public java.util.HashSet<java.lang.String> keySet()
        Get the key set of the object. The key set from local cache will be returned.
        To get the latest key set from cloud, calling #refresh() is necessary prior calling this method. On refresh, it replaces the local cache with the cloud one.
        The returned key set does not include reserved keys such as email, username, etc.
        Only includes arbitrary field keys set by application.
      • getJSONOfArbitraryFields

        protected org.json.JSONObject getJSONOfArbitraryFields()
        Return json that contains key/value of keyset.
        Throws:
        org.json.JSONException
      • set

        public void set​(@NonNull
                        java.lang.String key,
                        int value)
        Create/Update the key/value int in the KiiBaseObject
        Parameters:
        key - is Key string
        value - is Value int
        Throws:
        java.lang.IllegalArgumentException - when key is empty, null or any reserve key.
        IllegalKiiBaseObjectFormatException - if value contains illegal syntax
      • set

        public void set​(@NonNull
                        java.lang.String key,
                        long value)
        Create/Update the key/value long in the KiiBaseObject
        Parameters:
        key - is Key string
        value - is Value long
        Throws:
        java.lang.IllegalArgumentException - when key is empty, null or any reserve key.
        IllegalKiiBaseObjectFormatException - if value contains illegal syntax
      • has

        public boolean has​(@NonNull
                           java.lang.String key)
        Determine if the KiiBaseObject contains a specific key.
        Parameters:
        key - is Key string
        Returns:
        true if the key in exist in the KiiBaseObject
      • remove

        public void remove​(@NonNull
                           java.lang.String key)
        Remove a pair of key/value from KiiBaseObject
        Parameters:
        key - to remove.
        Throws:
        java.lang.IllegalArgumentException - when key is empty, null or any reserve key.
      • getByteArray

        @Nullable
        public byte[] getByteArray​(@NonNull
                                   java.lang.String key)
        Get byte array associated with the key if exists, otherwise returns null.
        Parameters:
        key - Key string.
        Returns:
        value in byte array or null if the array is empty.
        Throws:
        IllegalKiiBaseObjectFormatException - Value retrieve error.
      • set

        public void set​(@NonNull
                        java.lang.String key,
                        @NonNull
                        byte[] value)
        Create/Update the key/value byte array in the KiiBaseObject
        Parameters:
        key - is Key string
        value - in byte array
        Throws:
        IllegalKiiBaseObjectFormatException - if contains illegal syntax
        java.lang.IllegalArgumentException - when value is null, key is empty,null or or any reserve key.
      • getString

        @NonNull
        public java.lang.String getString​(@NonNull
                                          java.lang.String key)
        Get String in the KiiBaseObject associated with the key.
        Parameters:
        key - is Key string
        Returns:
        value in String
        Throws:
        IllegalKiiBaseObjectFormatException - if not exist or contains illegal syntax
      • getObject

        @NonNull
        public java.lang.Object getObject​(@NonNull
                                          java.lang.String key)
        Obtain value as Object.
        Parameters:
        key - which corresponds to value to obtain.
        Returns:
        value in Object.
        Throws:
        IllegalKiiBaseObjectFormatException - when the specified key is not exist in the object.
      • getObject

        @Nullable
        public java.lang.Object getObject​(@NonNull
                                          java.lang.String key,
                                          @Nullable
                                          java.lang.Object fallback)
        Get Object in the KiiBaseObject associated with the key. Returns fallback when specified key is not exist.
        Parameters:
        key - which corresponds to value to obtain.
        fallback - returned when specified key is not exist.
        Returns:
        value in Object.
      • getString

        @Nullable
        public java.lang.String getString​(@NonNull
                                          java.lang.String key,
                                          @Nullable
                                          java.lang.String value)
        Get String in the KiiBaseObject associated with the key. If not exist or error, it will return default_value.
        Parameters:
        key - is Key string
        value - is Default Value string
        Returns:
        value in String
      • set

        public void set​(@NonNull
                        java.lang.String key,
                        @NonNull
                        java.lang.String value)
        Create/Update the key/value string in the KiiBaseObject
        Parameters:
        key - is Key string
        value - is Value string
        Throws:
        java.lang.IllegalArgumentException - when key is empty, null, any reserve key or value is null
        IllegalKiiBaseObjectFormatException - if value contains illegal syntax
      • getBoolean

        @NonNull
        public java.lang.Boolean getBoolean​(@NonNull
                                            java.lang.String key)
        Get boolean in the Entity associated with the key.
        Parameters:
        key - is Key string
        Returns:
        value in boolean
        Throws:
        IllegalKiiBaseObjectFormatException - if not exist or contains illegal syntax
      • getBoolean

        @NonNull
        public java.lang.Boolean getBoolean​(@NonNull
                                            java.lang.String key,
                                            @NonNull
                                            java.lang.Boolean default_value)
        Get boolean in the KiiBaseObject associated with the key. If not exit or error, it will return the default value
        Parameters:
        key - is Key string
        default_value - is default value in boolean
        Returns:
        value in boolean
      • getDouble

        public double getDouble​(@NonNull
                                java.lang.String key)
        Get double in the Entity associated with the key.
        Parameters:
        key - is Key string
        Returns:
        value in double
        Throws:
        IllegalKiiBaseObjectFormatException - if not exist or contains illegal syntax
      • getDouble

        public double getDouble​(@NonNull
                                java.lang.String key,
                                double default_value)
        Get double in the KiiBaseObject associated with the key. If not exit or error, it will return the default value
        Parameters:
        key - is Key string
        default_value - is default value in double
        Returns:
        value in double
      • getJsonArray

        @NonNull
        public org.json.JSONArray getJsonArray​(@NonNull
                                               java.lang.String key)
        Get JSONArray in the Entity associated with the key.
        Parameters:
        key - is Key string
        Returns:
        value in JSONArray
        Throws:
        IllegalKiiBaseObjectFormatException - if not exist or contains illegal syntax
      • getJSONArray

        @NonNull
        public org.json.JSONArray getJSONArray​(@NonNull
                                               java.lang.String key,
                                               @NonNull
                                               org.json.JSONArray default_value)
        Get JSONArray in the KiiBaseObject associated with the key. If not exit or error, it will return the default value
        Parameters:
        key - is Key string
        default_value - is default value in JSONArray
        Returns:
        value in JSONArray
      • set

        public void set​(@NonNull
                        java.lang.String key,
                        @NonNull
                        java.lang.Boolean value)
        Create/Update the key/value boolean in the KiiBaseObject
        Parameters:
        key - is Key string
        value - is Value boolean
        Throws:
        java.lang.IllegalArgumentException - when key or value is empty,null, or any reserve key.
        IllegalKiiBaseObjectFormatException - if value contains illegal syntax
      • set

        public void set​(@NonNull
                        java.lang.String key,
                        double value)
        Create/Update association of the specified key with the specified double value in the KiiObject.
        NOTE: Before involving floating point value, please consider using integer(int/long) instead. For example, use percentage, permil, ppm, etc.
        The reason is:
      • Will dramatically improve the performance of bucket query.
      • Bucket query does not support the mixed result of integer and floating point. ex.) If you use same key for integer and floating point and inquire object with the integer value, objects which has double value with the key would not be evaluated in the query. (and vice versa)

Parameters:
key - Key string.
value - double value.
Throws:
java.lang.IllegalArgumentException - when key or value is empty, null, or any reserve key.
IllegalKiiBaseObjectFormatException - if value contains illegal syntax