net.rim.pushsdk.pap.control
Class PapControl

java.lang.Object
  extended by net.rim.pushsdk.pap.control.PapControl
Direct Known Subclasses:
CancelMessageControl, PushMessageControl, ResultNotificationResponseControl, StatusQueryMessageControl

public abstract class PapControl
extends Object

Base class for all PAP control objects.

Author:
mdicesare

Field Summary
static String ATTRIBUTE_KEY_VALUE_SEPARATOR
          The separator to use for attributes.
static String CLOSE_BRACKET
          A close bracket for an XML tag.
static String CLOSE_BRACKET_WITH_SLASH
          A forward slash followed by a close bracket for an XML tag.
static String DTD_DECLARATION_BES
          Deprecated. The enterprise (BES) DTD will now be obtained from the PushSDK.properties file.
static String DTD_DECLARATION_PUBLIC
          Deprecated. The public (BIS) DTD will now be obtained from the PushSDK.properties file.
static String EPILOGUE
          Deprecated. As of version 1.1 ,the XML epilogue should be generated on demand by calling the getEpilogue() method.
static String ESCAPED_DOUBLE_QUOTE
          An escaped double quote.
static String FORWARD_SLASH
          A forward slash.
static String NEW_LINE
          A new-line character (i.e.
static String OPEN_BRACKET
          An open bracket for an XML tag.
static String OPEN_BRACKET_WITH_SLASH
          An open bracket for an XML tag followed by a forward slash.
static String PREAMBLE_BES
          Deprecated. As of version 1.1, the enterprise (BES) XML preamble should be generated on demand by calling the getPreamble() method.
static String PREAMBLE_PUBLIC
          Deprecated. As of version 1.1, the public (BIS) XML preamble should be generated on demand by calling the getPreamble() method.
protected  String pushId
          The push id associated with the PAP control.
protected  PushSDKProperties pushSDKProperties
          Defaults to the provided PushSDKPropertiesImpl implementation, but can be overridden with the setter.
protected  Boolean usingPublicPush
          True if a public (BIS) push is being performed; false otherwise.
static String XML_DECLARATION
          The XML declaration tag.
 
Constructor Summary
PapControl()
           
 
Method Summary
static String getAttribute(String attribute, String value)
          Gets an attribute in the following form: attribute=\"value\".
 ContentType getContentType()
          Gets the content type of the PAP control.
static String getEndTag(String tag)
          Gets an XML end tag with the given tag name.
protected  String getEpilogue()
          Gets the PAP control epilogue.
protected  String getPreamble()
          Gets the PAP control preamble.
static String getStartTagClosed(String tag)
          Gets a closed XML start tag (i.e.
static String getStartTagOpen(String tag)
          Gets an open XML start tag (i.e.
 boolean isUsingPublicPush()
          Whether or not a PAP control is being used for a public (BIS) push or an enterprise (BES) push.
 void setPushSDKProperties(PushSDKProperties pushSDKProperties)
          Sets the push SDK properties to be used with the PAP control.
 void setUsingPublicPush(boolean usingPublicPush)
          Sets whether or not to use a PAP control for a public (BIS) push or for an enterprise (BES) push.
protected abstract  void validate()
          Validates the information contained within the PAP control.
protected  void validatePushIdForSpecialCharacters(String pushId)
          Validates if the provided push id does not contain any special characters defined in the "parser.special.characters" property of the PushSDK.properties file.
abstract  void writeTo(ByteArrayOutputStream out)
          Writes the PAP control out to the specified output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEW_LINE

public static final String NEW_LINE
A new-line character (i.e. \n).

See Also:
Constant Field Values

OPEN_BRACKET

public static final String OPEN_BRACKET
An open bracket for an XML tag.

See Also:
Constant Field Values

CLOSE_BRACKET

public static final String CLOSE_BRACKET
A close bracket for an XML tag.

See Also:
Constant Field Values

ESCAPED_DOUBLE_QUOTE

public static final String ESCAPED_DOUBLE_QUOTE
An escaped double quote.

See Also:
Constant Field Values

FORWARD_SLASH

public static final String FORWARD_SLASH
A forward slash.

See Also:
Constant Field Values

OPEN_BRACKET_WITH_SLASH

public static final String OPEN_BRACKET_WITH_SLASH
An open bracket for an XML tag followed by a forward slash.

See Also:
Constant Field Values

CLOSE_BRACKET_WITH_SLASH

public static final String CLOSE_BRACKET_WITH_SLASH
A forward slash followed by a close bracket for an XML tag.

See Also:
Constant Field Values

ATTRIBUTE_KEY_VALUE_SEPARATOR

public static final String ATTRIBUTE_KEY_VALUE_SEPARATOR
The separator to use for attributes.

See Also:
Constant Field Values

XML_DECLARATION

public static final String XML_DECLARATION
The XML declaration tag.

See Also:
Constant Field Values

DTD_DECLARATION_BES

@Deprecated
public static final String DTD_DECLARATION_BES
Deprecated. The enterprise (BES) DTD will now be obtained from the PushSDK.properties file.
The DTD information tag for enterprise (BES) pushes.

See Also:
Constant Field Values

DTD_DECLARATION_PUBLIC

@Deprecated
public static final String DTD_DECLARATION_PUBLIC
Deprecated. The public (BIS) DTD will now be obtained from the PushSDK.properties file.
The DTD information tag for public (BIS) pushes.

See Also:
Constant Field Values

PREAMBLE_BES

@Deprecated
public static final String PREAMBLE_BES
Deprecated. As of version 1.1, the enterprise (BES) XML preamble should be generated on demand by calling the getPreamble() method.
The preamble XML for enterprise (BES) pushes.

See Also:
Constant Field Values

PREAMBLE_PUBLIC

@Deprecated
public static final String PREAMBLE_PUBLIC
Deprecated. As of version 1.1, the public (BIS) XML preamble should be generated on demand by calling the getPreamble() method.
The preamble XML for public (BIS) pushes.

See Also:
Constant Field Values

EPILOGUE

@Deprecated
public static final String EPILOGUE
Deprecated. As of version 1.1 ,the XML epilogue should be generated on demand by calling the getEpilogue() method.
The epilogue XML.

See Also:
Constant Field Values

pushSDKProperties

protected PushSDKProperties pushSDKProperties
Defaults to the provided PushSDKPropertiesImpl implementation, but can be overridden with the setter.


usingPublicPush

protected Boolean usingPublicPush
True if a public (BIS) push is being performed; false otherwise.

Since:
1.1

pushId

protected String pushId
The push id associated with the PAP control.

Constructor Detail

PapControl

public PapControl()
Method Detail

writeTo

public abstract void writeTo(ByteArrayOutputStream out)
                      throws IOException
Writes the PAP control out to the specified output stream.

Parameters:
out - the output stream
Throws:
IOException - if any errors occur writing to the output stream

setUsingPublicPush

public void setUsingPublicPush(boolean usingPublicPush)
Sets whether or not to use a PAP control for a public (BIS) push or for an enterprise (BES) push.

Parameters:
usingPublicPush - true if using the PAP control for a public (BIS) push; false otherwise
Since:
1.1

isUsingPublicPush

public boolean isUsingPublicPush()
Whether or not a PAP control is being used for a public (BIS) push or an enterprise (BES) push. If not explicitly set, this method will return the value from the PushSDKProperties for backwards compatibility.

Returns:
true if using the PAP control for a public (BIS) push; false otherwise
Since:
1.1

setPushSDKProperties

public void setPushSDKProperties(PushSDKProperties pushSDKProperties)
Sets the push SDK properties to be used with the PAP control.

Parameters:
pushSDKProperties - the push SDK properties

getContentType

public ContentType getContentType()
Gets the content type of the PAP control. (i.e. application/xml; charset=UTF-8)

Returns:
the content type

getAttribute

public static String getAttribute(String attribute,
                                  String value)
Gets an attribute in the following form: attribute=\"value\".

Parameters:
attribute - the attribute name
value - the value of the attribute
Returns:
a string with the attribute and its value

getEndTag

public static String getEndTag(String tag)
Gets an XML end tag with the given tag name.

Parameters:
tag - the tag name
Returns:
an XML end tag

getStartTagOpen

public static String getStartTagOpen(String tag)
Gets an open XML start tag (i.e.
Parameters:
tag - the tag name
Returns:
an open XML start tag

getStartTagClosed

public static String getStartTagClosed(String tag)
Gets a closed XML start tag (i.e. ) with the given tag name.

Parameters:
tag - the tag name
Returns:
an XML start tag

getPreamble

protected String getPreamble()
Gets the PAP control preamble.

For a public (BIS) push, see the "dtd.declaration.public" property in PushSDK.properties for the DTD declaration in the preamble. For an enterprise (BES) push, see the "dtd.declaration.enterprise" property in PushSDK.properties for the DTD declaration in the preamble.

Returns:
the PAP control preamble

getEpilogue

protected String getEpilogue()
Gets the PAP control epilogue.

Returns:
the PAP control epilogue

validatePushIdForSpecialCharacters

protected void validatePushIdForSpecialCharacters(String pushId)
Validates if the provided push id does not contain any special characters defined in the "parser.special.characters" property of the PushSDK.properties file.

Parameters:
pushId - push id to validate

validate

protected abstract void validate()
Validates the information contained within the PAP control.



Copyright © 2011 Research In Motion. All Rights Reserved.