Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ba5492da
提交
ba5492da
authored
4月 08, 2011
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Android API
上级
a01642bb
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
76 行增加
和
20 行删除
+76
-20
H2Cursor.java
h2/src/tools/org/h2/android/H2Cursor.java
+15
-9
H2Database.java
h2/src/tools/org/h2/android/H2Database.java
+60
-10
H2Utils.java
h2/src/tools/org/h2/android/H2Utils.java
+1
-1
没有找到文件。
h2/src/tools/org/h2/android/H2Cursor.java
浏览文件 @
ba5492da
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*/
*/
package
org
.
h2
.
android
;
package
org
.
h2
.
android
;
import
org.h2.result.ResultInterface
;
import
android.content.ContentResolver
;
import
android.content.ContentResolver
;
import
android.database.AbstractWindowedCursor
;
import
android.database.AbstractWindowedCursor
;
import
android.database.CharArrayBuffer
;
import
android.database.CharArrayBuffer
;
...
@@ -21,13 +22,18 @@ import android.os.Bundle;
...
@@ -21,13 +22,18 @@ import android.os.Bundle;
public
class
H2Cursor
extends
AbstractWindowedCursor
{
public
class
H2Cursor
extends
AbstractWindowedCursor
{
private
H2Database
database
;
private
H2Database
database
;
private
ResultInterface
result
;
H2Cursor
(
H2Database
db
,
H2CursorDriver
driver
,
String
editTable
,
H2Query
query
)
{
H2Cursor
(
H2Database
db
,
H2CursorDriver
driver
,
String
editTable
,
H2Query
query
)
{
// TODO
// TODO
}
}
H2Cursor
(
ResultInterface
result
)
{
this
.
result
=
result
;
}
public
void
close
()
{
public
void
close
()
{
// TODO
result
.
close
();
}
}
public
void
deactivate
()
{
public
void
deactivate
()
{
...
@@ -43,7 +49,7 @@ public class H2Cursor extends AbstractWindowedCursor {
...
@@ -43,7 +49,7 @@ public class H2Cursor extends AbstractWindowedCursor {
}
}
public
int
getCount
()
{
public
int
getCount
()
{
return
0
;
return
result
.
getRowCount
()
;
}
}
/**
/**
...
@@ -93,7 +99,10 @@ public class H2Cursor extends AbstractWindowedCursor {
...
@@ -93,7 +99,10 @@ public class H2Cursor extends AbstractWindowedCursor {
}
}
public
boolean
move
(
int
offset
)
{
public
boolean
move
(
int
offset
)
{
return
false
;
if
(
offset
==
1
)
{
return
result
.
next
();
}
throw
H2Database
.
unsupported
();
}
}
public
void
copyStringToBuffer
(
int
columnIndex
,
CharArrayBuffer
buffer
)
{
public
void
copyStringToBuffer
(
int
columnIndex
,
CharArrayBuffer
buffer
)
{
...
@@ -137,13 +146,11 @@ public class H2Cursor extends AbstractWindowedCursor {
...
@@ -137,13 +146,11 @@ public class H2Cursor extends AbstractWindowedCursor {
}
}
public
int
getInt
(
int
columnIndex
)
{
public
int
getInt
(
int
columnIndex
)
{
// TODO
return
result
.
currentRow
()[
columnIndex
].
getInt
();
return
0
;
}
}
public
long
getLong
(
int
columnIndex
)
{
public
long
getLong
(
int
columnIndex
)
{
// TODO
return
result
.
currentRow
()[
columnIndex
].
getLong
();
return
0
;
}
}
public
int
getPosition
()
{
public
int
getPosition
()
{
...
@@ -157,8 +164,7 @@ public class H2Cursor extends AbstractWindowedCursor {
...
@@ -157,8 +164,7 @@ public class H2Cursor extends AbstractWindowedCursor {
}
}
public
String
getString
(
int
columnIndex
)
{
public
String
getString
(
int
columnIndex
)
{
// TODO
return
result
.
currentRow
()[
columnIndex
].
getString
();
return
null
;
}
}
public
boolean
getWantsAllOnMoveCalls
()
{
public
boolean
getWantsAllOnMoveCalls
()
{
...
...
h2/src/tools/org/h2/android/H2Database.java
浏览文件 @
ba5492da
...
@@ -7,11 +7,21 @@
...
@@ -7,11 +7,21 @@
package
org
.
h2
.
android
;
package
org
.
h2
.
android
;
import
java.io.File
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Map
;
import
org.h2.command.Prepared
;
import
org.h2.engine.ConnectionInfo
;
import
org.h2.engine.ConnectionInfo
;
import
org.h2.engine.
Engin
e
;
import
org.h2.engine.
Databas
e
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.expression.Parameter
;
import
org.h2.result.ResultInterface
;
import
org.h2.store.PageStore
;
import
org.h2.value.Value
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueString
;
import
android.content.ContentValues
;
import
android.content.ContentValues
;
import
android.database.Cursor
;
import
android.database.Cursor
;
...
@@ -73,8 +83,10 @@ public class H2Database {
...
@@ -73,8 +83,10 @@ public class H2Database {
public
static
final
int
OPEN_READWRITE
=
0
;
public
static
final
int
OPEN_READWRITE
=
0
;
private
final
Session
session
;
private
final
Session
session
;
private
final
CursorFactory
factory
;
private
H2Database
(
Session
session
)
{
H2Database
(
Session
session
,
CursorFactory
factory
)
{
this
.
factory
=
factory
;
this
.
session
=
session
;
this
.
session
=
session
;
}
}
...
@@ -86,8 +98,9 @@ public class H2Database {
...
@@ -86,8 +98,9 @@ public class H2Database {
*/
*/
public
static
H2Database
create
(
H2Database
.
CursorFactory
factory
)
{
public
static
H2Database
create
(
H2Database
.
CursorFactory
factory
)
{
ConnectionInfo
ci
=
new
ConnectionInfo
(
"mem:"
);
ConnectionInfo
ci
=
new
ConnectionInfo
(
"mem:"
);
Session
s
=
Engine
.
getInstance
().
createSession
(
ci
);
Database
db
=
new
Database
(
ci
,
null
);
return
new
H2Database
(
s
);
Session
s
=
db
.
getSystemSession
();
return
new
H2Database
(
s
,
factory
);
}
}
/**
/**
...
@@ -106,8 +119,10 @@ public class H2Database {
...
@@ -106,8 +119,10 @@ public class H2Database {
if
((
flags
&
CREATE_IF_NECESSARY
)
==
0
)
{
if
((
flags
&
CREATE_IF_NECESSARY
)
==
0
)
{
ci
.
setProperty
(
"IFEXISTS"
,
"TRUE"
);
ci
.
setProperty
(
"IFEXISTS"
,
"TRUE"
);
}
}
Session
s
=
Engine
.
getInstance
().
createSession
(
ci
);
ci
.
setProperty
(
"FILE_LOCK"
,
"FS"
);
return
new
H2Database
(
s
);
Database
db
=
new
Database
(
ci
,
null
);
Session
s
=
db
.
getSystemSession
();
return
new
H2Database
(
s
,
factory
);
}
}
/**
/**
...
@@ -194,7 +209,7 @@ public class H2Database {
...
@@ -194,7 +209,7 @@ public class H2Database {
* @param bindArgs the parameter values
* @param bindArgs the parameter values
*/
*/
public
void
execSQL
(
String
sql
,
Object
[]
bindArgs
)
{
public
void
execSQL
(
String
sql
,
Object
[]
bindArgs
)
{
// TODO
prepare
(
sql
,
bindArgs
).
update
();
}
}
/**
/**
...
@@ -203,7 +218,7 @@ public class H2Database {
...
@@ -203,7 +218,7 @@ public class H2Database {
* @param sql the statement
* @param sql the statement
*/
*/
public
void
execSQL
(
String
sql
)
{
public
void
execSQL
(
String
sql
)
{
// TODO
session
.
prepare
(
sql
).
update
();
}
}
/**
/**
...
@@ -232,7 +247,8 @@ public class H2Database {
...
@@ -232,7 +247,8 @@ public class H2Database {
* @return the page size
* @return the page size
*/
*/
public
long
getPageSize
()
{
public
long
getPageSize
()
{
return
0
;
PageStore
store
=
session
.
getDatabase
().
getPageStore
();
return
store
==
null
?
0
:
store
.
getPageSize
();
}
}
/**
/**
...
@@ -457,7 +473,9 @@ public class H2Database {
...
@@ -457,7 +473,9 @@ public class H2Database {
* @return the cursor
* @return the cursor
*/
*/
public
Cursor
rawQuery
(
String
sql
,
String
[]
selectionArgs
)
{
public
Cursor
rawQuery
(
String
sql
,
String
[]
selectionArgs
)
{
return
null
;
Prepared
prep
=
prepare
(
sql
,
selectionArgs
);
ResultInterface
result
=
prep
.
query
(
0
);
return
new
H2Cursor
(
result
);
}
}
/**
/**
...
@@ -635,4 +653,36 @@ public class H2Database {
...
@@ -635,4 +653,36 @@ public class H2Database {
Cursor
newCursor
(
H2Database
db
,
H2CursorDriver
masterQuery
,
String
editTable
,
H2Query
query
);
Cursor
newCursor
(
H2Database
db
,
H2CursorDriver
masterQuery
,
String
editTable
,
H2Query
query
);
}
}
private
Prepared
prepare
(
String
sql
,
Object
[]
args
)
{
Prepared
prep
=
session
.
prepare
(
sql
);
int
len
=
args
.
length
;
if
(
len
>
0
)
{
ArrayList
<
Parameter
>
params
=
prep
.
getParameters
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Parameter
p
=
params
.
get
(
i
);
p
.
setValue
(
getValue
(
args
[
i
]));
}
}
return
prep
;
}
private
Value
getValue
(
Object
o
)
{
if
(
o
==
null
)
{
return
ValueNull
.
INSTANCE
;
}
else
if
(
o
instanceof
String
)
{
return
ValueString
.
get
((
String
)
o
);
}
else
if
(
o
instanceof
Integer
)
{
return
ValueInt
.
get
((
Integer
)
o
);
}
else
if
(
o
instanceof
Long
)
{
return
ValueLong
.
get
((
Integer
)
o
);
}
return
ValueString
.
get
(
o
.
toString
());
// TODO
}
public
static
RuntimeException
unsupported
()
{
// TODO
return
new
RuntimeException
(
"Feature not supported"
);
}
}
}
h2/src/tools/org/h2/android/H2Utils.java
浏览文件 @
ba5492da
...
@@ -20,7 +20,7 @@ public class H2Utils {
...
@@ -20,7 +20,7 @@ public class H2Utils {
* @return the database connection
* @return the database connection
*/
*/
public
static
H2Database
openOrCreateDatabase
(
String
name
,
int
mode
,
H2Database
.
CursorFactory
factory
)
{
public
static
H2Database
openOrCreateDatabase
(
String
name
,
int
mode
,
H2Database
.
CursorFactory
factory
)
{
return
null
;
return
H2Database
.
openOrCreateDatabase
(
name
,
factory
)
;
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论