net.rim.pushsdk.pap.control
Class PapRequestMessage

java.lang.Object
  extended by net.rim.pushsdk.pap.control.PapRequestMessage

public class PapRequestMessage
extends Object

Represents a PAP request message.

A PAP request message can contain a control part (XML) and a content part formed as a MIME message such as Push or just have a control part (XML) such as Cancel and Status Query.

Author:
mdicesare

Constructor Summary
PapRequestMessage(PapControl control)
          Constructs a request for a PAP message that has only a control part (i.e.
PapRequestMessage(PapControl control, Content content)
          Constructs a request for a PAP message that has both a control and content part (i.e.
 
Method Summary
 String getBoundary()
          Returns the boundary string; null if not a MIME message.
 ContentType getContentTypeForHeader()
          Gets the content type for the PAP request message.
 void marshal(ByteArrayOutputStream out)
          Writes out the boundary, the control, and the content (if there is any) to the output stream.
 String toString()
          Constructs a String with all attributes in name = value format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PapRequestMessage

public PapRequestMessage(PapControl control,
                         Content content)
Constructs a request for a PAP message that has both a control and content part (i.e. a push message).

If content was specified, then this method will check if a Push-Message-Id header has been specified as part of the top-most Content. If it has not, a Push-Message-ID header will be automatically added with the push id. This may assist in implementing duplicate message detection on the device side and various other use cases.

Parameters:
control - PAP control element (represents the XML part of the PAP message)
content - the content to push

PapRequestMessage

public PapRequestMessage(PapControl control)
Constructs a request for a PAP message that has only a control part (i.e. a cancel or status query message).

Parameters:
control - PAP control element (represents the XML part of the PAP message)
Method Detail

marshal

public void marshal(ByteArrayOutputStream out)
             throws IOException
Writes out the boundary, the control, and the content (if there is any) to the output stream.

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

getContentTypeForHeader

public ContentType getContentTypeForHeader()
Gets the content type for the PAP request message.

Example for push messages: Content-Type: multipart/related; boundary=asdlfkjiurwghasf; type="application/xml"
Example for cancel and status query messages: Content-Type: application/xml

Returns:
the PAP request message's content type

getBoundary

public String getBoundary()
Returns the boundary string; null if not a MIME message.

Returns:
the boundary string

toString

public String toString()
Constructs a String with all attributes in name = value format.

Overrides:
toString in class Object
Returns:
a String representation of this object.


Copyright © 2011 Research In Motion. All Rights Reserved.