提交 473d0c6c authored 作者: Noel Grandin's avatar Noel Grandin

remove unfinished android API

was never finished to a degree that anyone was actually using it, can always be resurrected from git
上级 d4ed1a5d
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.app;
import android.content.Context;
/**
* Something a user can do.
*/
public class Activity extends Context {
// TODO
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0, Version 1.0,
and under the Eclipse Public License, Version 1.0
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p>
This package contains classes that are needed to compile the H2 Android database API.
</p></body></html>
\ No newline at end of file
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.content;
/**
* TODO
*/
public class ContentResolver {
// empty
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.content;
/**
* A key-value pair.
*/
public class ContentValues {
// TODO
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.content;
/**
* TODO
*/
public class Context {
/**
* The file may only be accessed by this application, or by application with
* the same user ID.
*/
public static final int MODE_PRIVATE = 0;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0, Version 1.0,
and under the Eclipse Public License, Version 1.0
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p>
This package contains classes that are needed to compile the H2 Android database API.
</p></body></html>
\ No newline at end of file
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.database;
/**
* This class implements some of the cursor operations.
*/
public abstract class AbstractCursor implements Cursor {
// empty
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.database;
/**
* The base class for a database cursor.
*/
public abstract class AbstractWindowedCursor extends AbstractCursor {
// empty
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.database;
/**
* TODO
*/
public class CharArrayBuffer {
// empty
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.database;
/**
* TODO
*/
public class ContentObserver {
// empty
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.database;
import android.content.ContentResolver;
import android.net.Uri;
import android.os.Bundle;
/**
* This interface allows to access the rows in a result set.
*/
public interface Cursor {
/**
* Get the row count.
*
* @return the row count
*/
int getCount();
/**
* Deactivate the cursor. The cursor can be re-activated using requery().
*/
void deactivate();
/**
* Get the column index. The first column is 0.
*
* @param columnName the name of the column
* @return the column index, or -1 if the column was not found
*/
int getColumnIndex(String columnName);
/**
* Close the cursor.
*/
void close();
/**
* Get the column names.
*
* @return the column names
*/
String[] getColumnNames();
/**
* Register a data set observer.
*
* @param observer the observer
*/
void registerDataSetObserver(DataSetObserver observer);
/**
* Re-run the query.
*
* @return TODO
*/
boolean requery();
/**
* Move the cursor by the given number of rows forward or backward.
*
* @param offset the row offset
* @return true if the operation was successful
*/
boolean move(int offset);
/**
* TODO
*/
void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer);
/**
* Get the value from the current row.
*
* @param columnIndex the column index (0, 1,...)
* @return the value
*/
byte[] getBlob(int columnIndex);
/**
* Get the number of columns in the result.
*
* @return the column count
*/
int getColumnCount();
/**
* Get the column index for the given column name, or throw an exception if
* not found.
*
* @param columnName the column name
* @return the index
*/
int getColumnIndexOrThrow(String columnName);
/**
* Get the name of the given column.
*
* @param columnIndex the column index (0, 1,...)
* @return the name
*/
String getColumnName(int columnIndex);
/**
* Get the value from the current row.
*
* @param columnIndex the column index (0, 1,...)
* @return the value
*/
double getDouble(int columnIndex);
/**
* TODO
*
* @return TODO
*/
Bundle getExtras();
/**
* Get the value from the current row.
*
* @param columnIndex the column index (0, 1,...)
* @return the value
*/
float getFloat(int columnIndex);
/**
* Get the value from the current row.
*
* @param columnIndex the column index (0, 1,...)
* @return the value
*/
int getInt(int columnIndex);
/**
* Get the value from the current row.
*
* @param columnIndex the column index (0, 1,...)
* @return the value
*/
long getLong(int columnIndex);
/**
* Get the current row number
*
* @return the row number TODO 0, 1,...
*/
int getPosition();
/**
* Get the value from the current row.
*
* @param columnIndex the column index (0, 1,...)
* @return the value
*/
short getShort(int columnIndex);
/**
* Get the value from the current row.
*
* @param columnIndex the column index (0, 1,...)
* @return the value
*/
String getString(int columnIndex);
/**
* The method onMove is only called if this method returns true.
*
* @return true if calling onMove is required
*/
boolean getWantsAllOnMoveCalls();
/**
* Check if the current position is past the last row.
*
* @return true if it is
*/
boolean isAfterLast();
/**
* Check if the current position is before the first row.
*
* @return true if it is
*/
boolean isBeforeFirst();
/**
* Check if the cursor is closed.
*
* @return true if it is
*/
boolean isClosed();
/**
* Check if the current position is on the first row.
*
* @return true if it is
*/
boolean isFirst();
/**
* Check if the current position is on the last row.
*
* @return true if it is
*/
boolean isLast();
/**
* Check if the value of the current row is null.
*
* @param columnIndex the column index (0, 1,...)
* @return true if it is
*/
boolean isNull(int columnIndex);
/**
* Move to the first row.
*
* @return TODO
*/
boolean moveToFirst();
/**
* Move to the last row.
*
* @return TODO
*/
boolean moveToLast();
/**
* Move to the next row.
*
* @return TODO
*/
boolean moveToNext();
/**
* Move to the given row.
*
* @param position TODO
* @return TODO
*/
boolean moveToPosition(int position);
/**
* Move to the previous row.
*
* @return TODO
*/
boolean moveToPrevious();
/**
* TODO
*
* @param observer TODO
*/
void registerContentObserver(ContentObserver observer);
/**
* TODO
*
* @param extras TODO
* @return TODO
*/
Bundle respond(Bundle extras);
/**
* TODO
*
* @param cr TODO
* @param uri TODO
*/
void setNotificationUri(ContentResolver cr, Uri uri);
/**
* TODO
*
* @param observer TODO
*/
void unregisterContentObserver(ContentObserver observer);
/**
* TODO
*
* @param observer TODO
*/
void unregisterDataSetObserver(DataSetObserver observer);
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.database;
/**
* An instance of this class can contain multiple rows.
*/
public class CursorWindow {
// empty
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.database;
/**
* A listener for changes in a data set.
*/
public abstract class DataSetObserver {
// empty
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.database;
/**
* A database exception.
*/
public class SQLException extends Exception {
private static final long serialVersionUID = 1L;
public SQLException() {
super();
}
public SQLException(String error) {
super(error);
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0, Version 1.0,
and under the Eclipse Public License, Version 1.0
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p>
This package contains classes that are needed to compile the H2 Android database API.
</p></body></html>
\ No newline at end of file
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.database.sqlite;
/**
* An object that can be closed.
*/
public abstract class SQLiteClosable {
// empty
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0, Version 1.0,
and under the Eclipse Public License, Version 1.0
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p>
This package contains classes that are needed to compile the H2 Android database API.
</p></body></html>
\ No newline at end of file
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.net;
/**
* TODO
*/
public class Uri {
// empty
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0, Version 1.0,
and under the Eclipse Public License, Version 1.0
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p>
This package contains classes that are needed to compile the H2 Android database API.
</p></body></html>
\ No newline at end of file
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.os;
/**
* TODO
*/
public class Bundle {
// empty
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0, Version 1.0,
and under the Eclipse Public License, Version 1.0
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p>
This package contains classes that are needed to compile the H2 Android database API.
</p></body></html>
\ No newline at end of file
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package android.test;
import org.h2.android.H2Database;
import org.h2.android.H2Utils;
import android.app.Activity;
import android.database.Cursor;
/**
* Tests the Android API.
*/
public class Test extends Activity {
public static void main(String... args) throws Exception {
H2Database db = H2Utils.openOrCreateDatabase(
"helloWorld.db", MODE_PRIVATE, null);
log("opened ps=" + db.getPageSize());
try {
// db.execSQL("DROP TABLE IF EXISTS test");
// log("dropped");
db.execSQL(
"CREATE TABLE if not exists test(ID INTEGER PRIMARY KEY, NAME VARCHAR)");
log("created");
for (int j = 0; j < 10; j++) {
Cursor c = db.rawQuery("select * from test", new String[0]);
int count = c.getCount();
for (int i = 0; i < count; i++) {
c.move(1);
c.getInt(0);
c.getString(1);
}
c.close();
}
// log("select " + count);
db.execSQL("delete from test");
log("delete");
db.beginTransaction();
for (int i = 0; i < 1000; i++) {
db.execSQL(
"INSERT INTO TEST VALUES(?, 'Hello')", new Object[] { i });
}
db.setTransactionSuccessful();
db.endTransaction();
log("inserted");
for (int i = 0; i < 10; i++) {
Cursor c = db.rawQuery(
"select * from test where id=?", new String[] { "" + i });
int count = c.getCount();
if (count > 0) {
c.move(1);
c.getInt(0);
c.getString(1);
}
c.close();
}
log("select");
} finally {
db.close();
log("closed");
}
}
private static void log(String s) {
System.out.println(s);
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0, Version 1.0,
and under the Eclipse Public License, Version 1.0
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p>
This package contains tests.
</p></body></html>
\ No newline at end of file
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
/**
* This exception is thrown when the operation was aborted.
*/
public class H2AbortException extends H2Exception {
private static final long serialVersionUID = 1L;
H2AbortException() {
super();
}
H2AbortException(String error) {
super(error);
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
import android.database.sqlite.SQLiteClosable;
/**
* An object that can be closed.
*/
public abstract class H2Closable extends SQLiteClosable {
/**
* TODO
*/
public void acquireReference() {
// TODO
}
/**
* TODO
*/
public void releaseReference() {
// TODO
}
/**
* TODO
*/
public void releaseReferenceFromContainer() {
// TODO
}
/**
* TODO
*/
protected abstract void onAllReferencesReleased();
/**
* TODO
*/
protected void onAllReferencesReleasedFromContainer() {
// TODO
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
/**
* This exception is thrown when a constraint was violated.
*/
public class H2ConstraintException extends H2Exception {
private static final long serialVersionUID = 1L;
H2ConstraintException() {
super();
}
H2ConstraintException(String error) {
super(error);
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
import org.h2.result.ResultInterface;
import android.content.ContentResolver;
import android.database.AbstractWindowedCursor;
import android.database.CharArrayBuffer;
import android.database.ContentObserver;
import android.database.CursorWindow;
import android.database.DataSetObserver;
import android.net.Uri;
import android.os.Bundle;
/**
* A cursor implementation.
*/
@SuppressWarnings("unused")
public class H2Cursor extends AbstractWindowedCursor {
private H2Database database;
private ResultInterface result;
H2Cursor(H2Database db, H2CursorDriver driver, String editTable,
H2Query query) {
this.database = db;
// TODO
}
H2Cursor(ResultInterface result) {
this.result = result;
}
@Override
public void close() {
result.close();
}
@Override
public void deactivate() {
// TODO
}
@Override
public int getColumnIndex(String columnName) {
return 0;
}
@Override
public String[] getColumnNames() {
return null;
}
@Override
public int getCount() {
return result.isLazy() ? -1 : result.getRowCount();
}
/**
* Get the database that created this cursor.
*
* @return the database
*/
public H2Database getDatabase() {
return database;
}
/**
* The cursor moved to a new position.
*
* @param oldPosition the previous position
* @param newPosition the new position
* @return TODO
*/
public boolean onMove(int oldPosition, int newPosition) {
return false;
}
@Override
public void registerDataSetObserver(DataSetObserver observer) {
// TODO
}
@Override
public boolean requery() {
return false;
}
/**
* Set the parameter values.
*
* @param selectionArgs the parameter values
*/
public void setSelectionArguments(String[] selectionArgs) {
// TODO
}
/**
* TODO
*
* @param window the window
*/
public void setWindow(CursorWindow window) {
// TODO
}
@Override
public boolean move(int offset) {
if (offset == 1) {
return result.next();
}
throw H2Database.unsupported();
}
@Override
public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {
// TODO
}
@Override
public byte[] getBlob(int columnIndex) {
// TODO
return null;
}
@Override
public int getColumnCount() {
// TODO
return 0;
}
@Override
public int getColumnIndexOrThrow(String columnName) {
// TODO
return 0;
}
@Override
public String getColumnName(int columnIndex) {
// TODO
return null;
}
@Override
public double getDouble(int columnIndex) {
// TODO
return 0;
}
@Override
public Bundle getExtras() {
// TODO
return null;
}
@Override
public float getFloat(int columnIndex) {
// TODO
return 0;
}
@Override
public int getInt(int columnIndex) {
return result.currentRow()[columnIndex].getInt();
}
@Override
public long getLong(int columnIndex) {
return result.currentRow()[columnIndex].getLong();
}
@Override
public int getPosition() {
// TODO
return 0;
}
@Override
public short getShort(int columnIndex) {
// TODO
return 0;
}
@Override
public String getString(int columnIndex) {
return result.currentRow()[columnIndex].getString();
}
@Override
public boolean getWantsAllOnMoveCalls() {
// TODO
return false;
}
@Override
public boolean isAfterLast() {
// TODO
return false;
}
@Override
public boolean isBeforeFirst() {
// TODO
return false;
}
@Override
public boolean isClosed() {
// TODO
return false;
}
@Override
public boolean isFirst() {
// TODO
return false;
}
@Override
public boolean isLast() {
// TODO
return false;
}
@Override
public boolean isNull(int columnIndex) {
// TODO
return false;
}
@Override
public boolean moveToFirst() {
// TODO
return false;
}
@Override
public boolean moveToLast() {
// TODO
return false;
}
@Override
public boolean moveToNext() {
// TODO
return false;
}
@Override
public boolean moveToPosition(int position) {
// TODO
return false;
}
@Override
public boolean moveToPrevious() {
// TODO
return false;
}
@Override
public void registerContentObserver(ContentObserver observer) {
// TODO
}
@Override
public Bundle respond(Bundle extras) {
// TODO
return null;
}
@Override
public void setNotificationUri(ContentResolver cr, Uri uri) {
// TODO
}
@Override
public void unregisterContentObserver(ContentObserver observer) {
// TODO
}
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
// TODO
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
import android.database.Cursor;
/**
* A factory and event listener for cursors.
*/
public interface H2CursorDriver {
/**
* The cursor was closed.
*/
void cursorClosed();
/**
* The cursor was deactivated.
*/
void cursorDeactivated();
/**
* The query was re-run.
*
* @param cursor the old cursor
*/
void cursorRequeried(Cursor cursor);
/**
* Execute the query.
*
* @param factory the cursor factory
* @param bindArgs the parameter values
* @return the cursor
*/
Cursor query(H2Database.CursorFactory factory, String[] bindArgs);
/**
* Set the parameter values.
*
* @param bindArgs the parameter values.
*/
void setBindArguments(String[] bindArgs);
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
/**
* This exception is thrown when the database file is corrupt.
*/
public class H2DatabaseCorruptException extends H2Exception {
private static final long serialVersionUID = 1L;
H2DatabaseCorruptException() {
super();
}
H2DatabaseCorruptException(String error) {
super(error);
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
/**
* This exception is thrown when there was a IO exception.
*/
public class H2DiskIOException extends H2Exception {
private static final long serialVersionUID = 1L;
H2DiskIOException() {
super();
}
H2DiskIOException(String error) {
super(error);
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
/**
* This exception is thrown the requested data is not available, for example
* when calling simpleQueryForString() or simpleQueryForLong() for a statement
* that doesn't return a value.
*/
public class H2DoneException extends H2Exception {
private static final long serialVersionUID = 1L;
H2DoneException() {
super();
}
H2DoneException(String error) {
super(error);
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
import android.database.SQLException;
/**
* This exception is thrown when there is a syntax error or similar problem.
*/
public class H2Exception extends SQLException {
private static final long serialVersionUID = 1L;
public H2Exception() {
super();
}
public H2Exception(String error) {
super(error);
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
/**
* This exception is thrown when the database file is full and can't grow.
*/
public class H2FullException extends H2Exception {
private static final long serialVersionUID = 1L;
H2FullException() {
super();
}
H2FullException(String error) {
super(error);
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
/**
* TODO
*/
public class H2MisuseException extends H2Exception {
private static final long serialVersionUID = 1L;
H2MisuseException() {
super();
}
H2MisuseException(String error) {
super(error);
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
import android.content.Context;
/**
* This helper class helps creating and managing databases. A subclass typically
* implements the "on" methods.
*/
@SuppressWarnings("unused")
public abstract class H2OpenHelper {
/**
* Construct a new instance.
*
* @param context the context to use
* @param name the name of the database (use null for an in-memory database)
* @param factory the cursor factory to use
* @param version the expected database version
*/
H2OpenHelper(Context context, String name,
H2Database.CursorFactory factory, int version) {
// TODO
}
/**
* Close the connection.
*/
public synchronized void close() {
// TODO
}
/**
* Open a read-only connection.
*
* @return a new read-only connection
*/
public synchronized H2Database getReadableDatabase() {
return null;
}
/**
* Open a read-write connection.
*
* @return a new read-write connection
*/
public synchronized H2Database getWritableDatabase() {
return null;
}
/**
* This method is called when the database did not already exist.
*
* @param db the connection
*/
public abstract void onCreate(H2Database db);
/**
* This method is called after opening the database.
*
* @param db the connection
*/
public void onOpen(H2Database db) {
// TODO
}
/**
* This method is called when the version stored in the database file does
* not match the expected value.
*
* @param db the connection
* @param oldVersion the current version
* @param newVersion the expected version
*/
public abstract void onUpgrade(H2Database db, int oldVersion, int newVersion);
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
import org.h2.command.Prepared;
import org.h2.expression.Parameter;
import org.h2.value.ValueBytes;
/**
* This class represents a prepared statement.
*/
@SuppressWarnings("unused")
public class H2Program extends H2Closable {
/**
* The prepared statement
*/
protected final Prepared prepared;
H2Program(Prepared prepared) {
this.prepared = prepared;
}
/**
* Set the specified parameter value.
*
* @param index the parameter index (0, 1,...)
* @param value the new value
*/
public void bindBlob(int index, byte[] value) {
getParameter(index).setValue(ValueBytes.get(value));
}
/**
* Set the specified parameter value.
*
* @param index the parameter index (0, 1,...)
* @param value the new value
*/
public void bindDouble(int index, double value) {
// TODO
}
/**
* Set the specified parameter value.
*
* @param index the parameter index (0, 1,...)
* @param value the new value
*/
public void bindLong(int index, long value) {
// TODO
}
/**
* Set the specified parameter to NULL.
*
* @param index the parameter index (0, 1,...)
*/
public void bindNull(int index) {
// TODO
}
/**
* Set the specified parameter value.
*
* @param index the parameter index (0, 1,...)
* @param value the new value
*/
public void bindString(int index, String value) {
// TODO
}
/**
* Reset all parameter values.
*/
public void clearBindings() {
// TODO
}
/**
* Close the statement.
*/
public void close() {
// TODO
}
/**
* Get the unique id of this statement.
*
* @return the id
*/
public final int getUniqueId() {
return 0;
}
/**
* TODO
*/
@Override
protected void onAllReferencesReleased() {
// TODO
}
/**
* TODO
*/
@Override
protected void onAllReferencesReleasedFromContainer() {
// TODO
}
private Parameter getParameter(int index) {
return prepared.getParameters().get(index);
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
import org.h2.command.Prepared;
/**
* This class represents a prepared statement that returns a result set.
*/
public class H2Query extends H2Program {
H2Query(Prepared prepared) {
super(prepared);
}
/**
* Set the specified parameter value.
*
* @param index the parameter index (0, 1,...)
* @param value the new value
*/
@Override
public void bindDouble(int index, double value) {
// TODO
}
/**
* Set the specified parameter value.
*
* @param index the parameter index (0, 1,...)
* @param value the new value
*/
@Override
public void bindLong(int index, long value) {
// TODO
}
/**
* Set the specified parameter to NULL.
*
* @param index the parameter index (0, 1,...)
*/
@Override
public void bindNull(int index) {
// TODO
}
/**
* Set the specified parameter value.
*
* @param index the parameter index (0, 1,...)
* @param value the new value
*/
@Override
public void bindString(int index, String value) {
// TODO
}
/**
* Close the statement.
*/
@Override
public void close() {
// TODO
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
import java.util.Map;
import java.util.Set;
import org.h2.util.StringUtils;
import android.database.Cursor;
/**
* This helper class is used to build SQL statements.
*/
@SuppressWarnings("unused")
public class H2QueryBuilder {
private H2Database.CursorFactory factory;
private boolean distinct;
private String tables;
private Map<String, String> columnMap;
/**
* Append the column to the string builder. The columns are separated by
* comma.
*
* @param s the target string builder
* @param columns the columns
*/
static void appendColumns(StringBuilder s, String[] columns) {
for (int i = 0; i < columns.length; i++) {
if (i > 0) {
s.append(", ");
}
s.append(StringUtils.quoteIdentifier(columns[i]));
}
}
/**
* Return the SELECT statement for the given parameters.
*
* @param distinct if only distinct rows should be returned
* @param tables the list of tables
* @param columns the list of columns
* @param where the where condition or null
* @param groupBy the group by list or null
* @param having the having condition or null
* @param orderBy the order by list or null
* @param limit the limit or null
* @return the query
*/
static String buildQueryString(boolean distinct, String tables,
String[] columns, String where, String groupBy, String having,
String orderBy, String limit) {
StringBuilder s = new StringBuilder();
s.append("select ");
if (distinct) {
s.append("distinct ");
}
appendColumns(s, columns);
s.append(" from ").append(tables);
if (where != null) {
s.append(" where ").append(where);
}
if (groupBy != null) {
s.append(" group by ").append(groupBy);
}
if (having != null) {
s.append(" having ").append(having);
}
if (orderBy != null) {
s.append(" order by ").append(groupBy);
}
if (limit != null) {
s.append(" limit ").append(limit);
}
return s.toString();
}
/**
* Append the text to the where clause.
*
* @param inWhere the text to append
*/
void appendWhere(CharSequence inWhere) {
// TODO
}
/**
* Append the text to the where clause. The text is escaped.
*
* @param inWhere the text to append
*/
void appendWhereEscapeString(String inWhere) {
// TODO how to escape
}
/**
* Return the SELECT UNION statement for the given parameters.
*
* @param projectionIn TODO
* @param selection TODO
* @param selectionArgs TODO
* @param groupBy the group by list or null
* @param having the having condition or null
* @param orderBy the order by list or null
* @param limit the limit or null
* @return the query
*/
String buildQuery(String[] projectionIn, String selection,
String[] selectionArgs, String groupBy, String having,
String orderBy, String limit) {
return null;
}
/**
* Return the SELECT UNION statement for the given parameters.
*
* @param subQueries TODO
* @param orderBy the order by list or null
* @param limit the limit or null
* @return the query
*/
String buildUnionQuery(String[] subQueries, String orderBy, String limit) {
return null;
}
/**
* Return the SELECT UNION statement for the given parameters.
*
* @param typeDiscriminatorColumn TODO
* @param unionColumns TODO
* @param columnsPresentInTable TODO
* @param computedColumnsOffset TODO
* @param typeDiscriminatorValue TODO
* @param selection TODO
* @param selectionArgs TODO
* @param groupBy the group by list or null
* @param having the having condition or null
* @return the query
*/
String buildUnionSubQuery(String typeDiscriminatorColumn,
String[] unionColumns, Set<String> columnsPresentInTable,
int computedColumnsOffset, String typeDiscriminatorValue,
String selection, String[] selectionArgs, String groupBy,
String having) {
return null;
}
/**
* Get the list of tables.
*
* @return the list of tables
*/
String getTables() {
return tables;
}
/**
* Run the query for the given parameters.
*
* @param db the connection
* @param projectionIn TODO
* @param selection TODO
* @param selectionArgs TODO
* @param groupBy the group by list or null
* @param having the having condition or null
* @param orderBy the order by list or null
* @return the cursor
*/
Cursor query(H2Database db, String[] projectionIn, String selection,
String[] selectionArgs, String groupBy, String having,
String orderBy) {
return null;
}
/**
* Run the query for the given parameters.
*
* @param db the connection
* @param projectionIn TODO
* @param selection TODO
* @param selectionArgs TODO
* @param groupBy the group by list or null
* @param having the having condition or null
* @param orderBy the order by list or null
* @param limit the limit or null
* @return the cursor
*/
Cursor query(H2Database db, String[] projectionIn, String selection,
String[] selectionArgs, String groupBy, String having,
String orderBy, String limit) {
return null;
}
/**
* Set the cursor factory.
*
* @param factory the new value
*/
void setCursorFactory(H2Database.CursorFactory factory) {
this.factory = factory;
}
/**
* Enable or disable the DISTINCT flag.
*
* @param distinct the new value
*/
void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* TODO
*
* @param columnMap TODO
*/
void setProjectionMap(Map<String, String> columnMap) {
this.columnMap = columnMap;
}
/**
* Set the list of tables.
*
* @param inTables the list of tables
*/
void setTables(String inTables) {
this.tables = inTables;
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
import org.h2.command.Prepared;
import org.h2.result.ResultInterface;
import org.h2.value.Value;
import org.h2.value.ValueNull;
/**
* Represents a prepared statement.
*/
public class H2Statement extends H2Program {
H2Statement(Prepared prepared) {
super(prepared);
}
/**
* Execute the statement.
*/
public void execute() {
if (prepared.isQuery()) {
prepared.query(0);
} else {
prepared.update();
}
}
/**
* Execute the insert statement and return the id of the inserted row.
*
* @return the id of the inserted row
*/
public long executeInsert() {
return prepared.update();
}
/**
* Execute the query and return the value of the first column and row as a
* long.
*
* @return the value
*/
public long simpleQueryForLong() {
return simpleQuery().getLong();
}
/**
* Execute the query and return the value of the first column and row as a
* string.
*
* @return the value
*/
public String simpleQueryForString() {
return simpleQuery().getString();
}
private Value simpleQuery() {
ResultInterface result = prepared.query(1);
try {
if (result.next()) {
Value[] row = result.currentRow();
if (row.length > 0) {
return row[0];
}
}
} finally {
result.close();
}
return ValueNull.INSTANCE;
}
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
/**
* A class that implements this interface can listen to transaction begin and
* end events.
*/
public interface H2TransactionListener {
/**
* The transaction has been started.
*/
void onBegin();
/**
* The transaction will be committed.
*/
void onCommit();
/**
* The transaction will be rolled back.
*/
void onRollback();
}
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.android;
/**
* Utility methods.
*/
public class H2Utils {
/**
* A replacement for Context.openOrCreateDatabase.
*
* @param name the database name
* @param mode the access mode
* @param factory the cursor factory to use
* @return the database connection
*/
public static H2Database openOrCreateDatabase(String name, @SuppressWarnings("unused") int mode,
H2Database.CursorFactory factory) {
return H2Database.openOrCreateDatabase(name, factory);
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0, Version 1.0,
and under the Eclipse Public License, Version 1.0
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p>
This package contains the H2 Android database API.
</p></body></html>
\ No newline at end of file
......@@ -195,11 +195,10 @@ public class Build extends BuildBase {
execJava(args(
"-Xmx128m",
"-javaagent:ext/jacocoagent.jar=destfile=coverage/jacoco.exec,"
+ "excludes=org.h2.test.*:org.h2.tools.*:org.h2.sample.*:android.*",
+ "excludes=org.h2.test.*:org.h2.tools.*:org.h2.sample.*",
"-cp", cp,
"org.h2.test.TestAll", "codeCoverage"));
// Remove classes that we don't want to include in report
delete(files("coverage/bin/android"));
delete(files("coverage/bin/org/h2/test"));
delete(files("coverage/bin/org/h2/tools"));
delete(files("coverage/bin/org/h2/sample"));
......@@ -520,8 +519,6 @@ public class Build extends BuildBase {
addVersions(true);
manifest("H2 Database Engine", "org.h2.tools.Console");
FileList files = files("temp").
exclude("temp/android/*").
exclude("temp/org/h2/android/*").
exclude("temp/org/h2/build/*").
exclude("temp/org/h2/dev/*").
exclude("temp/org/h2/jcr/*").
......@@ -543,38 +540,6 @@ public class Build extends BuildBase {
filter("src/installer/h2w.bat", "bin/h2w.bat", "h2.jar", "h2" + getJarSuffix());
}
/**
* Create the file h2android.jar. This only contains the embedded database,
* plus the H2 Android API. Debug information is disabled.
*/
@Description(summary = "Create h2android.jar with only the embedded DB and H2 Android API.")
public void jarAndroid() {
compile(false, false, true);
FileList files = files("temp").
exclude("temp/org/h2/bnf/*").
exclude("temp/org/h2/build/*").
exclude("temp/org/h2/dev/*").
exclude("temp/org/h2/fulltext/*").
exclude("temp/org/h2/jaqu/*").
exclude("temp/org/h2/java/*").
exclude("temp/org/h2/jdbcx/*").
exclude("temp/org/h2/jcr/*").
exclude("temp/org/h2/jmx/*").
exclude("temp/org/h2/mode/*").
exclude("temp/org/h2/samples/*").
exclude("temp/org/h2/server/*").
exclude("temp/org/h2/test/*").
exclude("temp/org/h2/tools/*").
exclude("*.bat").
exclude("*.sh").
exclude("*.txt").
exclude("*.DS_Store");
files = excludeTestMetaInfFiles(files);
files.add(new File("temp/org/h2/tools/DeleteDbFiles.class"));
files.add(new File("temp/org/h2/tools/CompressTool.class"));
jar("bin/h2android" + getJarSuffix(), files, "temp");
}
/**
* Create the h2client.jar. This only contains the remote JDBC
* implementation.
......@@ -626,8 +591,6 @@ public class Build extends BuildBase {
compile(false, false, true);
addVersions(true);
FileList files = files("temp").
exclude("temp/android/*").
exclude("temp/org/h2/android/*").
exclude("temp/org/h2/build/*").
exclude("temp/org/h2/dev/*").
exclude("temp/org/h2/jcr/*").
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论