net.rim.pushsdk.commons.content
Class XmlContent

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.XmlContent

public class XmlContent
extends TextContent

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

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
XmlContent(File file)
          Constructs content of an XML type from the contents of the file.
XmlContent(File file, String characterSet)
          Constructs content of an XML type from the contents of the file.
XmlContent(String content)
          Constructs content of an XML type.
XmlContent(String content, String characterSet)
          Constructs content of an XML type.
XmlContent(URL url)
          Constructs content of an XML type from the contents of the URL.
 
Method Summary
protected  void checkExtension(String string)
          Verifies that the file ends in the .xml 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

XmlContent

public XmlContent(String content)
Constructs content of an XML type. Automatically sets the content type header to application/xml. 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

XmlContent

public XmlContent(String content,
                  String characterSet)
Constructs content of an XML type. Automatically sets the content type header to application/xml. 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

XmlContent

public XmlContent(File file)
           throws IOException
Constructs content of an XML type from the contents of the file. Automatically sets the content type header to application/xml. 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

XmlContent

public XmlContent(File file,
                  String characterSet)
           throws IOException
Constructs content of an XML type from the contents of the file. Automatically sets the content type header to application/xml. 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

XmlContent

public XmlContent(URL url)
           throws IOException
Constructs content of an XML type from the contents of the URL. Automatically sets the content type header to application/xml. 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 .xml 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.