public final class KiiEvent
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected org.json.JSONObject |
mJSON |
Modifier and Type | Method and Description |
---|---|
boolean |
getBoolean(java.lang.String key)
Returns boolean value corresponding to the key.
|
float |
getFloat(java.lang.String key)
Returns float value corresponding to the key.
|
float[] |
getFloatArray(java.lang.String key)
Get float array.
|
int |
getInt(java.lang.String key)
Returns integer value corresponding to the key.
|
int[] |
getIntArray(java.lang.String key)
Get int array.
|
protected org.json.JSONArray |
getJSONArray(java.lang.String key)
Returns JSONArray value corresponding to the key.
|
protected org.json.JSONObject |
getJSONObject(java.lang.String key)
Returns JSONObject value corresponding to the key.
|
long |
getLong(java.lang.String key)
Returns long value corresponding to the key.
|
long[] |
getLongArray(java.lang.String key)
Get long array.
|
java.lang.String |
getString(java.lang.String key)
Returns String value corresponding to the key.
|
java.lang.String[] |
getStringArray(java.lang.String key)
Get String array.
|
boolean |
has(java.lang.String key)
Checks has value corresponding to the key.
|
static boolean |
isValidKey(java.lang.String key)
Check whether the key is valid or not.
|
static boolean |
isValidType(java.lang.String type)
Check whether the type is valid or not.
|
boolean |
optBoolean(java.lang.String key,
boolean defaultValue)
Returns boolean value corresponding to the key.
|
float |
optFloat(java.lang.String key,
float defaultValue)
Returns float value corresponding to the key.
|
float[] |
optFloatArray(java.lang.String key)
Returns float array corresponding to the key.
|
int |
optInt(java.lang.String key,
int defaultValue)
Returns integer value corresponding to the key.
|
int[] |
optIntArray(java.lang.String key)
Returns int array corresponding to the key.
|
protected org.json.JSONArray |
optJSONArray(java.lang.String key)
Returns JSONObject value mapped by the key.
If mapping does not exists or value is not JSONArray, returns null. |
protected org.json.JSONObject |
optJSONObject(java.lang.String key)
Returns JSONObject value mapped by the key.
If mapping does not exists or value is not JSONObject, returns null. |
long |
optLong(java.lang.String key,
long defaultValue)
Returns long value corresponding to the key.
|
long[] |
optLongArray(java.lang.String key)
Returns long array corresponding to the key.
|
java.lang.String |
optString(java.lang.String key,
java.lang.String defaultValue)
Returns String value corresponding to the key.
|
java.lang.String[] |
optStringArray(java.lang.String key)
Returns String array corresponding to the key.
|
void |
push()
Event will be cached in persistent storage and uploaded by batch.
Upload will be done automatically in a fixed interval. So no need to care about the upload after you pushed in the queue by calling this method. |
void |
push(KiiEventCallback callback)
Asynchronous version of
push()
NOTE: this api should be called from UI/Main thread. |
void |
remove(java.lang.String key)
Remove the value corresponding to the key.
|
void |
set(java.lang.String key,
boolean value)
Set the boolean value.
|
void |
set(java.lang.String key,
float value)
Set the float value.
|
void |
set(java.lang.String key,
int value)
Set the integer value.
|
protected void |
set(java.lang.String key,
org.json.JSONArray value)
Set the JSONArray value.
|
protected void |
set(java.lang.String key,
org.json.JSONObject value)
Set the JSONObject value.
|
void |
set(java.lang.String key,
long value)
Set the long value.
|
void |
set(java.lang.String key,
java.lang.String value)
Set the string value.
|
void |
setFloatArray(java.lang.String key,
float... values)
Set the float array.
|
void |
setIntArray(java.lang.String key,
int... values)
Set the int array.
|
void |
setLongArray(java.lang.String key,
long... values)
Set the long array.
|
void |
setStringArray(java.lang.String key,
java.lang.String... values)
Set the String array.
|
org.json.JSONObject |
toJson()
Return JSON representation of the event.
|
void |
upload()
Deprecated.
Use
push(KiiEventCallback) instead.
Upload this event to server.
Event will be analyzed by defined rule on server by batch. |
void |
upload(KiiEventCallback callback)
Deprecated.
Use
push(KiiEventCallback) instead.
Asynchronous version of upload()
NOTE: this api should be called from UI/Main thread. WrongThreadException will be thrown when this api called from
sub thread. |
static void |
validateKey(java.lang.String key)
Validate Key.
|
static void |
validateType(java.lang.String type)
Validate type
Must matches with the pattern ^\\S.*
Length must be less than or equals 128bytes in UTF-8
|
public void push(KiiEventCallback callback)
push()
WrongThreadException
will be thrown when this api called from
sub thread.callback
- Notifies completion of the push.
callback methods will be executed on UI/Main thread.public void push() throws java.io.IOException
java.io.IOException
- thrown when failed to store event on persistent storage.java.lang.IllegalStateException
- If SDK is not initialized.public org.json.JSONObject toJson()
public void upload() throws KiiAnalyticsException
push(KiiEventCallback)
instead.
Upload this event to server.
Event will be analyzed by defined rule on server by batch.KiiAnalyticsException
java.lang.IllegalStateException
- If SDK is not initialized.public void upload(KiiEventCallback callback)
push(KiiEventCallback)
instead.
Asynchronous version of upload()
WrongThreadException
will be thrown when this api called from
sub thread.callback
- notifies event.
callback methods will be executed on UI/Main thread.public static void validateKey(java.lang.String key) throws KiiAnalyticsFormatException
key
- KiiAnalyticsFormatException
- when key is invalid.
Key validation rules:public static boolean isValidKey(java.lang.String key)
key
- public static void validateType(java.lang.String type) throws KiiAnalyticsFormatException
type
- to validateKiiAnalyticsFormatException
- when type is not acceptable format.public static boolean isValidType(java.lang.String type)
type
- to checkpublic boolean has(java.lang.String key)
key
- to checkpublic void remove(java.lang.String key)
key
- public java.lang.String getString(java.lang.String key)
key
- KiiAnalyticsFormatException
- when corresponding key-value has not exist.public java.lang.String optString(java.lang.String key, java.lang.String defaultValue)
key
- defaultValue
- public void set(java.lang.String key, java.lang.String value)
key
- to set.value
- to setKiiAnalyticsFormatException
- when key or value is invalid.
For the explanation key validation rules, refer to
validateKey(String)
or isValidKey(String)
.public boolean getBoolean(java.lang.String key)
key
- KiiAnalyticsFormatException
- when corresponding key-value has not exist.public boolean optBoolean(java.lang.String key, boolean defaultValue)
key
- defaultValue
- public void set(java.lang.String key, boolean value)
key
- to set.value
- to setKiiAnalyticsFormatException
- when key is invalid.
For the explanation key validation rules, refer to
validateKey(String)
or isValidKey(String)
.public int getInt(java.lang.String key)
key
- KiiAnalyticsFormatException
- when corresponding key-value has not exist.public int optInt(java.lang.String key, int defaultValue)
key
- defaultValue
- public void set(java.lang.String key, int value)
key
- to set.value
- to setKiiAnalyticsFormatException
- when key/value is invalid.
For the explanation key validation rules, refer to
validateKey(String)
or isValidKey(String)
.public long getLong(java.lang.String key)
key
- KiiAnalyticsFormatException
- when corresponding key-value has not exist.public long optLong(java.lang.String key, long defaultValue)
key
- defaultValue
- public void set(java.lang.String key, long value)
key
- to set.value
- to setKiiAnalyticsFormatException
- when key/value is invalid.
For the explanation key validation rules, refer to validateKey(String)
or isValidKey(String)
.public void setIntArray(java.lang.String key, int... values)
key
- to setvalues
- to set. Accept int[] or several int values separated by comma.KiiAnalyticsFormatException
- when key/value is invalid.
For the explanation key validation rules, refer to
validateKey(String)
or isValidKey(String)
.java.lang.IllegalArgumentException
- Specified array is null or zero length.public int[] getIntArray(java.lang.String key)
key
- KiiAnalyticsFormatException
- when corresponding key-value has not exist.public int[] optIntArray(java.lang.String key)
key
- public void setStringArray(java.lang.String key, java.lang.String... values)
key
- to setvalues
- to set. Accept String[] or several String values separated by comma.KiiAnalyticsFormatException
- when key/value is invalid.
For the explanation key validation rules, refer to validateKey(String)
or isValidKey(String)
.java.lang.IllegalArgumentException
- Specified array is null or zero length.public java.lang.String[] getStringArray(java.lang.String key)
key
- KiiAnalyticsFormatException
- when corresponding key-value has not exist.public java.lang.String[] optStringArray(java.lang.String key)
key
- public void setLongArray(java.lang.String key, long... values)
key
- to setvalues
- to set. Accept long[] or several long values separated by comma.KiiAnalyticsFormatException
- when key/value is invalid.
For the explanation key validation rules, refer to
validateKey(String)
or isValidKey(String)
.
In Addition, It also follows other key/value validation rules followed by JSON.java.lang.IllegalArgumentException
- Specified array is null or zero length.public long[] getLongArray(java.lang.String key)
key
- KiiAnalyticsFormatException
- when corresponding key-value has not exist.public long[] optLongArray(java.lang.String key)
key
- public void setFloatArray(java.lang.String key, float... values)
key
- to setvalues
- to set. Accept float[] or several float values separated by comma.KiiAnalyticsFormatException
- when key/value is invalid.
For the explanation key validation rules, refer to
validateKey(String)
or isValidKey(String)
.
In Addition, It also follows other key/value validation rules followed by JSON.java.lang.IllegalArgumentException
- Specified array is null or zero length.public float[] getFloatArray(java.lang.String key)
key
- KiiAnalyticsFormatException
- when corresponding key-value has not exist.public float[] optFloatArray(java.lang.String key)
key
- protected org.json.JSONObject getJSONObject(java.lang.String key)
key
- KiiAnalyticsFormatException
- when corresponding key-value has not exist.protected org.json.JSONObject optJSONObject(java.lang.String key)
protected void set(java.lang.String key, org.json.JSONObject value)
key
- to set.value
- to setKiiAnalyticsFormatException
- when key or value is invalid. key/value validation is same as JSON.protected org.json.JSONArray getJSONArray(java.lang.String key)
key
- KiiAnalyticsFormatException
- when corresponding key-value has not exist.protected org.json.JSONArray optJSONArray(java.lang.String key)
protected void set(java.lang.String key, org.json.JSONArray value)
key
- to set.value
- to setKiiAnalyticsFormatException
- when key or value is invalid. key/value validation is same as JSON.public float getFloat(java.lang.String key)
key
- KiiAnalyticsFormatException
- when corresponding key-value has not exist.public float optFloat(java.lang.String key, float defaultValue)
key
- defaultValue
- public void set(java.lang.String key, float value)
key
- to set.value
- to setKiiAnalyticsFormatException
- when key/value is invalid.
For the explanation key validation rules, refer to
validateKey(String)
or isValidKey(String)
.
In Addition, It also follows other key/value validation rules followed by JSON.Copyright 2014 Kii Corporation. All rights reserved. (Last updated on 2015-05-26 10:13 UTC)