The API provides the basic definitions that are used in the Tizen Web Device API. These include generic callbacks that are invoked when the operations succeed or fail, WebAPIError and WebAPIException that give information of the platform's error and filter interfaces that are used to make query statements for searching.
Additionally, this API specifies the location in the ECMAScript hierarchy in which the Tizen Web Device API is instantiated (window.tizen).
For more information on the Tizen features, see Data Filtering and Sorting Guide or Error Handling Guide.
Since: 2.4
Interface | Method |
---|---|
TizenObject | |
Tizen | |
AbstractFilter | |
AttributeFilter | |
AttributeRangeFilter | |
CompositeFilter | |
SortMode | |
SimpleCoordinates | |
WebAPIException | |
WebAPIError | |
SuccessCallback | void onsuccess () |
ErrorCallback | void onerror (WebAPIError error) |
enum FilterMatchFlag { "EXACTLY", "FULLSTRING", "CONTAINS", "STARTSWITH", "ENDSWITH", "EXISTS" };
Since: 2.4
These values are supported:
enum SortModeOrder { "ASC", "DESC" };
Since: 2.4
The following values are supported:
enum CompositeFilterType { "UNION", "INTERSECTION" };
Since: 2.4
The following values are supported:
[NoInterfaceObject] interface TizenObject {
readonly attribute Tizen tizen;
};
Window implements TizenObject;
Since: 2.4
The Tizen interface is always available within the Window object in the ECMAScript hierarchy.
[NoInterfaceObject] interface Tizen {
};
Since: 2.4
This is the Tizen root interface. It is a property of the ECMAScript global object, as specified by the TizenObject interface.
[NoInterfaceObject] interface AbstractFilter {
};
Since: 2.4
Never use this base interface directly, instead use AbstractFilter subtypes, such as AttributeFilter, AttributeRangeFilter, and CompositeFilter.
[Constructor(DOMString attributeName, optional FilterMatchFlag? matchFlag, optional any matchValue)]
interface AttributeFilter : AbstractFilter {
attribute DOMString attributeName;
attribute FilterMatchFlag matchFlag setraises(WebAPIException);
attribute any matchValue;
};
Since: 2.4
It represents the query statement for the specified value of matchValue by the rule of matchFlag.
If no matchValue is defined, the filter matches all objects that have the attribute defined (same as the "EXISTS" filter works), otherwise, it only matches objects which have an attribute that match the specified value.
Code example:
// The following example retrieves all songs from the album "The Joshua Tree".
var count = 100;
var offset = 0;
var albumFilter = new tizen.AttributeFilter("album", "EXACTLY", "The Joshua Tree");
function errorCB(err) {
console.log( 'The following error occurred: ' + err.name);
}
function findCB(contents) {
console.log('The Joshua Tree :' + contents.length);
}
tizen.content.find(findCB, errorCB, null, albumFilter, null, count, offset);
AttributeFilter(DOMString attributeName, optional FilterMatchFlag? matchFlag, optional any matchValue);
This is the name of the object attribute exactly as it is defined in the object's interface. For attributes of complex type, use fully-qualified names (such as 'geolocation.latitude' to filter a video or image content's latitude in a geolocation).
For attributes of an array type, the filter will match if any value in the array matches.
Since: 2.4
By default, this attribute is set to "EXACTLY".
Since: 2.4
The filter will match if the attribute value matches the given matchValue.
This value is not used if the matchFlag is set to "EXISTS". By default, this attribute is set to null.
Since: 2.4
[Constructor(DOMString attributeName, optional any initialValue, optional any endValue)]
interface AttributeRangeFilter : AbstractFilter {
attribute DOMString attributeName;
attribute any initialValue;
attribute any endValue;
};
Since: 2.4
Range filters, where only one boundary is set, are available.
Code example:
var count = 100;
var offset = 0;
// Use the modifiedDate attribute with a range that starts today and ends in 1 day
// (meaning that you search for all contents modified today)
var today = new Date();
var today_begin = new Date(today.getFullYear(), today.getMonth(),today.getDate());
var today_end = new Date(today.getFullYear(), today.getMonth(),today.getDate()+1);
var dateRangeFilter = new tizen.AttributeRangeFilter("modifiedDate", today_begin, today_end);
function errorCB(err) {
console.log( 'The following error occurred: ' + err.name);
}
function findCB(contents) {
console.log('The contents modified today :' + contents.length);
}
tizen.content.find(findCB, errorCB, null, dateRangeFilter, null, count, offset);
AttributeRangeFilter(DOMString attributeName, optional any initialValue, optional any endValue);
The value of this attribute is exactly as it is defined in the object's interface. For attributes of complex type, use fully-qualified names (such as 'geolocation.latitude' to filter a video or image content's latitude in a geolocation).
For attributes of array type, the filter will match if any value in the array matches.
Since: 2.4
By default, this attribute is set to null.
Since: 2.4
By default, this attribute is set to null.
Since: 2.4
[Constructor(CompositeFilterType type, optional AbstractFilter[]? filters)]
interface CompositeFilter : AbstractFilter {
attribute CompositeFilterType type;
attribute AbstractFilter[] filters;
};
Since: 2.4
The composite filters can be one of the following 2 types:
Code example:
// The following example retrieves all songs from the album "The Joshua Tree", by artist "U2".
var count = 100;
var offset = 0;
var artistFilter = new tizen.AttributeFilter("artists", "EXACTLY", "U2");
var albumFilter = new tizen.AttributeFilter("album", "EXACTLY", "The Joshua Tree");
var filter = new tizen.CompositeFilter("INTERSECTION", [albumFilter, artistFilter]);
function errorCB(err) {
console.log( 'The following error occurred: ' + err.name);
}
function findCB(contents) {
console.log('The Joshua Tree by U2:' + contents.length);
}
tizen.content.find(findCB, errorCB, null, filter, null, count, offset);
CompositeFilter(CompositeFilterType type, optional AbstractFilter[]? filters);
Since: 2.4
Since: 2.4
[Constructor(DOMString attributeName, optional SortModeOrder? order)]
interface SortMode {
attribute DOMString attributeName;
attribute SortModeOrder order setraises(WebAPIException);
};
Since: 2.4
Note that the sorting result of list type attributes is not determined.
Code example:
// The following example retrieves all songs from the album "The Joshua Tree", by artist "U2", ordered by the track number.
var count = 100;
var offset = 0;
var sortMode = new tizen.SortMode("trackNumber", "ASC");
var artistFilter = new tizen.AttributeFilter("artists", "EXACTLY", "U2");
var albumFilter = new tizen.AttributeFilter("album", "EXACTLY", "The Joshua Tree");
var filter = new tizen.CompositeFilter("INTERSECTION", [albumFilter, artistFilter]);
function errorCB(err) {
console.log( 'The following error occurred: ' + err.name);
}
function printContent(content, index, contents) {
console.log('Track: ' + content.trackNumber + ' Title: ' + content.title + 'Duration: ' + content.duration + 'URL: ' + content.contentURI + 'MIME: ' + content.mimeType);
}
function findCB(contents) {
console.log('The Joshua Tree by U2:');
contents.forEach(printContent);
// Increase the offset as much as the count and then find content again.
if (contents.length == count) {
offset += count;
tizen.content.find(findCB, errorCB, null, filter, sortMode, count, offset);
}
}
tizen.content.find(findCB, errorCB, null, filter, sortMode, count, offset);
SortMode(DOMString attributeName, optional SortModeOrder? order);
Since: 2.4
By default, this attribute is set to ASC.
Since: 2.4
[Constructor(double latitude, double longitude)]
interface SimpleCoordinates {
attribute double latitude setraises(WebAPIException);
attribute double longitude setraises(WebAPIException);
};
Since: 2.4
Latitude and longitude are of the WGS84 datum.
SimpleCoordinates(double latitude, double longitude);
Since: 2.4
Since: 2.4
[NoInterfaceObject]
interface WebAPIException {
readonly attribute unsigned short code;
readonly attribute DOMString name;
readonly attribute DOMString message;
const unsigned short INDEX_SIZE_ERR = 1;
const unsigned short DOMSTRING_SIZE_ERR = 2;
const unsigned short HIERARCHY_REQUEST_ERR = 3;
const unsigned short WRONG_DOCUMENT_ERR = 4;
const unsigned short INVALID_CHARACTER_ERR = 5;
const unsigned short NO_DATA_ALLOWED_ERR = 6;
const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;
const unsigned short NOT_FOUND_ERR = 8;
const unsigned short NOT_SUPPORTED_ERR = 9;
const unsigned short INUSE_ATTRIBUTE_ERR = 10;
const unsigned short INVALID_STATE_ERR = 11;
const unsigned short SYNTAX_ERR = 12;
const unsigned short INVALID_MODIFICATION_ERR = 13;
const unsigned short NAMESPACE_ERR = 14;
const unsigned short INVALID_ACCESS_ERR = 15;
const unsigned short VALIDATION_ERR = 16;
const unsigned short TYPE_MISMATCH_ERR = 17;
const unsigned short SECURITY_ERR = 18;
const unsigned short NETWORK_ERR = 19;
const unsigned short ABORT_ERR = 20;
const unsigned short URL_MISMATCH_ERR = 21;
const unsigned short QUOTA_EXCEEDED_ERR = 22;
const unsigned short TIMEOUT_ERR = 23;
const unsigned short INVALID_NODE_TYPE_ERR = 24;
const unsigned short DATA_CLONE_ERR = 25;
};
Since: 2.4
This interface will be used by the APIs to throw errors synchronously.
The attempt to set an attribute value may or may not raise WebAPIException synchronously with error type TypeMismatchError or InvalidValuesError.
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
For the possible values of this attribute, see DOMException.
Since: 2.4
This attribute can have one of the following values:
For other possible values of this attribute, see the values defined in DOM error names
Since: 2.4
This attribute is mainly intended to be used for developers rather than end users, so it should not be used directly in the user interfaces as it is.
Since: 2.4
[NoInterfaceObject]
interface WebAPIError {
readonly attribute unsigned short code;
readonly attribute DOMString name;
readonly attribute DOMString message;
};
Since: 2.4
This interface will be used by the APIs in order to return them in the error callback of asynchronous methods.
Possible values are defined in DOMException.
Since: 2.4
This attribute can have one of the following values:
For other possible values of this attribute, see the values defined in DOM error names
Since: 2.4
This attribute is not intended to be used directly in the user interfaces as it is mainly intended to be useful for developers rather than end users.
Since: 2.4
[Callback=FunctionOnly, NoInterfaceObject]
interface SuccessCallback {
void onsuccess ();
};
Since: 2.4
In case of successful execution of an asynchronous call, SuccessCallback or an API defined callback must be called immediately to notify the user.
Code example:
function onSuccess() {
console.log("Application launched successfully");
}
tizen.application.launch('0pnxz8hbsr.MyFiles', onSuccess);
[Callback=FunctionOnly, NoInterfaceObject]
interface ErrorCallback {
void onerror (WebAPIError error);
};
Since: 2.4
If an invalid function (such as null) is passed to the API that accepts ErrorCallback, it silently fails and there is no further action.
Code example:
// Define the error callback.
function onerror(error) {
console.log(error.message);
}
function onsuccess() {
console.log("The application has launched successfully");
}
tizen.application.launch("targetApp0.main", onsuccess, onerror);
onerror
void onerror(WebAPIError error);
Since: 2.4
Parameters:
module Tizen {
enum FilterMatchFlag { "EXACTLY", "FULLSTRING", "CONTAINS", "STARTSWITH", "ENDSWITH", "EXISTS" };
enum SortModeOrder { "ASC", "DESC" };
enum CompositeFilterType { "UNION", "INTERSECTION" };
[NoInterfaceObject] interface TizenObject {
readonly attribute Tizen tizen;
};
Window implements TizenObject;
[NoInterfaceObject] interface Tizen {
};
[NoInterfaceObject] interface AbstractFilter {
};
[Constructor(DOMString attributeName, optional FilterMatchFlag? matchFlag, optional any matchValue)]
interface AttributeFilter : AbstractFilter {
attribute DOMString attributeName;
attribute FilterMatchFlag matchFlag setraises(WebAPIException);
attribute any matchValue;
};
[Constructor(DOMString attributeName, optional any initialValue, optional any endValue)]
interface AttributeRangeFilter : AbstractFilter {
attribute DOMString attributeName;
attribute any initialValue;
attribute any endValue;
};
[Constructor(CompositeFilterType type, optional AbstractFilter[]? filters)]
interface CompositeFilter : AbstractFilter {
attribute CompositeFilterType type;
attribute AbstractFilter[] filters;
};
[Constructor(DOMString attributeName, optional SortModeOrder? order)]
interface SortMode {
attribute DOMString attributeName;
attribute SortModeOrder order setraises(WebAPIException);
};
[Constructor(double latitude, double longitude)]
interface SimpleCoordinates {
attribute double latitude setraises(WebAPIException);
attribute double longitude setraises(WebAPIException);
};
[NoInterfaceObject]
interface WebAPIException {
readonly attribute unsigned short code;
readonly attribute DOMString name;
readonly attribute DOMString message;
const unsigned short INDEX_SIZE_ERR = 1;
const unsigned short DOMSTRING_SIZE_ERR = 2;
const unsigned short HIERARCHY_REQUEST_ERR = 3;
const unsigned short WRONG_DOCUMENT_ERR = 4;
const unsigned short INVALID_CHARACTER_ERR = 5;
const unsigned short NO_DATA_ALLOWED_ERR = 6;
const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;
const unsigned short NOT_FOUND_ERR = 8;
const unsigned short NOT_SUPPORTED_ERR = 9;
const unsigned short INUSE_ATTRIBUTE_ERR = 10;
const unsigned short INVALID_STATE_ERR = 11;
const unsigned short SYNTAX_ERR = 12;
const unsigned short INVALID_MODIFICATION_ERR = 13;
const unsigned short NAMESPACE_ERR = 14;
const unsigned short INVALID_ACCESS_ERR = 15;
const unsigned short VALIDATION_ERR = 16;
const unsigned short TYPE_MISMATCH_ERR = 17;
const unsigned short SECURITY_ERR = 18;
const unsigned short NETWORK_ERR = 19;
const unsigned short ABORT_ERR = 20;
const unsigned short URL_MISMATCH_ERR = 21;
const unsigned short QUOTA_EXCEEDED_ERR = 22;
const unsigned short TIMEOUT_ERR = 23;
const unsigned short INVALID_NODE_TYPE_ERR = 24;
const unsigned short DATA_CLONE_ERR = 25;
};
[NoInterfaceObject]
interface WebAPIError {
readonly attribute unsigned short code;
readonly attribute DOMString name;
readonly attribute DOMString message;
};
[Callback=FunctionOnly, NoInterfaceObject]
interface SuccessCallback {
void onsuccess ();
};
[Callback=FunctionOnly, NoInterfaceObject]
interface ErrorCallback {
void onerror (WebAPIError error);
};
};