public abstract class Payload extends Object
By default, this class has no payload content at all. Subclasses are responsible for imposing specific content based on the specifications they are intended to implement (such as the 'aps' dictionnary for APS payloads).
| Modifier | Constructor and Description |
|---|---|
protected |
Payload()
Construct a Payload object with a blank root JSONObject
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCustomDictionary(String name,
int value)
Add a custom dictionnary with a int value
|
void |
addCustomDictionary(String name,
List values)
Add a custom dictionnary with multiple values
|
void |
addCustomDictionary(String name,
Object value)
Add a custom dictionnary with object
|
void |
addCustomDictionary(String name,
String value)
Add a custom dictionnary with a string value
|
Payload |
asSimulationOnly()
Enables a special simulation mode which causes the library to behave
as usual *except* that at the precise point where the payload would
actually be streamed out to Apple, it is not.
|
String |
getCharacterEncoding()
Returns the character encoding that will be used by getPayloadAsBytes().
|
int |
getExpiry()
Return the number of seconds after which this payload should expire.
|
org.json.JSONObject |
getPayload()
Get the actual JSON object backing this payload.
|
byte[] |
getPayloadAsBytes()
Get this payload as a byte array using the preconfigured character encoding.
|
int |
getPayloadSize()
Get the number of bytes that the payload will occupy when streamed.
|
boolean |
isEstimatedPayloadSizeAllowedAfterAdding(String propertyName,
Object propertyValue)
Validate if the estimated payload size after adding a given property will be allowed.
|
boolean |
isPayloadSizeEstimatedWhenAdding()
Indicates if payload size is estimated and controlled when adding properties (default is false).
|
void |
setCharacterEncoding(String characterEncoding)
Changes the character encoding for streaming the payload.
|
void |
setPayloadSizeEstimatedWhenAdding(boolean checked)
Indicate if payload size should be estimated and controlled when adding properties (default is false).
|
String |
toString()
Get the string representation
|
protected Payload()
public org.json.JSONObject getPayload()
public void addCustomDictionary(String name, String value) throws org.json.JSONException
name - value - org.json.JSONExceptionpublic void addCustomDictionary(String name, int value) throws org.json.JSONException
name - value - org.json.JSONExceptionpublic void addCustomDictionary(String name, List values) throws org.json.JSONException
name - values - org.json.JSONExceptionpublic void addCustomDictionary(String name, Object value) throws org.json.JSONException
name - value - org.json.JSONExceptionpublic byte[] getPayloadAsBytes()
throws Exception
Exceptionpublic int getPayloadSize()
throws Exception
Exceptionpublic boolean isEstimatedPayloadSizeAllowedAfterAdding(String propertyName, Object propertyValue)
propertyName - the name of the property to use for calculating the estimationpropertyValue - the value of the property to use for calculating the estimationpublic boolean isPayloadSizeEstimatedWhenAdding()
public void setPayloadSizeEstimatedWhenAdding(boolean checked)
checked - true to throw an exception if the estimated size is too big when adding a property, false otherwisepublic String getCharacterEncoding()
public void setCharacterEncoding(String characterEncoding)
characterEncoding - a valid character encoding that String.getBytes(encoding) will acceptpublic int getExpiry()
public Payload asSimulationOnly()
Copyright © 2016. All rights reserved.