net.rim.blackberry.api.browser
Class MultipartPostData

java.lang.Object
  extended by net.rim.blackberry.api.browser.PostData
      extended by net.rim.blackberry.api.browser.MultipartPostData

public final class MultipartPostData
extends PostData

Encodes form data for submission as multipart/form-data.

We aim for compatibility with common Web browsers such as IE 6.0 rather than always following the specification in RFC 2388. Deviations include sending 8-bit data without including the Content-Transfer-Encoding header and, when the constructor's useWAPConventions parameter is false, excluding the Content-Type header and its charset parameter even for non-US-ASCII text parts.

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0

Field Summary
Category: Signed static String DEFAULT_CHARSET
          Default character set.
 
Fields inherited from class net.rim.blackberry.api.browser.PostData
ENCTYPE_MULTIPART_FORMDATA, ENCTYPE_URLENCODED
 
Constructor Summary
Category: Signed MultipartPostData(byte[] multipartData)
          Creates a MultipartPostData object from previously-encoded form data.
Category: Signed MultipartPostData(String charset, boolean useWAPConventions)
          Creates a new MultipartPostData instance for encoding form data.
 
Method Summary
Category: Signed  void append(String name, String value)
          Appends the given name-value pair to the form data.
Category: Signed  byte[] getBytes()
          Retrieves the form data as a byte array suitable for use as an HTTP request body.
Category: Signed  String getContentType()
          Retrieves the content type of the form data, including parameters.
Category: Signed  void setData(Object data)
          Sets the form data for this object.
Category: Signed  int size()
          Retrieves the size of the form data (the size of this object's underlying storing byte array).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

DEFAULT_CHARSET

public static final String DEFAULT_CHARSET
Default character set.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0


Constructor Detail

MultipartPostData

public MultipartPostData(String charset,
                         boolean useWAPConventions)
Creates a new MultipartPostData instance for encoding form data.

Parameters:
charset - Character encoding to use when writing the form data; if charset is null or an unsupported character encoding, iso-8859-1 is used
useWAPConventions - True if we should use WAP conventions for encoding the data (for example, explicitly specifying the Content-Type of each part); otherwise, false.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0

MultipartPostData

public MultipartPostData(byte[] multipartData)
Creates a MultipartPostData object from previously-encoded form data.

Parameters:
multipartData - Body of a multipart/form-data request.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0


Method Detail

getContentType

public String getContentType()
Retrieves the content type of the form data, including parameters.

Specified by:
getContentType in class PostData
Returns:
Form data's content type.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0

append

public void append(String name,
                   String value)
Appends the given name-value pair to the form data.

Specified by:
append in class PostData
Parameters:
name - Name of the form control; if the name is null or "", this method does nothing.
value - Value of the form control; a null value is considered equivalent to "".
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0

setData

public void setData(Object data)
Sets the form data for this object.

Specified by:
setData in class PostData
Parameters:
data - the form data in multipart/form-data format; must be a ByteArrayOutputStream or byte array. If the parameter is a ByteArrayOutputStream, the final boundary is appended to the stream; otherwise, no changes are made to the data.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0

getBytes

public byte[] getBytes()
Retrieves the form data as a byte array suitable for use as an HTTP request body.

Specified by:
getBytes in class PostData
Returns:
Form data.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0

size

public int size()
Retrieves the size of the form data (the size of this object's underlying storing byte array).

Specified by:
size in class PostData
Returns:
Size of the form data.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal