elemental.html.IDBFactory Maven / Gradle / Ivy
Show all versions of xapi-gwt Show documentation
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package elemental.html;
import elemental.events.*;
import elemental.util.*;
import elemental.dom.*;
import elemental.html.*;
import elemental.css.*;
import elemental.stylesheets.*;
import java.util.Date;
/**
* The IDBFactory
interface of the IndexedDB API lets applications asynchronously access the indexed databases. The object that implements the interface is window.indexedDB
. You open—that is, create and access—and delete a database with the object and not directly with IDBFactory
.
This interface still has vendor prefixes, that is to say, you have to make calls with mozIndexedDB.open()
for Firefox and webkitIndexedDB.open()
for Chrome.
*/
public interface IDBFactory {
/**
* Compares two values as keys to determine equality and ordering for IndexedDB operations, such as storing and iterating. Do not use this method for comparing arbitrary JavaScript values, because many JavaScript values are either not valid IndexedDB keys (booleans and objects, for example) or are treated as equivalent IndexedDB keys (for example, since IndexedDB ignores arrays with non-numeric properties and treats them as empty arrays, so any non-numeric array are treated as equivalent).
This throws an exception if either of the values is not a valid key.
Parameters
- first
- The first key to compare.
- second
- The second key to compare.
Returns
- Integer
-
Returned value Description -1 1st key < 2nd 0 1st key = 2nd 1 1st key > 2nd
Exceptions
This method can raise an IDBDatabaseException with the following code:
Attribute Description NON_TRANSIENT_ERR
One of the supplied keys was not a valid key.
*/
short cmp(Object first, Object second);
/**
* Request deleting a database. The method returns an IDBRequest object immediately, and performs the deletion operation asynchronously.
The deletion operation (performed in a different thread) consists of the following steps:
- If there is no database with the given name, exit successfully.
- Fire an IDBVersionChangeEvent at all connection objects connected to the named database, with
version
set to null
. - If any connection objects connected to the database are still open, fire a
blocked
event at the request object returned by the deleteDatabase
method, using IDBVersionChangeEvent with version
set to null
. - Wait until all open connections to the database are closed.
- Delete the database.
If the database is successfully deleted, then an IDBSuccessEvent is fired on the request object returned from this method, with its result
set to null
.
If an error occurs while the database is being deleted, then an error event is fired on the request object that is returned from this method, with its code
and message
set to appropriate values.
Tip: If the browser you are using hasn't implemented this yet, you can delete the object stores one by one, thus effectively removing the database.
Parameters
- name
- The name of the database.
Returns
IDBRequest
- A request object on which subsequent events related to this request are fired. In the latest draft of the specification, which has not yet been implemented by browsers, the returned object is
IDBOpenRequest
.
*/
IDBVersionChangeRequest deleteDatabase(String name);
IDBRequest getDatabaseNames();
/**
* Warning: The description documents the old specification. Some browsers still implement this method. The specifications have changed, but the changes have not yet been implemented by all browser. See the compatibility table for more information.
Request opening a connection to a database. The method returns an IDBRequest object immediately, and performs the opening operation asynchronously.
The opening operation—which is performed in a separate thread—consists of the following steps:
- If a database named
myAwesomeDatabase
already exists: - Wait until any existing
VERSION_CHANGE
transactions have finished. - If the database has a deletion pending, wait until it has been deleted.
- If no database with that name exists, create a database with the provided name, with the empty string as its version, and no object stores.
- Create a connection to the database.
If the operation is successful, an IDBSuccessEvent is fired on the request object that is returned from this method, with its result attribute set to the new IDBDatabase object for the connection.
If an error occurs while the database connection is being opened, then an error event is fired on the request object returned from this method, with its code
and message
set to appropriate values.
Parameters
- name
- The name of the database.
- version
- The version of the database.
Returns
IDBRequest
- A request object on which subsequent events related to this request are fired. In the latest draft of the specification, which has not yet been implemented by browsers, the returned object is
IDBOpenRequest
.
*/
IDBRequest open(String name);
}