com.kii.cloud.storage
Class KiiBaseObject

java.lang.Object
  extended by com.kii.cloud.storage.KiiBaseObject
Direct Known Subclasses:
KiiObject, KiiUser

public abstract class KiiBaseObject
extends java.lang.Object


Field Summary
protected  JSONObject mJSON
           
protected  JSONObject mJSONPatch
           
protected  java.util.HashSet<java.lang.String> mReservedKeys
           
 
Method Summary
 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.
 JSONArray getJsonArray(java.lang.String key)
          Get JSONArray in the Entity associated with the key.
 JSONArray getJSONArray(java.lang.String key, JSONArray default_value)
          Get JSONArray in the KiiBaseObject associated with the key.
 JSONObject getJSONObject(java.lang.String key)
          Get JSONObject in the KiiBaseObject associated with the key.
protected  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.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.
 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 * @throws IllegalArgumentException when key is empty, null or any reserve key.
 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, 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, JSONArray value)
          Create/Update association of the specified key with the specified JSONArray value in the KiiObject.
 void set(java.lang.String key, JSONObject value)
          Create/Update the key/value JSONObject 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, java.lang.String value)
          Create/Update the key/value string in the KiiBaseObject
 void set(java.lang.String key, Uri value)
          Create/Update the key/value Uri in the KiiBaseObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mJSON

protected JSONObject mJSON

mJSONPatch

protected JSONObject mJSONPatch

mReservedKeys

protected final java.util.HashSet<java.lang.String> mReservedKeys
Method Detail

getBoolean

public java.lang.Boolean getBoolean(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

public java.lang.Boolean getBoolean(java.lang.String key,
                                    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

getByteArray

public byte[] getByteArray(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.

getDouble

public double getDouble(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(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

getInt

public int getInt(java.lang.String key)
Get int in the KiiBaseObject associated with the key.

Parameters:
key - is Key string
Returns:
value in int
Throws:
IllegalKiiBaseObjectFormatException - if not exist or contains illegal syntax

getInt

public int getInt(java.lang.String key,
                  int default_value)
Get int 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 int
Returns:
value in int

getJsonArray

public JSONArray getJsonArray(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

public JSONArray getJSONArray(java.lang.String key,
                              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

getJSONObject

public JSONObject getJSONObject(java.lang.String key)
Get JSONObject in the KiiBaseObject associated with the key.

Parameters:
key - is Key string
Returns:
value in JSONObject
Throws:
IllegalKiiBaseObjectFormatException - if not exist or contains illegal syntax

getJSONOfArbitraryFields

protected JSONObject getJSONOfArbitraryFields()
Return json that contains key/value of keyset.

Throws:
JSONException

getLong

public long getLong(java.lang.String key)
Get long in the KiiBaseObject associated with the key.

Parameters:
key - is Key string
Returns:
value in long
Throws:
IllegalKiiBaseObjectFormatException - if not exist or contains illegal syntax

getLong

public long getLong(java.lang.String key,
                    long default_value)
Get long 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 long
Returns:
value in long

getString

public java.lang.String getString(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

getString

public java.lang.String getString(java.lang.String key,
                                  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

getUri

public Uri getUri(java.lang.String key)
Get Uri in the Entity associated with the key.

Parameters:
key - is Key string
Returns:
value in Uri
Throws:
IllegalKiiBaseObjectFormatException - if not exist or contains illegal syntax

has

public boolean has(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

keySet

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.


remove

public void remove(java.lang.String key)
Remove a pair of key/value from KiiBaseObject * @throws IllegalArgumentException when key is empty, null or any reserve key.

Parameters:
key - to remove.

set

public void set(java.lang.String key,
                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(java.lang.String key,
                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.

set

public void set(java.lang.String key,
                double value)
Create/Update association of the specified key with the specified double value in the KiiObject.

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

set

public void set(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(java.lang.String key,
                JSONArray value)
Create/Update association of the specified key with the specified JSONArray value in the KiiObject.

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

set

public void set(java.lang.String key,
                JSONObject value)
Create/Update the key/value JSONObject in the KiiBaseObject

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

set

public void set(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

set

public void set(java.lang.String key,
                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

set

public void set(java.lang.String key,
                Uri value)
Create/Update the key/value Uri in the KiiBaseObject

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