net.rim.pushsdk.commons.content
Class ContentType

java.lang.Object
  extended by net.rim.pushsdk.commons.content.ContentType

public class ContentType
extends Object

Represents a MIME content type.

Author:
mdicesare

Field Summary
static String APPLICATION_OCTET_STREAM
          The application/octet-stream content type used for binary content.
static String APPLICATION_XML
          The application/xml content type used for XML content.
static String AUDIO_3GP
          The audio/3gpp content type used for 3GP audio.
static String AUDIO_MP4
          The audio/mp4 content type used for MP4 audio.
static String AUDIO_MPEG
          The audio/mpeg content type used for MPEG audio.
static String BOUNDARY_PARAM
          The boundary parameter.
static String CHARSET_PARAM
          The charset parameter.
static String CONTENT_TYPE
          The content type header name.
static String CONTENT_TYPE_KEY_VALUE_SEPARATOR
          The separator between the content type header name and its value.
static String IMAGE_GIF
          The image/gif content type used for GIF images.
static String IMAGE_JPEG
          The image/jpeg content type used for JPEG images.
static String IMAGE_PNG
          The image/png content type used for PNG images.
static String MULTIPART_MIXED
          The multipart/mixed content type.
static String MULTIPART_RELATED
          The multipart/related content type.
static String TEXT_HTML
          The text/html content type used for HTML.
static String TEXT_PLAIN
          The text/plain content type used for plain text.
static String TYPE_PARAM
          The type parameter.
static String VIDEO_3GP
          The video/3gpp content type used for 3GP video.
static String VIDEO_MP4
          The video/mp4 content type used for MP4 video.
static String VIDEO_MPEG
          The video/mpeg content type used for MPEG video.
 
Constructor Summary
ContentType(String contentType)
          Constructs a MIME content type with the given content type as a string.
ContentType(String contentType, Map<String,String> parameters)
          Constructs a MIME content type with the given content type and map of parameters and their values.
ContentType(String contentType, String parameterName, String parameterValue)
          Constructs a MIME content type with the given content type, and one parameter.
 
Method Summary
 void addParameter(String parameterName, String parameterValue)
          Adds a parameter.
 String getContentType()
          Gets the MIME content.
 String getParameter(String parameterName)
          Gets the value of the parameter with the given name.
 Map<String,String> getParameters()
          Gets the map of parameters and their values.
 String print()
          Gets a string of the content type and its parameters in PAP XML format.
 String toString()
          Constructs a String with all attributes in name = value format.
 void writeTo(ByteArrayOutputStream out)
          Writes out the string from the print() method as bytes to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTENT_TYPE

public static final String CONTENT_TYPE
The content type header name.

See Also:
Constant Field Values

CONTENT_TYPE_KEY_VALUE_SEPARATOR

public static final String CONTENT_TYPE_KEY_VALUE_SEPARATOR
The separator between the content type header name and its value.

See Also:
Constant Field Values

APPLICATION_OCTET_STREAM

public static final String APPLICATION_OCTET_STREAM
The application/octet-stream content type used for binary content.

See Also:
Constant Field Values

APPLICATION_XML

public static final String APPLICATION_XML
The application/xml content type used for XML content.

See Also:
Constant Field Values

MULTIPART_MIXED

public static final String MULTIPART_MIXED
The multipart/mixed content type.

See Also:
Constant Field Values

MULTIPART_RELATED

public static final String MULTIPART_RELATED
The multipart/related content type.

See Also:
Constant Field Values

TEXT_PLAIN

public static final String TEXT_PLAIN
The text/plain content type used for plain text.

See Also:
Constant Field Values

TEXT_HTML

public static final String TEXT_HTML
The text/html content type used for HTML.

See Also:
Constant Field Values

IMAGE_JPEG

public static final String IMAGE_JPEG
The image/jpeg content type used for JPEG images.

See Also:
Constant Field Values

IMAGE_GIF

public static final String IMAGE_GIF
The image/gif content type used for GIF images.

See Also:
Constant Field Values

IMAGE_PNG

public static final String IMAGE_PNG
The image/png content type used for PNG images.

See Also:
Constant Field Values

AUDIO_MPEG

public static final String AUDIO_MPEG
The audio/mpeg content type used for MPEG audio.

See Also:
Constant Field Values

AUDIO_MP4

public static final String AUDIO_MP4
The audio/mp4 content type used for MP4 audio.

See Also:
Constant Field Values

AUDIO_3GP

public static final String AUDIO_3GP
The audio/3gpp content type used for 3GP audio.

See Also:
Constant Field Values

VIDEO_MPEG

public static final String VIDEO_MPEG
The video/mpeg content type used for MPEG video.

See Also:
Constant Field Values

VIDEO_MP4

public static final String VIDEO_MP4
The video/mp4 content type used for MP4 video.

See Also:
Constant Field Values

VIDEO_3GP

public static final String VIDEO_3GP
The video/3gpp content type used for 3GP video.

See Also:
Constant Field Values

TYPE_PARAM

public static final String TYPE_PARAM
The type parameter.

See Also:
Constant Field Values

BOUNDARY_PARAM

public static final String BOUNDARY_PARAM
The boundary parameter.

See Also:
Constant Field Values

CHARSET_PARAM

public static final String CHARSET_PARAM
The charset parameter.

See Also:
Constant Field Values
Constructor Detail

ContentType

public ContentType(String contentType)
Constructs a MIME content type with the given content type as a string.

Parameters:
contentType - the content type as a string

ContentType

public ContentType(String contentType,
                   String parameterName,
                   String parameterValue)
Constructs a MIME content type with the given content type, and one parameter.

Parameters:
contentType - the content type as a string
parameterName - the parameter name
parameterValue - the parameter value

ContentType

public ContentType(String contentType,
                   Map<String,String> parameters)
Constructs a MIME content type with the given content type and map of parameters and their values.

Parameters:
contentType - the content type as a string
parameters - the map of parameters and their values
Method Detail

addParameter

public void addParameter(String parameterName,
                         String parameterValue)
Adds a parameter.

Parameters:
parameterName - the parameter name
parameterValue - the parameter value

getParameter

public String getParameter(String parameterName)
Gets the value of the parameter with the given name.

Parameters:
parameterName - the parameter name
Returns:
the parameter value

getContentType

public String getContentType()
Gets the MIME content.

Returns:
the content type

getParameters

public Map<String,String> getParameters()
Gets the map of parameters and their values.

Returns:
the map of parameters

writeTo

public void writeTo(ByteArrayOutputStream out)
             throws IOException
Writes out the string from the print() method as bytes to the output stream.

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

print

public String print()
Gets a string of the content type and its parameters in PAP XML format.

Returns:
a string of the content type and its parameters

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.