net.rim.pushsdk.commons.content
Class SinglePartContent

java.lang.Object
  extended by net.rim.pushsdk.commons.content.Content
      extended by net.rim.pushsdk.commons.content.SinglePartContent
Direct Known Subclasses:
BinaryContent, GenericContent, TextContent

public abstract class SinglePartContent
extends Content

Abstract class that represents single part message content.

Author:
mdandrea

Field Summary
 
Fields inherited from class net.rim.pushsdk.commons.content.Content
BOUNDARY_DELIMITER_BYTES, contentType, headers, NEW_LINE, NEW_LINE_BYTES
 
Constructor Summary
SinglePartContent()
           
 
Method Summary
protected  void checkExtension(String string)
          Checks the extension of a file to make sure its valid for the content.
protected  byte[] getBytesFromFile(File file)
          Returns the contents of a file in a byte array.
protected  byte[] getBytesFromURL(URL url)
          Returns the contents of a URL in a byte array.
protected abstract  void writeContentTo(ByteArrayOutputStream out)
          Writes content out to the specified output stream.
 void writeTo(ByteArrayOutputStream out)
          Writes the content to the specified output stream.
 
Methods inherited from class net.rim.pushsdk.commons.content.Content
addHeader, getContentType, getHeader, getHeaders, isEmpty, setContentType, setHeader, toString, writeHeadersTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SinglePartContent

public SinglePartContent()
Method Detail

writeTo

public void writeTo(ByteArrayOutputStream out)
             throws IOException
Description copied from class: Content
Writes the content to the specified output stream.

Specified by:
writeTo in class Content
Parameters:
out - the output stream
Throws:
IOException - if any IO errors occur

getBytesFromFile

protected byte[] getBytesFromFile(File file)
                           throws IOException
Returns the contents of a file in a byte array.

Parameters:
file - a file
Returns:
the contents of the file
Throws:
IOException - if any IO errors occur reading from the file

getBytesFromURL

protected byte[] getBytesFromURL(URL url)
                          throws IOException
Returns the contents of a URL in a byte array.

Parameters:
url - a URL
Returns:
the contents of the URL
Throws:
IOException - if any IO errors occur reading from the URL

checkExtension

protected void checkExtension(String string)
Checks the extension of a file to make sure its valid for the content.

Parameters:
string - the file name

writeContentTo

protected abstract void writeContentTo(ByteArrayOutputStream out)
                                throws IOException
Writes content out to the specified output stream.

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


Copyright © 2011 Research In Motion. All Rights Reserved.