Utils

The Utils object provides useful utility functions and properties.

Supported Platform(s)

- BlackBerry OS 5.0+
- BlackBerry PlayBook
- Ripple Emulator

View Supported Platform Table

APIOS 5.0OS 6.0OS 7.0PlayBookRipple
blobToString Y Y Y YY
documentToBlob Y       
generateUniqueId Y Y Y YY
parseURL Y Y Y YY
stringToBlob Y Y Y YY

Configuration Document Settings

To use all of the API described for this object, you must ensure the following settings are in your configuration document:


You must declare the feature element(s) below in your configuration document:

Feature IDOS 5.0OS 6.0OS 7.0PlayBookRipple
<feature id="blackberry.utils" /> Y Y Y YY

Permission Elements (PlayBook Only)
This API does not require a <permission> element to be declared in the configuration document of your BlackBerry WebWorks Application.

API Summary


** Marked for Deprecation

blobToString


static String blobToString(blob : Blob, [encoding: String])

Supported Platform(s)

 - BlackBerry OS 5.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Construct a new String by converting the blob using the specified character encoding



Returns

The String result from converting the Blob

Parameter Type Description
blob Blob The Blob object to be converted.
The acceptable blob size is documented below:
 OS 5.0OS 6.0OS 7.0
BASE64<= 89,678 bytes
Other Encodings<= 524,288 bytes (512KB)<= 2,097,152 bytes (2MB)<= 524,236 bytes (511KB)
encoding String
Optional
[Default Value: ISO-8859-1]

The name of a supported character encoding.BlackBerry supports the following character encodings: ISO-8859-1, UTF-8, UTF-16BE, US-ASCII. Besides these encodings, Web API also supports BASE64 encoding. Support of other encodings depends on the configuration of the BlackBerry Smartphone.

documentToBlob


static Blob documentToBlob(doc : Document)

Deprecation Notice:

This API is deprecated, please use stringToBlob instead.

For example:
var foo = blackberry.utils.stringToBlob( document.toString() );

Supported Platform(s)

 - BlackBerry OS 5.0

Description

Convert a document into a Blob. Supported in 5.0.0 only.



Returns

The Blob result from converting the Document

Parameter Type Description
doc Document The document to be converted.

generateUniqueId


static Number generateUniqueId()

Supported Platform(s)

 - BlackBerry OS 5.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

This method will generate a unique number.



Returns

A unique number from JavaScript's Math.random() function.

parseURL


static blackberry.utils.URL parseURL(url : String)

Supported Platform(s)

 - BlackBerry OS 5.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Parses a URL string and returns an URL object.



Returns

A blackberry.utils.URL object is returned if the parsing is successful.

Parameter Type Description
url String The URL string to be parsed.

stringToBlob


static Blob stringToBlob(str : String, [encoding: String])

Supported Platform(s)

 - BlackBerry OS 5.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Convert a string object into a Blob using the specified character encoding.



Returns

The Blob result from converting the String

Parameter Type Description
str String The string to be converted.
The acceptable string length is documented below:
 OS 5.0OS 6.0OS 7.0
BASE64<= 65,535
Other Encodings<= 524,288<= 2,097,152<= 524,236
encoding String
Optional
[Default Value: ISO-8859-1]

The name of a supported character encoding.BlackBerry supports the following character encodings: ISO-8859-1, UTF-8, UTF-16BE, US-ASCII. Besides these encodings, Web API also supports BASE64 encoding. Support of other encodings depends on the configuration of the BlackBerry Smartphone.


Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 30 2012 13:31:21 GMT-0500 (EST)