javapns/src/main/java/javapns/notification/Payload.java
/**
	 * Puts a property in a JSONObject, while possibly checking for estimated payload size violation.
	 *
	 * @param propertyName the name of the property to use for calculating the estimation
	 * @param propertyValue the value of the property to use for calculating the estimation
	 * @param object the JSONObject to put the property in
	 * @param opt true to use putOpt, false to use put
	 * @throws JSONException
	 */
Puts a property in a JSONObject, while possibly checking for estimated payload size violation.
Puts a property in a JSONObject while possibly checking for estimated payload size violation .
protected void put(String propertyName, Object propertyValue, JSONObject object, boolean opt) throws JSONException {
		try {
			if (isPayloadSizeEstimatedWhenAdding()) {
				int maximumPayloadSize = getMaximumPayloadSize();
				int estimatedPayloadSize = estimatePayloadSizeAfterAdding(propertyName, propertyValue);
				boolean estimatedToExceed = estimatedPayloadSize > maximumPayloadSize;
				if (estimatedToExceed) throw new PayloadMaxSizeProbablyExceededException(maximumPayloadSize, estimatedPayloadSize);
			}
		} catch (PayloadMaxSizeProbablyExceededException e) {
			throw e;
		} catch (Exception e) {
		}
		if (opt) object.putOpt(propertyName, propertyValue);
		else object.put(propertyName, propertyValue);
	}
protected void put ( String propertyName , Object propertyValue , JSONObject object , boolean opt ) throws JSONException { try { if ( isPayloadSizeEstimatedWhenAdding ( ) ) { int maximumPayloadSize = getMaximumPayloadSize ( ) ; int estimatedPayloadSize = estimatePayloadSizeAfterAdding ( propertyName , propertyValue ) ; boolean estimatedToExceed = estimatedPayloadSize > maximumPayloadSize ; if ( estimatedToExceed ) throw new PayloadMaxSizeProbablyExceededException ( maximumPayloadSize , estimatedPayloadSize ) ; } } catch ( PayloadMaxSizeProbablyExceededException e ) { throw e ; } catch ( Exception e ) { } if ( opt ) object . putOpt ( propertyName , propertyValue ) ; else object . put ( propertyName , propertyValue ) ; }
Puts a property in a JSONObject, while possibly checking for estimated payload size violation.
Puts a property in a JSONObject while possibly checking for estimated payload size violation .