Appmate Droid  1.3.0
全部成員列表
Table 類別 參考文件

指向資料表的連接物件。 更多...

公開方法(Public Methods)

Tuple getSchema () throws IOException
 取得資料表結構敘述。 更多...
 
Tuple [] get () throws IOException
 取得資料表上的所有內容。 更多...
 
Tuple get (String primaryKey) throws IOException
 以主鍵取得表格上之物件 更多...
 
Tuple get (int id) throws IOException
 id 取得資料表上的特定物件。在 appmate 資料庫中多數的物件皆以 id 為主鍵。 更多...
 
Tuple [] get (String... filters) throws IOException
 取得符合特定條件的物件。 更多...
 
void add (Tuple... items) throws IOException
 新增物件到資料表中。 更多...
 
void update (String primaryKey, Tuple item, boolean overwrite) throws IOException
 更新一個資料表上的項目。 更多...
 
void update (int id, Tuple item, boolean overwrite) throws IOException
 更新一個資料表上的項目。 更多...
 
void update (String primaryKey, Tuple item) throws IOException
 更新一個資料表上的項目。 本函式僅更新 item 下帶著的內容。 更多...
 
void update (int id, Tuple item) throws IOException
 更新一個資料表上的項目。 本函式僅更新 item 下帶著的內容。 更多...
 
void update (Tuple item, boolean overwrite) throws IOException
 更新一個資料表上的項目。適用於當 item 已經帶有主鍵時。 本函式僅更新 item 下帶著的內容。 更多...
 
void update (Tuple item) throws IOException
 更新一個資料表上的項目。適用於當 item 已經帶有主鍵時。 更多...
 
void delete (int... ids) throws IOException
 刪除一些項目。 更多...
 
void delete (String... primaryKeys) throws IOException
 刪除一些項目。 更多...
 

建構子

 Table (@NonNull String apiRoot, @NonNull String table)
 建立一個不帶授權的 Table 實體。 更多...
 
 Table (@NonNull String apiRoot, @NonNull String table, @NonNull String username, @NonNull String password)
 建立一個帶授權的 Table 實體。 更多...
 
 Table (@NonNull Database database, @NonNull String table)
 自母資料庫建立表格連結。 更多...
 

詳細描述

指向資料表的連接物件。

備註
建立 Table 實體(instance)時候並不會建立網路連線。

建構子與解構子說明文件

◆ Table() [1/3]

Table ( @NonNull String  apiRoot,
@NonNull String  table 
)

建立一個不帶授權的 Table 實體。

注意
基於安全性因素,單一裝置上高頻率地進行操作會觸發 CSRF protection 保護機制。 對於需要頻繁進行操作的資料表,請考慮使用 Table#Table(String, String, String, String)
參數
apiRootapi root 所在位置( 表格路徑),須包含傳輸阜,如:http://example:8000/api/
table資料表名稱

◆ Table() [2/3]

Table ( @NonNull String  apiRoot,
@NonNull String  table,
@NonNull String  username,
@NonNull String  password 
)

建立一個帶授權的 Table 實體。

參數
apiRootapi root 所在位置( 表格路徑),須包含傳輸阜,如:http://example:8000/api/
username登入用使用者名稱
password登入用密碼
table資料表名稱

◆ Table() [3/3]

Table ( @NonNull Database  database,
@NonNull String  table 
)

自母資料庫建立表格連結。

參數
database母資料庫
table表格名稱

函式成員說明文件

◆ add()

void add ( Tuple...  items) throws IOException

新增物件到資料表中。

備註
此方法允許一次上傳多個 Tuple
此函式會使用網路連線。
參數
items要加入資料表的物件清單
例外
IOException資料表不存在,或網路錯誤
NetworkOnMainThreadException在主執行緒上使用此函式

◆ delete() [1/2]

void delete ( int...  ids) throws IOException

刪除一些項目。

備註
此方法允許一次刪除多個項目。
此函式會使用網路連線。
參數
ids要被刪除的項目的 id,在 appmate 資料庫中多數的物件皆以 id 為主鍵。
例外
IOException資料表不存在,或網路錯誤
NetworkOnMainThreadException在主執行緒上使用此函式

◆ delete() [2/2]

void delete ( String...  primaryKeys) throws IOException

刪除一些項目。

備註
此方法允許一次刪除多個項目。
此函式會使用網路連線。
參數
primaryKeys要被刪除的項目的主鍵
例外
IOException資料表不存在,或網路錯誤
NetworkOnMainThreadException在主執行緒上使用此函式

◆ get() [1/4]

Tuple [] get ( ) throws IOException

取得資料表上的所有內容。

備註
此函式會使用網路連線。
傳回值
資料表上的所有內容,當資料表為空的時候會回傳一個長度為0的陣列
例外
IOException資料表不存在,或網路錯誤
NetworkOnMainThreadException在主執行緒上使用此函式

◆ get() [2/4]

Tuple get ( String  primaryKey) throws IOException

以主鍵取得表格上之物件

備註
此函式會使用網路連線。
參數
primaryKey主鍵
傳回值
指定的物件
例外
IOException資料表不存在,或網路錯誤
NetworkOnMainThreadException在主執行緒上使用此函式

◆ get() [3/4]

Tuple get ( int  id) throws IOException

id 取得資料表上的特定物件。在 appmate 資料庫中多數的物件皆以 id 為主鍵。

備註
此函式會使用網路連線。
參數
id物件 id
傳回值
指定的物件
例外
IOException資料表不存在,或網路錯誤
NetworkOnMainThreadException在主執行緒上使用此函式

◆ get() [4/4]

Tuple [] get ( String...  filters) throws IOException

取得符合特定條件的物件。

可指定一個或多個過濾條件,用以篩選出指定的物件。 所有過濾條件皆需以字串形式給予,如:

Tuple[] result1 = table.get("qty>50"); // 查詢 qty 大於 50 的清單
Tuple[] result2 = table.get("pri<=2.8", "qty>50"); // 查詢 pri 小於等於 2.8 且 qty 大於 50 的清單
使用多個條件時回傳清單為所有條件之交集(AND運算),目前不支援聯集運算(OR運算)

現階段支援以下數種過濾條件

  • 完全比對 (適用型別: String

    使用符號: =, ==

    注意
    比對的字串中不允許出現引號,但允許空白
  • 完全等於 (適用型別:Integer, Boolean

    使用符號: =, ==

    布林型別使用 0, 1 而非 True, False
  • 不等式 (適用型別:Integer, Float, Double

    使用符號: >, >=, <, <=

備註
此函式會使用網路連線。
參數
filters篩選規則
傳回值
符合所有篩選條件的物件清單,當無物件符合時回傳長度為0的陣列
例外
IOException資料表不存在,或網路錯誤
NetworkOnMainThreadException在主執行緒上使用此函式

◆ getSchema()

Tuple getSchema ( ) throws IOException

取得資料表結構敘述。

如:

{
"id": {
"type": "integer",
"required": false,
"read_only": true,
"label": "ID"
},
"name": {
"type": "string",
"required": true,
"read_only": false,
"label": "Name",
"max_length": 42
},
"msg": {
"type": "string",
"required": false,
"read_only": false,
"label": "Msg"
},
"timestamp": {
"type": "datetime",
"required": false,
"read_only": true,
"label": "Timestamp"
}
}
備註
此函式會使用網路連線。
傳回值
資料表結構,如上述範例
例外
IOException資料表不存在,或網路錯誤
NetworkOnMainThreadException在主執行緒上使用此函式

◆ update() [1/6]

void update ( String  primaryKey,
Tuple  item,
boolean  overwrite 
) throws IOException

更新一個資料表上的項目。

備註
此函式會使用網路連線。
參數
primaryKey要更新的項目的主鍵
item要更新的資料
overwrite是否進行完全覆寫, False 時候僅 item 內所帶的欄位會被修正
例外
IOException資料表不存在、網路錯誤,或當 overwriteTrue 卻缺少部分欄位資料
NetworkOnMainThreadException在主執行緒上使用此函式

◆ update() [2/6]

void update ( int  id,
Tuple  item,
boolean  overwrite 
) throws IOException

更新一個資料表上的項目。

備註
此函式會使用網路連線。
參數
id要被更新的項目。在 appmate 資料庫中多數的物件皆以 id 為主鍵。
item要更新的資料
overwrite是否進行完全覆寫
例外
IOException資料表不存在、網路錯誤,或當 overwriteTrue 卻缺少部分欄位資料
NetworkOnMainThreadException在主執行緒上使用此函式

◆ update() [3/6]

void update ( String  primaryKey,
Tuple  item 
) throws IOException

更新一個資料表上的項目。 本函式僅更新 item 下帶著的內容。

備註
此函式會使用網路連線。
參數
primaryKey要更新的項目的主鍵
item要更新的資料
例外
IOException資料表不存在、網路錯誤,或當 overwriteTrue 卻缺少部分欄位資料
NetworkOnMainThreadException在主執行緒上使用此函式

◆ update() [4/6]

void update ( int  id,
Tuple  item 
) throws IOException

更新一個資料表上的項目。 本函式僅更新 item 下帶著的內容。

備註
此函式會使用網路連線。
參數
id要被更新的項目。在 appmate 資料庫中多數的物件皆以 id 為主鍵。
item要更新的資料
例外
IOException資料表不存在、網路錯誤,或當 overwriteTrue 卻缺少部分欄位資料
NetworkOnMainThreadException在主執行緒上使用此函式

◆ update() [5/6]

void update ( Tuple  item,
boolean  overwrite 
) throws IOException

更新一個資料表上的項目。適用於當 item 已經帶有主鍵時。 本函式僅更新 item 下帶著的內容。

備註
此函式會使用網路連線。
參數
itemitem to be updated
overwrite是否進行完全覆寫
例外
UnsupportedOperationExceptionitem 沒有主鍵
IOException資料表不存在,或網路錯誤
NetworkOnMainThreadException在主執行緒上使用此函式
參閱
Table::update(int, Tuple, boolean)

◆ update() [6/6]

void update ( Tuple  item) throws IOException

更新一個資料表上的項目。適用於當 item 已經帶有主鍵時。

備註
此函式會使用網路連線。
參數
itemitem to be updated
例外
UnsupportedOperationExceptionitem 沒有主鍵
IOException資料表不存在,或網路錯誤
NetworkOnMainThreadException在主執行緒上使用此函式
參閱
Table::update(int, Tuple, boolean)

此類別(class) 文件是由下列檔案中產生: