Package com.kii.cloud.storage
Class KiiPushMessage.Data
- java.lang.Object
-
- com.kii.cloud.storage.KiiPushMessage.Data
-
- Direct Known Subclasses:
APNSMessage.APNSData
,GCMMessage.GCMData
,JPushMessage.JPushData
,MqttMessage.Builder.MqttData
- Enclosing class:
- KiiPushMessage
public static class KiiPushMessage.Data extends java.lang.Object
Represent data to be delivered to each device. It contains a JSON object whose field represents key-value pairs of message's payload. Note that, if the data intended to deliver to GCM devices, key can not be a reserved word listed bellow:- any key starts with 'google'
- from
- registration_ids
- collapse_key
- data
- delay_while_idle
- time_to_live
- restricted_package_name
- dry_run
-
-
Field Summary
Fields Modifier and Type Field Description protected org.json.JSONObject
data
-
Constructor Summary
Constructors Constructor Description Data()
Create empty message data.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
_isValidKey(java.lang.String key)
static boolean
isValidKey(java.lang.String key)
Checks whether the key is valid.void
put(java.lang.String key, boolean value)
Put boolean value to the data.void
put(java.lang.String key, double value)
Put double value to the data.void
put(java.lang.String key, int value)
Put int value to the data.void
put(java.lang.String key, long value)
Put long value to the data.void
put(java.lang.String key, java.lang.String value)
Put String value to the data.org.json.JSONObject
toJSONObject()
Obtain JSONObject representation of the Data.
-
-
-
Method Detail
-
toJSONObject
@NonNull public org.json.JSONObject toJSONObject()
Obtain JSONObject representation of the Data. Operation for returned object won't affect this object.- Returns:
- JSONObject represents the data.
-
put
public void put(@NonNull java.lang.String key, int value)
Put int value to the data.- Parameters:
key
- when the same value specified, overwrite existing value.value
- int value.- Throws:
java.lang.IllegalArgumentException
- when the specified key is null or empty.
-
put
public void put(@NonNull java.lang.String key, long value)
Put long value to the data.- Parameters:
key
- when the same value specified, overwrite existing value.value
- long value.- Throws:
java.lang.IllegalArgumentException
- when the specified key is null or empty.
-
put
public void put(@NonNull java.lang.String key, double value)
Put double value to the data.- Parameters:
key
- when the same value specified, overwrite existing value.value
- double value.- Throws:
java.lang.IllegalArgumentException
- when the specified key is null or empty.
-
put
public void put(@NonNull java.lang.String key, boolean value)
Put boolean value to the data.- Parameters:
key
- when the same value specified, overwrite existing value.value
- boolean value.- Throws:
java.lang.IllegalArgumentException
- when the specified key is null or empty.
-
put
public void put(@NonNull java.lang.String key, @Nullable java.lang.String value)
Put String value to the data.- Parameters:
key
- when the same value specified, overwrite existing value.value
- string value.- Throws:
java.lang.IllegalArgumentException
- when the specified key is null or empty.
-
isValidKey
public static boolean isValidKey(@Nullable java.lang.String key)
Checks whether the key is valid.- Parameters:
key
- to be checked.- Returns:
- true for valid key.Return false when the specified key is null or empty.
-
_isValidKey
protected boolean _isValidKey(java.lang.String key)
-
-