net.rim.pushsdk.commons.content
Class HtmlContent

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.TextContent
              extended by net.rim.pushsdk.commons.content.HtmlContent

public class HtmlContent
extends TextContent

Represents HTML content (a specialized form of TextContent). It will automatically set the appropriate content type for an HTML payload.

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
HtmlContent(File file)
          Constructs content of an HTML type from the contents of the file.
HtmlContent(File file, String characterSet)
          Constructs content of an HTML type from the contents of the file.
HtmlContent(String content)
          Constructs content of an HTML type.
HtmlContent(String content, String characterSet)
          Constructs content of an HTML type.
HtmlContent(URL url)
          Constructs content of an HTML type from the contents of the URL.
 
Method Summary
protected  void checkExtension(String string)
          Verifies that the file ends in the .html or .htm file extension.
 String toString()
          Constructs a String with all attributes in name = value format.
 
Methods inherited from class net.rim.pushsdk.commons.content.TextContent
getCharacterSet, isEmpty, writeContentTo
 
Methods inherited from class net.rim.pushsdk.commons.content.SinglePartContent
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

HtmlContent

public HtmlContent(String content)
Constructs content of an HTML type. Automatically sets the content type header to text/html. The default platform character encoding (file.encoding) will be used to encode the textual content before being sent over the wire.

Parameters:
content - the textual content

HtmlContent

public HtmlContent(String content,
                   String characterSet)
Constructs content of an HTML type. Automatically sets the content type header to text/html. A character set parameter can be specified; the text content will be encoded into that character set before being sent over the wire.

Parameters:
content - the textual content
characterSet - the character set to encode the textual content

HtmlContent

public HtmlContent(File file)
            throws IOException
Constructs content of an HTML type from the contents of the file. Automatically sets the content type header to text/html. The default platform character encoding (file.encoding) will be used to encode the textual content before being sent over the wire.

Parameters:
file - the text content stored in a file
Throws:
IOException

HtmlContent

public HtmlContent(File file,
                   String characterSet)
            throws IOException
Constructs content of an HTML type from the contents of the file. Automatically sets the content type header to text/html. The text content will be encoded into that character set before being sent over the wire.

Parameters:
file - the text content stored in a file
characterSet - the character set to encode the textual content
Throws:
IOException - if any error occurs regarding the file passed in

HtmlContent

public HtmlContent(URL url)
            throws IOException
Constructs content of an HTML type from the contents of the URL. Automatically sets the content type header to text/html. If the URL has a character set it will be used, otherwise the default platform character encoding (file.encoding) will be used to encode the textual content before being sent over the wire.

Parameters:
url - the content URL
Throws:
IOException
Method Detail

checkExtension

protected void checkExtension(String string)
Verifies that the file ends in the .html or .htm file extension.

Overrides:
checkExtension in class TextContent
Parameters:
string - the file name

toString

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

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


Copyright © 2011 Research In Motion. All Rights Reserved.