OLD | NEW |
| (Empty) |
1 /** | |
2 * An API for storing data in the browser that can be queried with SQL. | |
3 * | |
4 * **Caution:** this specification is no longer actively maintained by the Web | |
5 * Applications Working Group and may be removed at any time. | |
6 * See [the W3C Web SQL Database specification](http://www.w3.org/TR/webdatabase
/) | |
7 * for more information. | |
8 * | |
9 * The [dart:indexed_db] APIs is a recommended alternatives. | |
10 */ | |
11 library dart.dom.web_sql; | |
12 | |
13 import 'dart:async'; | |
14 import 'dart:collection' hide LinkedList, LinkedListEntry; | |
15 import 'dart:_internal'; | |
16 import 'dart:html'; | |
17 import 'dart:html_common'; | |
18 import 'dart:nativewrappers'; | |
19 import 'dart:_blink' as _blink; | |
20 import 'dart:js' as js; | |
21 | |
22 // DO NOT EDIT - unless you are editing documentation as per: | |
23 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation | |
24 // Auto-generated dart:audio library. | |
25 | |
26 // FIXME: Can we make this private? | |
27 @Deprecated("Internal Use Only") | |
28 final web_sqlBlinkMap = { | |
29 'Database': () => SqlDatabase.instanceRuntimeType, | |
30 'SQLError': () => SqlError.instanceRuntimeType, | |
31 'SQLResultSet': () => SqlResultSet.instanceRuntimeType, | |
32 'SQLResultSetRowList': () => SqlResultSetRowList.instanceRuntimeType, | |
33 'SQLTransaction': () => SqlTransaction.instanceRuntimeType, | |
34 }; | |
35 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
36 // for details. All rights reserved. Use of this source code is governed by a | |
37 // BSD-style license that can be found in the LICENSE file. | |
38 | |
39 // WARNING: Do not edit - generated code. | |
40 | |
41 @DomName('SQLStatementCallback') | |
42 // http://www.w3.org/TR/webdatabase/#sqlstatementcallback | |
43 @Experimental() // deprecated | |
44 typedef void SqlStatementCallback( | |
45 SqlTransaction transaction, SqlResultSet resultSet); | |
46 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
47 // for details. All rights reserved. Use of this source code is governed by a | |
48 // BSD-style license that can be found in the LICENSE file. | |
49 | |
50 // WARNING: Do not edit - generated code. | |
51 | |
52 @DomName('SQLStatementErrorCallback') | |
53 // http://www.w3.org/TR/webdatabase/#sqlstatementerrorcallback | |
54 @Experimental() // deprecated | |
55 typedef void SqlStatementErrorCallback( | |
56 SqlTransaction transaction, SqlError error); | |
57 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
58 // for details. All rights reserved. Use of this source code is governed by a | |
59 // BSD-style license that can be found in the LICENSE file. | |
60 | |
61 // WARNING: Do not edit - generated code. | |
62 | |
63 @DomName('SQLTransactionCallback') | |
64 // http://www.w3.org/TR/webdatabase/#sqltransactioncallback | |
65 @Experimental() // deprecated | |
66 typedef void SqlTransactionCallback(SqlTransaction transaction); | |
67 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
68 // for details. All rights reserved. Use of this source code is governed by a | |
69 // BSD-style license that can be found in the LICENSE file. | |
70 | |
71 // WARNING: Do not edit - generated code. | |
72 | |
73 @DomName('SQLTransactionErrorCallback') | |
74 // http://www.w3.org/TR/webdatabase/#sqltransactionerrorcallback | |
75 @Experimental() // deprecated | |
76 typedef void SqlTransactionErrorCallback(SqlError error); | |
77 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
78 // for details. All rights reserved. Use of this source code is governed by a | |
79 // BSD-style license that can be found in the LICENSE file. | |
80 | |
81 // WARNING: Do not edit - generated code. | |
82 | |
83 @DocsEditable() | |
84 @DomName('Database') | |
85 @SupportedBrowser(SupportedBrowser.CHROME) | |
86 @SupportedBrowser(SupportedBrowser.SAFARI) | |
87 @Experimental() | |
88 // http://www.w3.org/TR/webdatabase/#asynchronous-database-api | |
89 @Experimental() // deprecated | |
90 class SqlDatabase extends DartHtmlDomObject { | |
91 // To suppress missing implicit constructor warnings. | |
92 factory SqlDatabase._() { | |
93 throw new UnsupportedError("Not supported"); | |
94 } | |
95 | |
96 @Deprecated("Internal Use Only") | |
97 external static Type get instanceRuntimeType; | |
98 | |
99 @Deprecated("Internal Use Only") | |
100 SqlDatabase.internal_() {} | |
101 | |
102 /// Checks if this type is supported on the current platform. | |
103 static bool get supported => true; | |
104 | |
105 @DomName('Database.version') | |
106 @DocsEditable() | |
107 String get version => _blink.BlinkDatabase.instance.version_Getter_(this); | |
108 | |
109 void changeVersion(String oldVersion, String newVersion, | |
110 [SqlTransactionCallback callback, | |
111 SqlTransactionErrorCallback errorCallback, | |
112 VoidCallback successCallback]) { | |
113 if (successCallback != null) { | |
114 _blink.BlinkDatabase.instance.changeVersion_Callback_5_(this, oldVersion, | |
115 newVersion, callback, errorCallback, successCallback); | |
116 return; | |
117 } | |
118 if (errorCallback != null) { | |
119 _blink.BlinkDatabase.instance.changeVersion_Callback_4_( | |
120 this, oldVersion, newVersion, callback, errorCallback); | |
121 return; | |
122 } | |
123 if (callback != null) { | |
124 _blink.BlinkDatabase.instance | |
125 .changeVersion_Callback_3_(this, oldVersion, newVersion, callback); | |
126 return; | |
127 } | |
128 _blink.BlinkDatabase.instance | |
129 .changeVersion_Callback_2_(this, oldVersion, newVersion); | |
130 return; | |
131 } | |
132 | |
133 void readTransaction(SqlTransactionCallback callback, | |
134 [SqlTransactionErrorCallback errorCallback, | |
135 VoidCallback successCallback]) { | |
136 if (successCallback != null) { | |
137 _blink.BlinkDatabase.instance.readTransaction_Callback_3_( | |
138 this, callback, errorCallback, successCallback); | |
139 return; | |
140 } | |
141 if (errorCallback != null) { | |
142 _blink.BlinkDatabase.instance | |
143 .readTransaction_Callback_2_(this, callback, errorCallback); | |
144 return; | |
145 } | |
146 _blink.BlinkDatabase.instance.readTransaction_Callback_1_(this, callback); | |
147 return; | |
148 } | |
149 | |
150 void transaction(SqlTransactionCallback callback, | |
151 [SqlTransactionErrorCallback errorCallback, | |
152 VoidCallback successCallback]) { | |
153 if (successCallback != null) { | |
154 _blink.BlinkDatabase.instance.transaction_Callback_3_( | |
155 this, callback, errorCallback, successCallback); | |
156 return; | |
157 } | |
158 if (errorCallback != null) { | |
159 _blink.BlinkDatabase.instance | |
160 .transaction_Callback_2_(this, callback, errorCallback); | |
161 return; | |
162 } | |
163 _blink.BlinkDatabase.instance.transaction_Callback_1_(this, callback); | |
164 return; | |
165 } | |
166 } | |
167 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
168 // for details. All rights reserved. Use of this source code is governed by a | |
169 // BSD-style license that can be found in the LICENSE file. | |
170 | |
171 // WARNING: Do not edit - generated code. | |
172 | |
173 @DocsEditable() | |
174 @DomName('SQLError') | |
175 // http://www.w3.org/TR/webdatabase/#sqlerror | |
176 @Experimental() // deprecated | |
177 class SqlError extends DartHtmlDomObject { | |
178 // To suppress missing implicit constructor warnings. | |
179 factory SqlError._() { | |
180 throw new UnsupportedError("Not supported"); | |
181 } | |
182 | |
183 @Deprecated("Internal Use Only") | |
184 external static Type get instanceRuntimeType; | |
185 | |
186 @Deprecated("Internal Use Only") | |
187 SqlError.internal_() {} | |
188 | |
189 @DomName('SQLError.CONSTRAINT_ERR') | |
190 @DocsEditable() | |
191 static const int CONSTRAINT_ERR = 6; | |
192 | |
193 @DomName('SQLError.DATABASE_ERR') | |
194 @DocsEditable() | |
195 static const int DATABASE_ERR = 1; | |
196 | |
197 @DomName('SQLError.QUOTA_ERR') | |
198 @DocsEditable() | |
199 static const int QUOTA_ERR = 4; | |
200 | |
201 @DomName('SQLError.SYNTAX_ERR') | |
202 @DocsEditable() | |
203 static const int SYNTAX_ERR = 5; | |
204 | |
205 @DomName('SQLError.TIMEOUT_ERR') | |
206 @DocsEditable() | |
207 static const int TIMEOUT_ERR = 7; | |
208 | |
209 @DomName('SQLError.TOO_LARGE_ERR') | |
210 @DocsEditable() | |
211 static const int TOO_LARGE_ERR = 3; | |
212 | |
213 @DomName('SQLError.UNKNOWN_ERR') | |
214 @DocsEditable() | |
215 static const int UNKNOWN_ERR = 0; | |
216 | |
217 @DomName('SQLError.VERSION_ERR') | |
218 @DocsEditable() | |
219 static const int VERSION_ERR = 2; | |
220 | |
221 @DomName('SQLError.code') | |
222 @DocsEditable() | |
223 int get code => _blink.BlinkSQLError.instance.code_Getter_(this); | |
224 | |
225 @DomName('SQLError.message') | |
226 @DocsEditable() | |
227 String get message => _blink.BlinkSQLError.instance.message_Getter_(this); | |
228 } | |
229 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
230 // for details. All rights reserved. Use of this source code is governed by a | |
231 // BSD-style license that can be found in the LICENSE file. | |
232 | |
233 // WARNING: Do not edit - generated code. | |
234 | |
235 @DocsEditable() | |
236 @DomName('SQLResultSet') | |
237 // http://www.w3.org/TR/webdatabase/#sqlresultset | |
238 @Experimental() // deprecated | |
239 class SqlResultSet extends DartHtmlDomObject { | |
240 // To suppress missing implicit constructor warnings. | |
241 factory SqlResultSet._() { | |
242 throw new UnsupportedError("Not supported"); | |
243 } | |
244 | |
245 @Deprecated("Internal Use Only") | |
246 external static Type get instanceRuntimeType; | |
247 | |
248 @Deprecated("Internal Use Only") | |
249 SqlResultSet.internal_() {} | |
250 | |
251 @DomName('SQLResultSet.insertId') | |
252 @DocsEditable() | |
253 int get insertId => _blink.BlinkSQLResultSet.instance.insertId_Getter_(this); | |
254 | |
255 @DomName('SQLResultSet.rows') | |
256 @DocsEditable() | |
257 SqlResultSetRowList get rows => | |
258 _blink.BlinkSQLResultSet.instance.rows_Getter_(this); | |
259 | |
260 @DomName('SQLResultSet.rowsAffected') | |
261 @DocsEditable() | |
262 int get rowsAffected => | |
263 _blink.BlinkSQLResultSet.instance.rowsAffected_Getter_(this); | |
264 } | |
265 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
266 // for details. All rights reserved. Use of this source code is governed by a | |
267 // BSD-style license that can be found in the LICENSE file. | |
268 | |
269 // WARNING: Do not edit - generated code. | |
270 | |
271 @DocsEditable() | |
272 @DomName('SQLResultSetRowList') | |
273 // http://www.w3.org/TR/webdatabase/#sqlresultsetrowlist | |
274 @Experimental() // deprecated | |
275 class SqlResultSetRowList extends DartHtmlDomObject | |
276 with ListMixin<Map>, ImmutableListMixin<Map> | |
277 implements List<Map> { | |
278 // To suppress missing implicit constructor warnings. | |
279 factory SqlResultSetRowList._() { | |
280 throw new UnsupportedError("Not supported"); | |
281 } | |
282 | |
283 @Deprecated("Internal Use Only") | |
284 external static Type get instanceRuntimeType; | |
285 | |
286 @Deprecated("Internal Use Only") | |
287 SqlResultSetRowList.internal_() {} | |
288 | |
289 @DomName('SQLResultSetRowList.length') | |
290 @DocsEditable() | |
291 int get length => | |
292 _blink.BlinkSQLResultSetRowList.instance.length_Getter_(this); | |
293 | |
294 Map operator [](int index) { | |
295 if (index < 0 || index >= length) throw new RangeError.index(index, this); | |
296 return _nativeIndexedGetter(index); | |
297 } | |
298 | |
299 Map _nativeIndexedGetter(int index) => convertNativeToDart_Dictionary( | |
300 _blink.BlinkSQLResultSetRowList.instance.item_Callback_1_(this, index)); | |
301 | |
302 void operator []=(int index, Map value) { | |
303 throw new UnsupportedError("Cannot assign element of immutable List."); | |
304 } | |
305 // -- start List<Map> mixins. | |
306 // Map is the element type. | |
307 | |
308 set length(int value) { | |
309 throw new UnsupportedError("Cannot resize immutable List."); | |
310 } | |
311 | |
312 Map get first { | |
313 if (this.length > 0) { | |
314 return _nativeIndexedGetter(0); | |
315 } | |
316 throw new StateError("No elements"); | |
317 } | |
318 | |
319 Map get last { | |
320 int len = this.length; | |
321 if (len > 0) { | |
322 return _nativeIndexedGetter(len - 1); | |
323 } | |
324 throw new StateError("No elements"); | |
325 } | |
326 | |
327 Map get single { | |
328 int len = this.length; | |
329 if (len == 1) { | |
330 return _nativeIndexedGetter(0); | |
331 } | |
332 if (len == 0) throw new StateError("No elements"); | |
333 throw new StateError("More than one element"); | |
334 } | |
335 | |
336 Map elementAt(int index) => this[index]; | |
337 // -- end List<Map> mixins. | |
338 | |
339 @DomName('SQLResultSetRowList.item') | |
340 @DocsEditable() | |
341 Object item(int index) => convertNativeToDart_Dictionary( | |
342 _blink.BlinkSQLResultSetRowList.instance.item_Callback_1_(this, index)); | |
343 } | |
344 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
345 // for details. All rights reserved. Use of this source code is governed by a | |
346 // BSD-style license that can be found in the LICENSE file. | |
347 | |
348 // WARNING: Do not edit - generated code. | |
349 | |
350 @DocsEditable() | |
351 @DomName('SQLTransaction') | |
352 @SupportedBrowser(SupportedBrowser.CHROME) | |
353 @SupportedBrowser(SupportedBrowser.SAFARI) | |
354 @Experimental() | |
355 // http://www.w3.org/TR/webdatabase/#sqltransaction | |
356 @deprecated // deprecated | |
357 class SqlTransaction extends DartHtmlDomObject { | |
358 // To suppress missing implicit constructor warnings. | |
359 factory SqlTransaction._() { | |
360 throw new UnsupportedError("Not supported"); | |
361 } | |
362 | |
363 @Deprecated("Internal Use Only") | |
364 external static Type get instanceRuntimeType; | |
365 | |
366 @Deprecated("Internal Use Only") | |
367 SqlTransaction.internal_() {} | |
368 | |
369 void executeSql(String sqlStatement, | |
370 [List arguments, | |
371 SqlStatementCallback callback, | |
372 SqlStatementErrorCallback errorCallback]) { | |
373 if (errorCallback != null) { | |
374 _blink.BlinkSQLTransaction.instance.executeSql_Callback_4_( | |
375 this, sqlStatement, arguments, callback, errorCallback); | |
376 return; | |
377 } | |
378 if (callback != null) { | |
379 _blink.BlinkSQLTransaction.instance | |
380 .executeSql_Callback_3_(this, sqlStatement, arguments, callback); | |
381 return; | |
382 } | |
383 if (arguments != null) { | |
384 _blink.BlinkSQLTransaction.instance | |
385 .executeSql_Callback_2_(this, sqlStatement, arguments); | |
386 return; | |
387 } | |
388 _blink.BlinkSQLTransaction.instance | |
389 .executeSql_Callback_1_(this, sqlStatement); | |
390 return; | |
391 } | |
392 } | |
OLD | NEW |