net.rim.pushsdk.commons.content
Class Content

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

public abstract class Content
extends Object

Abstract class that all types of content must extend.

Author:
mdandrea

Field Summary
static byte[] BOUNDARY_DELIMITER_BYTES
          The boundary delimiter in bytes (i.e.
protected  ContentType contentType
          The content type.
protected  HttpHeaderList headers
          The HTTP headers.
static String NEW_LINE
          The new-line character (i.e.
static byte[] NEW_LINE_BYTES
          The new-line character in bytes (i.e.
 
Constructor Summary
Content()
           
 
Method Summary
 void addHeader(String headerName, String headerValue)
          Adds a header; if a header with the same name already exists, the value will be added to the list of existing values.
 ContentType getContentType()
          Gets the content type.
 String getHeader(String headerName)
          Gets the first header value for the given header name.
 List<String> getHeaders(String headerName)
          Gets the header values for the given header name.
abstract  boolean isEmpty()
          Determines whether the content is empty.
 void setContentType(ContentType contentType)
          Sets the content type.
 void setHeader(String headerName, String headerValue)
          Adds a header; if a header with the same name already exists, the value(s) will be replaced with the one specified here.
 String toString()
          Constructs a String with all attributes in name = value format.
 void writeHeadersTo(ByteArrayOutputStream out)
          Writes the headers to the specified output stream.
abstract  void writeTo(ByteArrayOutputStream out)
          Writes the content to the specified output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BOUNDARY_DELIMITER_BYTES

public static final byte[] BOUNDARY_DELIMITER_BYTES
The boundary delimiter in bytes (i.e. --).


NEW_LINE_BYTES

public static final byte[] NEW_LINE_BYTES
The new-line character in bytes (i.e. \n).


NEW_LINE

public static final String NEW_LINE
The new-line character (i.e. \r\n).

See Also:
Constant Field Values

contentType

protected ContentType contentType
The content type.


headers

protected HttpHeaderList headers
The HTTP headers.

Constructor Detail

Content

public Content()
Method Detail

getContentType

public ContentType getContentType()
Gets the content type.

Returns:
the content type

setContentType

public void setContentType(ContentType contentType)
Sets the content type.

Parameters:
contentType - the content type

setHeader

public void setHeader(String headerName,
                      String headerValue)
Adds a header; if a header with the same name already exists, the value(s) will be replaced with the one specified here.

Parameters:
headerName - the header name
headerValue - the header value

addHeader

public void addHeader(String headerName,
                      String headerValue)
Adds a header; if a header with the same name already exists, the value will be added to the list of existing values.

Parameters:
headerName - the header name
headerValue - the header value

getHeader

public String getHeader(String headerName)
Gets the first header value for the given header name.

Parameters:
headerName - the header name
Returns:
the first header value

getHeaders

public List<String> getHeaders(String headerName)
Gets the header values for the given header name.

Parameters:
headerName - the header name
Returns:
the header values

writeHeadersTo

public void writeHeadersTo(ByteArrayOutputStream out)
                    throws IOException
Writes the headers to the specified output stream.

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

writeTo

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

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

isEmpty

public abstract boolean isEmpty()
Determines whether the content is empty.

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 Object
Returns:
a String representation of this object.


Copyright © 2011 Research In Motion. All Rights Reserved.