mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
More IndexedDB wrappers
This commit is contained in:
parent
2e4af24c99
commit
c3f8764bdc
|
@ -15,12 +15,44 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.dom.indexeddb;
|
package org.teavm.dom.indexeddb;
|
||||||
|
|
||||||
|
import org.teavm.jso.JSMethod;
|
||||||
import org.teavm.jso.JSObject;
|
import org.teavm.jso.JSObject;
|
||||||
|
import org.teavm.jso.JSProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface IDBCursor extends JSObject {
|
public interface IDBCursor extends JSObject {
|
||||||
|
String DIRECTION_NEXT = "next";
|
||||||
|
|
||||||
|
String DIRECTION_NEXT_UNIQUE = "nextunique";
|
||||||
|
|
||||||
|
String DIRECTION_PREVIOUS = "prev";
|
||||||
|
|
||||||
|
String DIRECTION_PREVIOUS_UNIQUE = "prevunique";
|
||||||
|
|
||||||
|
@JSProperty
|
||||||
|
IDBCursorSource getSource();
|
||||||
|
|
||||||
|
@JSProperty
|
||||||
|
String getDirection();
|
||||||
|
|
||||||
|
@JSProperty
|
||||||
|
JSObject getKey();
|
||||||
|
|
||||||
|
@JSProperty
|
||||||
|
JSObject getValue();
|
||||||
|
|
||||||
|
@JSProperty
|
||||||
|
JSObject getPrimaryKey();
|
||||||
|
|
||||||
|
IDBRequest update(JSObject value);
|
||||||
|
|
||||||
|
void advance(int count);
|
||||||
|
|
||||||
|
@JSMethod("continue")
|
||||||
|
void doContinue();
|
||||||
|
|
||||||
|
IDBRequest delete();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.teavm.dom.indexeddb;
|
||||||
|
|
||||||
|
import org.teavm.jso.JSObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexey Andreev
|
||||||
|
*/
|
||||||
|
public interface IDBCursorSource extends JSObject {
|
||||||
|
}
|
|
@ -15,12 +15,49 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.dom.indexeddb;
|
package org.teavm.dom.indexeddb;
|
||||||
|
|
||||||
|
import org.teavm.jso.JS;
|
||||||
import org.teavm.jso.JSObject;
|
import org.teavm.jso.JSObject;
|
||||||
|
import org.teavm.jso.JSProperty;
|
||||||
|
import org.teavm.jso.JSStringArray;
|
||||||
|
import org.teavm.jso.JSType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface IDBIndex extends JSObject {
|
public abstract class IDBIndex implements JSObject, IDBCursorSource {
|
||||||
|
@JSProperty
|
||||||
|
public abstract String getName();
|
||||||
|
|
||||||
|
@JSProperty("keyPath")
|
||||||
|
abstract JSObject getKeyPathImpl();
|
||||||
|
|
||||||
|
public final String[] getKeyPath() {
|
||||||
|
JSObject result = getKeyPathImpl();
|
||||||
|
if (JS.getType(result) == JSType.STRING) {
|
||||||
|
return new String[] { JS.unwrapString(result) };
|
||||||
|
} else {
|
||||||
|
return JS.unwrapArray((JSStringArray)result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSProperty
|
||||||
|
public abstract boolean isMultiEntry();
|
||||||
|
|
||||||
|
@JSProperty
|
||||||
|
public abstract boolean isUnique();
|
||||||
|
|
||||||
|
public abstract IDBCursorRequest openCursor();
|
||||||
|
|
||||||
|
public abstract IDBCursorRequest openCursor(IDBKeyRange range);
|
||||||
|
|
||||||
|
public abstract IDBCursorRequest openKeyCursor();
|
||||||
|
|
||||||
|
public abstract IDBGetRequest get(JSObject key);
|
||||||
|
|
||||||
|
public abstract IDBGetRequest getKey(JSObject key);
|
||||||
|
|
||||||
|
public abstract IDBCountRequest count(JSObject key);
|
||||||
|
|
||||||
|
public abstract IDBCountRequest count();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package org.teavm.dom.indexeddb;
|
||||||
|
|
||||||
|
import org.teavm.jso.JSBody;
|
||||||
|
import org.teavm.jso.JSObject;
|
||||||
|
import org.teavm.jso.JSProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexey Andreev
|
||||||
|
*/
|
||||||
|
public abstract class IDBKeyRange implements JSObject {
|
||||||
|
@JSProperty
|
||||||
|
public abstract JSObject getLower();
|
||||||
|
|
||||||
|
@JSProperty
|
||||||
|
public abstract JSObject getUpper();
|
||||||
|
|
||||||
|
@JSProperty
|
||||||
|
public abstract boolean isLowerOpen();
|
||||||
|
|
||||||
|
@JSProperty
|
||||||
|
public abstract boolean isUpperOpen();
|
||||||
|
|
||||||
|
@JSBody(params = "value", script = "return IDBKeyRange.only(value);")
|
||||||
|
public static native IDBKeyRange only(JSObject value);
|
||||||
|
|
||||||
|
@JSBody(params = { "lower", "open" }, script = "return IDBKeyRange.lowerBound(lower, open);")
|
||||||
|
public static native IDBKeyRange lowerBound(JSObject lower, boolean open);
|
||||||
|
|
||||||
|
public static IDBKeyRange lowerBound(JSObject lower) {
|
||||||
|
return lowerBound(lower, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSBody(params = { "upper", "open" }, script = "return IDBKeyRange.upperBound(upper, open);")
|
||||||
|
public static native IDBKeyRange upperBound(JSObject upper, boolean open);
|
||||||
|
|
||||||
|
public static IDBKeyRange upperBound(JSObject upper) {
|
||||||
|
return upperBound(upper, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSBody(params = { "lower", "upper", "lowerOpen", "upperOpen" },
|
||||||
|
script = "return IDBKeyRange.bound(lower, upper, lowerOpen, upperOpen);")
|
||||||
|
public static native IDBKeyRange bound(JSObject lower, JSObject upper, boolean lowerOpen, boolean upperOpen);
|
||||||
|
|
||||||
|
public static IDBKeyRange bound(JSObject lower, JSObject upper) {
|
||||||
|
return bound(lower, upper, false, false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ import org.teavm.jso.*;
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public abstract class IDBObjectStore implements JSObject {
|
public abstract class IDBObjectStore implements JSObject, IDBCursorSource {
|
||||||
@JSProperty
|
@JSProperty
|
||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ public abstract class IDBObjectStore implements JSObject {
|
||||||
|
|
||||||
public abstract IDBCursorRequest openCursor();
|
public abstract IDBCursorRequest openCursor();
|
||||||
|
|
||||||
|
public abstract IDBCursorRequest openCursor(IDBKeyRange range);
|
||||||
|
|
||||||
public abstract IDBIndex createIndex(String name, String key);
|
public abstract IDBIndex createIndex(String name, String key);
|
||||||
|
|
||||||
public abstract IDBIndex createIndex(String name, String[] keys);
|
public abstract IDBIndex createIndex(String name, String[] keys);
|
||||||
|
|
|
@ -23,6 +23,9 @@ import org.teavm.jso.JSProperty;
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface IDBOpenDBRequest extends IDBRequest {
|
public interface IDBOpenDBRequest extends IDBRequest {
|
||||||
|
@JSProperty
|
||||||
|
IDBDatabase getResult();
|
||||||
|
|
||||||
@JSProperty
|
@JSProperty
|
||||||
void setOnBlocked(EventHandler handler);
|
void setOnBlocked(EventHandler handler);
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,34 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.dom.indexeddb;
|
package org.teavm.dom.indexeddb;
|
||||||
|
|
||||||
|
import org.teavm.dom.events.EventTarget;
|
||||||
import org.teavm.jso.JSObject;
|
import org.teavm.jso.JSObject;
|
||||||
|
import org.teavm.jso.JSProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface IDBTransaction extends JSObject {
|
public interface IDBTransaction extends JSObject, EventTarget {
|
||||||
|
@JSProperty
|
||||||
|
String getMode();
|
||||||
|
|
||||||
|
@JSProperty
|
||||||
|
IDBDatabase getDb();
|
||||||
|
|
||||||
|
@JSProperty
|
||||||
|
IDBError getError();
|
||||||
|
|
||||||
|
IDBObjectStore objectStore(String name);
|
||||||
|
|
||||||
|
void abort();
|
||||||
|
|
||||||
|
@JSProperty("onabort")
|
||||||
|
void setOnAbort(EventHandler handler);
|
||||||
|
|
||||||
|
@JSProperty("oncomplete")
|
||||||
|
void setOnComplete(EventHandler handler);
|
||||||
|
|
||||||
|
@JSProperty("onerror")
|
||||||
|
void setOnError(EventHandler handler);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user