net.rim.pushsdk.commons.content
Class GenericContent

java.lang.Object
  extended by net.rim.pushsdk.commons.content.Content
      extended by net.rim.pushsdk.commons.content.SinglePartContent
          extended by net.rim.pushsdk.commons.content.GenericContent

public class GenericContent
extends SinglePartContent

Content payload that does not fit one of the predefined content types.

You must set the content MIME type and any headers manually.

Author:
mdicesare

Field Summary
 
Fields inherited from class net.rim.pushsdk.commons.content.Content
BOUNDARY_DELIMITER_BYTES, contentType, headers, NEW_LINE, NEW_LINE_BYTES
 
Constructor Summary
GenericContent(byte[] content, ContentType contentType)
          Creates generic content with the specified byte array as the payload and uses the given content type to set the content type header.
 
Method Summary
 boolean isEmpty()
          Determines whether the content is empty.
 String toString()
          Constructs a String with all attributes in name = value format.
protected  void writeContentTo(ByteArrayOutputStream out)
          Note: Printing generic content does not do any character set encoding.
 
Methods inherited from class net.rim.pushsdk.commons.content.SinglePartContent
checkExtension, getBytesFromFile, getBytesFromURL, writeTo
 
Methods inherited from class net.rim.pushsdk.commons.content.Content
addHeader, getContentType, getHeader, getHeaders, setContentType, setHeader, writeHeadersTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GenericContent

public GenericContent(byte[] content,
                      ContentType contentType)
Creates generic content with the specified byte array as the payload and uses the given content type to set the content type header.

Parameters:
content - the payload
contentType - the content MIME type
Method Detail

writeContentTo

protected void writeContentTo(ByteArrayOutputStream out)
                       throws IOException
Note: Printing generic content does not do any character set encoding. It is assumed that the byte array has already been encoded in the desired encoding (if needed).

Specified by:
writeContentTo in class SinglePartContent
Parameters:
out - the output stream
Throws:
IOException - if any IO errors occur writing to the output stream

isEmpty

public boolean isEmpty()
Description copied from class: Content
Determines whether the content is empty.

Specified by:
isEmpty in class Content
Returns:
true if the content is deemed to be empty; false otherwise

toString

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

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


Copyright © 2011 Research In Motion. All Rights Reserved.