|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavapns.notification.Payload
public abstract class Payload
Abstract class representing a payload that can be transmitted to Apple. 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).
| Field Summary | |
|---|---|
protected static org.apache.log4j.Logger |
logger
|
| Constructor Summary | |
|---|---|
Payload()
Construct a Payload object with a blank root JSONObject |
|
Payload(String rawJSON)
Construct a Payload object from a JSON-formatted string |
|
| Method Summary | |
|---|---|
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. |
int |
estimatePayloadSizeAfterAdding(String propertyName,
Object propertyValue)
Estimate the size that this payload will take after adding a given property. |
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. |
int |
getMaximumPayloadSize()
Return the maximum payload size in bytes. |
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. |
protected int |
getPreSendConfiguration()
|
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). |
protected void |
put(String propertyName,
Object propertyValue,
JSONObject object,
boolean opt)
Puts a property in a JSONObject, while possibly checking for estimated payload size violation. |
protected Object |
remove(String propertyName,
JSONObject object)
|
void |
setCharacterEncoding(String characterEncoding)
Changes the character encoding for streaming the payload. |
void |
setExpiry(int seconds)
Set the number of seconds after which this payload should expire. |
void |
setPayloadSizeEstimatedWhenAdding(boolean checked)
Indicate if payload size should be estimated and controlled when adding properties (default is false). |
protected void |
setPreSendConfiguration(int preSendConfiguration)
|
String |
toString()
Get the string representation |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.log4j.Logger logger
| Constructor Detail |
|---|
public Payload()
public Payload(String rawJSON)
throws JSONException
rawJSON - a JSON-formatted string (ex: {"aps":{"alert":"Hello World!"}} )
JSONException - thrown if a exception occurs while parsing the JSON string| Method Detail |
|---|
public JSONObject getPayload()
public void addCustomDictionary(String name,
String value)
throws JSONException
name - value -
JSONException
public void addCustomDictionary(String name,
int value)
throws JSONException
name - value -
JSONException
public void addCustomDictionary(String name,
List values)
throws JSONException
name - values -
JSONException
public void addCustomDictionary(String name,
Object value)
throws JSONException
name - value -
JSONExceptionpublic String toString()
toString in class Object
public byte[] getPayloadAsBytes()
throws Exception
Exception
public int getPayloadSize()
throws Exception
Exception
public int estimatePayloadSizeAfterAdding(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 estimation
public 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 estimation
protected void put(String propertyName,
Object propertyValue,
JSONObject object,
boolean opt)
throws JSONException
propertyName - the name of the property to use for calculating the estimationpropertyValue - the value of the property to use for calculating the estimationobject - the JSONObject to put the property inopt - true to use putOpt, false to use put
JSONException
protected Object remove(String propertyName,
JSONObject object)
public 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 int getMaximumPayloadSize()
public void setCharacterEncoding(String characterEncoding)
characterEncoding - a valid character encoding that String.getBytes(encoding) will acceptpublic String getCharacterEncoding()
public void setExpiry(int seconds)
seconds - public int getExpiry()
public Payload asSimulationOnly()
protected void setPreSendConfiguration(int preSendConfiguration)
protected int getPreSendConfiguration()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||