Utils
The Utils object provides useful utility functions and properties.
Supported Platform(s)
- BlackBerry OS 5.0+
- BlackBerry PlayBook
- Ripple Emulator
| API | OS 5.0 | OS 6.0 | OS 7.0 | PlayBook | Ripple |
|---|---|---|---|---|---|
| blobToString | Y | Y | Y | Y | Y |
| documentToBlob | Y | ||||
| generateUniqueId | Y | Y | Y | Y | Y |
| parseURL | Y | Y | Y | Y | Y |
| stringToBlob | Y | Y | Y | Y | Y |
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 ID | OS 5.0 | OS 6.0 | OS 7.0 | PlayBook | Ripple |
|---|---|---|---|---|---|
| <feature id="blackberry.utils" /> | Y | Y | Y | Y | Y |
| 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
Functions
** 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:
|
||||||||||||
| 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.0Description
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:
|
||||||||||||
| 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)